List of usage examples for javax.management.remote.rmi RMIConnector RMIConnector
public RMIConnector(RMIServer rmiServer, Map<String, ?> environment)
Constructs an RMIConnector using the given RMI stub.
From source file:org.lsc.jmx.LscAgent.java
/** * Bind to the JMX Server /*from w w w. j a va 2s. c o m*/ */ public boolean jmxBind() { try { String sUrl = "service:jmx:rmi:///jndi/rmi://" + hostname + ":" + port + "/jmxrmi"; LOGGER.info("Connecting to remote engine on : " + sUrl); url = new JMXServiceURL(sUrl); jmxC = new RMIConnector(url, null); jmxC.connect(); jmxc = jmxC.getMBeanServerConnection(); ObjectName lscServerName = new ObjectName("org.lsc.jmx:type=LscServer"); lscServer = JMX.newMXBeanProxy(jmxc, lscServerName, LscServer.class, true); return true; } catch (MalformedObjectNameException e) { LOGGER.error(e.toString(), e); } catch (NullPointerException e) { LOGGER.error(e.toString(), e); } catch (MalformedURLException e) { LOGGER.error(e.toString(), e); } catch (IOException e) { LOGGER.error(e.toString(), e); } return false; }
From source file:org.lsc.webai.services.LscRemoteCommands.java
private boolean jmxBind() { if (lscServer != null) { try {/* www. ja va 2s . c o m*/ return lscServer.ping(); } catch (UndeclaredThrowableException ce) { } } try { String sUrl = "service:jmx:rmi:///jndi/rmi://" + hostname + ":" + port + "/jmxrmi"; LOGGER.info("Connecting to remote engine on : " + sUrl); url = new JMXServiceURL(sUrl); jmxC = new RMIConnector(url, null); jmxC.connect(); jmxc = jmxC.getMBeanServerConnection(); ObjectName lscServerName = new ObjectName("org.lsc.jmx:type=LscServer"); lscServer = JMX.newMXBeanProxy(jmxc, lscServerName, LscServer.class, true); return true; } catch (MalformedObjectNameException e) { LOGGER.error(e.toString(), e); } catch (NullPointerException e) { LOGGER.error(e.toString(), e); } catch (MalformedURLException e) { LOGGER.error(e.toString(), e); } catch (IOException e) { if (!(e.getCause() instanceof ServiceUnavailableException)) { LOGGER.error(e.toString(), e); } } return false; }