atg.service.scheduler
Class SchedulableService

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.service.scheduler.SchedulableService
All Implemented Interfaces:
NameContextBindingListener, NameContextElement, NameResolver, AdminableService, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, Schedulable, java.util.EventListener
Direct Known Subclasses:
IndexingPeriodicService, LDAPRepositoryAccountManager.SecurityCache, SingletonSchedulableService

public abstract class SchedulableService
extends GenericService
implements Schedulable

A convenience base class for generic services that are schedulable. It is not difficult to implement Schedulable directly, but it does involve a fair amount of code. This base class is a simple implementation of Schedulable that is suitable for most services that want to implement Schedulable.

Subclasses need only implement performScheduledTask() to be schedulable. It is recommended that the jobName and jobDescription properties be configured on this component. Subclasses can also provide default values for these in their doStartService() methods if desired. Nota Bene: the schedule related properties are only consulted when startScheduledJob() is called. If any of these properties change, you can call stopScheduledJob() and startScheduledJob() to pick up the changes.


Field Summary
static java.lang.String CLASS_VERSION
          Class version string
protected  int mJobId
          the jobId of our scheduled task
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging
DEFAULT_LOG_TRACE_STATUS
 
Fields inherited from interface atg.nucleus.logging.ApplicationLogging
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
 
Constructor Summary
SchedulableService()
           
 
Method Summary
 void doStartService()
          The default implementation is to just start our scheduled job.
 void doStopService()
          The default implementation is to just stop our scheduled job.
 java.lang.String getJobDescription()
          Get property jobDescription
 int getJobId()
          Get the job ID.
 java.lang.String getJobName()
          Get property jobName
 Schedule getSchedule()
          Get property schedule
 Scheduler getScheduler()
          Get property scheduler
 int getThreadMethod()
          Get property threadMethod
 boolean isTransactional()
          Returns property Transactional
abstract  void performScheduledTask(Scheduler pScheduler, ScheduledJob pJob)
          Called by the scheduler when it is time for this service to perform its function.
 void setJobDescription(java.lang.String pJobDescription)
          Set property jobDescription
 void setJobName(java.lang.String pJobName)
          Set property jobName
 void setSchedule(Schedule pSchedule)
          Set property schedule
 void setScheduler(Scheduler pScheduler)
          Set property scheduler
 void setThreadMethod(int pThreadMethod)
          Set property threadMethod
 void setTransactional(boolean pTransactional)
          Sets property Transactional
protected  void startScheduledJob()
          If we have a scheduler and a schedule and we are not already running start our scheduled job.
protected  void stopScheduledJob()
          If we have a job running, stop it.
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, getAbsoluteName, getAdminServlet, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Class version string


mJobId

protected int mJobId
the jobId of our scheduled task

Constructor Detail

SchedulableService

public SchedulableService()
Method Detail

setScheduler

public void setScheduler(Scheduler pScheduler)
Set property scheduler

Parameters:
pScheduler - new value to set

getScheduler

public Scheduler getScheduler()
Get property scheduler

Returns:
scheduler

setSchedule

public void setSchedule(Schedule pSchedule)
Set property schedule

Parameters:
pSchedule - new value to set

getSchedule

public Schedule getSchedule()
Get property schedule

Returns:
schedule

setJobName

public void setJobName(java.lang.String pJobName)
Set property jobName

Parameters:
pJobName - new value to set

getJobName

public java.lang.String getJobName()
Get property jobName

Returns:
jobName

setJobDescription

public void setJobDescription(java.lang.String pJobDescription)
Set property jobDescription

Parameters:
pJobDescription - new value to set

getJobDescription

public java.lang.String getJobDescription()
Get property jobDescription

Returns:
jobDescription

setThreadMethod

public void setThreadMethod(int pThreadMethod)
Set property threadMethod

Parameters:
pThreadMethod - new value to set

getThreadMethod

public int getThreadMethod()
Get property threadMethod

Returns:
threadMethod

setTransactional

public void setTransactional(boolean pTransactional)
Sets property Transactional


isTransactional

public boolean isTransactional()
Returns property Transactional


doStartService

public void doStartService()
                    throws ServiceException
The default implementation is to just start our scheduled job. Subclasses should override this to perform any extra initialization they may require.

Overrides:
doStartService in class GenericService
Throws:
ServiceException - if an error occurred during the operation

doStopService

public void doStopService()
                   throws ServiceException
The default implementation is to just stop our scheduled job. Subclasses should override this to perform any extra cleanup they may require.

Overrides:
doStopService in class GenericService
Throws:
ServiceException - if an error occurred during the operation

startScheduledJob

protected void startScheduledJob()
If we have a scheduler and a schedule and we are not already running start our scheduled job. Subclasses should use this method to start the scheduled job.


stopScheduledJob

protected void stopScheduledJob()
If we have a job running, stop it. Subclasses should use this method to stop the scheduled job.


performScheduledTask

public abstract void performScheduledTask(Scheduler pScheduler,
                                          ScheduledJob pJob)
Called by the scheduler when it is time for this service to perform its function.

Specified by:
performScheduledTask in interface Schedulable
Parameters:
pScheduler - the scheduler managing this job
pJob - the scheduled job associated with this service

getJobId

public int getJobId()
Get the job ID. Returns -1 if there is no job ID.