javax.management
Class NotificationBroadcasterSupport

java.lang.Object
  |
  +--javax.management.NotificationBroadcasterSupport
Direct Known Subclasses:
Cascader, Monitor, RelationService, Timer, TrapListenerAndForwarder

public class NotificationBroadcasterSupport
extends java.lang.Object
implements NotificationEmitter

Provides an implementation of NotificationEmitter interface. This can be used as the super class of an MBean that sends notifications.

It is not specified whether the notification dispatch model is synchronous or asynchronous. That is, when a thread calls sendNotification, the NotificationListener.handleNotification method of each listener may be called within that thread (a synchronous model) or within some other thread (an asynchronous model).

Applications should not depend on notification dispatch being synchronous or being asynchronous. Thus:


Field Summary
(package private)  javax.management.NotificationBroadcasterSupport.ListenerInfo li
           
 
Constructor Summary
NotificationBroadcasterSupport()
          Creates a NotificationBraoadCasterSupport.
 
Method Summary
 void addNotificationListener(NotificationListener listener, NotificationFilter filter, java.lang.Object handback)
          Enables a couple (listener,handback) for a registered MBean to be added.
 MBeanNotificationInfo[] getNotificationInfo()
          Returns a NotificationInfo object contaning the name of the Java class of the notification and the notification types sent.
protected  void handleNotification(NotificationListener listener, Notification notif, java.lang.Object handback)
          This method is called by sendNotification for each listener in order to send the notification to that listener.
(package private)  void handleNotification(Notification notif, javax.management.NotificationBroadcasterSupport.ListenerInfo listenerInfo)
          This method is called by sendNotification for each listener in order to send the notification to that listener.
 void removeNotificationListener(NotificationListener listener)
          Enables a listener for an MBean to be removed.
 void removeNotificationListener(NotificationListener listener, NotificationFilter filter, java.lang.Object handback)
          Enables a listener for an MBean to be removed.
 void sendNotification(Notification notification)
          Enables a MBean to send a notification.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

li

javax.management.NotificationBroadcasterSupport.ListenerInfo li
Constructor Detail

NotificationBroadcasterSupport

public NotificationBroadcasterSupport()
Creates a NotificationBraoadCasterSupport. Default constructor
Method Detail

addNotificationListener

public void addNotificationListener(NotificationListener listener,
                                    NotificationFilter filter,
                                    java.lang.Object handback)
Enables a couple (listener,handback) for a registered MBean to be added.
Parameters:
listener - The listener object which will handles notifications emitted by the registered MBean.
filter - The filter object. If not specified, no filtering will be performed before handling notifications.
handback - The context to be sent to the listener when a notification is emitted.
Throws:
java.lang.IllegalArgumentException - - Listener parameter is null.

removeNotificationListener

public void removeNotificationListener(NotificationListener listener)
                                throws ListenerNotFoundException
Enables a listener for an MBean to be removed. All couple (listener, handback) are removed.
Parameters:
listener - The listener object which will handles notifications emitted by the registered MBean.
Throws:
ListenerNotFoundException - The listener is not registered in the MBean.

removeNotificationListener

public void removeNotificationListener(NotificationListener listener,
                                       NotificationFilter filter,
                                       java.lang.Object handback)
                                throws ListenerNotFoundException
Enables a listener for an MBean to be removed. Those listeners whose filter and handback objects are matching with the argument for this method will only be removed.
Specified by:
removeNotificationListener in interface NotificationEmitter
Parameters:
listener - The listener object which will handles notifications related details
filter - This is the filter object which will handles filter related details
handback - Using this object we are able to handle the handback related details emitted by the registered MBean.
Throws:
ListenerNotFoundException - The listener is not registered in the MBean.

getNotificationInfo

public MBeanNotificationInfo[] getNotificationInfo()
Returns a NotificationInfo object contaning the name of the Java class of the notification and the notification types sent.
Returns:
This returns a array of MBeanNotificationInfo which contains the notification information.

sendNotification

public void sendNotification(Notification notification)
Enables a MBean to send a notification.
Parameters:
notif - - The notification to send.

handleNotification

protected void handleNotification(NotificationListener listener,
                                  Notification notif,
                                  java.lang.Object handback)

This method is called by sendNotification for each listener in order to send the notification to that listener.

This method helps to deliver the notification in separate thread.

Parameters:
listener - the listener to which the notification is being delivered.
notif - the notification being delivered to the listener.
handback - the handback object that was supplied when the listener was added.

handleNotification

void handleNotification(Notification notif,
                        javax.management.NotificationBroadcasterSupport.ListenerInfo listenerInfo)

This method is called by sendNotification for each listener in order to send the notification to that listener. It can be overridden in subclasses to change the behaviour of notification delivery, for instance to deliver the notification in a separate thread.

It is not guaranteed that this method is called by the same thread as the one that called sendNotification.

The default implementation of this method is equivalent to

 listener.handleNotification(notif, handback);
 
Parameters:
listenerInfo - the ListenerInfo object