1 8 9 package mx4j.examples.mbeans.legacy; 10 11 import javax.management.MBeanServer ; 12 import javax.management.MBeanServerFactory ; 13 import javax.management.Notification ; 14 import javax.management.NotificationListener ; 15 import javax.management.ObjectName ; 16 17 24 public class LegacyExample 25 { 26 public static void main(String [] args) throws Exception  27 { 28 LegacyService legacyService = new LegacyService(); 30 31 MBeanServer server = MBeanServerFactory.newMBeanServer(); 33 ObjectName serviceName = new ObjectName ("examples", "mbean", "legacy"); 34 DynamicLegacyService dynamicService = new DynamicLegacyService(legacyService); 35 server.registerMBean(dynamicService, serviceName); 36 37 server.addNotificationListener(serviceName, new NotificationListener () 39 { 40 public void handleNotification(Notification notification, Object handback) 41 { 42 System.out.println(notification); 43 } 44 }, null, null); 45 46 server.invoke(serviceName, "start", null, null); 48 } 49 50 57 public static void oldMain(String [] args) 58 { 59 LegacyService service = new LegacyService(); 60 service.execute(); 61 } 62 } 63 | Popular Tags |