org.jboss.system
Class BarrierController

java.lang.Object
  extended byorg.jboss.mx.util.JBossNotificationBroadcasterSupport (src) 
      extended byorg.jboss.system.ServiceMBeanSupport (src) 
          extended byorg.jboss.system.ListenerServiceMBeanSupport (src) 
              extended byorg.jboss.system.BarrierController
All Implemented Interfaces:
java.util.EventListener, ListenerServiceMBean (src) , MBeanRegistration (src) , NotificationBroadcaster (src) , NotificationEmitter (src) , NotificationListener (src) , Service (src) , ServiceMBean (src)

public class BarrierController
extends ListenerServiceMBeanSupport (src)

BarrierController service. A service that controls the lifecycle of a secondary mbean (the BarrierMbean) that can be used as a dependency for other services. Starting and stopping the barrier mbean (and as a result all services depending on it) is performed by listening for any kind of JMX notification. In particular we use the handback object of a notification subscription to qualify the start and stop signals. Manual control of the barrier is also supported through startBarrier()/stopBarrier() methods. You may subclass BarrierController and override enableOnStartup() to apply complex logic in deciding whether to initially start the barrier (e.g. query some other mbean).


Nested Class Summary
static class BarrierController.Barrier (src)
          The controlled barrier MBean class
static interface BarrierController.BarrierMBean (src)
          The controlled barrier MBean interface
 
Nested classes inherited from class org.jboss.system.ListenerServiceMBeanSupport (src)
ListenerServiceMBeanSupport.SubscriptionInfo (src)
 
Field Summary
protected  BarrierController.Barrier (src) barrier
          The controlled Barrier
 
Fields inherited from class org.jboss.system.ServiceMBeanSupport (src)
log, server, SERVICE_CONTROLLER_SIG, serviceName
 
Fields inherited from interface org.jboss.system.ListenerServiceMBean (src)
SL_FILTER_ELEMENT, SL_FILTER_FACTORY_ATTRIBUTE, 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 (src)
CREATE_EVENT, CREATED, DESTROY_EVENT, DESTROYED, FAILED, REGISTERED, START_EVENT, STARTED, STARTING, states, STOP_EVENT, STOPPED, STOPPING, UNREGISTERED
 
Constructor Summary
BarrierController()
          Default CTOR
 
Method Summary
protected  void createService()
          Sub-classes should override this method to provide custum 'create' logic.
protected  void destroyService()
          Sub-classes should override this method to provide custum 'destroy' logic.
protected  java.lang.Boolean enableOnStartup()
          Override this method to apply complex logic whether to start the Barrier service upon startup or not.
 java.lang.Boolean getBarrierEnabledOnStartup()
          The initial state of the barrier.
 ObjectName (src) getBarrierObjectName()
          The controlled barrier ObjectName.
 java.lang.String getBarrierStateString()
          The controlled barrier StateString.
 java.lang.Boolean getDynamicSubscriptions()
          The ability to dynamically subscribe for notifications.
 java.lang.String getStartBarrierHandback()
          The notification subscription handback string that starts the barrier.
 java.lang.String getStopBarrierHandback()
          The notification subscription handback string that stops the barrier.
 void handleNotification2(Notification (src)  n, java.lang.Object handback)
          Base on the handback object the decision for starting/stopping the barrier
 void setBarrierEnabledOnStartup(java.lang.Boolean enableOnStartup)
          The initial state of the barrier.
 void setBarrierObjectName(ObjectName (src)  barrierName)
          The controlled barrier ObjectName.
 void setDynamicSubscriptions(java.lang.Boolean dynamicSubscriptions)
          The ability to dynamically subscribe for notifications.
 void setStartBarrierHandback(java.lang.String startHandback)
          The notification subscription handback string that starts the barrier.
 void setStopBarrierHandback(java.lang.String stopHandback)
          The notification subscription handback string that stops the barrier.
 void startBarrier()
          Manually start the controlled barrier
 void stopBarrier()
          Manually stop the controlled barrier
 
Methods inherited from class org.jboss.system.ListenerServiceMBeanSupport (src)
handleNotification, setSubscriptionList, subscribe, subscribe, subscribe, unsubscribe
 
Methods inherited from class org.jboss.system.ServiceMBeanSupport (src)
create, destroy, 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 (src)
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 (src)
getName, getState, getStateString, jbossInternalLifecycle
 
Methods inherited from interface org.jboss.system.Service (src)
create, destroy, start, stop
 

Field Detail

barrier

protected BarrierController.Barrier (src)  barrier
The controlled Barrier

Constructor Detail

BarrierController

public BarrierController()
Default CTOR

Method Detail

getBarrierStateString

public java.lang.String getBarrierStateString()
The controlled barrier StateString.


setBarrierObjectName

public void setBarrierObjectName(ObjectName (src)  barrierName)
The controlled barrier ObjectName.


getBarrierObjectName

public ObjectName (src)  getBarrierObjectName()
The controlled barrier ObjectName.


setBarrierEnabledOnStartup

public void setBarrierEnabledOnStartup(java.lang.Boolean enableOnStartup)
The initial state of the barrier. If set, it overrides the internal call to enableOnStartup() which will never get called.


getBarrierEnabledOnStartup

public java.lang.Boolean getBarrierEnabledOnStartup()
The initial state of the barrier. Use the value set through setBarrierEnabledOnStartup() otherwise call the internal enableOnStartup() override to make a decision.


setStartBarrierHandback

public void setStartBarrierHandback(java.lang.String startHandback)
The notification subscription handback string that starts the barrier.


getStartBarrierHandback

public java.lang.String getStartBarrierHandback()
The notification subscription handback string that starts the barrier.


setStopBarrierHandback

public void setStopBarrierHandback(java.lang.String stopHandback)
The notification subscription handback string that stops the barrier.


getStopBarrierHandback

public java.lang.String getStopBarrierHandback()
The notification subscription handback string that stops the barrier.


setDynamicSubscriptions

public void setDynamicSubscriptions(java.lang.Boolean dynamicSubscriptions)
The ability to dynamically subscribe for notifications.


getDynamicSubscriptions

public java.lang.Boolean getDynamicSubscriptions()
The ability to dynamically subscribe for notifications.


enableOnStartup

protected java.lang.Boolean enableOnStartup()
Override this method to apply complex logic whether to start the Barrier service upon startup or not. This method will be only called once and only if setBarrierEnabledOnStartup(Boolean) has not been called. The default implementation is to return false.


createService

protected void createService()
                      throws java.lang.Exception
Description copied from class: ServiceMBeanSupport (src)
Sub-classes should override this method to provide custum 'create' logic.

This method is empty, and is provided for convenience when concrete service classes do not need to perform anything specific for this state change.

Overrides:
createService in class ServiceMBeanSupport (src)
Throws:
java.lang.Exception

destroyService

protected void destroyService()
Description copied from class: ServiceMBeanSupport (src)
Sub-classes should override this method to provide custum 'destroy' logic.

This method is empty, and is provided for convenience when concrete service classes do not need to perform anything specific for this state change.

Overrides:
destroyService in class ServiceMBeanSupport (src)

handleNotification2

public void handleNotification2(Notification (src)  n,
                                java.lang.Object handback)
Base on the handback object the decision for starting/stopping the barrier

Overrides:
handleNotification2 in class ListenerServiceMBeanSupport (src)

startBarrier

public void startBarrier()
Manually start the controlled barrier


stopBarrier

public void stopBarrier()
Manually stop the controlled barrier