This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.


javax.management
class NotificationBroadcasterSupport

java.lang.Object extended by javax.management.NotificationBroadcasterSupport
All Implemented Interfaces:
NotificationEmitter
Direct Known Subclasses:
JMXConnectorServer, Monitor, RelationService, Timer

Most common way to construct:

NotificationBroadcasterSupport broadcaster = new NotificationBroadcasterSupport();

Based on 50 examples


public class NotificationBroadcasterSupport
extends Object
implements NotificationEmitter

Provides an implementation of {@link javax.management.NotificationEmitter NotificationEmitter} interface. This can be used as the super class of an MBean that sends notifications.

By default, the notification dispatch model is synchronous. That is, when a thread calls sendNotification, the NotificationListener.handleNotification method of each listener is called within that thread. You can override this default by overriding handleNotification in a subclass, or by passing an Executor to the constructor.

If the method call of a filter or listener throws an {@link Exception}, then that exception does not prevent other listeners from being invoked. However, if the method call of a filter or of {@code Executor.execute} or of {@code handleNotification} (when no {@code Excecutor} is specified) throws an {@link Error}, then that {@code Error} is propagated to the caller of {@link #sendNotification sendNotification}.

Remote listeners added using the JMX Remote API (see JMXConnector) are not usually called synchronously. That is, when sendNotification returns, it is not guaranteed that any remote listeners have yet received the notification.


Constructor Summary

          Constructs a NotificationBroadcasterSupport where each listener is invoked by the thread sending the notification.

          Constructs a NotificationBroadcasterSupport where each listener is invoked using the given java.util.concurrent.Executor.

          Constructs a NotificationBroadcasterSupport with information about the notifications that may be sent, and where each listener is invoked using the given java.util.concurrent.Executor.

          Constructs a NotificationBroadcasterSupport with information about the notifications that may be sent.
 
Method Summary
 void

          Adds a listener.
 MBeanNotificationInfo[]

          
protected void

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

          
 void

          
 void

          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()
Constructs a NotificationBroadcasterSupport where each listener is invoked by the thread sending the notification. This constructor is equivalent to {@link NotificationBroadcasterSupport#NotificationBroadcasterSupport(Executor, MBeanNotificationInfo[] info) NotificationBroadcasterSupport(null, null)}.


NotificationBroadcasterSupport

public NotificationBroadcasterSupport(Executor executor)
Constructs a NotificationBroadcasterSupport where each listener is invoked using the given {@link java.util.concurrent.Executor}. When {@link #sendNotification sendNotification} is called, a listener is selected if it was added with a null {@link NotificationFilter}, or if {@link NotificationFilter#isNotificationEnabled isNotificationEnabled} returns true for the notification being sent. The call to NotificationFilter.isNotificationEnabled takes place in the thread that called sendNotification. Then, for each selected listener, {@link Executor#execute executor.execute} is called with a command that calls the handleNotification method. This constructor is equivalent to {@link NotificationBroadcasterSupport#NotificationBroadcasterSupport(Executor, MBeanNotificationInfo[] info) NotificationBroadcasterSupport(executor, null)}.

Parameters:
executor - an executor used by the method sendNotification to send each notification. If it is null, the thread calling sendNotification will invoke the handleNotification method itself.

NotificationBroadcasterSupport

public NotificationBroadcasterSupport(Executor executor,
                                      MBeanNotificationInfo[] info)

Constructs a NotificationBroadcasterSupport with information about the notifications that may be sent, and where each listener is invoked using the given {@link java.util.concurrent.Executor}.

When {@link #sendNotification sendNotification} is called, a listener is selected if it was added with a null {@link NotificationFilter}, or if {@link NotificationFilter#isNotificationEnabled isNotificationEnabled} returns true for the notification being sent. The call to NotificationFilter.isNotificationEnabled takes place in the thread that called sendNotification. Then, for each selected listener, {@link Executor#execute executor.execute} is called with a command that calls the handleNotification method.

If the info array is not empty, then it is cloned by the constructor as if by {@code info.clone()}, and each call to {@link #getNotificationInfo()} returns a new clone.

Parameters:
executor - an executor used by the method sendNotification to send each notification. If it is null, the thread calling sendNotification will invoke the handleNotification method itself.
info - an array indicating, for each notification this MBean may send, the name of the Java class of the notification and the notification type. Can be null, which is equivalent to an empty array.

NotificationBroadcasterSupport

public NotificationBroadcasterSupport(MBeanNotificationInfo[] info)

Constructs a NotificationBroadcasterSupport with information about the notifications that may be sent. Each listener is invoked by the thread sending the notification. This constructor is equivalent to {@link NotificationBroadcasterSupport#NotificationBroadcasterSupport(Executor, MBeanNotificationInfo[] info) NotificationBroadcasterSupport(null, info)}.

If the info array is not empty, then it is cloned by the constructor as if by {@code info.clone()}, and each call to {@link #getNotificationInfo()} returns a new clone.

Parameters:
info - an array indicating, for each notification this MBean may send, the name of the Java class of the notification and the notification type. Can be null, which is equivalent to an empty array.
Method Detail

addNotificationListener

public void addNotificationListener(NotificationListener listener,
                                    NotificationFilter filter,
                                    Object handback)
Adds a listener.

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.

getNotificationInfo

public MBeanNotificationInfo[] getNotificationInfo()

handleNotification

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

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

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.

removeNotificationListener

public void removeNotificationListener(NotificationListener listener)
                                throws ListenerNotFoundException
Parameters:
listener
Throws:
ListenerNotFoundException

removeNotificationListener

public void removeNotificationListener(NotificationListener listener,
                                       NotificationFilter filter,
                                       Object handback)
                                throws ListenerNotFoundException
Parameters:
listener
filter
handback
Throws:
ListenerNotFoundException

sendNotification

public void sendNotification(Notification notification)
Sends a notification. If an {@code Executor} was specified in the constructor, it will be given one task per selected listener to deliver the notification to that listener.

Parameters:
notification - The notification to send.


This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.
This page displays the Jadeite version of the documention, which is derived from the offical documentation that contains this copyright notice:
Copyright 2008 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
The official Sun™ documentation can be found here at http://java.sun.com/javase/6/docs/api/.