Home » quartz-1.6.0 » org » quartz » [javadoc | source]
org.quartz
public interface: Scheduler [javadoc | source]

All Known Implementing Classes:
    RemoteMBeanScheduler, JBoss4RMIRemoteMBeanScheduler, StdScheduler, RemoteScheduler

This is the main interface of a Quartz Scheduler.

A Scheduler maintains a registery of org.quartz.JobDetail s and Trigger s. Once registered, the Scheduler is responible for executing Job s when their associated Trigger s fire (when their scheduled time arrives).

Scheduler instances are produced by a SchedulerFactory . A scheduler that has already been created/initialized can be found and used through the same factory that produced it. After a Scheduler has been created, it is in "stand-by" mode, and must have its start() method called before it will fire any Jobs.

Job s are to be created by the 'client program', by defining a class that implements the org.quartz.Job interface. JobDetail objects are then created (also by the client) to define a individual instances of the Job. JobDetail instances can then be registered with the Scheduler via the scheduleJob(JobDetail, Trigger) or addJob(JobDetail, boolean) method.

Trigger s can then be defined to fire individual Job instances based on given schedules. SimpleTrigger s are most useful for one-time firings, or firing at an exact moment in time, with N repeats with a given delay between them. CronTrigger s allow scheduling based on time of day, day of week, day of month, and month of year.

Job s and Trigger s have a name and group associated with them, which should uniquely identify them within a single Scheduler . The 'group' feature may be useful for creating logical groupings or categorizations of Jobs s and Triggerss. If you don't have need for assigning a group to a given Jobs of Triggers, then you can use the DEFAULT_GROUP constant defined on this interface.

Stored Job s can also be 'manually' triggered through the use of the triggerJob(String jobName, String jobGroup) function.

Client programs may also be interested in the 'listener' interfaces that are available from Quartz. The JobListener interface provides notifications of Job executions. The TriggerListener interface provides notifications of Trigger firings. The SchedulerListener interface provides notifications of Scheduler events and errors.

The setup/configuration of a Scheduler instance is very customizable. Please consult the documentation distributed with Quartz.

Field Summary
 String DEFAULT_GROUP   

A (possibly) usefull constant that can be used for specifying the group that Job and Trigger instances belong to.

 
 String DEFAULT_MANUAL_TRIGGERS   

A constant Trigger group name used internally by the scheduler - clients should not use the value of this constant ("MANUAL_TRIGGER") for the name of a Trigger's group.

 
 String DEFAULT_RECOVERY_GROUP   

A constant Trigger group name used internally by the scheduler - clients should not use the value of this constant ("RECOVERING_JOBS") for the name of a Trigger's group.

    Also see:
    org.quartz.JobDetail#requestsRecovery()
 
 String DEFAULT_FAIL_OVER_GROUP   

A constant Trigger group name used internally by the scheduler - clients should not use the value of this constant ("FAILED_OVER_JOBS") for the name of a Trigger's group.

    Also see:
    org.quartz.JobDetail#requestsRecovery()
 
 String FAILED_JOB_ORIGINAL_TRIGGER_NAME    A constant JobDataMap key that can be used to retrieve the name of the original Trigger from a recovery trigger's data map in the case of a job recovering after a failed scheduler instance.
    Also see:
    org.quartz.JobDetail#requestsRecovery()
 
 String FAILED_JOB_ORIGINAL_TRIGGER_GROUP    A constant JobDataMap key that can be used to retrieve the group of the original Trigger from a recovery trigger's data map in the case of a job recovering after a failed scheduler instance.
    Also see:
    org.quartz.JobDetail#requestsRecovery()
 
 String FAILED_JOB_ORIGINAL_TRIGGER_FIRETIME_IN_MILLISECONDS    A constant JobDataMap key that can be used to retrieve the scheduled fire time of the original Trigger from a recovery trigger's data map in the case of a job recovering after a failed scheduler instance.
    Also see:
    org.quartz.JobDetail#requestsRecovery()
 
Method from org.quartz.Scheduler Summary:
addCalendar,   addGlobalJobListener,   addGlobalTriggerListener,   addJob,   addJobListener,   addSchedulerListener,   addTriggerListener,   deleteCalendar,   deleteJob,   getCalendar,   getCalendarNames,   getContext,   getCurrentlyExecutingJobs,   getGlobalJobListener,   getGlobalJobListeners,   getGlobalTriggerListener,   getGlobalTriggerListeners,   getJobDetail,   getJobGroupNames,   getJobListener,   getJobListenerNames,   getJobNames,   getMetaData,   getPausedTriggerGroups,   getSchedulerInstanceId,   getSchedulerListeners,   getSchedulerName,   getTrigger,   getTriggerGroupNames,   getTriggerListener,   getTriggerListenerNames,   getTriggerNames,   getTriggerState,   getTriggersOfJob,   interrupt,   isInStandbyMode,   isPaused,   isShutdown,   isStarted,   pause,   pauseAll,   pauseJob,   pauseJobGroup,   pauseTrigger,   pauseTriggerGroup,   removeGlobalJobListener,   removeGlobalJobListener,   removeGlobalTriggerListener,   removeGlobalTriggerListener,   removeJobListener,   removeSchedulerListener,   removeTriggerListener,   rescheduleJob,   resumeAll,   resumeJob,   resumeJobGroup,   resumeTrigger,   resumeTriggerGroup,   scheduleJob,   scheduleJob,   setJobFactory,   shutdown,   shutdown,   standby,   start,   triggerJob,   triggerJob,   triggerJobWithVolatileTrigger,   triggerJobWithVolatileTrigger,   unscheduleJob
Method from org.quartz.Scheduler Detail:
 public  void addCalendar(String calName,
    Calendar calendar,
    boolean replace,
    boolean updateTriggers) throws SchedulerException

    Add (register) the given Calendar to the Scheduler.

 public  void addGlobalJobListener(JobListener jobListener) throws SchedulerException

    Add the given JobListener to the Scheduler's global list.

    Listeners in the 'global' list receive notification of execution events for ALL org.quartz.JobDetail s.

 public  void addGlobalTriggerListener(TriggerListener triggerListener) throws SchedulerException

    Add the given TriggerListener to the Scheduler's global list.

    Listeners in the 'global' list receive notification of execution events for ALL Trigger s.

 public  void addJob(JobDetail jobDetail,
    boolean replace) throws SchedulerException

    Add the given Job to the Scheduler - with no associated Trigger. The Job will be 'dormant' until it is scheduled with a Trigger, or Scheduler.triggerJob() is called for it.

    The Job must by definition be 'durable', if it is not, SchedulerException will be thrown.

 public  void addJobListener(JobListener jobListener) throws SchedulerException

    Add the given JobListener to the Scheduler's list, of registered JobListeners.

 public  void addSchedulerListener(SchedulerListener schedulerListener) throws SchedulerException
 public  void addTriggerListener(TriggerListener triggerListener) throws SchedulerException

    Add the given TriggerListener to the Scheduler's list, of registered TriggerListeners.

 public boolean deleteCalendar(String calName) throws SchedulerException

    Delete the identified Calendar from the Scheduler.

 public boolean deleteJob(String jobName,
    String groupName) throws SchedulerException

    Delete the identified Job from the Scheduler - and any associated Triggers.

 public Calendar getCalendar(String calName) throws SchedulerException

    Get the Calendar instance with the given name.

 public String[] getCalendarNames() throws SchedulerException

    Get the names of all registered Calendar s.

 public SchedulerContext getContext() throws SchedulerException

    Returns the SchedulerContext of the Scheduler.

 public List getCurrentlyExecutingJobs() throws SchedulerException

    Return a list of JobExecutionContext 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. Also please read the doc associated with JobExecutionContext- especially if you're using RMI.

 public JobListener getGlobalJobListener(String name) throws SchedulerException
 public List getGlobalJobListeners() throws SchedulerException

    Get a List containing all of the JobListener s in the Scheduler'sglobal list.

 public TriggerListener getGlobalTriggerListener(String name) throws SchedulerException
 public List getGlobalTriggerListeners() throws SchedulerException

    Get a List containing all of the TriggerListener s in the Scheduler'sglobal list.

 public JobDetail getJobDetail(String jobName,
    String jobGroup) throws SchedulerException

    Get the JobDetail for the Job instance with the given name and group.

 public String[] getJobGroupNames() throws SchedulerException
 public JobListener getJobListener(String name) throws SchedulerException

    Get the non-globalJobListener that has the given name.

 public Set getJobListenerNames() throws SchedulerException

    Get a Set containing the names of all the non-globalJobListener s registered with the Scheduler.

 public String[] getJobNames(String groupName) throws SchedulerException
 public SchedulerMetaData getMetaData() throws SchedulerException

    Get a SchedulerMetaData object describiing the settings and capabilities of the scheduler instance.

    Note that the data returned is an 'instantaneous' snap-shot, and that as soon as it's returned, the meta data values may be different.

 public Set getPausedTriggerGroups() throws SchedulerException

    Get the names of all Trigger groups that are paused.

 public String getSchedulerInstanceId() throws SchedulerException

    Returns the instance Id of the Scheduler.

 public List getSchedulerListeners() throws SchedulerException

    Get a List containing all of the SchedulerListener s registered with the Scheduler.

 public String getSchedulerName() throws SchedulerException

    Returns the name of the Scheduler.

 public Trigger getTrigger(String triggerName,
    String triggerGroup) throws SchedulerException

    Get the Trigger instance with the given name and group.

 public String[] getTriggerGroupNames() throws SchedulerException

    Get the names of all known Trigger groups.

 public TriggerListener getTriggerListener(String name) throws SchedulerException
 public Set getTriggerListenerNames() throws SchedulerException

    Get a Set containing the names of all the non-globalTriggerListener s registered with the Scheduler.

 public String[] getTriggerNames(String groupName) throws SchedulerException

    Get the names of all the Trigger s in the given group.

 public int getTriggerState(String triggerName,
    String triggerGroup) throws SchedulerException

    Get the current state of the identified Trigger .

 public Trigger[] getTriggersOfJob(String jobName,
    String groupName) throws SchedulerException
 public boolean interrupt(String jobName,
    String groupName) throws UnableToInterruptJobException

    Request the interruption, within this Scheduler instance, of all currently executing instances of the identified Job, which must be an implementor of the InterruptableJob interface.

    If more than one instance of the identified job is currently executing, the InterruptableJob#interrupt() method will be called on each instance. However, there is a limitation that in the case that interrupt() on one instances throws an exception, all remaining instances (that have not yet been interrupted) will not have their interrupt() method called.

    If you wish to interrupt a specific instance of a job (when more than one is executing) you can do so by calling #getCurrentlyExecutingJobs() to obtain a handle to the job instance, and then invoke interrupt() on it yourself.

    This method is not cluster aware. That is, it will only interrupt instances of the identified InterruptableJob currently executing in this Scheduler instance, not across the entire cluster.

 public boolean isInStandbyMode() throws SchedulerException

    Reports whether the Scheduler is in stand-by mode.

 public boolean isPaused() throws SchedulerExceptionDeprecated! 
 public boolean isShutdown() throws SchedulerException

    Reports whether the Scheduler has been shutdown.

 public boolean isStarted() throws SchedulerException
    Whether the scheduler has been started.

    Note: This only reflects whether #start() has ever been called on this Scheduler, so it will return true even if the Scheduler is currently in standby mode or has been since shutdown.

 public  void pause() throws SchedulerExceptionDeprecated! replaced -  by better-named standby() method.

 public  void pauseAll() throws SchedulerException

    Pause all triggers - similar to calling pauseTriggerGroup(group) on every group, however, after using this method resumeAll() must be called to clear the scheduler's state of 'remembering' that all new triggers will be paused as they are added.

    When resumeAll() is called (to un-pause), trigger misfire instructions WILL be applied.

 public  void pauseJob(String jobName,
    String groupName) throws SchedulerException
 public  void pauseJobGroup(String groupName) throws SchedulerException

    Pause all of the org.quartz.JobDetail s in the given group - by pausing all of their Triggers.

    The Scheduler will "remember" that the group is paused, and impose the pause on any new jobs that are added to the group while the group is paused.

 public  void pauseTrigger(String triggerName,
    String groupName) throws SchedulerException

    Pause the Trigger with the given name.

 public  void pauseTriggerGroup(String groupName) throws SchedulerException

    Pause all of the Trigger s in the given group.

    The Scheduler will "remember" that the group is paused, and impose the pause on any new triggers that are added to the group while the group is paused.

 public boolean removeGlobalJobListener(JobListener jobListener) throws SchedulerExceptionDeprecated! Use -  #removeGlobalJobListener(String) 

    Remove the given JobListener from the Scheduler's list of global listeners.

 public boolean removeGlobalJobListener(String name) throws SchedulerException

    Remove the identifed JobListener from the Scheduler's list of global listeners.

 public boolean removeGlobalTriggerListener(TriggerListener triggerListener) throws SchedulerExceptionDeprecated! Use -  #removeGlobalTriggerListener(String) 

    Remove the given TriggerListener from the Scheduler's list of global listeners.

 public boolean removeGlobalTriggerListener(String name) throws SchedulerException

    Remove the identifed TriggerListener from the Scheduler's list of global listeners.

 public boolean removeJobListener(String name) throws SchedulerException

    Remove the identifed JobListener from the Scheduler's list of registered listeners.

 public boolean removeSchedulerListener(SchedulerListener schedulerListener) throws SchedulerException
 public boolean removeTriggerListener(String name) throws SchedulerException

    Remove the identifed TriggerListener from the Scheduler's list of registered listeners.

 public Date rescheduleJob(String triggerName,
    String groupName,
    Trigger newTrigger) throws SchedulerException

    Remove (delete) the org.quartz.Trigger with the given name, and store the new given one - which must be associated with the same job (the new trigger must have the job name & group specified) - however, the new trigger need not have the same name as the old trigger.

 public  void resumeAll() throws SchedulerException

    Resume (un-pause) all triggers - similar to calling resumeTriggerGroup(group) on every group.

    If any Trigger missed one or more fire-times, then the Trigger's misfire instruction will be applied.

 public  void resumeJob(String jobName,
    String groupName) throws SchedulerException

    Resume (un-pause) the org.quartz.JobDetail with the given name.

    If any of the Job'sTrigger s missed one or more fire-times, then the Trigger's misfire instruction will be applied.

 public  void resumeJobGroup(String groupName) throws SchedulerException

    Resume (un-pause) all of the org.quartz.JobDetail s in the given group.

    If any of the Job s had Trigger s that missed one or more fire-times, then the Trigger's misfire instruction will be applied.

 public  void resumeTrigger(String triggerName,
    String groupName) throws SchedulerException

    Resume (un-pause) the Trigger with the given name.

    If the Trigger missed one or more fire-times, then the Trigger's misfire instruction will be applied.

 public  void resumeTriggerGroup(String groupName) throws SchedulerException

    Resume (un-pause) all of the Trigger s in the given group.

    If any Trigger missed one or more fire-times, then the Trigger's misfire instruction will be applied.

 public Date scheduleJob(Trigger trigger) throws SchedulerException

    Schedule the given org.quartz.Trigger with the Job identified by the Trigger's settings.

 public Date scheduleJob(JobDetail jobDetail,
    Trigger trigger) throws SchedulerException

    Add the given org.quartz.JobDetail to the Scheduler, and associate the given Trigger with it.

    If the given Trigger does not reference any Job, then it will be set to reference the Job passed with it into this method.

 public  void setJobFactory(JobFactory factory) throws SchedulerException

    Set the JobFactory that will be responsible for producing instances of Job 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 opertunity for dependency injection.

 public  void shutdown() throws SchedulerException

    Halts the Scheduler's firing of Trigger s, and cleans up all resources associated with the Scheduler. Equivalent to shutdown(false).

    The scheduler cannot be re-started.

 public  void shutdown(boolean waitForJobsToComplete) throws SchedulerException

    Halts the Scheduler's firing of Trigger s, and cleans up all resources associated with the Scheduler.

    The scheduler cannot be re-started.

 public  void standby() throws SchedulerException

    Temporarily halts the Scheduler's firing of Trigger s.

    When start() is called (to bring the scheduler out of stand-by mode), trigger misfire instructions will NOT be applied during the execution of the start() method - any misfires will be detected immediately afterward (by the JobStore's normal process).

    The scheduler is not destroyed, and can be re-started at any time.

 public  void start() throws SchedulerException

    Starts the Scheduler's threads that fire Trigger s. When a scheduler is first created it is in "stand-by" mode, and will not fire triggers. The scheduler can also be put into stand-by mode by calling the standby() method.

    The misfire/recovery process will be started, if it is the initial call to this method on this scheduler instance.

 public  void triggerJob(String jobName,
    String groupName) throws SchedulerException

    Trigger the identified org.quartz.JobDetail (execute it now) - the generated trigger will be non-volatile.

 public  void triggerJob(String jobName,
    String groupName,
    JobDataMap data) throws SchedulerException

    Trigger the identified org.quartz.JobDetail (execute it now) - the generated trigger will be non-volatile.

 public  void triggerJobWithVolatileTrigger(String jobName,
    String groupName) throws SchedulerException

    Trigger the identified org.quartz.JobDetail (execute it now) - the generated trigger will be volatile.

 public  void triggerJobWithVolatileTrigger(String jobName,
    String groupName,
    JobDataMap data) throws SchedulerException

    Trigger the identified org.quartz.JobDetail (execute it now) - the generated trigger will be volatile.

 public boolean unscheduleJob(String triggerName,
    String groupName) throws SchedulerException

    Remove the indicated Trigger from the scheduler.