|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jboss.mx.util.JBossNotificationBroadcasterSupport org.jboss.system.ServiceMBeanSupport org.jboss.system.ListenerServiceMBeanSupport
An abstract base class that provides for declarative JMX notification subscription handling.
A JBoss service that is in addition a NotificationListener can subclass ListenerServiceMBeanSupport instead of ServiceMBeanSupport and specify at run-time, inline in the MBean descriptor using the SubscriptionList attribute, the set of MBeans/notifications the service wants to subscribe/receive.
Call subscribe(boolean dynamicSubscriptions) at anytime to register to those MBeans and for those notifications that match the specified criteria. Call unsubscribe() to unsubscribe for Notifications.
If true is passed to subscribe() the baseclass will monitor for registration events from the MBeanServer and automatically subscribe to new instances of MBeans that match the subscription criteria. Monitoring for unsubscribe events in not necessary, since the MBeanServer automatically removes subscriptions to unregistering MBeans.
An alternative subscribe(boolean dynamicSubscription, ObjectName listener) can be used to specify a different MBean as the receiver of the subscribed notifications. The specified MBean must be a NotificationListener.
To handle the incoming notifications override the handleNotification2() method. The usual handleNotification() method should not be overriden, since it is used to monitor the incoming notifications for registration events coming from the MBeanServer, before delegating to handleNotification2(), in order to implement dynamic subscriptions.
REVISIONS
=========
19/10/04, dimitris
renamed inner class MBeanInfo to SubscriptionInfo and made public,
using NotificationFilter instead of NotificationFilterSupport and added new
subscribe(List subscriptionList, boolean dynamicSubscriptions, ObjectName listener)
to allow external programmatic specification of the subscription list.
28/02/04, dimitris
explicit subscribe()/unsubscribe() replaced implicit start()/stop();
dynamic subscription behaviour can be enabled/disabled, plus it is
now possible to specify an external MBean as notification listener.
Nested Class Summary | |
static class |
ListenerServiceMBeanSupport.SubscriptionInfo
Inner data holder class to store the parsed subscription specification. |
Field Summary |
Fields inherited from class org.jboss.system.ServiceMBeanSupport |
log, server, SERVICE_CONTROLLER_SIG, serviceName |
Fields inherited from interface org.jboss.system.ListenerServiceMBean |
SL_MBEAN_ELEMENT, SL_MBEAN_HANDBACK_ATTRIBUTE, SL_MBEAN_NAME_ATTRIBUTE, SL_NOTIFICATION_ELEMENT, SL_NOTIFICATION_TYPE_ATTRIBUTE, SL_ROOT_ELEMENT |
Fields inherited from interface org.jboss.system.ServiceMBean |
CREATE_EVENT, CREATED, DESTROY_EVENT, DESTROYED, FAILED, REGISTERED, START_EVENT, STARTED, STARTING, states, STOP_EVENT, STOPPED, STOPPING, UNREGISTERED |
Constructor Summary | |
ListenerServiceMBeanSupport()
Constructs a ListenerServiceMBeanSupport. |
|
ListenerServiceMBeanSupport(Class type)
Constructs a ListenerServiceMBeanSupport. |
|
ListenerServiceMBeanSupport(org.jboss.logging.Logger log)
Constructs a ListenerServiceMBeanSupport. |
|
ListenerServiceMBeanSupport(String category)
Constructs a ListenerServiceMBeanSupport. |
Method Summary | |
void |
handleNotification(javax.management.Notification notification,
Object handback)
DO NOT OVERRIDE THIS! Handles dynamic subscriptions before delegating to handleNotification2() |
void |
handleNotification2(javax.management.Notification notification,
Object handback)
Override to add notification handling! |
void |
setSubscriptionList(Element list)
Used to configure the JMX notification subscriptions. |
void |
subscribe(boolean dynamicSubscriptions)
Subscribes this MBean for JMX notifications. |
void |
subscribe(boolean dynamicSubscriptions,
javax.management.ObjectName listener)
Subscribes a listener MBean for JMX notifications. |
void |
subscribe(List subscriptionList,
boolean dynamicSubscriptions,
javax.management.ObjectName listener)
Subscribes a listener MBean for JMX notifications. |
void |
unsubscribe()
Unsubscribes for JMX notifications |
Methods inherited from class org.jboss.system.ServiceMBeanSupport |
create, createService, destroy, destroyService, getLog, getName, getNextNotificationSequenceNumber, getObjectName, getServer, getServiceName, getState, getStateString, jbossInternalCreate, jbossInternalDescription, jbossInternalDestroy, jbossInternalLifecycle, jbossInternalStart, jbossInternalStop, postDeregister, postRegister, preDeregister, preRegister, start, startService, stop, stopService |
Methods inherited from class org.jboss.mx.util.JBossNotificationBroadcasterSupport |
addNotificationListener, getNotificationInfo, handleNotification, removeNotificationListener, removeNotificationListener, sendNotification |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.jboss.system.ServiceMBean |
getName, getState, getStateString, jbossInternalLifecycle |
Methods inherited from interface org.jboss.system.Service |
create, destroy, start, stop |
Constructor Detail |
public ListenerServiceMBeanSupport()
public ListenerServiceMBeanSupport(Class type)
type
- The class type to determine Logger name from.public ListenerServiceMBeanSupport(String category)
category
- The logger category name.public ListenerServiceMBeanSupport(org.jboss.logging.Logger log)
log
- The logger to use.Method Detail |
public void setSubscriptionList(Element list)
setSubscriptionList
in interface ListenerServiceMBean
public void subscribe(boolean dynamicSubscriptions) throws Exception
dynamicSubscriptions
- indicates whether to monitor and subscribe
to new MBeans that match the specification.
Exception
public void subscribe(boolean dynamicSubscriptions, javax.management.ObjectName listener) throws Exception
dynamicSubscriptions
- indicates whether to monitor and subscribe
to new MBeans that match the specification.listener
- the receiver of the notifications.
Exception
public void subscribe(List subscriptionList, boolean dynamicSubscriptions, javax.management.ObjectName listener) throws Exception
subscriptionList
- the list containing SubscriptionInfo data.dynamicSubscriptions
- indicates whether to monitor and subscribe
to new MBeans that match the specification.listener
- the receiver of the notifications.
Exception
public void unsubscribe()
public void handleNotification(javax.management.Notification notification, Object handback)
handleNotification
in interface javax.management.NotificationListener
public void handleNotification2(javax.management.Notification notification, Object handback)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |