|
Java™ Platform Standard Ed. 7 DRAFT ea-b76 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.management.event.EventSubscriber
public class EventSubscriber extends Object implements EventConsumer
An object that can be used to subscribe for notifications from all MBeans
in an MBeanServer that match a pattern. For example, to listen for
notifications from all MBeans in the MBeanServer mbs that match
com.example:type=Controller,name=* you could write:
EventSubscriber subscriber = EventSubscriber.getEventSubscriber(mbs);
ObjectName pattern = new ObjectName("com.example:type=Controller,name=*");
NotificationListener myListener = ...;
NotificationFilter myFilter = null; // or whatever
Object handback = null; // or whatever
subscriber.subscribe(pattern, myListener, myFilter, myHandback);
| Modifier and Type | Method and Description |
|---|---|
static EventSubscriber |
getEventSubscriber(MBeanServer mbs)
Returns an EventSubscriber object to subscribe for notifications
from the given MBeanServer. |
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static EventSubscriber getEventSubscriber(MBeanServer mbs)
EventSubscriber object to subscribe for notifications
from the given MBeanServer. Calling this method more
than once with the same parameter may or may not return the same object.
mbs - the MBeanServer containing MBeans to be subscribed to.EventSubscriber object.NullPointerException - if mbs is null.
public void subscribe(ObjectName name,
NotificationListener listener,
NotificationFilter filter,
Object handback)
throws IOException
EventConsumerSubscribes 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.
subscribe in interface EventConsumername - 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.IOException - for a remote client, thrown if
an I/O error occurs.EventConsumer.unsubscribe(ObjectName, NotificationListener)
public void unsubscribe(ObjectName name,
NotificationListener listener)
throws ListenerNotFoundException,
IOException
EventConsumerUnsubscribes 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.
unsubscribe in interface EventConsumername - 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).ListenerNotFoundException - The given listener was not
subscribed to the given name.IOException - for a remote client, thrown if
an I/O error occurs.EventConsumer.subscribe(javax.management.ObjectName, javax.management.NotificationListener, javax.management.NotificationFilter, java.lang.Object)
|
Java™ Platform Standard Ed. 7 DRAFT ea-b76 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
Copyright 2009 Sun Microsystems, Inc. All Rights Reserved. Use is subject to license terms.