1 8 9 package test.jmx.browser.mx4j; 10 11 import javax.management.remote.JMXServiceURL ; 12 import javax.management.remote.JMXConnector ; 13 import javax.management.remote.JMXConnectorFactory ; 14 import javax.management.MBeanServerConnection ; 15 import javax.management.ObjectName ; 16 import javax.management.NotificationListener ; 17 import javax.management.Notification ; 18 19 24 public class RemotingClient 25 { 26 public static void main(String [] args) throws Exception 27 { 28 JMXServiceURL url = new JMXServiceURL ("rmi", "localhost", 0, "/jndi/jmx"); 29 30 JMXConnector cntor = JMXConnectorFactory.connect(url, null); 31 32 MBeanServerConnection connection = cntor.getMBeanServerConnection(); 33 34 ObjectName delegateName = new ObjectName ("JMImplementation:type=MBeanServerDelegate"); 36 37 NotificationListener listener = new NotificationListener () 38 { 39 public void handleNotification(Notification notification, Object handback) 40 { 41 System.out.println(notification); 42 } 43 }; 44 45 connection.addNotificationListener(delegateName, listener, null, null); 46 } 47 } 48 | Popular Tags |