Class QuartzScheduler
- All Implemented Interfaces:
Scheduler
Scheduler
interface, containing methods to schedule
Job
s, register JobListener
instances, etc.- Author:
- James House
-
Constructor Summary
ConstructorDescriptionQuartzScheduler
(QuartzSchedulerResources quartzSchedulerResources) Create aQuartzScheduler
with the given configuration properties. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addInternalSchedulerListener
(SchedulerListener schedulerListener) Register the given
with theSchedulerListener
Scheduler
's list of internal listeners.void
Add the givenJob
to the Scheduler - with no associatedTrigger
.void
Delete the identifiedJob
from the Scheduler - and any associatedTrigger
s.Return a list ofJobExecutionContext
objects that represent all currently executing Jobs in this Scheduler instance.Get a List containing all of the
s in theJobListener
Scheduler
's internal list.Get a List containing all of the internal
s registered with theSchedulerListener
Scheduler
.Get a list containing all of the
s in theTriggerListener
Scheduler
's internal list.getJobDetail
(String jobKey) Get the
for theJobDetail
Job
instance with the given name and group.Get the names of all the
in the matching groups.Job
sReturns the name of the thread group for Quartz's main threads.int
getTrigger
(String triggerKey) Get the
instance with the given name and group.Trigger
getTriggersOfJob
(String jobKey) void
boolean
Reports whether theScheduler
is paused.boolean
Reports whether theScheduler
has been shutdown.boolean
boolean
boolean
Whether the scheduler has been started.void
void
void
void
notifyJobStoreJobComplete
(OperableTrigger trigger, JobDetail detail, Trigger.CompletedExecutionInstruction instCode) void
notifyJobStoreJobVetoed
(OperableTrigger trigger, JobDetail detail, Trigger.CompletedExecutionInstruction instCode) void
void
notifySchedulerListenersFinalized
(Trigger trigger) void
void
notifyTriggerListenersComplete
(JobExecutionContext jec, Trigger.CompletedExecutionInstruction instCode) boolean
void
notifyTriggerListenersMisfired
(Trigger trigger) boolean
removeInternalSchedulerListener
(SchedulerListener schedulerListener) Remove the given
from theSchedulerListener
Scheduler
's list of internal listeners.rescheduleJob
(String triggerName, OperableTrigger newTrigger) Remove (delete) the
with 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
scheduleJob
(JobDetail jobDetail, OperableTrigger trigger) scheduleJob
(OperableTrigger trigger) void
setJobFactory
(JobFactory factory) Set theJobFactory
that will be responsible for producing instances ofJob
classes.void
setSignalOnSchedulingChange
(boolean signalOnSchedulingChange) void
shutdown()
Halts theQuartzScheduler
's firing of
, and cleans up all resources associated with the QuartzScheduler.Trigger
svoid
standby()
Temporarily halts theQuartzScheduler
's firing ofTrigger
svoid
start()
Starts theQuartzScheduler
's threads that fireTrigger
svoid
startDelayed
(int seconds) Calls {#start()} after the indicated number of seconds.void
triggerJob
(String jobKey, JobDataMap data) Trigger the identified
(execute it now) - with a non-volatile trigger.Job
void
unscheduleJob
(String triggerKey) Remove the indicated
from the scheduler.Trigger
-
Constructor Details
-
QuartzScheduler
Create aQuartzScheduler
with 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 fireTrigger
sAll
that have misfired will be passed to the appropriate TriggerListener(s).Trigger
s- Specified by:
start
in interfaceScheduler
- Throws:
SchedulerException
- ifshutdown()
has been called, or there is an error within theScheduler
.
-
startDelayed
Description copied from interface:Scheduler
Calls {#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:
startDelayed
in interfaceScheduler
- Throws:
SchedulerException
- ifshutdown()
has been called, or there is an error within theScheduler
.
-
standby
public void standby()Temporarily halts theQuartzScheduler
's firing ofTrigger
sThe scheduler is not destroyed, and can be re-started at any time.
-
isInStandbyMode
public boolean isInStandbyMode()Reports whether theScheduler
is paused.- Specified by:
isInStandbyMode
in 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.Trigger
sThe scheduler cannot be re-started.
-
isShutdown
public boolean isShutdown()Reports whether theScheduler
has been shutdown.- Specified by:
isShutdown
in interfaceScheduler
-
isShuttingDown
public boolean isShuttingDown() -
isStarted
public boolean isStarted()Description copied from interface:Scheduler
Whether the scheduler has been started.Note: This only reflects whether
has ever been called on this Scheduler, so it will returnScheduler.start()
true
even if theScheduler
is currently in standby mode or has been since shutdown. -
getCurrentlyExecutingJobs
Return a list ofJobExecutionContext
objects 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:
getCurrentlyExecutingJobs
in interfaceScheduler
-
scheduleJob
Add the
identified by the givenJob
JobDetail
Trigger
If 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:
scheduleJob
in interfaceScheduler
- Throws:
SchedulerException
- if the Job or Trigger cannot be added to the Scheduler, or there is an internal Scheduler error.
-
scheduleJob
- Specified by:
scheduleJob
in 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 givenJob
to the Scheduler - with no associatedTrigger
. TheJob
will be 'dormant' until it is scheduled with aTrigger
, orScheduler.triggerJob()
is called for it.- Specified by:
addJob
in 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, andreplace
isfalse
.
-
deleteJob
Description copied from interface:Scheduler
Delete the identifiedJob
from the Scheduler - and any associatedTrigger
s.- Specified by:
deleteJob
in interfaceScheduler
- Throws:
SchedulerException
- if there is an internal Scheduler error.
-
unscheduleJob
Description copied from interface:Scheduler
Remove the indicated
from the scheduler.Trigger
If the related job does not have any other triggers, and the job is not durable, then the job will also be deleted.
- Specified by:
unscheduleJob
in interfaceScheduler
- Throws:
SchedulerException
-
rescheduleJob
Description copied from interface:Scheduler
Remove (delete) the
with 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:
rescheduleJob
in interfaceScheduler
- Parameters:
triggerName
- identity of the trigger to replacenewTrigger
- The newTrigger
to be stored.- Returns:
null
if aTrigger
with 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:
triggerJob
in interfaceScheduler
- Parameters:
data
- the (possiblynull
) JobDataMap to be associated with the trigger that fires the job immediately.- Throws:
SchedulerException
-
getTriggersOfJob
- Specified by:
getTriggersOfJob
in interfaceScheduler
- Throws:
SchedulerException
-
getJobDetail
Get the
for theJobDetail
Job
instance with the given name and group.- Specified by:
getJobDetail
in interfaceScheduler
- Throws:
SchedulerException
-
getTrigger
Get the
instance with the given name and group.Trigger
- Specified by:
getTrigger
in interfaceScheduler
- Throws:
SchedulerException
-
getListenerManager
- Specified by:
getListenerManager
in interfaceScheduler
- Returns:
- the scheduler's
ListenerManager
- Throws:
SchedulerException
-
getInternalJobListeners
Get a List containing all of the
s in theJobListener
Scheduler
's internal list. -
getInternalTriggerListeners
Get a list containing all of the
s in theTriggerListener
Scheduler
's internal list. -
addInternalSchedulerListener
Register the given
with theSchedulerListener
Scheduler
's list of internal listeners. -
removeInternalSchedulerListener
Remove the given
from theSchedulerListener
Scheduler
'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 internal
s registered with theSchedulerListener
Scheduler
. -
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:Scheduler
Set theJobFactory
that will be responsible for producing instances ofJob
classes.JobFactories may be of use to those wishing to have their application produce
Job
instances via some special mechanism, such as to give the opportunity for dependency injection.- Specified by:
setJobFactory
in interfaceScheduler
- Throws:
SchedulerException
-
getJobFactory
-
getCascadingClassLoadHelper
- Specified by:
getCascadingClassLoadHelper
in interfaceScheduler
-
getJobKeys
Get the names of all the
in the matching groups.Job
s- Specified by:
getJobKeys
in interfaceScheduler
- Returns:
- Set of all keys matching
- Throws:
SchedulerException
- On error
-