public abstract class AbstractSchedulerService extends TurbineBaseService implements ScheduleService
| Modifier and Type | Class and Description |
|---|---|
protected class |
AbstractSchedulerService.MainLoop
Inner class.
|
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
enabled
Current status of the scheduler
|
protected static org.apache.commons.logging.Log |
log
Logging
|
protected AbstractSchedulerService.MainLoop |
mainLoop
The main loop for starting jobs.
|
protected JobQueue<JobEntry> |
scheduleQueue
The queue
|
protected Thread |
thread
The thread used to process commands.
|
configuration, name, serviceBrokerinitableBroker, isInitializedINTIALLY_ACTIVE, LOGGER_NAME, SERVICE_NAME| Constructor and Description |
|---|
AbstractSchedulerService()
Creates a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addJob(JobEntry je)
Add a new job to the queue.
|
protected void |
clearThread()
Set thread to null to indicate termination.
|
abstract JobEntry |
getJob(int oid)
Get a specific Job from Storage.
|
Thread |
getThread()
Return the thread being used to process commands, or null if there is no
such thread.
|
void |
init()
Initializes the SchedulerService.
|
boolean |
isEnabled()
Determines if the scheduler service is currently enabled.
|
List<JobEntry> |
listJobs()
List jobs in the queue.
|
protected abstract List<? extends JobEntry> |
loadJobs()
Load all jobs from configuration storage
|
abstract JobEntry |
newJob(int sec,
int min,
int hour,
int wd,
int day_mo,
String task)
Factory method for a new Job
Schedule a job to run on a certain point of time.
|
protected JobEntry |
nextJob()
Return the next Job to execute, or null if thread is interrupted.
|
abstract void |
removeJob(JobEntry je)
Remove a job from the queue.
|
void |
restart()
Start (or restart) a thread to process commands, or wake up an existing
thread if one is already running.
|
protected void |
setEnabled(boolean enabled)
Sets the enabled status of the scheduler
|
void |
shutdown()
Shutdowns the service.
|
void |
startScheduler()
Starts or restarts the scheduler if not already running.
|
void |
stopScheduler()
Stops the scheduler if it is currently running.
|
abstract void |
updateJob(JobEntry je)
Add or update a job.
|
init, initgetConfiguration, getName, getProperties, getServiceBroker, setName, setServiceBrokergetInit, getInitableBroker, setInit, setInitableBrokerclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetConfiguration, getName, getProperties, setName, setServiceBrokergetInit, init, setInitableBrokerprotected static org.apache.commons.logging.Log log
protected JobQueue<JobEntry> scheduleQueue
protected boolean enabled
protected AbstractSchedulerService.MainLoop mainLoop
public AbstractSchedulerService()
public void init() throws InitializationException
init in interface Initableinit in class TurbineBaseServiceInitializationException - Something went wrong in the init stageprotected abstract List<? extends JobEntry> loadJobs() throws TurbineException
TurbineExceptionpublic void shutdown()
shutdown in interface Initableshutdown in class TurbineBaseServicepublic abstract JobEntry newJob(int sec, int min, int hour, int wd, int day_mo, String task) throws TurbineException
ScheduleServicenewJob in interface ScheduleServicesec - Value for entry "seconds".min - Value for entry "minutes".hour - Value for entry "hours".wd - Value for entry "week days".day_mo - Value for entry "month days".task - Task to execute.TurbineException - could not create jobScheduleService.newJob(int, int, int, int, int, java.lang.String)public abstract JobEntry getJob(int oid) throws TurbineException
getJob in interface ScheduleServiceoid - The int id for the job.TurbineException - job could not be retrieved.public void addJob(JobEntry je) throws TurbineException
addJob in interface ScheduleServiceje - A JobEntry with the job to add.TurbineException - job could not be addedpublic abstract void removeJob(JobEntry je) throws TurbineException
removeJob in interface ScheduleServiceje - A JobEntry with the job to remove.TurbineException - job could not be removedpublic abstract void updateJob(JobEntry je) throws TurbineException
updateJob in interface ScheduleServiceje - A JobEntry with the job to modifyTurbineException - job could not be updatedpublic List<JobEntry> listJobs()
listJobs in interface ScheduleServiceprotected void setEnabled(boolean enabled)
enabled - public boolean isEnabled()
isEnabled in interface ScheduleServicepublic void startScheduler()
startScheduler in interface ScheduleServicepublic void stopScheduler()
stopScheduler in interface ScheduleServicepublic Thread getThread()
protected void clearThread()
public void restart()
protected JobEntry nextJob() throws TurbineException
TurbineException - a generic exception.Copyright © 2000-2015 The Apache Software Foundation. All Rights Reserved.