StandardEmitterMBean (Java SE 15 & JDK 15) (original) (raw)
All Implemented Interfaces:
[DynamicMBean](DynamicMBean.html "interface in javax.management")
, [MBeanRegistration](MBeanRegistration.html "interface in javax.management")
, [NotificationBroadcaster](NotificationBroadcaster.html "interface in javax.management")
, [NotificationEmitter](NotificationEmitter.html "interface in javax.management")
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 constructorStandardEmitterMBean(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 interfaceNotificationEmitter. The example uses the classNotificationBroadcasterSupport 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:
Constructor Summary
Constructors
Modifier | Constructor | Description |
---|---|---|
protected | StandardEmitterMBean(Class<?> mbeanInterface, boolean isMXBean,NotificationEmitter emitter) | Make an MBean whose management interface is specified bymbeanInterface, and where notifications are handled by the given NotificationEmitter. |
protected | StandardEmitterMBean(Class<?> mbeanInterface,NotificationEmitter emitter) | Make an MBean whose management interface is specified bymbeanInterface, and where notifications are handled by the given NotificationEmitter. |
StandardEmitterMBean(T implementation,Class 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 given NotificationEmitter. | |
StandardEmitterMBean(T implementation,Class mbeanInterface,NotificationEmitter emitter) | Make an MBean whose management interface is specified bymbeanInterface, with the given implementation and where notifications are handled by the given NotificationEmitter. |
Method Summary
Modifier and Type | Method | Description |
---|---|---|
void | sendNotification(Notification n) | Sends a notification. |
Methods declared in class javax.management.StandardMBean
[cacheMBeanInfo](StandardMBean.html#cacheMBeanInfo%28javax.management.MBeanInfo%29), [getCachedMBeanInfo](StandardMBean.html#getCachedMBeanInfo%28%29), [getClassName](StandardMBean.html#getClassName%28javax.management.MBeanInfo%29), [getConstructors](StandardMBean.html#getConstructors%28javax.management.MBeanConstructorInfo%5B%5D,java.lang.Object%29), [getDescription](StandardMBean.html#getDescription%28javax.management.MBeanAttributeInfo%29), [getDescription](StandardMBean.html#getDescription%28javax.management.MBeanConstructorInfo%29), [getDescription](StandardMBean.html#getDescription%28javax.management.MBeanConstructorInfo,javax.management.MBeanParameterInfo,int%29), [getDescription](StandardMBean.html#getDescription%28javax.management.MBeanFeatureInfo%29), [getDescription](StandardMBean.html#getDescription%28javax.management.MBeanInfo%29), [getDescription](StandardMBean.html#getDescription%28javax.management.MBeanOperationInfo%29), [getDescription](StandardMBean.html#getDescription%28javax.management.MBeanOperationInfo,javax.management.MBeanParameterInfo,int%29), [getImpact](StandardMBean.html#getImpact%28javax.management.MBeanOperationInfo%29), [getImplementation](StandardMBean.html#getImplementation%28%29), [getImplementationClass](StandardMBean.html#getImplementationClass%28%29), [getMBeanInfo](StandardMBean.html#getMBeanInfo%28%29), [getMBeanInterface](StandardMBean.html#getMBeanInterface%28%29), [getParameterName](StandardMBean.html#getParameterName%28javax.management.MBeanConstructorInfo,javax.management.MBeanParameterInfo,int%29), [getParameterName](StandardMBean.html#getParameterName%28javax.management.MBeanOperationInfo,javax.management.MBeanParameterInfo,int%29), [postDeregister](StandardMBean.html#postDeregister%28%29), [postRegister](StandardMBean.html#postRegister%28java.lang.Boolean%29), [preDeregister](StandardMBean.html#preDeregister%28%29), [preRegister](StandardMBean.html#preRegister%28javax.management.MBeanServer,javax.management.ObjectName%29), [setImplementation](StandardMBean.html#setImplementation%28java.lang.Object%29)
Methods declared in class java.lang.Object
[clone](../../../java.base/java/lang/Object.html#clone%28%29), [equals](../../../java.base/java/lang/Object.html#equals%28java.lang.Object%29), [finalize](../../../java.base/java/lang/Object.html#finalize%28%29), [getClass](../../../java.base/java/lang/Object.html#getClass%28%29), [hashCode](../../../java.base/java/lang/Object.html#hashCode%28%29), [notify](../../../java.base/java/lang/Object.html#notify%28%29), [notifyAll](../../../java.base/java/lang/Object.html#notifyAll%28%29), [toString](../../../java.base/java/lang/Object.html#toString%28%29), [wait](../../../java.base/java/lang/Object.html#wait%28%29), [wait](../../../java.base/java/lang/Object.html#wait%28long%29), [wait](../../../java.base/java/lang/Object.html#wait%28long,int%29)
Constructor Details
StandardEmitterMBean
public StandardEmitterMBean(T implementation,Class mbeanInterface,NotificationEmitter emitter)
Make an MBean whose management interface is specified bymbeanInterface
, with the given implementation and where notifications are handled by the givenNotificationEmitter
. The resultant MBean implements theNotificationEmitter
interface by forwarding its methods toemitter
. It is legal and useful forimplementation
andemitter
to be the same object.
Ifemitter
is an instance ofNotificationBroadcasterSupport
then the MBean's sendNotification method 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](../../../java.base/java/lang/IllegalArgumentException.html "class in java.lang")
- if thembeanInterface
does not follow JMX design patterns for Management Interfaces, or if the givenimplementation
does not implement the specified interface, or ifemitter
is null.StandardEmitterMBean
public StandardEmitterMBean(T implementation,Class 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
. This constructor can be used to make either Standard MBeans or MXBeans. The resultant MBean implements theNotificationEmitter
interface by forwarding its methods toemitter
. It is legal and useful forimplementation
andemitter
to be the same object.
Ifemitter
is an instance ofNotificationBroadcasterSupport
then the MBean's sendNotification method 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, thembeanInterface
parameter names an MXBean interface and the resultant MBean is an MXBean.
emitter
- the object that will handle notifications.
Throws:
[IllegalArgumentException](../../../java.base/java/lang/IllegalArgumentException.html "class in java.lang")
- if thembeanInterface
does not follow JMX design patterns for Management Interfaces, or if the givenimplementation
does not implement the specified interface, or ifemitter
is null.StandardEmitterMBean
Make an MBean whose management interface is specified by
mbeanInterface
, and where notifications are handled by the givenNotificationEmitter
. The resultant MBean implements theNotificationEmitter
interface by forwarding its methods toemitter
.
Ifemitter
is an instance ofNotificationBroadcasterSupport
then the MBean's sendNotification method 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 givenmbeanInterface
.
Parameters:
mbeanInterface
- a StandardMBean interface.
emitter
- the object that will handle notifications.
Throws:
[IllegalArgumentException](../../../java.base/java/lang/IllegalArgumentException.html "class in java.lang")
- if thembeanInterface
does not follow JMX design patterns for Management Interfaces, or ifthis
does not implement the specified interface, or ifemitter
is null.StandardEmitterMBean
protected StandardEmitterMBean(Class<?> mbeanInterface, boolean isMXBean,NotificationEmitter emitter)
Make an MBean whose management interface is specified bymbeanInterface
, and where notifications are handled by the givenNotificationEmitter
. This constructor can be used to make either Standard MBeans or MXBeans. The resultant MBean implements theNotificationEmitter
interface by forwarding its methods toemitter
.
Ifemitter
is an instance ofNotificationBroadcasterSupport
then the MBean's sendNotification method 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 givenmbeanInterface
.
Parameters:
mbeanInterface
- a StandardMBean interface.
isMXBean
- If true, thembeanInterface
parameter names an MXBean interface and the resultant MBean is an MXBean.
emitter
- the object that will handle notifications.
Throws:
[IllegalArgumentException](../../../java.base/java/lang/IllegalArgumentException.html "class in java.lang")
- if thembeanInterface
does not follow JMX design patterns for Management Interfaces, or ifthis
does not implement the specified interface, or ifemitter
is null.Method Details
sendNotification
Sends a notification.
If theemitter
parameter to the constructor was an instance ofNotificationBroadcasterSupport
then this method will callemitter.
sendNotification.
Parameters:
n
- the notification to send.
Throws:
[ClassCastException](../../../java.base/java/lang/ClassCastException.html "class in java.lang")
- if theemitter
parameter to the constructor was not aNotificationBroadcasterSupport
.