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 Thread
The housekeeping thread.protected static final org.apache.logging.log4j.Logger
LoggingThe queueprotected ExecutorService
The thread pool used to process jobs.Von Klasse geerbte Felder org.apache.turbine.services.BaseService
configuration, name, serviceBroker
Von Klasse geerbte Felder org.apache.turbine.services.BaseInitable
initableBroker, isInitialized
Von Schnittstelle geerbte Felder org.apache.turbine.services.schedule.ScheduleService
INTIALLY_ACTIVE, LOGGER_NAME, SERVICE_NAME
Von Schnittstelle geerbte Felder org.apache.turbine.services.Service
SERVICE_NAME
-
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungvoid
Add a new job to the queue.protected void
Set thread to null to indicate termination.abstract JobEntry
getJob
(int oid) Get a specific Job from Storage.Return the thread being used to process commands, or null if there is no such thread.void
init()
Initializes the SchedulerService.boolean
Determines if the scheduler service is currently enabled.listJobs()
List jobs in the queue.loadJobs()
Load all jobs from configuration storageabstract JobEntry
Factory 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 JobEntry
nextJob()
Return the next Job to execute, or null if thread is interrupted.abstract void
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 schedulervoid
shutdown()
Shutdowns the service.void
Starts or restarts the scheduler if not already running.void
Stops the scheduler if it is currently running.abstract void
Add or update a job.Von Klasse geerbte Methoden org.apache.turbine.services.TurbineBaseService
init, init
Von Klasse geerbte Methoden org.apache.turbine.services.BaseService
getConfiguration, getName, getProperties, getServiceBroker, setName, setServiceBroker
Von Klasse geerbte Methoden org.apache.turbine.services.BaseInitable
getInit, getInitableBroker, setInit, setInitableBroker
Von Klasse geerbte Methoden java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Von Schnittstelle geerbte Methoden org.apache.turbine.services.Initable
getInit, init, setInitableBroker
Von 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:
init
in SchnittstelleInitable
- Setzt außer Kraft:
init
in 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:
shutdown
in SchnittstelleInitable
- Setzt außer Kraft:
shutdown
in 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:ScheduleService
Factory 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:
newJob
in 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:
getJob
in 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:
addJob
in 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:
removeJob
in 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:
updateJob
in 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:
listJobs
in 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:
isEnabled
in SchnittstelleScheduleService
- Gibt zurück:
- Status of the scheduler service.
-
startScheduler
Starts or restarts the scheduler if not already running.- Angegeben von:
startScheduler
in SchnittstelleScheduleService
-
stopScheduler
Stops the scheduler if it is currently running.- Angegeben von:
stopScheduler
in 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.
-