1 8 9 package mx4j.examples.remote.rmi.iiop; 10 11 import javax.management.Attribute ; 12 import javax.management.MBeanServer ; 13 import javax.management.MBeanServerFactory ; 14 import javax.management.ObjectName ; 15 import javax.management.remote.JMXConnectorServer ; 16 import javax.management.remote.JMXConnectorServerFactory ; 17 import javax.management.remote.JMXServiceURL ; 18 19 27 public class Server 28 { 29 public static void main(String [] args) throws Exception 30 { 31 MBeanServer server = MBeanServerFactory.createMBeanServer(); 33 34 ObjectName namingName = ObjectName.getInstance("naming:type=tnameserv"); 38 server.createMBean("mx4j.tools.naming.CosNamingService", namingName, null); 39 int namingPort = 1199; 41 server.setAttribute(namingName, new Attribute ("Port", new Integer (namingPort))); 42 server.invoke(namingName, "start", null, null); 43 44 String jndiPath = "/jmxconnector"; 45 JMXServiceURL url = new JMXServiceURL ("service:jmx:iiop://localhost/jndi/iiop://localhost:" + namingPort + jndiPath); 50 51 JMXConnectorServer connectorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, null, server); 53 connectorServer.start(); 54 55 System.out.println("Server up and running"); 56 } 57 } 58 | Popular Tags |