Top Description Fields Constructors Methods
javax.management

public Class StandardEmitterMBean

extends StandardMBean
implements NotificationEmitter
Class Inheritance
All Implemented Interfaces
javax.management.NotificationEmitter, javax.management.NotificationBroadcaster

An MBean whose management interface is determined by reflection on a Java interface, and that emits notifications.

The following example shows how to use the public constructor StandardEmitterMBean(implementation, mbeanInterface, emitter) to create an MBean emitting notifications with any implementation class name Impl, with a management interface defined (as for current Standard MBeans) by any interface Intf, and with any implementation of the interface NotificationEmitter. The example uses the class NotificationBroadcasterSupport as an implementation of the interface NotificationEmitter.

    MBeanServer mbs;
    ...
    final String[] types = new String[] {"sun.disc.space","sun.disc.alarm"};
    final MBeanNotificationInfo info = new MBeanNotificationInfo(
                                         types,
                                         Notification.class.getName(),
                                         "Notification about disc info.");
    final NotificationEmitter emitter =
                   new NotificationBroadcasterSupport(info);

    final Intf impl = new Impl(...);
    final Object mbean = new StandardEmitterMBean(
                                    impl, Intf.class, emitter);
    mbs.registerMBean(mbean, objectName);
    
Since
1.6
See Also
StandardMBean

Field Summary

Modifier and TypeField and Description
private final NotificationEmitter
private static final MBeanNotificationInfo[]
private final MBeanNotificationInfo[]

Constructor Summary

AccessConstructor and Description
public <
the implementation type of the MBean
T
>
StandardEmitterMBean(T
the implementation of the MBean interface.
implementation
,
Class<T>
a Standard MBean interface.
mbeanInterface
,
NotificationEmitter
the object that will handle notifications.
emitter
)

Make an MBean whose management interface is specified by mbeanInterface, with the given implementation and where notifications are handled by the given NotificationEmitter.

public <
the implementation type of the MBean
T
>
StandardEmitterMBean(T
the implementation of the MBean interface.
implementation
,
Class<T>
a Standard MBean interface.
mbeanInterface
,
boolean
If true, the mbeanInterface parameter names an MXBean interface and the resultant MBean is an MXBean.
isMXBean
,
NotificationEmitter
the object that will handle notifications.
emitter
)

Make an MBean whose management interface is specified by mbeanInterface, with the given implementation and where notifications are handled by the given NotificationEmitter.

protected
StandardEmitterMBean(Class<?>
a StandardMBean interface.
mbeanInterface
,
NotificationEmitter
the object that will handle notifications.
emitter
)

Make an MBean whose management interface is specified by mbeanInterface, and where notifications are handled by the given NotificationEmitter.

protected
StandardEmitterMBean(Class<?>
a StandardMBean interface.
mbeanInterface
,
boolean
If true, the mbeanInterface parameter names an MXBean interface and the resultant MBean is an MXBean.
isMXBean
,
NotificationEmitter
the object that will handle notifications.
emitter
)

Make an MBean whose management interface is specified by mbeanInterface, and where notifications are handled by the given NotificationEmitter.

Method Summary

Modifier and TypeMethod and Description
public void
addNotificationListener(NotificationListener
The listener object which will handle the notifications emitted by the broadcaster.
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 to this MBean.

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.

pack-priv MBeanNotificationInfo[]

Returns:

the MBeanNotificationInfo[] for the new MBeanInfo.
getNotifications
(MBeanInfo
The default MBeanInfo derived by reflection.
info
)

Overrides javax.management.StandardMBean.getNotifications.

Get the MBeanNotificationInfo[] that will be used in the MBeanInfo returned by this MBean.

public void
removeNotificationListener(NotificationListener
A listener that was previously added to this MBean.
listener
)

Implements javax.management.NotificationBroadcaster.removeNotificationListener.

Removes a listener from this MBean.

public void
removeNotificationListener(NotificationListener
A listener that was previously added to this MBean.
listener
,
NotificationFilter
The filter that was specified when the listener was added.
filter
,
Object
The handback that was specified when the listener was added.
handback
)

Implements javax.management.NotificationEmitter.removeNotificationListener.

Removes a listener from this MBean.

public void
sendNotification(Notification
the notification to send.
n
)

Sends a notification.

Inherited from javax.management.StandardMBean:
cacheMBeanInfogetAttributegetAttributesgetCachedMBeanInfogetClassNamegetConstructorsgetDescriptiongetDescriptiongetDescriptiongetDescriptiongetDescriptiongetDescriptiongetDescriptiongetDescriptorgetImpactgetImplementationgetImplementationClassgetMBeanInfogetMBeanInterfacegetParameterNamegetParameterNameimmutableInfoinvokeoverridespostDeregisterpostRegisterpreDeregisterpreRegistersetAttributesetAttributessetImplementation

Field Detail

emitterback to summary
private final NotificationEmitter emitter
NO_NOTIFICATION_INFOback to summary
private static final MBeanNotificationInfo[] NO_NOTIFICATION_INFO
notificationInfoback to summary
private final MBeanNotificationInfo[] notificationInfo

Constructor Detail

StandardEmitterMBeanback to summary
public <T> StandardEmitterMBean(T implementation, Class<T> mbeanInterface, NotificationEmitter emitter)

Make an MBean whose management interface is specified by mbeanInterface, with the given implementation and where notifications are handled by the given NotificationEmitter. The resultant MBean implements the NotificationEmitter interface by forwarding its methods to emitter. It is legal and useful for implementation and emitter to be the same object.

If emitter is an instance of NotificationBroadcasterSupport then the MBean's sendNotification method will call emitter.sendNotification.

The array returned by getNotificationInfo() on the new MBean is a copy of the array returned by emitter.getNotificationInfo() at the time of construction. If the array returned by emitter.getNotificationInfo() later changes, that will have no effect on this object's getNotificationInfo().

Parameters
<T>
the implementation type of the MBean
implementation:T

the implementation of the MBean interface.

mbeanInterface:Class<T>

a Standard MBean interface.

emitter:NotificationEmitter

the object that will handle notifications.

Exceptions
IllegalArgumentException:
if the mbeanInterface does not follow JMX design patterns for Management Interfaces, or if the given implementation does not implement the specified interface, or if emitter is null.
StandardEmitterMBeanback to summary
public <T> StandardEmitterMBean(T implementation, Class<T> mbeanInterface, boolean isMXBean, NotificationEmitter emitter)

Make an MBean whose management interface is specified by mbeanInterface, with the given implementation and where notifications are handled by the given NotificationEmitter. This constructor can be used to make either Standard MBeans or MXBeans. The resultant MBean implements the NotificationEmitter interface by forwarding its methods to emitter. It is legal and useful for implementation and emitter to be the same object.

If emitter is an instance of NotificationBroadcasterSupport then the MBean's sendNotification method will call emitter.sendNotification.

The array returned by getNotificationInfo() on the new MBean is a copy of the array returned by emitter.getNotificationInfo() at the time of construction. If the array returned by emitter.getNotificationInfo() later changes, that will have no effect on this object's getNotificationInfo().

Parameters
<T>
the implementation type of the MBean
implementation:T

the implementation of the MBean interface.

mbeanInterface:Class<T>

a Standard MBean interface.

isMXBean:boolean

If true, the mbeanInterface parameter names an MXBean interface and the resultant MBean is an MXBean.

emitter:NotificationEmitter

the object that will handle notifications.

Exceptions
IllegalArgumentException:
if the mbeanInterface does not follow JMX design patterns for Management Interfaces, or if the given implementation does not implement the specified interface, or if emitter is null.
StandardEmitterMBeanback to summary
protected StandardEmitterMBean(Class<?> mbeanInterface, NotificationEmitter emitter)

Make an MBean whose management interface is specified by mbeanInterface, and where notifications are handled by the given NotificationEmitter. The resultant MBean implements the NotificationEmitter interface by forwarding its methods to emitter.

If emitter is an instance of NotificationBroadcasterSupport then the MBean's sendNotification method will call emitter.sendNotification.

The array returned by getNotificationInfo() on the new MBean is a copy of the array returned by emitter.getNotificationInfo() at the time of construction. If the array returned by emitter.getNotificationInfo() later changes, that will have no effect on this object's getNotificationInfo().

This constructor must be called from a subclass that implements the given mbeanInterface.

Parameters
mbeanInterface:Class<?>

a StandardMBean interface.

emitter:NotificationEmitter

the object that will handle notifications.

Exceptions
IllegalArgumentException:
if the mbeanInterface does not follow JMX design patterns for Management Interfaces, or if this does not implement the specified interface, or if emitter is null.
StandardEmitterMBeanback to summary
protected StandardEmitterMBean(Class<?> mbeanInterface, boolean isMXBean, NotificationEmitter emitter)

Make an MBean whose management interface is specified by mbeanInterface, and where notifications are handled by the given NotificationEmitter. This constructor can be used to make either Standard MBeans or MXBeans. The resultant MBean implements the NotificationEmitter interface by forwarding its methods to emitter.

If emitter is an instance of NotificationBroadcasterSupport then the MBean's sendNotification method will call emitter.sendNotification.

The array returned by getNotificationInfo() on the new MBean is a copy of the array returned by emitter.getNotificationInfo() at the time of construction. If the array returned by emitter.getNotificationInfo() later changes, that will have no effect on this object's getNotificationInfo().

This constructor must be called from a subclass that implements the given mbeanInterface.

Parameters
mbeanInterface:Class<?>

a StandardMBean interface.

isMXBean:boolean

If true, the mbeanInterface parameter names an MXBean interface and the resultant MBean is an MXBean.

emitter:NotificationEmitter

the object that will handle notifications.

Exceptions
IllegalArgumentException:
if the mbeanInterface does not follow JMX design patterns for Management Interfaces, or if this does not implement the specified interface, or if emitter is null.

Method Detail

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

Implements javax.management.NotificationBroadcaster.addNotificationListener.

Doc from javax.management.NotificationBroadcaster.addNotificationListener.

Adds a listener to this MBean.

Parameters
listener:NotificationListener

The listener object which will handle the notifications emitted by the broadcaster.

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.

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.

Returns:MBeanNotificationInfo[]

the array of possible notifications.

getNotificationsback to summary
pack-priv MBeanNotificationInfo[] getNotifications(MBeanInfo info)

Overrides javax.management.StandardMBean.getNotifications.

Get the MBeanNotificationInfo[] that will be used in the MBeanInfo returned by this MBean.

The default implementation of this method returns getNotificationInfo().

Parameters
info:MBeanInfo

The default MBeanInfo derived by reflection.

Returns:MBeanNotificationInfo[]

the MBeanNotificationInfo[] for the new MBeanInfo.

Annotations
@Override
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.

Parameters
listener:NotificationListener

A listener that was previously added to this MBean.

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.

Parameters
listener:NotificationListener

A listener that was previously added to this MBean.

filter:NotificationFilter

The filter that was specified when the listener was added.

handback:Object

The handback that was specified when the listener was added.

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 n)

Sends a notification.

If the emitter parameter to the constructor was an instance of NotificationBroadcasterSupport then this method will call emitter.sendNotification.

Parameters
n:Notification

the notification to send.

Exceptions
ClassCastException:
if the emitter parameter to the constructor was not a NotificationBroadcasterSupport.