Class QuartzScheduler
- All Implemented Interfaces:
Scheduler
Scheduler interface, containing methods to schedule
Jobs, register JobListener
instances, etc.- Author:
- James House
-
Constructor Summary
ConstructorsConstructorDescriptionQuartzScheduler(QuartzSchedulerResources quartzSchedulerResources) Create aQuartzSchedulerwith the given configuration properties. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddInternalSchedulerListener(SchedulerListener schedulerListener) Register the givenwith theSchedulerListenerScheduler's list of internal listeners.voidAdd the givenJobto the Scheduler - with no associatedTrigger.voidDelete the identifiedJobfrom the Scheduler - and any associatedTriggers.Return a list ofJobExecutionContextobjects that represent all currently executing Jobs in this Scheduler instance.Get a List containing all of thes in theJobListenerScheduler's internal list.Get a List containing all of the internals registered with theSchedulerListenerScheduler.Get a list containing all of thes in theTriggerListenerScheduler's internal list.getJobDetail(String jobKey) Get thefor theJobDetailJobinstance with the given name and group.Get the names of all thein the matching groups.JobsReturns the name of the thread group for Quartz's main threads.intgetTrigger(String triggerKey) Get theinstance with the given name and group.TriggergetTriggersOfJob(String jobKey) voidbooleanReports whether theScheduleris paused.booleanReports whether theSchedulerhas been shutdown.booleanbooleanbooleanWhether the scheduler has been started.voidvoidvoidvoidnotifyJobStoreJobComplete(OperableTrigger trigger, JobDetail detail, Trigger.CompletedExecutionInstruction instCode) voidnotifyJobStoreJobVetoed(OperableTrigger trigger, JobDetail detail, Trigger.CompletedExecutionInstruction instCode) voidvoidnotifySchedulerListenersFinalized(Trigger trigger) voidvoidnotifyTriggerListenersComplete(JobExecutionContext jec, Trigger.CompletedExecutionInstruction instCode) booleanvoidnotifyTriggerListenersMisfired(Trigger trigger) booleanremoveInternalSchedulerListener(SchedulerListener schedulerListener) Remove the givenfrom theSchedulerListenerScheduler's list of internal listeners.rescheduleJob(String triggerName, OperableTrigger newTrigger) Remove (delete) thewith the given key, and store the new given one - which must be associated with the same job (the new trigger must have the job name specified) - however, the new trigger need not have the same name as the old trigger.OperableTriggerscheduleJob(JobDetail jobDetail, OperableTrigger trigger) scheduleJob(OperableTrigger trigger) voidsetJobFactory(JobFactory factory) Set theJobFactorythat will be responsible for producing instances ofJobclasses.voidsetSignalOnSchedulingChange(boolean signalOnSchedulingChange) voidshutdown()Halts theQuartzScheduler's firing of, and cleans up all resources associated with the QuartzScheduler.Triggersvoidstandby()Temporarily halts theQuartzScheduler's firing of.Triggersvoidstart()Starts theQuartzScheduler's threads that fire.TriggersvoidstartDelayed(int seconds) Calls {#start()} after the indicated number of seconds.voidtriggerJob(String jobKey, JobDataMap data) Trigger the identified(execute it now) - with a non-volatile trigger.JobvoidunscheduleJob(String triggerKey) Remove the indicatedfrom the scheduler.Trigger
-
Constructor Details
-
QuartzScheduler
Create aQuartzSchedulerwith the given configuration properties.- Throws:
SchedulerException- See Also:
-
-
Method Details
-
initialize
- Throws:
SchedulerException
-
getSchedulerSignaler
-
getSchedulerThreadGroup
Returns the name of the thread group for Quartz's main threads. -
isSignalOnSchedulingChange
public boolean isSignalOnSchedulingChange() -
setSignalOnSchedulingChange
public void setSignalOnSchedulingChange(boolean signalOnSchedulingChange) -
start
Starts theQuartzScheduler's threads that fire.TriggersAll
that have misfired will be passed to the appropriate TriggerListener(s).Triggers- Specified by:
startin interfaceScheduler- Throws:
SchedulerException- ifshutdown()has been called, or there is an error within theScheduler.
-
startDelayed
Description copied from interface:SchedulerCalls {#start()} after the indicated number of seconds. (This call does not block). This can be useful within applications that have initializers that create the scheduler immediately, before the resources needed by the executing jobs have been fully initialized.- Specified by:
startDelayedin interfaceScheduler- Throws:
SchedulerException- ifshutdown()has been called, or there is an error within theScheduler.
-
standby
public void standby()Temporarily halts theQuartzScheduler's firing of.TriggersThe scheduler is not destroyed, and can be re-started at any time.
-
isInStandbyMode
public boolean isInStandbyMode()Reports whether theScheduleris paused.- Specified by:
isInStandbyModein interfaceScheduler
-
getJobStoreClass
-
getThreadPoolClass
-
getThreadPoolSize
public int getThreadPoolSize() -
shutdown
public void shutdown()Halts theQuartzScheduler's firing of, and cleans up all resources associated with the QuartzScheduler.TriggersThe scheduler cannot be re-started.
-
isShutdown
public boolean isShutdown()Reports whether theSchedulerhas been shutdown.- Specified by:
isShutdownin interfaceScheduler
-
isShuttingDown
public boolean isShuttingDown() -
isStarted
public boolean isStarted()Description copied from interface:SchedulerWhether the scheduler has been started.Note: This only reflects whether
has ever been called on this Scheduler, so it will returnScheduler.start()trueeven if theScheduleris currently in standby mode or has been since shutdown. -
getCurrentlyExecutingJobs
Return a list ofJobExecutionContextobjects that represent all currently executing Jobs in this Scheduler instance.This method is not cluster aware. That is, it will only return Jobs currently executing in this Scheduler instance, not across the entire cluster.
Note that the list returned is an 'instantaneous' snap-shot, and that as soon as it's returned, the true list of executing jobs may be different.
- Specified by:
getCurrentlyExecutingJobsin interfaceScheduler
-
scheduleJob
Add theidentified by the givenJobto the Scheduler, and associate the givenJobDetailwith it.TriggerIf the given Trigger does not reference any
Job, then it will be set to reference the Job passed with it into this method.- Specified by:
scheduleJobin interfaceScheduler- Throws:
SchedulerException- if the Job or Trigger cannot be added to the Scheduler, or there is an internal Scheduler error.
-
scheduleJob
- Specified by:
scheduleJobin interfaceScheduler- Throws:
SchedulerException- if the indicated Job does not exist, or the Trigger cannot be added to the Scheduler, or there is an internal Scheduler error.
-
addJob
Add the givenJobto the Scheduler - with no associatedTrigger. TheJobwill be 'dormant' until it is scheduled with aTrigger, orScheduler.triggerJob()is called for it.- Specified by:
addJobin interfaceScheduler- Throws:
SchedulerException- if there is an internal Scheduler error, or if the Job is not durable, or a Job with the same name already exists, andreplaceisfalse.
-
deleteJob
Description copied from interface:SchedulerDelete the identifiedJobfrom the Scheduler - and any associatedTriggers.- Specified by:
deleteJobin interfaceScheduler- Throws:
SchedulerException- if there is an internal Scheduler error.
-
unscheduleJob
Description copied from interface:SchedulerRemove the indicatedfrom the scheduler.TriggerIf the related job does not have any other triggers, and the job is not durable, then the job will also be deleted.
- Specified by:
unscheduleJobin interfaceScheduler- Throws:
SchedulerException
-
rescheduleJob
Description copied from interface:SchedulerRemove (delete) thewith the given key, and store the new given one - which must be associated with the same job (the new trigger must have the job name specified) - however, the new trigger need not have the same name as the old trigger.OperableTrigger- Specified by:
rescheduleJobin interfaceScheduler- Parameters:
triggerName- identity of the trigger to replacenewTrigger- The newTriggerto be stored.- Returns:
nullif aTriggerwith the given name invalid input: '&' group was not found and removed from the store, otherwise the first fire time of the newly scheduled trigger.- Throws:
SchedulerException
-
triggerJob
Trigger the identified(execute it now) - with a non-volatile trigger.Job- Specified by:
triggerJobin interfaceScheduler- Parameters:
data- the (possiblynull) JobDataMap to be associated with the trigger that fires the job immediately.- Throws:
SchedulerException
-
getTriggersOfJob
- Specified by:
getTriggersOfJobin interfaceScheduler- Throws:
SchedulerException
-
getJobDetail
Get thefor theJobDetailJobinstance with the given name and group.- Specified by:
getJobDetailin interfaceScheduler- Throws:
SchedulerException
-
getTrigger
Get theinstance with the given name and group.Trigger- Specified by:
getTriggerin interfaceScheduler- Throws:
SchedulerException
-
getListenerManager
- Specified by:
getListenerManagerin interfaceScheduler- Returns:
- the scheduler's
ListenerManager - Throws:
SchedulerException
-
getInternalJobListeners
Get a List containing all of thes in theJobListenerScheduler's internal list. -
getInternalTriggerListeners
Get a list containing all of thes in theTriggerListenerScheduler's internal list. -
addInternalSchedulerListener
Register the givenwith theSchedulerListenerScheduler's list of internal listeners. -
removeInternalSchedulerListener
Remove the givenfrom theSchedulerListenerScheduler's list of internal listeners.- Returns:
- true if the identified listener was found in the list, and removed.
-
getInternalSchedulerListeners
Get a List containing all of the internals registered with theSchedulerListenerScheduler. -
notifyJobStoreJobComplete
public void notifyJobStoreJobComplete(OperableTrigger trigger, JobDetail detail, Trigger.CompletedExecutionInstruction instCode) throws JobPersistenceException - Throws:
JobPersistenceException
-
notifyJobStoreJobVetoed
public void notifyJobStoreJobVetoed(OperableTrigger trigger, JobDetail detail, Trigger.CompletedExecutionInstruction instCode) throws JobPersistenceException - Throws:
JobPersistenceException
-
notifyTriggerListenersFired
- Throws:
SchedulerException
-
notifyTriggerListenersMisfired
- Throws:
SchedulerException
-
notifyTriggerListenersComplete
public void notifyTriggerListenersComplete(JobExecutionContext jec, Trigger.CompletedExecutionInstruction instCode) throws SchedulerException - Throws:
SchedulerException
-
notifyJobListenersToBeExecuted
- Throws:
SchedulerException
-
notifyJobListenersWasVetoed
- Throws:
SchedulerException
-
notifyJobListenersWasExecuted
public void notifyJobListenersWasExecuted(JobExecutionContext jec, JobExecutionException je) throws SchedulerException - Throws:
SchedulerException
-
notifySchedulerListenersError
-
notifySchedulerListenersFinalized
-
notifySchedulerListenersJobDeleted
-
setJobFactory
Description copied from interface:SchedulerSet theJobFactorythat will be responsible for producing instances ofJobclasses.JobFactories may be of use to those wishing to have their application produce
Jobinstances via some special mechanism, such as to give the opportunity for dependency injection.- Specified by:
setJobFactoryin interfaceScheduler- Throws:
SchedulerException
-
getJobFactory
-
getCascadingClassLoadHelper
- Specified by:
getCascadingClassLoadHelperin interfaceScheduler
-
getJobKeys
Get the names of all thein the matching groups.Jobs- Specified by:
getJobKeysin interfaceScheduler- Returns:
- Set of all keys matching
- Throws:
SchedulerException- On error
-