1 23 package com.sun.enterprise.management.base; 24 25 import java.util.Set ; 26 27 import javax.management.Notification ; 28 import javax.management.NotificationListener ; 29 import javax.management.NotificationFilter ; 30 import javax.management.NotificationFilterSupport ; 31 32 import com.sun.appserv.management.config.Enabled; 33 import com.sun.appserv.management.base.AMX; 34 35 import com.sun.enterprise.management.AMXTestBase; 36 37 38 40 public final class ListenerTest extends AMXTestBase 41 { 42 public ListenerTest() 43 { 44 } 45 46 private static class DummyListener implements NotificationListener 47 { 48 public DummyListener() {} 49 50 public void 51 handleNotification( 52 final Notification notif, 53 final Object handback ) 54 { 55 } 56 } 57 58 public void 59 testAddRemoveNotificationListener() 60 throws Exception 61 { 62 final long start = now(); 63 final Set <AMX> all = getAllAMX(); 64 65 final NotificationListener listener1 = new DummyListener(); 66 final NotificationListener listener2 = new DummyListener(); 67 68 final NotificationFilter filter = new NotificationFilterSupport (); 69 final Object handback = "handback"; 70 71 for( final AMX amx : all ) 72 { 73 amx.getNotificationInfo(); 74 amx.addNotificationListener( listener1, null, null ); 75 amx.addNotificationListener( listener2, filter, handback ); 76 } 77 78 for( final AMX amx : all ) 79 { 80 amx.removeNotificationListener( listener1 ); 81 amx.removeNotificationListener( listener2, filter, handback ); 82 } 83 84 printElapsed( "Added/removed NotificationListener", all.size(), start ); 85 } 86 87 88 89 } 90 91 92 | Popular Tags |