Example usage for javax.management.remote JMXConnector getConnectionId

List of usage examples for javax.management.remote JMXConnector getConnectionId

Introduction

In this page you can find the example usage for javax.management.remote JMXConnector getConnectionId.

Prototype

public String getConnectionId() throws IOException;

Source Link

Document

Gets this connection's ID from the connector server.

Usage

From source file:com.googlecode.jmxtrans.connections.JmxConnectionFactory.java

/**
 * Validates that the connection is good.
 *//*from www  .j  a v  a2 s. c o  m*/
@Override
public boolean validateObject(JMXConnectionParams params, JMXConnector connector) {
    boolean result = false;
    try {
        connector.getConnectionId();
        connector.getMBeanServerConnection().getMBeanCount();
        result = true;
    } catch (IOException ex) {
        // ignored
    }
    return result;
}

From source file:com.xoriant.jmx.pool.JmxPoolFactory.java

/**
 * This method will destroy the JMX connection. 
 *//*www.  j  a va 2s  .c o  m*/
@Override
public void destroyObject(PooledObject<Q> jmxPooledObject) throws Exception {
    JMXConnector jMXConnector = ((JMXConnector) (jmxPooledObject.getObject()));
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("In destroyObject : jMXConnector " + jMXConnector.getConnectionId());
    }
    jMXConnector.close();
}

From source file:org.wso2.appserver.integration.tests.config.EnvironmentVariableReadTestCase.java

@Test(groups = "wso2.as", description = "Try to persist a Employee obj through the Sessionfactory")
public void testConnectingToJMXServer() throws Exception {
    JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://localhost:" + (SERVER_PORT + portOffset)
            + "/jndi/rmi://localhost:" + (REGISTRY_PORT + portOffset) + "/jmxrmi");
    Map<String, Object> environment = new HashMap<>();
    String[] credentials = { "admin", "admin" };
    environment.put(JMXConnector.CREDENTIALS, credentials);
    JMXConnector jmxc = JMXConnectorFactory.connect(url, environment);
    log.info("Connection Id =" + jmxc.getConnectionId());
}