Class AbstractTrigger

java.lang.Object
org.quartz.triggers.AbstractTrigger
All Implemented Interfaces:
Serializable, Cloneable, Comparable<Trigger>, MutableTrigger, OperableTrigger, Trigger
Direct Known Subclasses:
CronTriggerImpl, SimpleTriggerImpl

public abstract class AbstractTrigger extends Object implements OperableTrigger
The base abstract class to be extended by all Triggers.

Triggers s have a name and group associated with them, which should uniquely identify them within a single Scheduler.

Triggers are the 'mechanism' by which Job s are scheduled. Many Trigger s can point to the same Job, but a single Trigger can only point to one Job.

Triggers can 'send' parameters/data to Jobs by placing contents into the JobDataMap on the Trigger.

Author:
James House, Sharada Jambula
See Also:
  • Field Details

    • startTime

      protected Date startTime
    • endTime

      protected Date endTime
    • nextFireTime

      protected Date nextFireTime
    • previousFireTime

      protected Date previousFireTime
  • Constructor Details

  • Method Details

    • validateMisfireInstruction

      protected abstract boolean validateMisfireInstruction(int misfireInstruction)
    • getName

      public String getName()
      Description copied from interface: Trigger
      Get the name of this Trigger.
      Specified by:
      getName in interface Trigger
    • getJobName

      public String getJobName()
      Description copied from interface: Trigger
      Get the name of the associated JobDetail.
      Specified by:
      getJobName in interface Trigger
    • setName

      public void setName(String name)
      Description copied from interface: MutableTrigger
      Set the name of this Trigger.
      Specified by:
      setName in interface MutableTrigger
    • setJobName

      public void setJobName(String jobName)
      Description copied from interface: MutableTrigger
      Set the name of the associated JobDetail.
      Specified by:
      setJobName in interface MutableTrigger
    • getDescription

      public String getDescription()
      Description copied from interface: Trigger
      Return the description given to the Trigger instance by its creator (if any).
      Specified by:
      getDescription in interface Trigger
      Returns:
      null if no description was set.
    • setDescription

      public void setDescription(String description)
      Description copied from interface: MutableTrigger
      Set a description for the Trigger instance - may be useful for remembering/displaying the purpose of the trigger, though the description has no meaning to Quartz.
      Specified by:
      setDescription in interface MutableTrigger
    • setCalendarName

      public void setCalendarName(String calendarName)
      Description copied from interface: MutableTrigger
      Associate the Calendar with the given name with this Trigger.
      Specified by:
      setCalendarName in interface MutableTrigger
      Parameters:
      calendarName - use null to dis-associate a Calendar.
    • getCalendarName

      public String getCalendarName()
      Description copied from interface: Trigger
      Get the name of the Calendar associated with this Trigger.
      Specified by:
      getCalendarName in interface Trigger
      Returns:
      null if there is no associated Calendar.
    • getJobDataMap

      public JobDataMap getJobDataMap()
      Description copied from interface: Trigger
      Get the JobDataMap that is associated with the Trigger.

      Changes made to this map during job execution are not re-persisted, and in fact typically result in an IllegalStateException.

      Specified by:
      getJobDataMap in interface Trigger
    • setJobDataMap

      public void setJobDataMap(JobDataMap jobDataMap)
      Description copied from interface: MutableTrigger
      Set the JobDataMap to be associated with the Trigger.
      Specified by:
      setJobDataMap in interface MutableTrigger
    • getPriority

      public int getPriority()
      Description copied from interface: Trigger
      The priority of a Trigger acts as a tiebreaker such that if two Trigger s have the same scheduled fire time, then the one with the higher priority will get first access to a worker thread.

      If not explicitly set, the default value is 5.

      Specified by:
      getPriority in interface Trigger
      See Also:
    • setPriority

      public void setPriority(int priority)
      Description copied from interface: MutableTrigger
      The priority of a Trigger acts as a tie breaker such that if two Trigger s have the same scheduled fire time, then Quartz will do its best to give the one with the higher priority first access to a worker thread.

      If not explicitly set, the default value is 5.

      Specified by:
      setPriority in interface MutableTrigger
      See Also:
    • getMisfireInstruction

      public int getMisfireInstruction()
      Description copied from interface: Trigger
      Get the instruction the Scheduler should be given for handling misfire situations for this Trigger- the concrete Trigger type that you are using will have defined a set of additional MISFIRE_INSTRUCTION_XXX constants that may be set as this property's value.

      If not explicitly set, the default value is MISFIRE_INSTRUCTION_SMART_POLICY.

      Specified by:
      getMisfireInstruction in interface Trigger
      See Also:
    • setMisfireInstruction

      public void setMisfireInstruction(int misfireInstruction)
      Description copied from interface: MutableTrigger
      Set the instruction the Scheduler should be given for handling misfire situations for this Trigger- the concrete Trigger type that you are using will have defined a set of additional MISFIRE_INSTRUCTION_XXX constants that may be passed to this method.

      If not explicitly set, the default value is MISFIRE_INSTRUCTION_SMART_POLICY.

      Specified by:
      setMisfireInstruction in interface MutableTrigger
      See Also:
    • executionComplete

      Description copied from interface: OperableTrigger
      This method should not be used by the Quartz client.

      Called after the Scheduler has executed the JobDetail associated with the Trigger in order to get the final instruction code from the trigger.

      Specified by:
      executionComplete in interface OperableTrigger
      Parameters:
      context - is the JobExecutionContext that was used by the Job's execute(xx) method.
      result - is the JobExecutionException thrown by the Job, if any (may be null).
      Returns:
      one of the CompletedExecutionInstruction constants.
      See Also:
    • validate

      public void validate() throws SchedulerException
      Description copied from interface: OperableTrigger
      Validates whether the properties of the JobDetail are valid for submission into a Scheduler.
      Specified by:
      validate in interface OperableTrigger
      Throws:
      SchedulerException
    • setFireInstanceId

      public void setFireInstanceId(String id)
      Description copied from interface: OperableTrigger
      This method should not be used by the Quartz client.

      Usable by JobStore implementations, in order to facilitate 'recognizing' instances of fired Trigger s as their jobs complete execution.

      Specified by:
      setFireInstanceId in interface OperableTrigger
    • getFireInstanceId

      public String getFireInstanceId()
      Description copied from interface: OperableTrigger
      This method should not be used by the Quartz client.
      Specified by:
      getFireInstanceId in interface OperableTrigger
    • compareTo

      public int compareTo(Trigger other)
      Compare the next fire time of this Trigger to that of another by comparing their keys, or in other words, sorts them according to the natural (i.e. alphabetical) order of their keys.
      Specified by:
      compareTo in interface Comparable<Trigger>
    • equals

      public boolean equals(Object o)
      Trigger equality is based upon the equality of the Trigger name.
      Specified by:
      equals in interface Trigger
      Overrides:
      equals in class Object
      Returns:
      true if the key of this Trigger equals that of the given Trigger.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • clone

      public Object clone()
      Specified by:
      clone in interface MutableTrigger
      Overrides:
      clone in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object