-
- All Known Subinterfaces:
- ModelMBean, ModelMBeanNotificationBroadcaster, NotificationEmitter
- All Known Implementing Classes:
- CounterMonitor, GaugeMonitor, JMXConnectorServer, MBeanServerDelegate, Monitor, NotificationBroadcasterSupport, RelationService, RequiredModelMBean, RMIConnectorServer, StandardEmitterMBean, StringMonitor, Timer
public interface NotificationBroadcaster
Interface implemented by an MBean that emits Notifications. It allows a listener to be registered with the MBean as a notification listener.
Notification dispatch
When an MBean emits a notification, it considers each listener that has been added with
addNotificationListener
and not subsequently removed withremoveNotificationListener
. If a filter was provided with that listener, and if the filter'sisNotificationEnabled
method returns false, the listener is ignored. Otherwise, the listener'shandleNotification
method is called with the notification, as well as the handback object that was provided toaddNotificationListener
.If the same listener is added more than once, it is considered as many times as it was added. It is often useful to add the same listener with different filters or handback objects.
Implementations of this interface can differ regarding the thread in which the methods of filters and listeners are called.
If the method call of a filter or listener throws an
Exception
, then that exception should not prevent other listeners from being invoked. However, if the method call throws anError
, then it is recommended that processing of the notification stop at that point, and if it is possible to propagate theError
to the sender of the notification, this should be done.New code should use the
NotificationEmitter
interface instead.Implementations of this interface and of
NotificationEmitter
should be careful about synchronization. In particular, it is not a good idea for an implementation to hold any locks while it is calling a listener. To deal with the possibility that the list of listeners might change while a notification is being dispatched, a good strategy is to use aCopyOnWriteArrayList
for this list.- Since:
- 1.5
-
-
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.
-
-
-
Method Detail
-
addNotificationListener
void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws IllegalArgumentException
Adds a listener to this MBean.- 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.- Throws:
IllegalArgumentException
- Listener parameter is null.- See Also:
removeNotificationListener(javax.management.NotificationListener)
-
removeNotificationListener
void removeNotificationListener(NotificationListener listener) throws ListenerNotFoundException
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.- Parameters:
listener
- A listener that was previously added to this MBean.- Throws:
ListenerNotFoundException
- The listener is not registered with the MBean.- See Also:
addNotificationListener(javax.management.NotificationListener, javax.management.NotificationFilter, java.lang.Object)
,NotificationEmitter.removeNotificationListener(javax.management.NotificationListener, javax.management.NotificationFilter, java.lang.Object)
-
getNotificationInfo
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.
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.
- Returns:
- the array of possible notifications.
-
-
Traduction non disponible
Les API Java ne sont pas encore traduites en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.
Version en cache
21/11/2024 22:13:05 Cette version de la page est en cache (à la date du 21/11/2024 22:13:05) afin d'accélérer le traitement. Vous pouvez activer le mode utilisateur dans le menu en haut pour afficher la dernère version de la page.Document créé le 30/08/2006, dernière modification le 04/03/2020
Source du document imprimé : https://www.gaudry.be/java-api-rf-javax/management/notificationbroadcaster.html
L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.
Références
Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.