org.jboss.varia.scheduler
Class AbstractScheduleProvider

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.varia.scheduler.AbstractScheduleProvider
All Implemented Interfaces:
HAServiceMBean (src) , HASingleton (src) , HASingletonMBean (src) , MBeanRegistration (src) , NotificationBroadcaster (src) , NotificationEmitter (src) , Service (src) , ServiceMBean (src)
Direct Known Subclasses:
DBScheduleProvider (src) , SingleScheduleProvider (src) , XMLScheduleProvider (src)

public abstract class AbstractScheduleProvider
extends HASingletonSupport (src)

Abstract Base Class for Schedule Provider. Any Schedule Provider should extend from this class or must provide the MBean Interface methods. This class is cluster aware and allows the use of the HASingleton MBean attribute to control whether or not it should run as a singleton service or not. When HASingleton is set to true the MBean will usually declare dependency on a cluster partition. When not explicitly set the attribute defaults to false.


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
AbstractScheduleProvider()
          Default (no-args) Constructor
 
Method Summary
protected  int addSchedule(ObjectName (src)  pTarget, java.lang.String pMethodName, java.lang.String[] pMethodSignature, java.util.Date pStart, long pPeriod, int pRepetitions)
          Add a single Schedule add the Schedule Manager
 java.lang.String getScheduleManagerName()
          Get the Schedule Manager Name
 boolean isHASingleton()
          determines whether or not the service is clustered singleton
protected  void removeSchedule(int pID)
          Remove a Schedule from the Schedule Manager
 void setHASingleton(boolean hasingleton)
          determines whether or not the service is clustered singleton
 void setScheduleManagerName(java.lang.String pSchedulerManagerName)
          Set the Schedule Manager Name
abstract  void startProviding()
          Add the Schedules to the Schedule Manager
protected  void startScheduleProviderService()
          When the Service is started it will register itself at the Schedule Manager which makes it necessary that the Schedule Manager is already running.
protected  void startService()
           Implementors of this method should not code the singleton logic here.
 void startSingleton()
          When HASingleton is enabled, this method will be invoked on the master node to start the singleton.
abstract  void stopProviding()
          Stops the Provider from providing and causing him to remove all Schedules
protected  void stopScheduleProviderService()
          When the Service is stopped it will unregister itself at the Schedule Manager.
protected  void stopService()
           Attention: Always call this method when you overwrite it in a subclass
 void stopSingleton()
          When HASingleton is enabled, this method will be invoked on the master node to stop the singleton.
 
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, 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.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

AbstractScheduleProvider

public AbstractScheduleProvider()
Default (no-args) Constructor

Method Detail

getScheduleManagerName

public java.lang.String getScheduleManagerName()
Get the Schedule Manager Name


setScheduleManagerName

public void setScheduleManagerName(java.lang.String pSchedulerManagerName)
                            throws MalformedObjectNameException (src) 
Set the Schedule Manager Name

Throws:
MalformedObjectNameException (src)

startProviding

public abstract void startProviding()
                             throws java.lang.Exception
Add the Schedules to the Schedule Manager

Throws:
java.lang.Exception

stopProviding

public abstract void stopProviding()
Stops the Provider from providing and causing him to remove all Schedules


addSchedule

protected int addSchedule(ObjectName (src)  pTarget,
                          java.lang.String pMethodName,
                          java.lang.String[] pMethodSignature,
                          java.util.Date pStart,
                          long pPeriod,
                          int pRepetitions)
                   throws JMException (src) 
Add a single Schedule add the Schedule Manager

Parameters:
pTarget - Object Name of the target MBean (receiver of the time notification)
pMethodName - Name of the Method to be called on the target
pMethodSignature - Signature of the Method
pStart - Date when the Schedule has to start
pPeriod - Time between two notifications
pRepetitions - Number of repetitions (-1 for unlimited)
Returns:
Identification of the Schedule which is used to remove it later
Throws:
JMException (src)

removeSchedule

protected void removeSchedule(int pID)
                       throws JMException (src) 
Remove a Schedule from the Schedule Manager

Parameters:
pID - Identification of the Schedule
Throws:
JMException (src)

startScheduleProviderService

protected void startScheduleProviderService()
                                     throws InstanceNotFoundException (src) ,
                                            MBeanException (src) ,
                                            ReflectionException (src) 
When the Service is started it will register itself at the Schedule Manager which makes it necessary that the Schedule Manager is already running. This allows the Schedule Manager to call startProviding() which is the point to for the Provider to add the Schedules on the Schedule Manager. ATTENTION: If you overwrite this method in a subclass you have to call this method (super.startService())

Throws:
InstanceNotFoundException (src)
MBeanException (src)
ReflectionException (src)

stopScheduleProviderService

protected void stopScheduleProviderService()
                                    throws InstanceNotFoundException (src) ,
                                           MBeanException (src) ,
                                           ReflectionException (src) 
When the Service is stopped it will unregister itself at the Schedule Manager. This allws the Schedule Manager to remove the Provider from its list and then call stopProviding() which is the point for the Provider to remove the Schedules from the Schedule Manager. ATTENTION: If you overwrite this method in a subclass you have to call this method (super.stopService())

Throws:
InstanceNotFoundException (src)
MBeanException (src)
ReflectionException (src)

startService

protected void startService()
                     throws java.lang.Exception
Description copied from class: HAServiceMBeanSupport (src)

Implementors of this method should not code the singleton logic here. The MBean lifecycle create/start/stop are separate from the singleton logic. Singleton logic should originate in becomeMaster().

Attention: Always call this method when you overwrite it in a subclass because it elects the master singleton node.

Overrides:
startService in class HAServiceMBeanSupport (src)
Throws:
java.lang.Exception

stopService

protected void stopService()
                    throws java.lang.Exception
Description copied from class: HAServiceMBeanSupport (src)

Attention: Always call this method when you overwrite it in a subclass

Overrides:
stopService in class HAServiceMBeanSupport (src)
Throws:
java.lang.Exception

startSingleton

public void startSingleton()
When HASingleton is enabled, this method will be invoked on the master node to start the singleton.

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

stopSingleton

public void stopSingleton()
When HASingleton is enabled, this method will be invoked on the master node to stop the singleton.

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

isHASingleton

public boolean isHASingleton()
determines whether or not the service is clustered singleton


setHASingleton

public void setHASingleton(boolean hasingleton)
determines whether or not the service is clustered singleton