Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## javax.management
Class NotificationBroadcasterSupport

    java.lang.Object
      |
      +--javax.management.NotificationBroadcasterSupport

All Implemented Interfaces:
  NotificationBroadcaster, NotificationEmitter

Direct Known Subclasses:
  Monitor, RelationService, Timer

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:

- Applications should not assume a synchronous model. When the `sendNotification` method returns, it is not guaranteed that every listener's `handleNotification` method has been called. It is not guaranteed either that a listener will see notifications in the same order as they were generated. Listeners that depend on order should use the sequence number of notifications to determine their order (see `Notification.getSequenceNumber()`).
- Applications should not assume an asynchronous model. If the actions performed by a listener are potentially slow, the listener should arrange for them to be performed in another thread, to avoid holding up other listeners and the caller of `sendNotification`.

Author:
  Young Yang

Constructor Summary
`NotificationBroadcasterSupport()`

Method Summary
`void` | `addNotificationListener(NotificationListener listener, NotificationFilter filter, java.lang.Object handback)` Adds a listener.
`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.
`void` | `removeNotificationListener(NotificationListener listener)` Removes a listener.
`void` | `removeNotificationListener(NotificationListener listener, NotificationFilter filter, java.lang.Object handback)` Removes a listener from this MBean.
`void` | `sendNotification(Notification notification)` Sends a notification.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### NotificationBroadcasterSupport

    public NotificationBroadcasterSupport()

Method Detail

### addNotificationListener

    public void addNotificationListener(NotificationListener listener,
                                        NotificationFilter filter,
                                        java.lang.Object handback)

  Adds a listener.
  Specified by:
    `addNotificationListener` in interface `NotificationBroadcaster`
  Parameters:
    `listener` - The listener to receive notifications.
    `filter` - The filter object. If filter is null, no filtering will be performed before handling notifications.
    `handback` - An opaque object to be sent back to the listener when a notification is emitted. This object cannot be used by the Notification broadcaster object. It should be resent unchanged with the notification to the listener.
  Throws:
    `java.lang.IllegalArgumentException` - thrown if the istener is null.
  See Also:
    `removeNotificationListener(javax.management.NotificationListener)`

### removeNotificationListener

    public void removeNotificationListener(NotificationListener listener)
                                    throws ListenerNotFoundException

  Removes a listener. Note that if the listener has been registered with different handback objects or notification filters, all entries corresponding to the listener will be removed.
  Specified by:
    `removeNotificationListener` in interface `NotificationBroadcaster`
  Parameters:
    `listener` - the listener to receive notifications.
  Throws:
    `ListenerNotFoundException` -

### removeNotificationListener

    public void removeNotificationListener(NotificationListener listener,
                                           NotificationFilter filter,
                                           java.lang.Object handback)
                                    throws ListenerNotFoundException

  Description copied from interface: `NotificationEmitter`

  Removes a listener from this MBean. The MBean must have a listener that exactly matches the given `listener`, `filter`, and `handback` parameters. If there is more than one such listener, only one is removed.

  The `filter` and `handback` parameters may be null if and only if they are null in a listener to be removed.

  Specified by:
    `removeNotificationListener` in interface `NotificationEmitter`
  Following copied from interface: `javax.management.NotificationEmitter`
  Parameters:
    `listener` - A listener that was previously added to this MBean.
    `filter` - The filter that was specified when the listener was added.
    `handback` - The handback that was specified when the listener was added.
  Throws:
    `ListenerNotFoundException` - The listener is not registered with the MBean, or it is not registered with the given filter and handback.

### getNotificationInfo

    public MBeanNotificationInfo[] getNotificationInfo()

  Returns a NotificationInfo object contaning the name of the Java class of the notification and the notification types sent.
  Specified by:
    `getNotificationInfo` in interface `NotificationBroadcaster`

### sendNotification

    public void sendNotification(Notification notification)

  Sends a notification. A listener will be removed if an exception appears when calling the listener's handleNotification method.
  Parameters:
    `notification` -

### 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. 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:
    `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.
  Since:
    JMX 1.2

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD