1 8 9 package mx4j.examples.tools.remote.hessian.ssl; 10 11 import javax.management.MBeanServerConnection ; 12 import javax.management.MBeanServerDelegateMBean ; 13 import javax.management.MBeanServerInvocationHandler ; 14 import javax.management.Notification ; 15 import javax.management.NotificationListener ; 16 import javax.management.ObjectName ; 17 import javax.management.remote.JMXConnector ; 18 import javax.management.remote.JMXConnectorFactory ; 19 import javax.management.remote.JMXServiceURL ; 20 import javax.management.timer.Timer ; 21 22 41 public class Client 42 { 43 public static void main(String [] args) throws Exception 44 { 45 System.setProperty("javax.net.ssl.trustStore", "<your-keystore>"); 48 49 JMXServiceURL address = new JMXServiceURL ("hessian+ssl", null, 8443, "/hessianssl"); 52 53 JMXConnector connector = JMXConnectorFactory.connect(address); 55 56 MBeanServerConnection connection = connector.getMBeanServerConnection(); 59 60 ObjectName delegateName = ObjectName.getInstance("JMImplementation:type=MBeanServerDelegate"); 62 Object proxy = MBeanServerInvocationHandler.newProxyInstance(connection, delegateName, MBeanServerDelegateMBean .class, true); 63 MBeanServerDelegateMBean delegate = (MBeanServerDelegateMBean )proxy; 64 65 System.out.println(delegate.getImplementationVendor() + " is cool !"); 66 67 connection.addNotificationListener(delegateName, new NotificationListener () 69 { 70 public void handleNotification(Notification notification, Object handback) 71 { 72 System.out.println("Got the following notification: " + notification); 73 } 74 }, null, null); 75 76 ObjectName timerName = ObjectName.getInstance("services:type=Timer"); 77 connection.createMBean(Timer .class.getName(), timerName, null); 78 79 connection.unregisterMBean(timerName); 81 82 Thread.sleep(1000); 84 85 connector.close(); 86 } 87 } 88 | Popular Tags |