APIdia Launch Partner
Top Description Inners Fields Constructors Methods
javax.management

public Class NotificationBroadcasterSupport

extends Object
implements NotificationEmitter
Class Inheritance
All Implemented Interfaces
javax.management.NotificationEmitter, javax.management.NotificationBroadcaster
Known Direct Subclasses
javax.management.monitor.Monitor, javax.management.relation.RelationService, javax.management.remote.JMXConnectorServer, javax.management.timer.Timer
Imports
java.util.Collections, .List, .Objects, java.util.concurrent.CopyOnWriteArrayList, .Executor, com.sun.jmx.remote.util.ClassLogger

Provides an implementation of 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 Exception, then that exception does not prevent other listeners from being invoked. However, if the method call of a filter or of Executor.execute or of handleNotification (when no Executor is specified) throws an Error, then that Error is propagated to the caller of 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.

Since
1.5

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private class
private static class

Field Summary

Modifier and TypeField and Description
private static final Executor
private final Executor
private List<NotificationBroadcasterSupport.ListenerInfo>
private static final ClassLogger
private static final MBeanNotificationInfo[]
private final MBeanNotificationInfo[]

Constructor Summary

AccessConstructor and Description
public
NotificationBroadcasterSupport()

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

public
NotificationBroadcasterSupport(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.
executor
)

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

public
NotificationBroadcasterSupport(MBeanNotificationInfo...
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.
info
)

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

public
NotificationBroadcasterSupport(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.
executor
,
MBeanNotificationInfo...
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.
info
)

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.

Method Summary

Modifier and TypeMethod and Description
public void
addNotificationListener(NotificationListener
The listener to receive notifications.
listener
,
NotificationFilter
The filter object. If filter is null, no filtering will be performed before handling notifications.
filter
,
Object
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.
handback
)

Implements javax.management.NotificationBroadcaster.addNotificationListener.

Adds a listener.

public MBeanNotificationInfo[]
getNotificationInfo()

Implements javax.management.NotificationBroadcaster.getNotificationInfo.

Returns an array indicating, for each notification this MBean may send, the name of the Java class of the notification and the notification type.

protected void
handleNotification(NotificationListener
the listener to which the notification is being delivered.
listener
,
Notification
the notification being delivered to the listener.
notif
,
Object
the handback object that was supplied when the listener was added.
handback
)

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

public void
public void
public void
sendNotification(Notification
The notification to send.
notification
)

Sends a notification.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

defaultExecutorback to summary
private static final Executor defaultExecutor
executorback to summary
private final Executor executor
listenerListback to summary
private List<NotificationBroadcasterSupport.ListenerInfo> listenerList
loggerback to summary
private static final ClassLogger logger
NO_NOTIFICATION_INFOback to summary
private static final MBeanNotificationInfo[] NO_NOTIFICATION_INFO
notifInfoback to summary
private final MBeanNotificationInfo[] notifInfo

Constructor Detail

NotificationBroadcasterSupportback to summary
public NotificationBroadcasterSupport()

Constructs a NotificationBroadcasterSupport where each listener is invoked by the thread sending the notification. This constructor is equivalent to NotificationBroadcasterSupport(null, null).

NotificationBroadcasterSupportback to summary
public NotificationBroadcasterSupport(Executor executor)

Constructs a NotificationBroadcasterSupport where each listener is invoked using the given java.util.concurrent.Executor. When sendNotification is called, a listener is selected if it was added with a null NotificationFilter, or if 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, executor.execute is called with a command that calls the handleNotification method. This constructor is equivalent to NotificationBroadcasterSupport(executor, null).

Parameters
executor: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.

Since
1.6
NotificationBroadcasterSupportback to summary
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 NotificationBroadcasterSupport(null, info).

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

Parameters
info:MBeanNotificationInfo[]

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.

Since
1.6
NotificationBroadcasterSupportback to summary
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 java.util.concurrent.Executor.

When sendNotification is called, a listener is selected if it was added with a null NotificationFilter, or if 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, 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 info.clone(), and each call to getNotificationInfo() returns a new clone.

Parameters
executor: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:MBeanNotificationInfo[]

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.

Since
1.6

Method Detail

addNotificationListenerback to summary
public void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback)

Implements javax.management.NotificationBroadcaster.addNotificationListener.

Adds a listener.

Parameters
listener:NotificationListener

The listener to receive notifications.

filter:NotificationFilter

The filter object. If filter is null, no filtering will be performed before handling notifications.

handback:Object

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.

Exceptions
IllegalArgumentException:
thrown if the listener is null.
See Also
removeNotificationListener
getNotificationInfoback to summary
public MBeanNotificationInfo[] getNotificationInfo()

Implements javax.management.NotificationBroadcaster.getNotificationInfo.

Doc from javax.management.NotificationBroadcaster.getNotificationInfo.

Returns an array indicating, for each notification this MBean may send, the name of the Java class of the notification and the notification type.

It is not illegal for the MBean to send notifications not described in this array. However, some clients of the MBean server may depend on the array being complete for their correct functioning.

handleNotificationback to summary
protected void handleNotification(NotificationListener listener, Notification notif, 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 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:NotificationListener

the listener to which the notification is being delivered.

notif:Notification

the notification being delivered to the listener.

handback:Object

the handback object that was supplied when the listener was added.

removeNotificationListenerback to summary
public void removeNotificationListener(NotificationListener listener) throws ListenerNotFoundException

Implements javax.management.NotificationBroadcaster.removeNotificationListener.

Doc from javax.management.NotificationBroadcaster.removeNotificationListener.

Removes a listener from this MBean. If the listener has been registered with different handback objects or notification filters, all entries corresponding to the listener will be removed.

Exceptions
ListenerNotFoundException:
The listener is not registered with the MBean.
removeNotificationListenerback to summary
public void removeNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws ListenerNotFoundException

Implements javax.management.NotificationEmitter.removeNotificationListener.

Doc from javax.management.NotificationEmitter.removeNotificationListener.

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.

Exceptions
ListenerNotFoundException:
The listener is not registered with the MBean, or it is not registered with the given filter and handback.
sendNotificationback to summary
public void sendNotification(Notification notification)

Sends a notification. If an Executor was specified in the constructor, it will be given one task per selected listener to deliver the notification to that listener.

Parameters
notification:Notification

The notification to send.

javax.management back to summary

private Class NotificationBroadcasterSupport.ListenerInfo

extends Object
Class Inheritance
Known Direct Subclasses
javax.management.NotificationBroadcasterSupport.WildcardListenerInfo

Field Summary

Modifier and TypeField and Description
pack-priv NotificationFilter
pack-priv Object
pack-priv NotificationListener

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object o)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

filterback to summary
pack-priv NotificationFilter filter
handbackback to summary
pack-priv Object handback
listenerback to summary
pack-priv NotificationListener listener

Constructor Detail

ListenerInfoback to summary
pack-priv ListenerInfo(NotificationListener listener, NotificationFilter filter, Object handback)

Method Detail

equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Annotations
@Override
javax.management back to summary

private Class NotificationBroadcasterSupport.SendNotifJob

extends Object
implements Runnable
Class Inheritance
All Implemented Interfaces
java.lang.Runnable

Field Summary

Modifier and TypeField and Description
private final NotificationBroadcasterSupport.ListenerInfo
private final Notification

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
run()

Implements java.lang.Runnable.run.

Runs this operation.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

listenerInfoback to summary
private final NotificationBroadcasterSupport.ListenerInfo listenerInfo
notifback to summary
private final Notification notif

Constructor Detail

SendNotifJobback to summary
public SendNotifJob(Notification notif, NotificationBroadcasterSupport.ListenerInfo listenerInfo)

Method Detail

runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

javax.management back to summary

private Class NotificationBroadcasterSupport.WildcardListenerInfo

extends ListenerInfo
Class Inheritance

Field Summary

Inherited from javax.management.NotificationBroadcasterSupport.ListenerInfo:
filterhandbacklistener

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object o)

Overrides javax.management.NotificationBroadcasterSupport.ListenerInfo.equals.

Indicates whether some other object is "equal to" this one.

public int
hashCode()

Overrides javax.management.NotificationBroadcasterSupport.ListenerInfo.hashCode.

Returns a hash code value for this object.

Constructor Detail

WildcardListenerInfoback to summary
pack-priv WildcardListenerInfo(NotificationListener listener)

Method Detail

equalsback to summary
public boolean equals(Object o)

Overrides javax.management.NotificationBroadcasterSupport.ListenerInfo.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides javax.management.NotificationBroadcasterSupport.ListenerInfo.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Annotations
@Override