org.jboss.system
Class BarrierController

java.lang.Object
  extended by org.jboss.mx.util.JBossNotificationBroadcasterSupport
      extended by org.jboss.system.ServiceMBeanSupport
          extended by org.jboss.system.ListenerServiceMBeanSupport
              extended by org.jboss.system.BarrierController
All Implemented Interfaces:
EventListener, javax.management.MBeanRegistration, javax.management.NotificationBroadcaster, javax.management.NotificationEmitter, javax.management.NotificationListener, BarrierControllerMBean, ListenerServiceMBean, Service, ServiceMBean

public class BarrierController
extends ListenerServiceMBeanSupport
implements BarrierControllerMBean

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).

Version:
$Revision: 1.2.4.3 $
Author:
Dimitris Andreadis, Scott.Stark@jboss.org

Nested Class Summary
static class BarrierController.Barrier
          The controlled barrier MBean class
static interface BarrierController.BarrierMBean
          The controlled barrier MBean interface
 
Nested classes/interfaces inherited from class org.jboss.system.ListenerServiceMBeanSupport
ListenerServiceMBeanSupport.SubscriptionInfo
 
Field Summary
protected  BarrierController.Barrier barrier
          The controlled Barrier
 
Fields inherited from class org.jboss.system.ServiceMBeanSupport
log, server, SERVICE_CONTROLLER_SIG, serviceName
 
Fields inherited from interface org.jboss.system.BarrierControllerMBean
OBJECT_NAME
 
Fields inherited from interface org.jboss.system.ListenerServiceMBean
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
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  Boolean enableOnStartup()
          Override this method to apply complex logic whether to start the Barrier service upon startup or not.
 Boolean getBarrierEnabledOnStartup()
          The initial state of the barrier.
 javax.management.ObjectName getBarrierObjectName()
          The controlled barrier ObjectName.
 String getBarrierStateString()
          The controlled barrier StateString.
 Boolean getDynamicSubscriptions()
          The ability to dynamically subscribe for notifications.
 String getStartBarrierHandback()
          The notification subscription handback string that starts the barrier.
 String getStopBarrierHandback()
          The notification subscription handback string that stops the barrier.
 void handleNotification2(javax.management.Notification n, Object handback)
          Base on the handback object the decision for starting/stopping the barrier
 void setBarrierEnabledOnStartup(Boolean enableOnStartup)
          The initial state of the barrier.
 void setBarrierObjectName(javax.management.ObjectName barrierName)
          The controlled barrier ObjectName.
 void setDynamicSubscriptions(Boolean dynamicSubscriptions)
          The ability to dynamically subscribe for notifications.
 void setStartBarrierHandback(String startHandback)
          The notification subscription handback string that starts the barrier.
 void setStopBarrierHandback(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
handleNotification, setSubscriptionList, subscribe, subscribe, subscribe, unsubscribe
 
Methods inherited from class org.jboss.system.ServiceMBeanSupport
create, destroy, getDeploymentInfo, 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, nextNotificationSequenceNumber, 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.ListenerServiceMBean
setSubscriptionList
 
Methods inherited from interface org.jboss.system.ServiceMBean
getName, getState, getStateString, jbossInternalLifecycle
 
Methods inherited from interface org.jboss.system.Service
create, destroy, start, stop
 

Field Detail

barrier

protected BarrierController.Barrier barrier
The controlled Barrier

Constructor Detail

BarrierController

public BarrierController()
Default CTOR

Method Detail

getBarrierStateString

public String getBarrierStateString()
The controlled barrier StateString.

Specified by:
getBarrierStateString in interface BarrierControllerMBean

setBarrierObjectName

public void setBarrierObjectName(javax.management.ObjectName barrierName)
The controlled barrier ObjectName.

Specified by:
setBarrierObjectName in interface BarrierControllerMBean

getBarrierObjectName

public javax.management.ObjectName getBarrierObjectName()
The controlled barrier ObjectName.

Specified by:
getBarrierObjectName in interface BarrierControllerMBean

setBarrierEnabledOnStartup

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

Specified by:
setBarrierEnabledOnStartup in interface BarrierControllerMBean

getBarrierEnabledOnStartup

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

Specified by:
getBarrierEnabledOnStartup in interface BarrierControllerMBean

setStartBarrierHandback

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

Specified by:
setStartBarrierHandback in interface BarrierControllerMBean

getStartBarrierHandback

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

Specified by:
getStartBarrierHandback in interface BarrierControllerMBean

setStopBarrierHandback

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

Specified by:
setStopBarrierHandback in interface BarrierControllerMBean

getStopBarrierHandback

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

Specified by:
getStopBarrierHandback in interface BarrierControllerMBean

setDynamicSubscriptions

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

Specified by:
setDynamicSubscriptions in interface BarrierControllerMBean

getDynamicSubscriptions

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

Specified by:
getDynamicSubscriptions in interface BarrierControllerMBean

enableOnStartup

protected 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 Exception
Description copied from class: ServiceMBeanSupport
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
Throws:
Exception

destroyService

protected void destroyService()
Description copied from class: ServiceMBeanSupport
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

handleNotification2

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

Overrides:
handleNotification2 in class ListenerServiceMBeanSupport

startBarrier

public void startBarrier()
Manually start the controlled barrier

Specified by:
startBarrier in interface BarrierControllerMBean

stopBarrier

public void stopBarrier()
Manually stop the controlled barrier

Specified by:
stopBarrier in interface BarrierControllerMBean


Copyright © 2002 JBoss Group, LLC. All Rights Reserved.