Class AbstractTrigger<T extends Trigger>
- java.lang.Object
-
- org.quartz.impl.triggers.AbstractTrigger<T>
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,java.lang.Comparable<Trigger>,MutableTrigger,OperableTrigger,Trigger
- Direct Known Subclasses:
CalendarIntervalTriggerImpl,CronTriggerImpl,DailyTimeIntervalTriggerImpl,SimpleTriggerImpl
public abstract class AbstractTrigger<T extends Trigger> extends java.lang.Object implements OperableTrigger
The base abstract class to be extended by all
Triggers.Triggerss have a name and group associated with them, which should uniquely identify them within a single.SchedulerTriggers are the 'mechanism' by whichJobs are scheduled. ManyTriggers can point to the sameJob, but a singleTriggercan only point to oneJob.Triggers can 'send' parameters/data to
Jobs by placing contents into theJobDataMapon theTrigger.- Author:
- James House, Sharada Jambula
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.quartz.Trigger
Trigger.CompletedExecutionInstruction, Trigger.TriggerState, Trigger.TriggerTimeComparator
-
-
Field Summary
-
Fields inherited from interface org.quartz.Trigger
DEFAULT_PRIORITY, MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICY, MISFIRE_INSTRUCTION_SMART_POLICY
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractTrigger()Create aTriggerwith no specified name, group, or.JobDetailprotectedAbstractTrigger(java.lang.String name)Create aTriggerwith the given name, and default group.protectedAbstractTrigger(java.lang.String name, java.lang.String group)Create aTriggerwith the given name, and group.protectedAbstractTrigger(java.lang.String name, java.lang.String group, java.lang.String jobName, java.lang.String jobGroup)Create aTriggerwith the given name, and group.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.lang.Objectclone()intcompareTo(Trigger other)Compare the next fire time of thisTriggerto that of another by comparing their keys, or in other words, sorts them according to the natural (i.e.booleanequals(java.lang.Object o)Trigger equality is based upon the equality of the TriggerKey.Trigger.CompletedExecutionInstructionexecutionComplete(JobExecutionContext context, JobExecutionException result)This method should not be used by the Quartz client.java.lang.StringgetCalendarName()Get the name of theassociated with this Trigger.Calendarjava.lang.StringgetDescription()Return the description given to theTriggerinstance by its creator (if any).java.lang.StringgetFireInstanceId()This method should not be used by the Quartz client.java.lang.StringgetFullJobName()Returns the 'full name' of theJobthat theTriggerpoints to, in the format "group.name".java.lang.StringgetFullName()Returns the 'full name' of theTriggerin the format "group.name".java.lang.StringgetGroup()Get the group of thisTrigger.JobDataMapgetJobDataMap()Get theJobDataMapthat is associated with theTrigger.java.lang.StringgetJobGroup()Get the name of the associated's group.JobDetailJobKeygetJobKey()java.lang.StringgetJobName()Get the name of the associated.JobDetailTriggerKeygetKey()intgetMisfireInstruction()Get the instruction theSchedulershould be given for handling misfire situations for thisTrigger- the concreteTriggertype that you are using will have defined a set of additionalMISFIRE_INSTRUCTION_XXXconstants that may be passed to this method.java.lang.StringgetName()Get the name of thisTrigger.intgetPriority()The priority of aTriggeracts as a tiebreaker such that if twoTriggers have the same scheduled fire time, then the one with the higher priority will get first access to a worker thread.abstract ScheduleBuilder<T>getScheduleBuilder()Get aScheduleBuilderthat is configured to produce a schedule identical to this trigger's schedule.TriggerBuilder<T>getTriggerBuilder()Get aTriggerBuilderthat is configured to produce aTriggeridentical to this one.inthashCode()voidsetCalendarName(java.lang.String calendarName)Associate thewith the given name with this Trigger.CalendarvoidsetDescription(java.lang.String description)Set a description for theTriggerinstance - may be useful for remembering/displaying the purpose of the trigger, though the description has no meaning to Quartz.voidsetFireInstanceId(java.lang.String id)This method should not be used by the Quartz client.voidsetGroup(java.lang.String group)Set the name of thisTrigger.voidsetJobDataMap(JobDataMap jobDataMap)Set theJobDataMapto be associated with theTrigger.voidsetJobGroup(java.lang.String jobGroup)Set the name of the associated's group.JobDetailvoidsetJobKey(JobKey key)voidsetJobName(java.lang.String jobName)Set the name of the associated.JobDetailvoidsetKey(TriggerKey key)voidsetMisfireInstruction(int misfireInstruction)Set the instruction theSchedulershould be given for handling misfire situations for thisTrigger- the concreteTriggertype that you are using will have defined a set of additionalMISFIRE_INSTRUCTION_XXXconstants that may be passed to this method.voidsetName(java.lang.String name)Set the name of thisTrigger.voidsetPriority(int priority)The priority of aTriggeracts as a tie breaker such that if twoTriggers 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.java.lang.StringtoString()Return a simple string representation of this object.voidvalidate()Validates whether the properties of theJobDetailare valid for submission into aScheduler.protected abstract booleanvalidateMisfireInstruction(int candidateMisfireInstruction)-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.quartz.spi.MutableTrigger
setEndTime, setStartTime
-
Methods inherited from interface org.quartz.spi.OperableTrigger
computeFirstFireTime, setNextFireTime, setPreviousFireTime, triggered, updateAfterMisfire, updateWithNewCalendar
-
Methods inherited from interface org.quartz.Trigger
getEndTime, getFinalFireTime, getFireTimeAfter, getNextFireTime, getPreviousFireTime, getStartTime, mayFireAgain
-
-
-
-
Constructor Detail
-
AbstractTrigger
protected AbstractTrigger()
Create a
Triggerwith no specified name, group, or.JobDetailNote that the
setName(String),setGroup(String)and thesetJobName(String)andsetJobGroup(String)methods must be called before theTriggercan be placed into aScheduler.
-
AbstractTrigger
protected AbstractTrigger(java.lang.String name)
Create a
Triggerwith the given name, and default group.Note that the
setJobName(String)andsetJobGroup(String)methods must be called before theTriggercan be placed into aScheduler.- Throws:
java.lang.IllegalArgumentException- if name is null or empty, or the group is an empty string.
-
AbstractTrigger
protected AbstractTrigger(java.lang.String name, java.lang.String group)Create a
Triggerwith the given name, and group.Note that the
setJobName(String)andsetJobGroup(String)methods must be called before theTriggercan be placed into aScheduler.- Parameters:
group- ifnull, Scheduler.DEFAULT_GROUP will be used.- Throws:
java.lang.IllegalArgumentException- if name is null or empty, or the group is an empty string.
-
AbstractTrigger
protected AbstractTrigger(java.lang.String name, java.lang.String group, java.lang.String jobName, java.lang.String jobGroup)Create a
Triggerwith the given name, and group.- Parameters:
group- ifnull, Scheduler.DEFAULT_GROUP will be used.- Throws:
java.lang.IllegalArgumentException- if name is null or empty, or the group is an empty string.
-
-
Method Detail
-
getName
public java.lang.String getName()
Get the name of this
Trigger.
-
setName
public void setName(java.lang.String name)
Set the name of this
Trigger.- Throws:
java.lang.IllegalArgumentException- if name is null or empty.
-
getGroup
public java.lang.String getGroup()
Get the group of this
Trigger.
-
setGroup
public void setGroup(java.lang.String group)
Set the name of this
Trigger.- Parameters:
group- ifnull, Scheduler.DEFAULT_GROUP will be used.- Throws:
java.lang.IllegalArgumentException- if group is an empty string.
-
setKey
public void setKey(TriggerKey key)
- Specified by:
setKeyin interfaceMutableTrigger
-
getJobName
public java.lang.String getJobName()
Get the name of the associated
.JobDetail
-
setJobName
public void setJobName(java.lang.String jobName)
Set the name of the associated
.JobDetail- Throws:
java.lang.IllegalArgumentException- if jobName is null or empty.
-
getJobGroup
public java.lang.String getJobGroup()
Get the name of the associated
's group.JobDetail
-
setJobGroup
public void setJobGroup(java.lang.String jobGroup)
Set the name of the associated
's group.JobDetail- Parameters:
jobGroup- ifnull, Scheduler.DEFAULT_GROUP will be used.- Throws:
java.lang.IllegalArgumentException- if group is an empty string.
-
setJobKey
public void setJobKey(JobKey key)
- Specified by:
setJobKeyin interfaceMutableTrigger
-
getFullName
public java.lang.String getFullName()
Returns the 'full name' of the
Triggerin the format "group.name".
-
getKey
public TriggerKey getKey()
-
getFullJobName
public java.lang.String getFullJobName()
Returns the 'full name' of the
Jobthat theTriggerpoints to, in the format "group.name".
-
getDescription
public java.lang.String getDescription()
Return the description given to the
Triggerinstance by its creator (if any).- Specified by:
getDescriptionin interfaceTrigger- Returns:
- null if no description was set.
-
setDescription
public void setDescription(java.lang.String description)
Set a description for the
Triggerinstance - may be useful for remembering/displaying the purpose of the trigger, though the description has no meaning to Quartz.- Specified by:
setDescriptionin interfaceMutableTrigger
-
setCalendarName
public void setCalendarName(java.lang.String calendarName)
Associate the
with the given name with this Trigger.Calendar- Specified by:
setCalendarNamein interfaceMutableTrigger- Parameters:
calendarName- usenullto dis-associate a Calendar.
-
getCalendarName
public java.lang.String getCalendarName()
Get the name of the
associated with this Trigger.Calendar- Specified by:
getCalendarNamein interfaceTrigger- Returns:
nullif there is no associated Calendar.
-
getJobDataMap
public JobDataMap getJobDataMap()
Get the
JobDataMapthat is associated with theTrigger.Changes made to this map during job execution are not re-persisted, and in fact typically result in an
IllegalStateException.- Specified by:
getJobDataMapin interfaceTrigger
-
setJobDataMap
public void setJobDataMap(JobDataMap jobDataMap)
Set the
JobDataMapto be associated with theTrigger.- Specified by:
setJobDataMapin interfaceMutableTrigger
-
getPriority
public int getPriority()
The priority of aTriggeracts as a tiebreaker such that if twoTriggers 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:
getPriorityin interfaceTrigger- See Also:
Trigger.DEFAULT_PRIORITY
-
setPriority
public void setPriority(int priority)
The priority of aTriggeracts as a tie breaker such that if twoTriggers 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:
setPriorityin interfaceMutableTrigger- See Also:
Trigger.DEFAULT_PRIORITY
-
executionComplete
public Trigger.CompletedExecutionInstruction executionComplete(JobExecutionContext context, JobExecutionException result)
This method should not be used by the Quartz client.
Called after the
has executed theSchedulerassociated with theJobDetailTriggerin order to get the final instruction code from the trigger.- Specified by:
executionCompletein interfaceOperableTrigger- Parameters:
context- is theJobExecutionContextthat was used by theJob'sexecute(xx)method.result- is theJobExecutionExceptionthrown by theJob, if any (may be null).- Returns:
- one of the CompletedExecutionInstruction constants.
- See Also:
Trigger.CompletedExecutionInstruction,OperableTrigger.triggered(Calendar)
-
setMisfireInstruction
public void setMisfireInstruction(int misfireInstruction)
Set the instruction the
Schedulershould be given for handling misfire situations for thisTrigger- the concreteTriggertype that you are using will have defined a set of additionalMISFIRE_INSTRUCTION_XXXconstants that may be passed to this method.If not explicitly set, the default value is
MISFIRE_INSTRUCTION_SMART_POLICY.- Specified by:
setMisfireInstructionin interfaceMutableTrigger- See Also:
Trigger.MISFIRE_INSTRUCTION_SMART_POLICY,OperableTrigger.updateAfterMisfire(Calendar),SimpleTrigger,CronTrigger
-
validateMisfireInstruction
protected abstract boolean validateMisfireInstruction(int candidateMisfireInstruction)
-
getMisfireInstruction
public int getMisfireInstruction()
Get the instruction the
Schedulershould be given for handling misfire situations for thisTrigger- the concreteTriggertype that you are using will have defined a set of additionalMISFIRE_INSTRUCTION_XXXconstants that may be passed to this method.If not explicitly set, the default value is
MISFIRE_INSTRUCTION_SMART_POLICY.- Specified by:
getMisfireInstructionin interfaceTrigger- See Also:
Trigger.MISFIRE_INSTRUCTION_SMART_POLICY,OperableTrigger.updateAfterMisfire(Calendar),SimpleTrigger,CronTrigger
-
validate
public void validate() throws SchedulerExceptionValidates whether the properties of the
JobDetailare valid for submission into aScheduler.- Specified by:
validatein interfaceOperableTrigger- Throws:
java.lang.IllegalStateException- if a required property (such as Name, Group, Class) is not set.SchedulerException
-
setFireInstanceId
public void setFireInstanceId(java.lang.String id)
This method should not be used by the Quartz client.
Usable by
implementations, in order to facilitate 'recognizing' instances of firedJobStoreTriggers as their jobs complete execution.- Specified by:
setFireInstanceIdin interfaceOperableTrigger
-
getFireInstanceId
public java.lang.String getFireInstanceId()
This method should not be used by the Quartz client.
- Specified by:
getFireInstanceIdin interfaceOperableTrigger
-
toString
public java.lang.String toString()
Return a simple string representation of this object.
- Overrides:
toStringin classjava.lang.Object
-
compareTo
public int compareTo(Trigger other)
Compare the next fire time of this
Triggerto that of another by comparing their keys, or in other words, sorts them according to the natural (i.e. alphabetical) order of their keys.
-
equals
public boolean equals(java.lang.Object o)
Trigger equality is based upon the equality of the TriggerKey.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
clone
public java.lang.Object clone()
- Specified by:
clonein interfaceMutableTrigger- Overrides:
clonein classjava.lang.Object
-
getTriggerBuilder
public TriggerBuilder<T> getTriggerBuilder()
Description copied from interface:TriggerGet aTriggerBuilderthat is configured to produce aTriggeridentical to this one.- Specified by:
getTriggerBuilderin interfaceTrigger- See Also:
Trigger.getScheduleBuilder()
-
getScheduleBuilder
public abstract ScheduleBuilder<T> getScheduleBuilder()
Description copied from interface:TriggerGet aScheduleBuilderthat is configured to produce a schedule identical to this trigger's schedule.- Specified by:
getScheduleBuilderin interfaceTrigger- See Also:
Trigger.getTriggerBuilder()
-
-