StandardEmitterMBean (Java SE 16 & JDK 16) (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")
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
Constructorsprotected
Make an MBean whose management interface is specified bymbeanInterface
, and where notifications are handled by the given NotificationEmitter
.protected
Make an MBean whose management interface is specified bymbeanInterface
, and where notifications are handled by the given NotificationEmitter
.
Make an MBean whose management interface is specified bymbeanInterface
, with the given implementation and where notifications are handled by the given NotificationEmitter
.
Make an MBean whose management interface is specified bymbeanInterface
, with the given implementation and where notifications are handled by the given NotificationEmitter
.
Method Summary
void
Adds a listener to this MBean.
Returns an array indicating, for each notification this MBean may send, the name of the Java class of the notification and the notification type.void
Removes a listener from this MBean.void
Removes a listener from this MBean.void
Methods declared in class javax.management.StandardMBean
[cacheMBeanInfo](StandardMBean.html#cacheMBeanInfo%28javax.management.MBeanInfo%29), [getAttribute](StandardMBean.html#getAttribute%28java.lang.String%29), [getAttributes](StandardMBean.html#getAttributes%28java.lang.String%5B%5D%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), [invoke](StandardMBean.html#invoke%28java.lang.String,java.lang.Object%5B%5D,java.lang.String%5B%5D%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), [setAttribute](StandardMBean.html#setAttribute%28javax.management.Attribute%29), [setAttributes](StandardMBean.html#setAttributes%28javax.management.AttributeList%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 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 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 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 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
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.
Specified by:
[removeNotificationListener](NotificationBroadcaster.html#removeNotificationListener%28javax.management.NotificationListener%29)
in interface[NotificationBroadcaster](NotificationBroadcaster.html "interface in javax.management")
Parameters:
listener
- A listener that was previously added to this MBean.
Throws:
[ListenerNotFoundException](ListenerNotFoundException.html "class in javax.management")
- The listener is not registered with the MBean.
See Also:
NotificationBroadcaster.addNotificationListener(javax.management.NotificationListener, javax.management.NotificationFilter, java.lang.Object), NotificationEmitter.removeNotificationListener(javax.management.NotificationListener, javax.management.NotificationFilter, java.lang.Object)removeNotificationListener
Removes a listener from this MBean. The MBean must have a listener that exactly matches the given
listener
,filter
, andhandback
parameters. If there is more than one such listener, only one is removed.
Thefilter
andhandback
parameters may be null if and only if they are null in a listener to be removed.
Specified by:
[removeNotificationListener](NotificationEmitter.html#removeNotificationListener%28javax.management.NotificationListener,javax.management.NotificationFilter,java.lang.Object%29)
in interface[NotificationEmitter](NotificationEmitter.html "interface in javax.management")
Parameters:
listener
- A listener that was previously added to this MBean.
filter
- The filter that was specified when the listener was added.
handback
- The handback that was specified when the listener was added.
Throws:
[ListenerNotFoundException](ListenerNotFoundException.html "class in javax.management")
- The listener is not registered with the MBean, or it is not registered with the given filter and handback.addNotificationListener
Adds a listener to this MBean.
Specified by:
[addNotificationListener](NotificationBroadcaster.html#addNotificationListener%28javax.management.NotificationListener,javax.management.NotificationFilter,java.lang.Object%29)
in interface[NotificationBroadcaster](NotificationBroadcaster.html "interface in javax.management")
Parameters:
listener
- The listener object which will handle the notifications emitted by the broadcaster.
filter
- The filter object. If filter is null, no filtering will be performed before handling notifications.
handback
- 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.
See Also:
NotificationBroadcaster.removeNotificationListener(javax.management.NotificationListener)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](NotificationBroadcaster.html#getNotificationInfo%28%29)
in interface[NotificationBroadcaster](NotificationBroadcaster.html "interface in javax.management")
Returns:
the array of possible notifications.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
.