org.jboss.ha.singleton
Class HASingletonController

java.lang.Object
  extended byorg.jboss.mx.util.JBossNotificationBroadcasterSupport (src) 
      extended byorg.jboss.system.ServiceMBeanSupport (src) 
          extended byorg.jboss.ha.jmx.HAServiceMBeanSupport (src) 
              extended byorg.jboss.ha.singleton.HASingletonSupport (src) 
                  extended byorg.jboss.ha.singleton.HASingletonController
All Implemented Interfaces:
HAServiceMBean (src) , HASingleton (src) , HASingletonControllerMBean (src) , HASingletonMBean (src) , MBeanRegistration (src) , NotificationBroadcaster (src) , NotificationEmitter (src) , Service (src) , ServiceMBean (src)
Direct Known Subclasses:
HASingletonControllerTester (src)

public class HASingletonController
extends HASingletonSupport (src)
implements HASingletonControllerMBean (src)

Allows singleton MBeans to be added declaratively at deployment time


Field Summary
 
Fields inherited from class org.jboss.system.ServiceMBeanSupport (src)
log, server, SERVICE_CONTROLLER_SIG, serviceName
 
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
HASingletonController()
           
 
Method Summary
 ObjectName (src) getTargetName()
           
 java.lang.String getTargetStartMethod()
           
 java.lang.String getTargetStartMethodArgument()
           
 java.lang.String getTargetStopMethod()
           
 java.lang.String getTargetStopMethodArgument()
           
protected  java.lang.Object invokeSingletonMBeanMethod(ObjectName (src)  name, java.lang.String operationName, java.lang.Object param)
           
 void setTargetName(ObjectName (src)  targetObjectName)
          Sets the fully qualified JMX MBean Object Name of the Schedulable MBean to be called.
 void setTargetStartMethod(java.lang.String targetStartMethod)
          Sets the start method name to be called on the Singleton MBean.
 void setTargetStartMethodArgument(java.lang.String targetStartMethodArgument)
          Sets the argument to be passed to the start method of the Singleton MBean.
 void setTargetStopMethod(java.lang.String targetStopMethod)
          Sets the stop method name to be called on the Singleton MBean.
 void setTargetStopMethodArgument(java.lang.String targetStopMethodArgument)
          Sets the argument to be passed to the stop method of the Singleton MBean.
 void startSingleton()
           Extending classes should override this method and implement the custom singleton logic.
 void stopSingleton()
          Extending classes should override this method and implement the custom singleton logic.
 
Methods inherited from class org.jboss.ha.singleton.HASingletonSupport (src)
_stopOldMaster, isMasterNode, makeThisNodeMaster, partitionTopologyChanged
 
Methods inherited from class org.jboss.ha.jmx.HAServiceMBeanSupport (src)
_receiveRemoteNotification, callAsyncMethodOnPartition, callMethodOnPartition, callMethodOnPartition, findHAPartitionWithName, getDistributedState, getPartition, getPartitionName, getServiceHAName, isDRMMasterReplica, registerDRMListener, registerRPCHandler, sendNotification, sendNotificationRemote, sendNotificationToLocalListeners, setDistributedState, setPartitionName, setupPartition, startService, stopService, unregisterDRMListener, unregisterRPCHandler
 
Methods inherited from class org.jboss.system.ServiceMBeanSupport (src)
create, createService, destroy, destroyService, getLog, getName, getNextNotificationSequenceNumber, getObjectName, getServer, getServiceName, getState, getStateString, jbossInternalCreate, jbossInternalDescription, jbossInternalDestroy, jbossInternalLifecycle, jbossInternalStart, jbossInternalStop, postDeregister, postRegister, preDeregister, preRegister, start, stop
 
Methods inherited from class org.jboss.mx.util.JBossNotificationBroadcasterSupport (src)
addNotificationListener, getNotificationInfo, handleNotification, removeNotificationListener, removeNotificationListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jboss.ha.singleton.HASingletonMBean (src)
isMasterNode
 
Methods inherited from interface org.jboss.ha.jmx.HAServiceMBean (src)
callMethodOnPartition, getDistributedState, getPartitionName, sendNotification, setDistributedState, setPartitionName
 
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
 
Methods inherited from interface javax.management.NotificationBroadcaster (src)
addNotificationListener, getNotificationInfo, removeNotificationListener
 

Constructor Detail

HASingletonController

public HASingletonController()
Method Detail

startSingleton

public void startSingleton()
Description copied from class: HASingletonSupport (src)

Extending classes should override this method and implement the custom singleton logic. Only one node in the cluster is the active master. If the current node is elected for master, this method is invoked. When another node is elected for master for some reason, the stopSingleton() method is invokded.

When the extending class is a stateful singleton, it will usually use putDistributedState() and getDistributedState() to save in the cluster environment information that will be needed by the next node elected for master should the current master node fail.

Specified by:
startSingleton in interface HASingleton (src)
Overrides:
startSingleton in class HASingletonSupport (src)
See Also:
HASingleton (src)

stopSingleton

public void stopSingleton()
Description copied from class: HASingletonSupport (src)
Extending classes should override this method and implement the custom singleton logic. Only one node in the cluster is the active master. If the current node is master and another node is elected for master, this method is invoked.

Specified by:
stopSingleton in interface HASingleton (src)
Overrides:
stopSingleton in class HASingletonSupport (src)
See Also:
HASingleton (src)

invokeSingletonMBeanMethod

protected java.lang.Object invokeSingletonMBeanMethod(ObjectName (src)  name,
                                                      java.lang.String operationName,
                                                      java.lang.Object param)
                                               throws InstanceNotFoundException (src) ,
                                                      MBeanException (src) ,
                                                      ReflectionException (src) 
Throws:
InstanceNotFoundException (src)
MBeanException (src)
ReflectionException (src)

getTargetName

public ObjectName (src)  getTargetName()
Specified by:
getTargetName in interface HASingletonControllerMBean (src)
Returns:
Object Name of the Target MBean for the timer notifications

setTargetName

public void setTargetName(ObjectName (src)  targetObjectName)
Description copied from interface: HASingletonControllerMBean (src)
Sets the fully qualified JMX MBean Object Name of the Schedulable MBean to be called.

Specified by:
setTargetName in interface HASingletonControllerMBean (src)

getTargetStartMethod

public java.lang.String getTargetStartMethod()
Specified by:
getTargetStartMethod in interface HASingletonControllerMBean (src)
Returns:
start method description of the target MBean to be called

setTargetStartMethod

public void setTargetStartMethod(java.lang.String targetStartMethod)
                          throws java.security.InvalidParameterException
Description copied from interface: HASingletonControllerMBean (src)
Sets the start method name to be called on the Singleton MBean.

Specified by:
setTargetStartMethod in interface HASingletonControllerMBean (src)
Throws:
java.security.InvalidParameterException

getTargetStopMethod

public java.lang.String getTargetStopMethod()
Specified by:
getTargetStopMethod in interface HASingletonControllerMBean (src)
Returns:
stop method description of the target MBean to be called

setTargetStopMethod

public void setTargetStopMethod(java.lang.String targetStopMethod)
                         throws java.security.InvalidParameterException
Description copied from interface: HASingletonControllerMBean (src)
Sets the stop method name to be called on the Singleton MBean.

Specified by:
setTargetStopMethod in interface HASingletonControllerMBean (src)
Throws:
java.security.InvalidParameterException

getTargetStartMethodArgument

public java.lang.String getTargetStartMethodArgument()
Specified by:
getTargetStartMethodArgument in interface HASingletonControllerMBean (src)
Returns:
start method argument of the target MBean to be called

setTargetStartMethodArgument

public void setTargetStartMethodArgument(java.lang.String targetStartMethodArgument)
Description copied from interface: HASingletonControllerMBean (src)
Sets the argument to be passed to the start method of the Singleton MBean.

Specified by:
setTargetStartMethodArgument in interface HASingletonControllerMBean (src)

getTargetStopMethodArgument

public java.lang.String getTargetStopMethodArgument()
Specified by:
getTargetStopMethodArgument in interface HASingletonControllerMBean (src)
Returns:
stop method argument of the target MBean to be called

setTargetStopMethodArgument

public void setTargetStopMethodArgument(java.lang.String targetStopMethodArgument)
Description copied from interface: HASingletonControllerMBean (src)
Sets the argument to be passed to the stop method of the Singleton MBean.

Specified by:
setTargetStopMethodArgument in interface HASingletonControllerMBean (src)