/** * Removes all registrations for a listener. * * @param listener the listener to remove * @exception ListenerNotFoundException when the listener is not registered */ public void remove(NotificationListener listener) throws ListenerNotFoundException { ArrayList registrations = null; synchronized(listeners) { if (listeners.containsKey(listener) == false) throw new ListenerNotFoundException("Listener not found " + listener); HashMap newListeners = (HashMap) listeners.clone(); registrations = (ArrayList) newListeners.remove(listener); listeners = newListeners; } for (Iterator iterator = registrations.iterator(); iterator.hasNext();) { ListenerRegistration registration = (ListenerRegistration) iterator.next(); registration.removed(); } }
public void sendNotification(Notification notification) { ListenerRegistry.ListenerRegistrationIterator iterator = registry.iterator(); while (iterator.hasNext()) { ListenerRegistration registration = iterator.nextRegistration(); NotificationFilter filter = registration.getFilter(); if (filter == null) handleNotification(registration.getListener(), notification, registration.getHandback()); else if (filter.isNotificationEnabled(notification)) handleNotification(registration.getListener(), notification, registration.getHandback()); } }
public boolean equals(Object obj) { if (obj == null || (obj instanceof ListenerRegistration) == false) return false; ListenerRegistration other = (ListenerRegistration) obj; if (getRegisteredListener().equals(other.getRegisteredListener()) == false) return false; NotificationFilter myFilter = getRegisteredFilter(); NotificationFilter otherFilter = other.getRegisteredFilter(); if (myFilter != null && myFilter.equals(otherFilter) == false) return false; else if (myFilter == null && otherFilter != null) return false; Object myHandback = getHandback(); Object otherHandback = other.getHandback(); if (myHandback != null && myHandback.equals(otherHandback) == false) return false; else if (myHandback == null && otherHandback != null) return false; return true; }
registration.removed();
/** * Removes all registrations for an mbean broadcaster. * * @param name the object name * @exception IllegalArgumentException for a null object name */ public void remove(ObjectName name) { if (name == null) throw new IllegalArgumentException("Null name"); ListenerRegistry registry = null; synchronized(registries) { registry = (ListenerRegistry) registries.remove(name); if (registry == null) return; } // Remove the registrations with the MBean for (ListenerRegistry.ListenerRegistrationIterator iterator = registry.iterator(); iterator.hasNext();) { ListenerRegistration registration = iterator.nextRegistration(); registration.removed(); } }
/** * Removes all registrations for an mbean broadcaster. * * @param name the object name * @exception IllegalArgumentException for a null object name */ public void remove(ObjectName name) { if (name == null) throw new IllegalArgumentException("Null name"); ListenerRegistry registry = null; synchronized(registries) { registry = (ListenerRegistry) registries.remove(name); if (registry == null) return; } // Remove the registrations with the MBean for (ListenerRegistry.ListenerRegistrationIterator iterator = registry.iterator(); iterator.hasNext();) { ListenerRegistration registration = iterator.nextRegistration(); registration.removed(); } }