FileDocCategorySizeDatePackage
HASingletonController.javaAPI DocJBoss 4.2.16513Fri Jul 13 20:52:36 BST 2007org.jboss.ha.singleton

HASingletonController

public class HASingletonController extends HASingletonSupport implements HASingletonControllerMBean
A clustered singleton service that calls a configurable method on a target mbean, whenever the current node becomes the master. Correspondigly, it calls a configurable method on the target mbean, whenever the current node resigns from being the master. Optional string arguments may be passed to those methods. The prevailing usage of this MBean is to deploy on the master node the content of the deploy-hasingleton directory.
author
Ivelin Ivanov
author
Scott Stark
author
Marcus Redeker
author
Dimitris Andreadis
version
$Revision: 57188 $

Fields Summary
private ObjectName
mSingletonMBean
private String
mSingletonMBeanStartMethod
private String
mSingletonMBeanStopMethod
private String
mSingletonMBeanStartMethodArgument
private String
mSingletonMBeanStopMethodArgument
private static final Object[]
NO_ARGS
private static final String[]
NO_TYPES
Constructors Summary
public HASingletonController()
Default CTOR


   // Constructors --------------------------------------------------
   
         
    
   
      // empty
   
Methods Summary
public javax.management.ObjectNamegetTargetName()

      return mSingletonMBean;
   
public java.lang.StringgetTargetStartMethod()

      return mSingletonMBeanStartMethod;
   
public java.lang.StringgetTargetStartMethodArgument()

      return mSingletonMBeanStartMethodArgument ;
   
public java.lang.StringgetTargetStopMethod()

      return mSingletonMBeanStopMethod;
   
public java.lang.StringgetTargetStopMethodArgument()

      return mSingletonMBeanStopMethodArgument ;
   
protected java.lang.ObjectinvokeSingletonMBeanMethod(javax.management.ObjectName target, java.lang.String operationName, java.lang.Object param)

      if (target != null && operationName != null)
      {
         Object[] params;
         String[] signature;
         
         if (param != null) 
         {
            params = new Object[] { param };
            signature = new String[] { param.getClass().getName() };
            
            log.debug("Calling operation: " + operationName +
                  "(" + param + "), on target: '" + target + "'");            
         }
         else
         {
            params = NO_ARGS;
            signature = NO_TYPES;
            
            log.debug("Calling operation: " + operationName + 
                  "(), on target: '" + target + "'");               
         }

         return server.invoke(target, operationName, params, signature);
      }
      else
      {
         log.debug("No configured target mbean or operation to call");
         
         return null;
      }
   
public voidsetTargetName(javax.management.ObjectName targetObjectName)

      this.mSingletonMBean = targetObjectName;
   
public voidsetTargetStartMethod(java.lang.String targetStartMethod)

      if (targetStartMethod != null)
         mSingletonMBeanStartMethod = targetStartMethod;
   
public voidsetTargetStartMethodArgument(java.lang.String targetStartMethodArgument)

      mSingletonMBeanStartMethodArgument = targetStartMethodArgument;
   
public voidsetTargetStopMethod(java.lang.String targetStopMethod)

      if (targetStopMethod != null)
         mSingletonMBeanStopMethod = targetStopMethod;
   
public voidsetTargetStopMethodArgument(java.lang.String targetStopMethodArgument)

      mSingletonMBeanStopMethodArgument =  targetStopMethodArgument;
   
public voidstartSingleton()
Call the target start method

see
org.jboss.ha.singleton.HASingletonSupport#startSingleton()

      super.startSingleton();

      try
      {
         invokeSingletonMBeanMethod(
            mSingletonMBean,
            mSingletonMBeanStartMethod,
            mSingletonMBeanStartMethodArgument 
            );
      }
      catch (JMException jme)
      {
         log.error("Controlled Singleton MBean failed to become master", jme);
      }
   
public voidstopSingleton()
Call the target stop method

see
org.jboss.ha.singleton.HASingletonSupport#stopSingleton()

      super.stopSingleton();

      try
      {
         invokeSingletonMBeanMethod(
            mSingletonMBean,
            mSingletonMBeanStopMethod,
            mSingletonMBeanStopMethodArgument
            );
      }
      catch (JMException jme)
      {
         log.error("Controlled Singleton MBean failed to resign from master position", jme);
      }