1 7 package test.sample.simple; 8 9 import java.rmi.registry.LocateRegistry ; 10 import java.rmi.registry.Registry ; 11 import javax.management.MBeanServer ; 12 import javax.management.MBeanServerFactory ; 13 import javax.management.remote.JMXConnectorServer ; 14 import javax.management.remote.JMXConnectorServerFactory ; 15 import javax.management.remote.JMXServiceURL ; 16 17 20 public class Server 21 { 22 public static void main(String [] args) throws Exception 23 { 24 MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer(); 25 26 int registryPort = Registry.REGISTRY_PORT; 27 Registry rmiRegistry = LocateRegistry.createRegistry(registryPort); 28 29 String jndiPath = "/jmxconnector"; 30 JMXServiceURL url = new JMXServiceURL ("service:jmx:rmi://localhost/jndi/rmi://localhost:" + registryPort + jndiPath); 31 32 JMXConnectorServer connectorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbeanServer); 34 connectorServer.start(); 35 36 System.out.println("Connector server started."); 37 38 } 40 } | Popular Tags |