private int getURLLocalHostPort(String url) { int portStart = url.indexOf("localhost") + 10; int portEnd; int port = 0; if (portStart > 0) { portEnd = indexNotOfNumber(url, portStart); if (portEnd > portStart) { final String portString = url.substring(portStart, portEnd); port = Integer.parseInt(portString); } } return port; }
mcf = MBServerConnectorFactory.getInstance(); mcf.setMBeanServer(mbs); mcf.setThreaded(isThreaded()); mcf.setDaemon(isDaemon()); mcf.setServiceUrl(getJMXServiceURL()); try { mcf.createConnector(); } catch (IOException ex) { connectFailed = true;
public void shutdown() { if (!isEnabled()) { return; } if (mcf != null) { try { mcf.destroy(); } catch (IOException ex) { LOG.log(Level.SEVERE, "STOP_CONNECTOR_FAILURE_MSG", new Object[] {ex}); } } //Using the array to hold the busMBeans to avoid the CurrentModificationException Object[] mBeans = busMBeans.toArray(); for (Object name : mBeans) { busMBeans.remove(name); try { unregister((ObjectName)name); } catch (JMException jmex) { LOG.log(Level.SEVERE, "UNREGISTER_FAILURE_MSG", new Object[]{name, jmex}); } } }
&& url.getProtocol().compareToIgnoreCase("rmi") == 0) { try { int port = getURLLocalHostPort(serviceUrl); try { LocateRegistry.createRegistry(port);