Spec-Zone .ru
спецификации, руководства, описания, API
Please note that this documentation is not final and is subject to change.

Java™ Platform
Standard Ed. 7

DRAFT ea-b76

javax.management.namespace
Class VirtualEventManager

java.lang.Object
  extended by javax.management.namespace.VirtualEventManager
All Implemented Interfaces:
EventConsumer

public class VirtualEventManager
extends Object
implements EventConsumer

This class maintains a list of subscribers for ObjectName patterns and allows a notification to be sent to all subscribers for a given ObjectName. It is typically used in conjunction with MBeanServerSupport to implement a namespace with Virtual MBeans that can emit notifications. The VirtualEventManager keeps track of the listeners that have been added to each Virtual MBean. When an event occurs that should trigger a notification from a Virtual MBean, the publish method can be used to send it to the appropriate listeners.

Since:
1.7

Constructor Summary
Constructor and Description
VirtualEventManager()
          Create a new VirtualEventManager.
 
Method Summary
Modifier and Type Method and Description
 NotificationEmitter getNotificationEmitterFor(ObjectName name)
          Returns a NotificationEmitter object which can be used to subscribe or unsubscribe for notifications with the named mbean.
 void publish(ObjectName emitterName, Notification n)
          Sends a notification to the subscribers for a given MBean.
 void subscribe(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback)
          Subscribes a listener to receive events from an MBean or a set of MBeans represented by an ObjectName pattern.
 void unsubscribe(ObjectName name, NotificationListener listener)
          Unsubscribes a listener which is listening to an MBean or a set of MBeans represented by an ObjectName pattern.
 void unsubscribe(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback)
          Unsubscribes a listener which is listening to an MBean or a set of MBeans represented by an ObjectName pattern.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VirtualEventManager

public VirtualEventManager()

Create a new VirtualEventManager.

Method Detail

subscribe

public void subscribe(ObjectName name,
                      NotificationListener listener,
                      NotificationFilter filter,
                      Object handback)
Description copied from interface: EventConsumer

Subscribes a listener to receive events from an MBean or a set of MBeans represented by an ObjectName pattern.

An event emitted by an MBean is forwarded to every listener that was subscribed with the name of that MBean, or with a pattern that matches that name.

Specified by:
subscribe in interface EventConsumer
Parameters:
name - The name of an MBean or an ObjectName pattern representing a set of MBeans to which the listener should listen.
listener - The listener object that will handle the notifications emitted by the MBeans.
filter - The filter object. If filter is null, no filtering will be performed before notification handling.
handback - The context to be sent to the listener when a notification is emitted.
See Also:
EventConsumer.unsubscribe(ObjectName, NotificationListener)

unsubscribe

public void unsubscribe(ObjectName name,
                        NotificationListener listener)
                 throws ListenerNotFoundException
Description copied from interface: EventConsumer

Unsubscribes a listener which is listening to an MBean or a set of MBeans represented by an ObjectName pattern.

The listener to be removed must have been added by the subscribe method with the given name. If the name is a pattern, then the subscribe must have used the same pattern. If the same listener has been subscribed more than once to the name, perhaps with different filters or handbacks, then all such listeners are removed.

Specified by:
unsubscribe in interface EventConsumer
Parameters:
name - The name of the MBean or an ObjectName pattern representing a set of MBeans to which the listener was subscribed.
listener - A listener that was previously subscribed to the MBean(s).
Throws:
ListenerNotFoundException - The given listener was not subscribed to the given name.
See Also:
EventConsumer.subscribe(javax.management.ObjectName, javax.management.NotificationListener, javax.management.NotificationFilter, java.lang.Object)

unsubscribe

public void unsubscribe(ObjectName name,
                        NotificationListener listener,
                        NotificationFilter filter,
                        Object handback)
                 throws ListenerNotFoundException

Unsubscribes a listener which is listening to an MBean or a set of MBeans represented by an ObjectName pattern.

The listener to be removed must have been added by the subscribe method with the given name, filter, and handback. If the name is a pattern, then the subscribe must have used the same pattern. If the same listener has been subscribed more than once to the name with the same filter and handback, only one listener is removed.

Parameters:
name - The name of the MBean or an ObjectName pattern representing a set of MBeans to which the listener was subscribed.
listener - A listener that was previously subscribed to the MBean(s).
Throws:
ListenerNotFoundException - The given listener was not subscribed to the given name.
See Also:
subscribe(javax.management.ObjectName, javax.management.NotificationListener, javax.management.NotificationFilter, java.lang.Object)

publish

public void publish(ObjectName emitterName,
                    Notification n)

Sends a notification to the subscribers for a given MBean.

For each listener subscribed with an ObjectName that either is equal to emitterName or is a pattern that matches emitterName, if the associated filter accepts the notification then it is forwarded to the listener.

Parameters:
emitterName - The name of the MBean emitting the notification.
n - The notification being sent by the MBean called emitterName.
Throws:
IllegalArgumentException - If the emitterName of the notification is null or is an ObjectName pattern.

getNotificationEmitterFor

public NotificationEmitter getNotificationEmitterFor(ObjectName name)
                                              throws InstanceNotFoundException

Returns a NotificationEmitter object which can be used to subscribe or unsubscribe for notifications with the named mbean. The returned object implements addNotificationListener(listener, filter, handback) as this.subscribe(name, listener, filter, handback) and the two removeNotificationListener methods from NotificationEmitter as the corresponding unsubscribe methods from this class.

Parameters:
name - The name of the MBean whose notifications are being subscribed, or unsuscribed.
Returns:
A NotificationEmitter that can be used to subscribe or unsubscribe for notifications emitted by the named MBean, or null if the MBean does not emit notifications and should not be considered as a NotificationBroadcaster. This class never returns null but a subclass is allowed to.
Throws:
InstanceNotFoundException - if name does not exist. This implementation never throws InstanceNotFoundException but a subclass is allowed to override this method to do so.

Java™ Platform
Standard Ed. 7

DRAFT ea-b76

Submit a bug or feature

Copyright 2009 Sun Microsystems, Inc. All Rights Reserved. Use is subject to license terms.

free hit counter