use of javax.management.MBeanServerConnection in project jmxtrans by jmxtrans.
the class TreeWalker method main.
public static void main(String[] args) throws Exception {
Server server = Server.builder().setHost("localhost").setPort("1099").build();
JMXConnector conn = null;
try {
conn = server.getServerConnection();
MBeanServerConnection mbeanServer = conn.getMBeanServerConnection();
TreeWalker tw = new TreeWalker();
tw.walkTree(mbeanServer);
} catch (IOException e) {
log.error("Problem processing queries for server: " + server.getHost() + ":" + server.getPort(), e);
} finally {
if (conn != null) {
conn.close();
}
}
}
use of javax.management.MBeanServerConnection in project jmxtrans by jmxtrans.
the class TreeWalker2 method main.
/** */
public static void main(String[] args) throws Exception {
Server server = Server.builder().setHost("localhost").setPort("1099").build();
JMXConnector conn = null;
try {
conn = server.getServerConnection();
MBeanServerConnection mbeanServer = conn.getMBeanServerConnection();
TreeWalker2 tw = new TreeWalker2();
tw.walkTree(mbeanServer, server);
} catch (IOException e) {
log.error("Problem processing queries for server: " + server.getHost() + ":" + server.getPort(), e);
} finally {
if (conn != null) {
conn.close();
}
}
}
use of javax.management.MBeanServerConnection in project jmxtrans by jmxtrans.
the class TreeWalker3 method main.
/** */
public static void main(String[] args) throws Exception {
Server server = Server.builder().setHost("w2").setPort("1105").build();
JMXConnector conn = null;
try {
conn = server.getServerConnection();
MBeanServerConnection mbeanServer = conn.getMBeanServerConnection();
TreeWalker3 tw = new TreeWalker3();
tw.walkTree(mbeanServer, server);
} catch (IOException e) {
log.error("Problem processing queries for server: " + server.getHost() + ":" + server.getPort(), e);
} finally {
if (conn != null) {
conn.close();
}
}
}
use of javax.management.MBeanServerConnection in project jvm-breakglass by matlux.
the class MBeanTest method testStartStopViaJMX.
@Test
public void testStartStopViaJMX() throws Exception {
int port = 9876;
JMXServiceURL url = new JMXServiceURL(String.format("service:jmx:rmi:///jndi/rmi://localhost:%d/jmxrmi", port));
JMXConnectorServer jmxServer = createJMXServer(port, url);
try {
jmxServer.start();
assertFalse(nreplServer.isStarted());
JMXConnector connector = JMXConnectorFactory.connect(url);
try {
MBeanServerConnection conn = connector.getMBeanServerConnection();
ObjectName objectName = MBeanRegistration.getObjectName();
NreplMBean proxy = JMX.newMBeanProxy(conn, objectName, NreplMBean.class);
assertFalse(proxy.isStarted());
proxy.start();
assertTrue(proxy.isStarted());
proxy.stop();
assertFalse(proxy.isStarted());
} finally {
connector.close();
}
} finally {
jmxServer.stop();
}
assertFalse(nreplServer.isStarted());
}
use of javax.management.MBeanServerConnection in project jvm-breakglass by matlux.
the class MBeanTest method testStartViaJMX.
@Test
public void testStartViaJMX() throws Exception {
int port = 9875;
JMXServiceURL url = new JMXServiceURL(String.format("service:jmx:rmi:///jndi/rmi://localhost:%d/jmxrmi", port));
JMXConnectorServer jmxServer = createJMXServer(port, url);
try {
jmxServer.start();
assertFalse(nreplServer.isStarted());
JMXConnector connector = JMXConnectorFactory.connect(url);
try {
MBeanServerConnection conn = connector.getMBeanServerConnection();
ObjectName objectName = MBeanRegistration.getObjectName();
NreplMBean proxy = JMX.newMBeanProxy(conn, objectName, NreplMBean.class);
assertFalse(proxy.isStarted());
proxy.start();
assertTrue(proxy.isStarted());
} finally {
connector.close();
}
assertTrue(nreplServer.isStarted());
} finally {
jmxServer.stop();
}
}
Aggregations