org.jboss.ha.singleton
Class HASingletonController

java.lang.Object
  extended by org.jboss.mx.util.JBossNotificationBroadcasterSupport
      extended by org.jboss.system.ServiceMBeanSupport
          extended by org.jboss.ha.jmx.AbstractHAServiceMBeanSupport<org.jboss.ha.framework.interfaces.HASingleton<Notification>>
              extended by org.jboss.ha.singleton.HASingletonSupport
                  extended by org.jboss.ha.singleton.HASingletonController
All Implemented Interfaces:
EventListener, MBeanRegistration, NotificationBroadcaster, NotificationEmitter, org.jboss.ha.framework.interfaces.HAService<Notification>, org.jboss.ha.framework.interfaces.HAServiceKeyProvider, org.jboss.ha.framework.interfaces.HASingleton<Notification>, org.jboss.ha.framework.interfaces.HASingletonLifecycle, org.jboss.ha.framework.interfaces.HASingletonMBean, org.jboss.ha.framework.server.EventFacility<Notification>, org.jboss.ha.framework.server.EventFactory<Notification>, org.jboss.ha.framework.server.HAServiceRpcHandler<Notification>, org.jboss.ha.framework.server.HASingletonRpcHandler<Notification>, HAServiceMBean, HASingletonControllerMBean, HASingletonSupportMBean, org.jboss.kernel.spi.dependency.KernelControllerContextAware, Service, ServiceMBean

public class HASingletonController
extends HASingletonSupport
implements HASingletonControllerMBean

A clustered singleton service that calls a configurable method on a target (m)bean, whenever the current node becomes the master. Correspondingly, it calls a configurable method on the target (m)bean, whenever the current node resigns from being the master. Optional string arguments may be passed to those methods.

Version:
$Revision: 81001 $
Author:
Ivelin Ivanov, Scott Stark, Marcus Redeker, Dimitris Andreadis, Brian Stansberry

Field Summary
 
Fields inherited from class org.jboss.system.ServiceMBeanSupport
log, server, SERVICE_CONTROLLER_SIG, serviceName
 
Fields inherited from interface org.jboss.ha.framework.interfaces.HASingleton
HASINGLETON_STARTED_NOTIFICATION, HASINGLETON_STARTING_NOTIFICATION, HASINGLETON_STOPPED_NOTIFICATION, HASINGLETON_STOPPING_NOTIFICATION
 
Fields inherited from interface org.jboss.ha.singleton.HASingletonMBean
HASINGLETON_STARTED_NOTIFICATION, HASINGLETON_STARTING_NOTIFICATION, HASINGLETON_STOPPED_NOTIFICATION, HASINGLETON_STOPPING_NOTIFICATION
 
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
HASingletonController()
           
 
Method Summary
 Object getTarget()
          Gets controlled target singleton
static Method getTargetMethod(Object target, String methodName, Class<?>[] types)
           
 ObjectName getTargetName()
          Gets the ObjectName of the controlled target Singleton MBean
 String getTargetStartMethod()
          The target method to call when the Singleton is started
 String getTargetStartMethodArgument()
          The argument to pass to the start method of the singleton MBean
 String getTargetStopMethod()
          The target method to call when the Singleton is stopped
 String getTargetStopMethodArgument()
          The argument to pass to the stop method of the singleton MBean
protected  Object invokeSingletonMBeanMethod(ObjectName target, String operationName, Object param)
           
protected  Object invokeSingletonMethod(Object target, String operationName, Object param)
           
 void setTarget(Object target)
          Sets the controlled target singleton
 void setTargetName(ObjectName targetObjectName)
          Sets the ObjectName of the controlled target Singleton MBean
 void setTargetStartMethod(String targetStartMethod)
           
 void setTargetStartMethodArgument(String targetStartMethodArgument)
           
 void setTargetStopMethod(String targetStopMethod)
           
 void setTargetStopMethodArgument(String targetStopMethodArgument)
           
 void startSingleton()
          Call the target start method
 void stopSingleton()
          Call the target stop method
 
Methods inherited from class org.jboss.ha.singleton.HASingletonSupport
createHAService, getElectionPolicy, getRestartOnMerge, isMasterNode, setElectionPolicy, setRestartOnMerge, stopOldMaster
 
Methods inherited from class org.jboss.ha.jmx.AbstractHAServiceMBeanSupport
callAsyncMethodOnPartition, callMethodOnPartition, createEvent, createService, destroyService, getDistributedState, getHAPartition, getHAService, getHAServiceKey, getPartitionName, getSendLocalLifecycleNotifications, getSendRemoteLifecycleNotifications, getServiceHAName, handleEvent, isRegisterThreadContextClassLoader, notifyListeners, sendNotification, sendNotificationRemote, sendNotificationToLocalListeners, setClusterPartition, setDistributedState, setHAPartition, setRegisterThreadContextClassLoader, setSendLocalLifecycleNotifications, setSendRemoteLifecycleNotifications, setServiceHAName, setupPartition, startService, stopService
 
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, pojoChange, pojoCreate, pojoDestroy, pojoStart, pojoStop, postDeregister, postRegister, preDeregister, preRegister, setKernelControllerContext, start, stop, unsetKernelControllerContext
 
Methods inherited from class org.jboss.mx.util.JBossNotificationBroadcasterSupport
addNotificationListener, getNotificationInfo, handleNotification, nextNotificationSequenceNumber, 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.framework.interfaces.HASingleton
getElectionPolicy, getRestartOnMerge, setElectionPolicy, setRestartOnMerge
 
Methods inherited from interface org.jboss.ha.framework.interfaces.HAService
create, destroy, getServiceHAName, isRegisterThreadContextClassLoader, setHAPartition, setRegisterThreadContextClassLoader, setServiceHAName, start, stop
 
Methods inherited from interface org.jboss.ha.framework.interfaces.HAServiceKeyProvider
getHAPartition, getHAServiceKey
 
Methods inherited from interface org.jboss.ha.framework.interfaces.EventListener
handleEvent
 
Methods inherited from interface org.jboss.ha.jmx.HAServiceMBean
callMethodOnPartition, getDistributedState, getPartitionName, sendNotification, setClusterPartition, setDistributedState, setHAPartition
 
Methods inherited from interface org.jboss.system.ServiceMBean
getName, getState, getStateString, jbossInternalLifecycle
 
Methods inherited from interface org.jboss.system.Service
create, destroy, start, stop
 
Methods inherited from interface javax.management.NotificationBroadcaster
addNotificationListener, getNotificationInfo, removeNotificationListener
 
Methods inherited from interface org.jboss.ha.framework.interfaces.HASingletonMBean
isMasterNode
 

Constructor Detail

HASingletonController

public HASingletonController()
Method Detail

getTarget

public Object getTarget()
Description copied from interface: HASingletonControllerMBean
Gets controlled target singleton

Specified by:
getTarget in interface HASingletonControllerMBean
Returns:
the singleton, or null if this object is configured to use a JMX object name.

setTarget

public void setTarget(Object target)
Description copied from interface: HASingletonControllerMBean
Sets the controlled target singleton

Specified by:
setTarget in interface HASingletonControllerMBean

getTargetName

public ObjectName getTargetName()
Description copied from interface: HASingletonControllerMBean
Gets the ObjectName of the controlled target Singleton MBean

Specified by:
getTargetName in interface HASingletonControllerMBean
Returns:
the target object name, or null if this object is configured via HASingletonControllerMBean.setTarget(Object).

setTargetName

public void setTargetName(ObjectName targetObjectName)
Description copied from interface: HASingletonControllerMBean
Sets the ObjectName of the controlled target Singleton MBean

Specified by:
setTargetName in interface HASingletonControllerMBean
Parameters:
targetObjectName - target of the MBean singleton

getTargetStartMethod

public String getTargetStartMethod()
Description copied from interface: HASingletonControllerMBean
The target method to call when the Singleton is started

Specified by:
getTargetStartMethod in interface HASingletonControllerMBean

setTargetStartMethod

public void setTargetStartMethod(String targetStartMethod)
                          throws InvalidParameterException
Specified by:
setTargetStartMethod in interface HASingletonControllerMBean
Throws:
InvalidParameterException

getTargetStopMethod

public String getTargetStopMethod()
Description copied from interface: HASingletonControllerMBean
The target method to call when the Singleton is stopped

Specified by:
getTargetStopMethod in interface HASingletonControllerMBean

setTargetStopMethod

public void setTargetStopMethod(String targetStopMethod)
                         throws InvalidParameterException
Specified by:
setTargetStopMethod in interface HASingletonControllerMBean
Throws:
InvalidParameterException

getTargetStartMethodArgument

public String getTargetStartMethodArgument()
Description copied from interface: HASingletonControllerMBean
The argument to pass to the start method of the singleton MBean

Specified by:
getTargetStartMethodArgument in interface HASingletonControllerMBean

setTargetStartMethodArgument

public void setTargetStartMethodArgument(String targetStartMethodArgument)
Specified by:
setTargetStartMethodArgument in interface HASingletonControllerMBean

getTargetStopMethodArgument

public String getTargetStopMethodArgument()
Description copied from interface: HASingletonControllerMBean
The argument to pass to the stop method of the singleton MBean

Specified by:
getTargetStopMethodArgument in interface HASingletonControllerMBean

setTargetStopMethodArgument

public void setTargetStopMethodArgument(String targetStopMethodArgument)
Specified by:
setTargetStopMethodArgument in interface HASingletonControllerMBean

startSingleton

public void startSingleton()
Call the target start method

Specified by:
startSingleton in interface org.jboss.ha.framework.interfaces.HASingletonLifecycle
Overrides:
startSingleton in class HASingletonSupport
See Also:
HASingletonSupport.startSingleton()

stopSingleton

public void stopSingleton()
Call the target stop method

Specified by:
stopSingleton in interface org.jboss.ha.framework.interfaces.HASingletonLifecycle
Overrides:
stopSingleton in class HASingletonSupport
See Also:
HASingletonSupport.stopSingleton()

invokeSingletonMethod

protected Object invokeSingletonMethod(Object target,
                                       String operationName,
                                       Object param)
                                throws IllegalAccessException,
                                       InvocationTargetException,
                                       NoSuchMethodException
Throws:
IllegalAccessException
InvocationTargetException
NoSuchMethodException

invokeSingletonMBeanMethod

protected Object invokeSingletonMBeanMethod(ObjectName target,
                                            String operationName,
                                            Object param)
                                     throws InstanceNotFoundException,
                                            MBeanException,
                                            ReflectionException
Throws:
InstanceNotFoundException
MBeanException
ReflectionException

getTargetMethod

public static Method getTargetMethod(Object target,
                                     String methodName,
                                     Class<?>[] types)
                              throws NoSuchMethodException
Throws:
NoSuchMethodException


Copyright © 2009 JBoss, a division of Red Hat, Inc.. All Rights Reserved.