public abstract class SchedulableService extends GenericService implements 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.
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
CLASS_VERSION
Class version string
|
protected int |
mJobId
the jobId of our scheduled task
|
SERVICE_INFO_KEYDEFAULT_LOG_TRACE_STATUSDEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS| Constructor and Description |
|---|
SchedulableService() |
| Modifier and Type | Method and Description |
|---|---|
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 |
java.lang.String |
getThreadMethodString()
Return the thread method as a string.
|
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 |
setThreadMethodString(java.lang.String pThreadMethod)
Set the thread method from a string.
|
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.
|
addLogListener, createAdminServlet, getAbsoluteName, getAdminServlet, getAdminServletOutputStreamEncoding, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isAdminServletUseServletOutputStream, 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, setAdminServletOutputStreamEncoding, setAdminServletUseServletOutputStream, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopServicevlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarningpublic static java.lang.String CLASS_VERSION
protected int mJobId
public void setScheduler(Scheduler pScheduler)
schedulerpScheduler - new value to setpublic Scheduler getScheduler()
schedulerschedulerpublic void setSchedule(Schedule pSchedule)
schedulepSchedule - new value to setpublic Schedule getSchedule()
scheduleschedulepublic void setJobName(java.lang.String pJobName)
jobNamepJobName - new value to setpublic java.lang.String getJobName()
jobNamejobNamepublic void setJobDescription(java.lang.String pJobDescription)
jobDescriptionpJobDescription - new value to setpublic java.lang.String getJobDescription()
jobDescriptionjobDescriptionpublic void setThreadMethod(int pThreadMethod)
threadMethodpThreadMethod - new value to setpublic int getThreadMethod()
threadMethodthreadMethodpublic java.lang.String getThreadMethodString()
public void setThreadMethodString(java.lang.String pThreadMethod)
public void setTransactional(boolean pTransactional)
public boolean isTransactional()
public void doStartService()
throws ServiceException
doStartService in class GenericServiceServiceException - if an error occurred during the operationpublic void doStopService()
throws ServiceException
doStopService in class GenericServiceServiceException - if an error occurred during the operationprotected void startScheduledJob()
protected void stopScheduledJob()
public abstract void performScheduledTask(Scheduler pScheduler, ScheduledJob pJob)
performScheduledTask in interface SchedulablepScheduler - the scheduler managing this jobpJob - the scheduled job associated with this servicepublic int getJobId()