1 22 package org.jboss.mx.notification; 23 24 import javax.management.ListenerNotFoundException ; 25 import javax.management.NotificationBroadcaster ; 26 import javax.management.NotificationEmitter ; 27 import javax.management.NotificationFilter ; 28 import javax.management.NotificationListener ; 29 import javax.management.ObjectName ; 30 31 44 public class MBeanServerListenerRegistration 45 extends DefaultListenerRegistration 46 { 47 49 52 private NotificationListener proxy; 53 54 private NotificationFilter filterProxy; 55 56 59 private NotificationBroadcaster broadcaster; 60 61 63 72 public MBeanServerListenerRegistration(ObjectName name, 73 NotificationBroadcaster broadcaster, 74 NotificationListener listener, 75 NotificationFilter filter, 76 Object handback) 77 { 78 super(listener, filter, handback); 79 proxy = (NotificationListener ) NotificationListenerProxy.newInstance(name, listener); 80 this.broadcaster = broadcaster; 81 this.filterProxy = (filter==null) ? null : new NotificationFilterProxy(name,filter); 82 broadcaster.addNotificationListener(proxy, filterProxy, handback); 83 } 84 85 87 89 public NotificationListener getListener() 90 { 91 return proxy; 92 } 93 94 public NotificationFilter getFilter() 95 { 96 return filterProxy; 97 } 98 99 public void removed() 100 { 101 try 102 { 103 if (broadcaster instanceof NotificationEmitter ) 104 ((NotificationEmitter ) broadcaster).removeNotificationListener(getListener(), getFilter(), getHandback()); 105 else 106 broadcaster.removeNotificationListener(getListener()); 107 } 108 catch (ListenerNotFoundException ignored) 109 { 110 } 111 } 112 } 113 | Popular Tags |