Class: javax.management.StandardEmitterMBean
- public class StandardEmitterMBean
- extends StandardMBean
- implements NotificationEmitter
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 javax.management.NotificationEmitter. The example uses the class javax.management.NotificationBroadcasterSupport as an implementation of the interface javax.management.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);
Inheritance
Superclass tree:- java.lang.Object
- javax.management.StandardMBean
- javax.management.StandardEmitterMBean
Methods
-
StandardEmitterMBeantop
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 javax.management.StandardEmitterMBean.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.
-
StandardEmitterMBeantop
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 javax.management.StandardEmitterMBean.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.
-
StandardEmitterMBeantop
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 javax.management.StandardEmitterMBean.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().
-
StandardEmitterMBeantop
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 javax.management.StandardEmitterMBean.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().
-
addNotificationListenertop
public void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback)Adds a listener to this MBean.- Specified by:
- addNotificationListener from NotificationBroadcaster
-
getNotificationInfotop
public MBeanNotificationInfo[] 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.
- Specified by:
- getNotificationInfo from NotificationBroadcaster
-
removeNotificationListenertop
public void removeNotificationListener(NotificationListener listener) throws ListenerNotFoundExceptionRemoves 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.- Specified by:
- removeNotificationListener from NotificationBroadcaster
-
removeNotificationListenertop
public void removeNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws ListenerNotFoundExceptionRemoves a listener from this MBean. The MBean must have a listener that exactly matches the given
listener,filter, andhandbackparameters. If there is more than one such listener, only one is removed.The
filterandhandbackparameters may be null if and only if they are null in a listener to be removed.- Specified by:
- removeNotificationListener from NotificationEmitter
-
sendNotificationtop
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.
