Example usage for javax.management.remote.rmi RMIConnector RMIConnector

List of usage examples for javax.management.remote.rmi RMIConnector RMIConnector

Introduction

In this page you can find the example usage for javax.management.remote.rmi RMIConnector RMIConnector.

Prototype

public RMIConnector(RMIServer rmiServer, Map<String, ?> environment) 

Source Link

Document

Constructs an RMIConnector using the given RMI stub.

Usage

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;
}