Klasse AbstractSchedulerService
java.lang.Object
org.apache.turbine.services.BaseInitable
org.apache.turbine.services.BaseService
org.apache.turbine.services.TurbineBaseService
org.apache.turbine.services.schedule.AbstractSchedulerService
- Alle implementierten Schnittstellen:
Initable,ScheduleService,Service
- Bekannte direkte Unterklassen:
TorqueSchedulerService,TurbineNonPersistentSchedulerService
public abstract class AbstractSchedulerService
extends TurbineBaseService
implements ScheduleService
Service for a cron like scheduler.
- Version:
- $Id: TorqueSchedulerService.java 534527 2007-05-02 16:10:59Z tv $
- Autor:
- Dave Bryson, Quinton McCombs
-
Feldübersicht
FelderModifizierer und TypFeldBeschreibungprotected ThreadThe housekeeping thread.protected static final org.apache.logging.log4j.LoggerLoggingThe queueprotected ExecutorServiceThe thread pool used to process jobs.Von Klasse geerbte Felder org.apache.turbine.services.BaseService
configuration, name, serviceBrokerVon Klasse geerbte Felder org.apache.turbine.services.BaseInitable
initableBroker, isInitializedVon Schnittstelle geerbte Felder org.apache.turbine.services.schedule.ScheduleService
INTIALLY_ACTIVE, LOGGER_NAME, SERVICE_NAMEVon Schnittstelle geerbte Felder org.apache.turbine.services.Service
SERVICE_NAME -
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungvoidAdd a new job to the queue.protected voidSet thread to null to indicate termination.abstract JobEntrygetJob(int oid) Get a specific Job from Storage.Return the thread being used to process commands, or null if there is no such thread.voidinit()Initializes the SchedulerService.booleanDetermines if the scheduler service is currently enabled.listJobs()List jobs in the queue.loadJobs()Load all jobs from configuration storageabstract JobEntryFactory method for a new Job Schedule a job to run on a certain point of time.
Example 1: Run the DefaultScheduledJob at 8:00am every 15th of the month -
JobEntry je = newJob(0,0,8,-1,15,"DefaultScheduledJob");
Example 2: Run the DefaultScheduledJob at 8:00am every day -
JobEntry je = newJob(0,0,8,-1,-1,"DefaultScheduledJob");
Example 3: Run the DefaultScheduledJob every 2 hours. -
JobEntry je = newJob(0,120,-1,-1,-1,"DefaultScheduledJob");
Example 4: Run the DefaultScheduledJob every 30 seconds. -
JobEntry je = newJob(30,-1,-1,-1,-1,"DefaultScheduledJob");protected JobEntrynextJob()Return the next Job to execute, or null if thread is interrupted.abstract voidRemove a job from the queue.voidrestart()Start (or restart) a thread to process commands, or wake up an existing thread if one is already running.protected voidsetEnabled(boolean enabled) Sets the enabled status of the schedulervoidshutdown()Shutdowns the service.voidStarts or restarts the scheduler if not already running.voidStops the scheduler if it is currently running.abstract voidAdd or update a job.Von Klasse geerbte Methoden org.apache.turbine.services.TurbineBaseService
init, initVon Klasse geerbte Methoden org.apache.turbine.services.BaseService
getConfiguration, getName, getProperties, getServiceBroker, setName, setServiceBrokerVon Klasse geerbte Methoden org.apache.turbine.services.BaseInitable
getInit, getInitableBroker, setInit, setInitableBrokerVon Klasse geerbte Methoden java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitVon Schnittstelle geerbte Methoden org.apache.turbine.services.Initable
getInit, init, setInitableBrokerVon Schnittstelle geerbte Methoden org.apache.turbine.services.Service
getConfiguration, getName, getProperties, setName, setServiceBroker
-
Felddetails
-
log
Logging -
scheduleQueue
The queue -
houseKeepingThread
The housekeeping thread. -
threadPool
The thread pool used to process jobs.
-
-
Konstruktordetails
-
AbstractSchedulerService
public AbstractSchedulerService()
-
-
Methodendetails
-
init
Initializes the SchedulerService.- Angegeben von:
initin SchnittstelleInitable- Setzt außer Kraft:
initin KlasseTurbineBaseService- Löst aus:
InitializationException- Something went wrong in the init stage
-
loadJobs
Load all jobs from configuration storage- Gibt zurück:
- the list of pre-configured jobs
- Löst aus:
TurbineException- if jobs could not be loaded
-
shutdown
Shutdowns the service. This methods interrupts the housekeeping thread.- Angegeben von:
shutdownin SchnittstelleInitable- Setzt außer Kraft:
shutdownin KlasseTurbineBaseService
-
newJob
public abstract JobEntry newJob(int sec, int min, int hour, int wd, int day_mo, String task) throws TurbineException Beschreibung aus Schnittstelle kopiert:ScheduleServiceFactory method for a new Job Schedule a job to run on a certain point of time.
Example 1: Run the DefaultScheduledJob at 8:00am every 15th of the month -
JobEntry je = newJob(0,0,8,-1,15,"DefaultScheduledJob");
Example 2: Run the DefaultScheduledJob at 8:00am every day -
JobEntry je = newJob(0,0,8,-1,-1,"DefaultScheduledJob");
Example 3: Run the DefaultScheduledJob every 2 hours. -
JobEntry je = newJob(0,120,-1,-1,-1,"DefaultScheduledJob");
Example 4: Run the DefaultScheduledJob every 30 seconds. -
JobEntry je = newJob(30,-1,-1,-1,-1,"DefaultScheduledJob");- Angegeben von:
newJobin SchnittstelleScheduleService- Parameter:
sec- 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.- Gibt zurück:
- A JobEntry.
- Löst aus:
TurbineException- could not create job- Siehe auch:
-
getJob
Get a specific Job from Storage.- Angegeben von:
getJobin SchnittstelleScheduleService- Parameter:
oid- The int id for the job.- Gibt zurück:
- A JobEntry.
- Löst aus:
TurbineException- job could not be retrieved.
-
addJob
Add a new job to the queue.- Angegeben von:
addJobin SchnittstelleScheduleService- Parameter:
je- A JobEntry with the job to add.- Löst aus:
TurbineException- job could not be added
-
removeJob
Remove a job from the queue.- Angegeben von:
removeJobin SchnittstelleScheduleService- Parameter:
je- A JobEntry with the job to remove.- Löst aus:
TurbineException- job could not be removed
-
updateJob
Add or update a job.- Angegeben von:
updateJobin SchnittstelleScheduleService- Parameter:
je- A JobEntry with the job to modify- Löst aus:
TurbineException- job could not be updated
-
listJobs
List jobs in the queue. This is used by the scheduler UI.- Angegeben von:
listJobsin SchnittstelleScheduleService- Gibt zurück:
- A List of jobs.
-
setEnabled
Sets the enabled status of the scheduler- Parameter:
enabled- true to enable the scheduler
-
isEnabled
Determines if the scheduler service is currently enabled.- Angegeben von:
isEnabledin SchnittstelleScheduleService- Gibt zurück:
- Status of the scheduler service.
-
startScheduler
Starts or restarts the scheduler if not already running.- Angegeben von:
startSchedulerin SchnittstelleScheduleService
-
stopScheduler
Stops the scheduler if it is currently running.- Angegeben von:
stopSchedulerin SchnittstelleScheduleService
-
getThread
Return the thread being used to process commands, or null if there is no such thread. You can use this to invoke any special methods on the thread, for example, to interrupt it.- Gibt zurück:
- A Thread.
-
clearThread
Set thread to null to indicate termination. -
restart
Start (or restart) a thread to process commands, or wake up an existing thread if one is already running. This method can be invoked if the background thread crashed due to an unrecoverable exception in an executed command. -
nextJob
Return the next Job to execute, or null if thread is interrupted.- Gibt zurück:
- A JobEntry.
- Löst aus:
TurbineException- a generic exception.
-