| |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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 {@link #StandardEmitterMBean(Object, Class, NotificationEmitter) 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 {@link NotificationEmitter}. The example uses the class {@link NotificationBroadcasterSupport} as an implementation of the interface {@link 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);
Constructor Summary | |
---|---|
protected |
StandardEmitterMBean(Class mbeanInterface, boolean isMXBean, NotificationEmitter emitter) Make an MBean whose management interface is specified by , and where notifications are handled by the given . |
protected |
StandardEmitterMBean(Class mbeanInterface, NotificationEmitter emitter) Make an MBean whose management interface is specified by , and where notifications are handled by the given . |
StandardEmitterMBean(Object implementation, Class mbeanInterface, boolean isMXBean, NotificationEmitter emitter) Make an MBean whose management interface is specified by , with the given implementation and where notifications are handled by the given . |
|
StandardEmitterMBean(Object implementation, Class mbeanInterface, NotificationEmitter emitter) Make an MBean whose management interface is specified by , with the given implementation and where notifications are handled by the given . |
Method Summary | |
---|---|
void |
addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) |
MBeanNotificationInfo[] |
|
void |
|
void |
removeNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) |
void |
Sends a notification. |
Methods inherited from class javax.management.StandardMBean |
---|
cacheMBeanInfo, getAttribute, getAttributes, getCachedMBeanInfo, getClassName, getConstructors, getDescription, getDescription, getDescription, getDescription, getDescription, getDescription, getDescription, getImpact, getImplementation, getImplementationClass, getMBeanInfo, getMBeanInterface, getParameterName, getParameterName, invoke, postDeregister, postRegister, preDeregister, preRegister, setAttribute, setAttributes, setImplementation |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected StandardEmitterMBean(Class mbeanInterface, boolean isMXBean, NotificationEmitter emitter)
Make an MBean whose management interface is specified by {@code mbeanInterface}, and where notifications are handled by the given {@code NotificationEmitter}. This constructor can be used to make either Standard MBeans or MXBeans. The resultant MBean implements the {@code NotificationEmitter} interface by forwarding its methods to {@code emitter}.
If {@code emitter} is an instance of {@code NotificationBroadcasterSupport} then the MBean's {@link #sendNotification sendNotification} method will call {@code emitter.}{@link NotificationBroadcasterSupport#sendNotification sendNotification}.
The array returned by {@link #getNotificationInfo()} on the new MBean is a copy of the array returned by {@code emitter.}{@link NotificationBroadcaster#getNotificationInfo getNotificationInfo()} at the time of construction. If the array returned by {@code emitter.getNotificationInfo()} later changes, that will have no effect on this object's {@code getNotificationInfo()}.
This constructor must be called from a subclass that implements the given {@code mbeanInterface}.
mbeanInterface
- a StandardMBean interface.isMXBean
- If true, the {@code mbeanInterface} parameter
names an MXBean interface and the resultant MBean is an MXBean.emitter
- the object that will handle notifications.protected StandardEmitterMBean(Class mbeanInterface, NotificationEmitter emitter)
Make an MBean whose management interface is specified by {@code mbeanInterface}, and where notifications are handled by the given {@code NotificationEmitter}. The resultant MBean implements the {@code NotificationEmitter} interface by forwarding its methods to {@code emitter}.
If {@code emitter} is an instance of {@code NotificationBroadcasterSupport} then the MBean's {@link #sendNotification sendNotification} method will call {@code emitter.}{@link NotificationBroadcasterSupport#sendNotification sendNotification}.
The array returned by {@link #getNotificationInfo()} on the new MBean is a copy of the array returned by {@code emitter.}{@link NotificationBroadcaster#getNotificationInfo getNotificationInfo()} at the time of construction. If the array returned by {@code emitter.getNotificationInfo()} later changes, that will have no effect on this object's {@code getNotificationInfo()}.
This constructor must be called from a subclass that implements the given {@code mbeanInterface}.
mbeanInterface
- a StandardMBean interface.emitter
- the object that will handle notifications.public StandardEmitterMBean(Object implementation, Class mbeanInterface, boolean isMXBean, NotificationEmitter emitter)
Make an MBean whose management interface is specified by {@code mbeanInterface}, with the given implementation and where notifications are handled by the given {@code NotificationEmitter}. This constructor can be used to make either Standard MBeans or MXBeans. The resultant MBean implements the {@code NotificationEmitter} interface by forwarding its methods to {@code emitter}. It is legal and useful for {@code implementation} and {@code emitter} to be the same object.
If {@code emitter} is an instance of {@code NotificationBroadcasterSupport} then the MBean's {@link #sendNotification sendNotification} method will call {@code emitter.}{@link NotificationBroadcasterSupport#sendNotification sendNotification}.
The array returned by {@link #getNotificationInfo()} on the new MBean is a copy of the array returned by {@code emitter.}{@link NotificationBroadcaster#getNotificationInfo getNotificationInfo()} at the time of construction. If the array returned by {@code emitter.getNotificationInfo()} later changes, that will have no effect on this object's {@code getNotificationInfo()}.
implementation
- the implementation of the MBean interface.mbeanInterface
- a Standard MBean interface.isMXBean
- If true, the {@code mbeanInterface} parameter
names an MXBean interface and the resultant MBean is an MXBean.emitter
- the object that will handle notifications.public StandardEmitterMBean(Object implementation, Class mbeanInterface, NotificationEmitter emitter)
Make an MBean whose management interface is specified by {@code mbeanInterface}, with the given implementation and where notifications are handled by the given {@code NotificationEmitter}. The resultant MBean implements the {@code NotificationEmitter} interface by forwarding its methods to {@code emitter}. It is legal and useful for {@code implementation} and {@code emitter} to be the same object.
If {@code emitter} is an instance of {@code NotificationBroadcasterSupport} then the MBean's {@link #sendNotification sendNotification} method will call {@code emitter.}{@link NotificationBroadcasterSupport#sendNotification sendNotification}.
The array returned by {@link #getNotificationInfo()} on the new MBean is a copy of the array returned by {@code emitter.}{@link NotificationBroadcaster#getNotificationInfo getNotificationInfo()} at the time of construction. If the array returned by {@code emitter.getNotificationInfo()} later changes, that will have no effect on this object's {@code getNotificationInfo()}.
implementation
- the implementation of the MBean interface.mbeanInterface
- a Standard MBean interface.emitter
- the object that will handle notifications.Method Detail |
---|
public void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback)
listener
filter
handback
public MBeanNotificationInfo[] getNotificationInfo()
public void removeNotificationListener(NotificationListener listener) throws ListenerNotFoundException
listener
ListenerNotFoundException
public void removeNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws ListenerNotFoundException
listener
filter
handback
ListenerNotFoundException
public void sendNotification(Notification n)
Sends a notification.
If the {@code emitter} parameter to the constructor was an instance of {@code NotificationBroadcasterSupport} then this method will call {@code emitter.}{@link NotificationBroadcasterSupport#sendNotification sendNotification}.
n
- the notification to send.
| |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |