jmx添加naming service以及一個rmi 監聽方式

			ObjectName namingName = new ObjectName("naming:type=rmiregistry");
mx4j.tools.naming.NamingService service = new mx4j.tools.naming.NamingService();
_mBeanServer.registerMBean(service, namingName);
_mBeanServer.setAttribute(namingName, new Attribute("Port", new Integer(1984)));
_mBeanServer.invoke(namingName, "start", null, null);
//startup the naming service. Just like a dns server.
int port = ((Integer) _mBeanServer.getAttribute(namingName, "Port")).intValue();

// The address of the connector
JMXServiceURL address = new JMXServiceURL(
"service:jmx:rmi://localhost/jndi/rmi://localhost" + ":" + port + "/jmxconnector");
JMXConnectorServer connectorServer = JMXConnectorServerFactory.newJMXConnectorServer(address, null, _mBeanServer);
connectorServer.start();
// start up the rmi service. Just like a application server, such as http, ftp, smtp server.


jdk1.6對mx4j的一些東西有兼容性問題,需要手動指定:
-Djavax.management.builder.initial=mx4j.server.MX4JMBeanServerBuilder
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章