- java.lang.Object
-
- javax.management.StandardMBean
-
- javax.management.StandardEmitterMBean
-
- 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 interfaceNotificationEmitter
. The example uses the classNotificationBroadcasterSupport
as an implementation of the interfaceNotificationEmitter
.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 Summary
Constructors Modifier Constructor and 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 givenNotificationEmitter
.protected
StandardEmitterMBean(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 Summary
Methods Modifier and Type Method and Description void
addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback)
Adds a listener to this MBean.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.void
removeNotificationListener(NotificationListener listener)
Removes a listener from this MBean.void
removeNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback)
Removes a listener from this MBean.void
sendNotification(Notification n)
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
-
-
-
-
Constructor Detail
-
StandardEmitterMBean
public 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 theNotificationEmitter
interface by forwarding its methods toemitter
. It is legal and useful forimplementation
andemitter
to be the same object.If
emitter
is an instance ofNotificationBroadcasterSupport
then the MBean'ssendNotification
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()
.- Parameters:
implementation
- the implementation of the MBean interface.mbeanInterface
- a Standard MBean interface.emitter
- the object that will handle notifications.- Throws:
IllegalArgumentException
- 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<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 theNotificationEmitter
interface by forwarding its methods toemitter
. It is legal and useful forimplementation
andemitter
to be the same object.If
emitter
is an instance ofNotificationBroadcasterSupport
then the MBean'ssendNotification
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()
.- 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
- 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
protected StandardEmitterMBean(Class<?> mbeanInterface, NotificationEmitter emitter)
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
.If
emitter
is an instance ofNotificationBroadcasterSupport
then the MBean'ssendNotification
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 given
mbeanInterface
.- Parameters:
mbeanInterface
- a StandardMBean interface.emitter
- the object that will handle notifications.- Throws:
IllegalArgumentException
- 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 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 theNotificationEmitter
interface by forwarding its methods toemitter
.If
emitter
is an instance ofNotificationBroadcasterSupport
then the MBean'ssendNotification
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 given
mbeanInterface
.- 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
- if thembeanInterface
does not follow JMX design patterns for Management Interfaces, or ifthis
does not implement the specified interface, or ifemitter
is null.
-
-
Method Detail
-
removeNotificationListener
public void removeNotificationListener(NotificationListener listener) throws ListenerNotFoundException
Description copied from interface:NotificationBroadcaster
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
in interfaceNotificationBroadcaster
- Parameters:
listener
- A listener that was previously added to this MBean.- Throws:
ListenerNotFoundException
- 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
public void removeNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws ListenerNotFoundException
Description copied from interface:NotificationEmitter
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.The
filter
andhandback
parameters may be null if and only if they are null in a listener to be removed.- Specified by:
removeNotificationListener
in interfaceNotificationEmitter
- 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
- The listener is not registered with the MBean, or it is not registered with the given filter and handback.
-
addNotificationListener
public void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback)
Description copied from interface:NotificationBroadcaster
Adds a listener to this MBean.- Specified by:
addNotificationListener
in interfaceNotificationBroadcaster
- 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
public MBeanNotificationInfo[] getNotificationInfo()
Description copied from interface:NotificationBroadcaster
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
in interfaceNotificationBroadcaster
- Returns:
- the array of possible notifications.
-
sendNotification
public void sendNotification(Notification n)
Sends a notification.
If the
emitter
parameter to the constructor was an instance ofNotificationBroadcasterSupport
then this method will callemitter.
sendNotification
.- Parameters:
n
- the notification to send.- Throws:
ClassCastException
- if theemitter
parameter to the constructor was not aNotificationBroadcasterSupport
.
-
-
Deutsche Übersetzung
Sie haben gebeten, diese Seite auf Deutsch zu besuchen. Momentan ist nur die Oberfläche übersetzt, aber noch nicht der gesamte Inhalt.Wenn Sie mir bei Übersetzungen helfen wollen, ist Ihr Beitrag willkommen. Alles, was Sie tun müssen, ist, sich auf der Website zu registrieren und mir eine Nachricht zu schicken, in der Sie gebeten werden, Sie der Gruppe der Übersetzer hinzuzufügen, die Ihnen die Möglichkeit gibt, die gewünschten Seiten zu übersetzen. Ein Link am Ende jeder übersetzten Seite zeigt an, dass Sie der Übersetzer sind und einen Link zu Ihrem Profil haben.
Vielen Dank im Voraus.
Dokument erstellt 11/06/2005, zuletzt geändert 04/03/2020
Quelle des gedruckten Dokuments:https://www.gaudry.be/de/java-api-rf-javax/management/standardemittermbean.html
Die Infobro ist eine persönliche Seite, deren Inhalt in meiner alleinigen Verantwortung liegt. Der Text ist unter der CreativeCommons-Lizenz (BY-NC-SA) verfügbar. Weitere Informationen auf die Nutzungsbedingungen und dem Autor.
Referenzen
Diese Verweise und Links verweisen auf Dokumente, die während des Schreibens dieser Seite konsultiert wurden, oder die zusätzliche Informationen liefern können, aber die Autoren dieser Quellen können nicht für den Inhalt dieser Seite verantwortlich gemacht werden.
Der Autor Diese Website ist allein dafür verantwortlich, wie die verschiedenen Konzepte und Freiheiten, die mit den Nachschlagewerken gemacht werden, hier dargestellt werden. Denken Sie daran, dass Sie mehrere Quellinformationen austauschen müssen, um das Risiko von Fehlern zu reduzieren.