- All Implemented Interfaces:
- DynamicMBean,- MBeanRegistration,- NotificationBroadcaster,- NotificationEmitter
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
 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
- 
Constructor SummaryConstructors Modifier Constructor Description protectedStandardEmitterMBean(Class<?> mbeanInterface, boolean isMXBean, NotificationEmitter emitter)Make an MBean whose management interface is specified bymbeanInterface, and where notifications are handled by the givenNotificationEmitter.protectedStandardEmitterMBean(Class<?> mbeanInterface, NotificationEmitter emitter)Make an MBean whose management interface is specified bymbeanInterface, and where notifications are handled by the givenNotificationEmitter.StandardEmitterMBean(T implementation, Class<T> mbeanInterface, boolean isMXBean, NotificationEmitter emitter)Make an MBean whose management interface is specified bymbeanInterface, with the given implementation and where notifications are handled by the givenNotificationEmitter.StandardEmitterMBean(T implementation, Class<T> mbeanInterface, NotificationEmitter emitter)Make an MBean whose management interface is specified bymbeanInterface, with the given implementation and where notifications are handled by the givenNotificationEmitter.
- 
Method SummaryModifier and Type Method Description voidsendNotification(Notification n)Sends a notification.Methods declared in class javax.management.StandardMBeancacheMBeanInfo, getCachedMBeanInfo, getClassName, getConstructors, getDescription, getDescription, getDescription, getDescription, getDescription, getDescription, getDescription, getImpact, getImplementation, getImplementationClass, getMBeanInfo, getMBeanInterface, getParameterName, getParameterName, postDeregister, postRegister, preDeregister, preRegister, setImplementationMethods declared in class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods declared in interface javax.management.DynamicMBeangetAttribute, getAttributes, invoke, setAttribute, setAttributesMethods declared in interface javax.management.NotificationBroadcasteraddNotificationListener, getNotificationInfo, removeNotificationListener
- 
Constructor Details- 
StandardEmitterMBeanpublic 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 givenNotificationEmitter. The resultant MBean implements theNotificationEmitterinterface by forwarding its methods toemitter. It is legal and useful forimplementationandemitterto be the same object.If emitteris an instance ofNotificationBroadcasterSupportthen the MBean'ssendNotificationmethod will callemitter.sendNotification.The array returned by NotificationBroadcaster.getNotificationInfo()on the new MBean is a copy of the array returned byemitter.getNotificationInfo()at the time of construction. If the array returned byemitter.getNotificationInfo()later changes, that will have no effect on this object'sgetNotificationInfo().- Type Parameters:
- T- the implementation type of the MBean
- Parameters:
- implementation- the implementation of the MBean interface.
- mbeanInterface- a Standard MBean interface.
- emitter- the object that will handle notifications.
- Throws:
- IllegalArgumentException- if the- mbeanInterfacedoes not follow JMX design patterns for Management Interfaces, or if the given- implementationdoes not implement the specified interface, or if- emitteris null.
 
- 
StandardEmitterMBeanpublic 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 givenNotificationEmitter. This constructor can be used to make either Standard MBeans or MXBeans. The resultant MBean implements theNotificationEmitterinterface by forwarding its methods toemitter. It is legal and useful forimplementationandemitterto be the same object.If emitteris an instance ofNotificationBroadcasterSupportthen the MBean'ssendNotificationmethod will callemitter.sendNotification.The array returned by NotificationBroadcaster.getNotificationInfo()on the new MBean is a copy of the array returned byemitter.getNotificationInfo()at the time of construction. If the array returned byemitter.getNotificationInfo()later changes, that will have no effect on this object'sgetNotificationInfo().- Type Parameters:
- T- the implementation type of the MBean
- Parameters:
- implementation- the implementation of the MBean interface.
- mbeanInterface- a Standard MBean interface.
- isMXBean- If true, the- mbeanInterfaceparameter names an MXBean interface and the resultant MBean is an MXBean.
- emitter- the object that will handle notifications.
- Throws:
- IllegalArgumentException- if the- mbeanInterfacedoes not follow JMX design patterns for Management Interfaces, or if the given- implementationdoes not implement the specified interface, or if- emitteris null.
 
- 
StandardEmitterMBeanMake an MBean whose management interface is specified by mbeanInterface, and where notifications are handled by the givenNotificationEmitter. The resultant MBean implements theNotificationEmitterinterface by forwarding its methods toemitter.If emitteris an instance ofNotificationBroadcasterSupportthen the MBean'ssendNotificationmethod will callemitter.sendNotification.The array returned by NotificationBroadcaster.getNotificationInfo()on the new MBean is a copy of the array returned byemitter.getNotificationInfo()at the time of construction. If the array returned byemitter.getNotificationInfo()later changes, that will have no effect on this object'sgetNotificationInfo().This constructor must be called from a subclass that implements the given mbeanInterface.- Parameters:
- mbeanInterface- a StandardMBean interface.
- emitter- the object that will handle notifications.
- Throws:
- IllegalArgumentException- if the- mbeanInterfacedoes not follow JMX design patterns for Management Interfaces, or if- thisdoes not implement the specified interface, or if- emitteris null.
 
- 
StandardEmitterMBeanprotected StandardEmitterMBean(Class<?> mbeanInterface, boolean isMXBean, NotificationEmitter emitter)Make an MBean whose management interface is specified by mbeanInterface, and where notifications are handled by the givenNotificationEmitter. This constructor can be used to make either Standard MBeans or MXBeans. The resultant MBean implements theNotificationEmitterinterface by forwarding its methods toemitter.If emitteris an instance ofNotificationBroadcasterSupportthen the MBean'ssendNotificationmethod will callemitter.sendNotification.The array returned by NotificationBroadcaster.getNotificationInfo()on the new MBean is a copy of the array returned byemitter.getNotificationInfo()at the time of construction. If the array returned byemitter.getNotificationInfo()later changes, that will have no effect on this object'sgetNotificationInfo().This constructor must be called from a subclass that implements the given mbeanInterface.- Parameters:
- mbeanInterface- a StandardMBean interface.
- isMXBean- If true, the- mbeanInterfaceparameter names an MXBean interface and the resultant MBean is an MXBean.
- emitter- the object that will handle notifications.
- Throws:
- IllegalArgumentException- if the- mbeanInterfacedoes not follow JMX design patterns for Management Interfaces, or if- thisdoes not implement the specified interface, or if- emitteris null.
 
 
- 
- 
Method Details- 
sendNotificationSends a notification. If the emitterparameter to the constructor was an instance ofNotificationBroadcasterSupportthen this method will callemitter.sendNotification.- Parameters:
- n- the notification to send.
- Throws:
- ClassCastException- if the- emitterparameter to the constructor was not a- NotificationBroadcasterSupport.
 
 
-