This section outlines how to start the Socket adaptor in your Java MBeanServer. This will allow C# MBeanServers to transparently connect to your Java MBean server.
Listing 1 |
---|
MBeanServer mbs = MBeanServerFactory.createMBeanServer("net.sourceforge.monojmx.socket"); |
Listing 2 |
---|
JMXServiceURL nativeurl = new JMXServiceURL("socket","localhost",8765,"/socketconnector"); Map env = new java.util.HashMap(); env.put(JMXConnectorServerFactory.PROTOCOL_PROVIDER_PACKAGES,"net.sourceforge.monojmx"); JMXConnectorServer jcs = JMXConnectorServerFactory.newJMXConnectorServer(nativeurl,env,mbs); jcs.start(); |
Listing 3 |
---|
Map env = new java.util.HashMap(); env.put(JMXConnectorServerFactory.PROTOCOL_PROVIDER_PACKAGES,"net.sourceforge.monojmx"); JMXServiceURL url = new JMXServiceURL("service:jmx:socket://localhost:8765"); JMXConnector remoteConnectorClient = JMXConnectorFactory.connect(url,env); MBeanServerConnection rmbs = remoteConnectorClient.getMBeanServerConnection(); |