1 22 package org.jboss.test.jmx.listener; 23 24 import java.util.ArrayList ; 25 import java.util.Collections ; 26 import java.util.List ; 27 28 import javax.management.Notification ; 29 30 import org.jboss.system.ListenerServiceMBeanSupport; 31 32 41 public class NotificationListener extends ListenerServiceMBeanSupport 42 implements NotificationListenerMBean 43 { 44 46 47 private List notifList; 48 49 51 54 public NotificationListener() 55 { 56 notifList = Collections.synchronizedList(new ArrayList ()); 57 } 58 59 61 64 public int getNotificationCount() 65 { 66 return notifList.size(); 67 } 68 69 72 public List retrieveNotifications() 73 { 74 return new ArrayList (notifList); 75 } 76 77 80 public void clearNotifications() 81 { 82 notifList.clear(); 83 } 84 85 87 protected void startService() throws Exception 88 { 89 clearNotifications(); 90 super.subscribe(false); 91 } 92 93 protected void stopService() 94 { 95 super.unsubscribe(); 96 clearNotifications(); 97 } 98 99 101 public void handleNotification2(Notification notification, Object handback) 102 { 103 notifList.add(notification); 104 log.debug("Received notification #" + notifList.size() + ": " + notification); 105 } 106 } 107 | Popular Tags |