public ListenerRegistration create(NotificationListener listener, NotificationFilter filter, Object handback) { return new DefaultListenerRegistration(listener, filter, handback); } }
public void removeNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws ListenerNotFoundException { registry.remove(listener, filter, handback); }
/** * Convenience method to returned a typed object */ public ListenerRegistration nextRegistration() { return (ListenerRegistration) next(); }
/** * 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(); } }
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; }
public void removed() { try { if (broadcaster instanceof NotificationEmitter) ((NotificationEmitter) broadcaster).removeNotificationListener(getListener(), getFilter(), getHandback()); else broadcaster.removeNotificationListener(getListener()); } catch (ListenerNotFoundException ignored) { } } }
/** * Create a listener registration * * @param name the object name to use as the notifiation source * @param broadcaster the notification broadcaster * @param listener the notification listener * @param filter the notification filter * @param handback the handback object a */ public MBeanServerListenerRegistration(ObjectName name, NotificationBroadcaster broadcaster, NotificationListener listener, NotificationFilter filter, Object handback) { super(listener, filter, handback); proxy = (NotificationListener) NotificationListenerProxy.newInstance(name, listener); this.broadcaster = broadcaster; this.filterProxy = (filter==null) ? null : new NotificationFilterProxy(name,filter); broadcaster.addNotificationListener(proxy, filterProxy, handback); }
public Object next() { if (hasNext() == false) throw new NoSuchElementException("Use hasNext before next"); return registrationIterator.next(); }
public String toString() { StringBuffer buffer = new StringBuffer(50); buffer.append(getClass()).append(":"); buffer.append(" listener=").append(getRegisteredListener()); buffer.append(" filter=") .append(getRegisteredFilter()); buffer.append(" handback=").append(getHandback()); return buffer.toString(); } }
public void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) { try { registry.add(listener, filter, handback); } catch (JMException e) { // This shouldn't happen? throw new RuntimeException(e.toString()); } }
public ListenerRegistration create(NotificationListener listener, NotificationFilter filter, Object handback) { return new MBeanServerListenerRegistration(name, broadcaster, listener, filter, handback); } }
public void releaseServer() { // shutdown the loader repository // try // { // invoke(new ObjectName(DEFAULT_LOADER_NAME), // "releaseLoaderRepository", // new Object[0], // new String[0] ); // } // catch (Exception e) // { // log.error("Unable to shutdown loader repository"); // e.printStackTrace(); // } registry.releaseRegistry(); listeners.removeAll(); listeners = null; registry = null; }
/** * Retrieve an iterator over the registrations<p> * * The iterator behaves like a snapshot of the registrations * is taken during this operation. * * @return the iterator */ public ListenerRegistrationIterator iterator() { return new ListenerRegistrationIterator(); }
/** * Create a notification listener registry using the passed * listener registration factory.<p> * * @param factory the factory to create registrations, use * null for the default factory */ public ListenerRegistry(ListenerRegistrationFactory factory) { if (factory == null) this.factory = new DefaultListenerRegistrationFactory(); else this.factory = factory; }
/** * Handle the notification, asynchronously invoke the listener. * * @param listener the listener to notify * @param notification the notification * @param handback the handback object */ public void handleNotification(NotificationListener listener, Notification notification, Object handback) { AsynchNotifier notifier = new AsynchNotifier(listener, notification, handback); pool.run(notifier, 0, notificationTimeout); }
/** * 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(); } }
/** * Create a listener registration * * @param name the object name to use as the notifiation source * @param broadcaster the notification broadcaster * @param listener the notification listener * @param filter the notification filter * @param handback the handback object a */ public MBeanServerListenerRegistration(ObjectName name, NotificationBroadcaster broadcaster, NotificationListener listener, NotificationFilter filter, Object handback) { super(listener, filter, handback); proxy = (NotificationListener) NotificationListenerProxy.newInstance(name, listener); this.broadcaster = broadcaster; this.filterProxy = (filter==null) ? null : new NotificationFilterProxy(name,filter); broadcaster.addNotificationListener(proxy, filterProxy, handback); }
public ListenerRegistration create(NotificationListener listener, NotificationFilter filter, Object handback) { return new MBeanServerListenerRegistration(name, broadcaster, listener, filter, handback); } }
public void releaseServer() { // shutdown the loader repository // try // { // invoke(new ObjectName(DEFAULT_LOADER_NAME), // "releaseLoaderRepository", // new Object[0], // new String[0] ); // } // catch (Exception e) // { // log.error("Unable to shutdown loader repository"); // e.printStackTrace(); // } registry.releaseRegistry(); listeners.removeAll(); listeners = null; registry = null; }