Interface Trigger
-
- All Superinterfaces:
java.lang.Cloneable,java.lang.Comparable<Trigger>,java.io.Serializable
- All Known Subinterfaces:
CalendarIntervalTrigger,CoreTrigger,CronTrigger,DailyTimeIntervalTrigger,MutableTrigger,OperableTrigger,SimpleTrigger
- All Known Implementing Classes:
AbstractTrigger,CalendarIntervalTriggerImpl,CronTriggerImpl,DailyTimeIntervalTriggerImpl,SimpleTriggerImpl
public interface Trigger extends java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<Trigger>
The base interface with properties common to allTriggers - useTriggerBuilderto instantiate an actual Trigger.Triggerss have aTriggerKeyassociated 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
- See Also:
TriggerBuilder,JobDataMap,JobExecutionContext,TriggerUtils,SimpleTrigger,CronTrigger,CalendarIntervalTrigger
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classTrigger.CompletedExecutionInstructionstatic classTrigger.TriggerStatestatic classTrigger.TriggerTimeComparatorA Comparator that compares trigger's next fire times, or in other words, sorts them according to earliest next fire time.
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_PRIORITYThe default value for priority.static intMISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICYInstructs thethat theSchedulerTriggerwill never be evaluated for a misfire situation, and that the scheduler will simply try to fire it as soon as it can, and then update the Trigger as if it had fired at the proper time.static intMISFIRE_INSTRUCTION_SMART_POLICYInstructs thethat upon a mis-fire situation, theSchedulerupdateAfterMisfire()method will be called on theTriggerto determine the mis-fire instruction, which logic will be trigger-implementation-dependent.static longserialVersionUID
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description 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 other)Trigger equality is based upon the equality of the TriggerKey.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.util.DategetEndTime()Get the time at which theTriggershould quit repeating - regardless of any remaining repeats (based on the trigger's particular repeat settings).java.util.DategetFinalFireTime()Returns the last time at which theTriggerwill fire, if the Trigger will repeat indefinitely, null will be returned.java.util.DategetFireTimeAfter(java.util.Date afterTime)Returns the next time at which theTriggerwill fire, after the given time.JobDataMapgetJobDataMap()Get theJobDataMapthat is associated with theTrigger.JobKeygetJobKey()TriggerKeygetKey()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 set as this property's value.java.util.DategetNextFireTime()Returns the next time at which theTriggeris scheduled to fire.java.util.DategetPreviousFireTime()Returns the previous time at which theTriggerfired.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.ScheduleBuilder<? extends Trigger>getScheduleBuilder()Get aScheduleBuilderthat is configured to produce a schedule identical to this trigger's schedule.java.util.DategetStartTime()Get the time at which theTriggershould occur.TriggerBuilder<? extends Trigger>getTriggerBuilder()Get aTriggerBuilderthat is configured to produce aTriggeridentical to this one.booleanmayFireAgain()Used by theto determine whether or not it is possible for thisSchedulerTriggerto fire again.
-
-
-
Field Detail
-
serialVersionUID
static final long serialVersionUID
- See Also:
- Constant Field Values
-
MISFIRE_INSTRUCTION_SMART_POLICY
static final int MISFIRE_INSTRUCTION_SMART_POLICY
Instructs thethat upon a mis-fire situation, theSchedulerupdateAfterMisfire()method will be called on theTriggerto determine the mis-fire instruction, which logic will be trigger-implementation-dependent.In order to see if this instruction fits your needs, you should look at the documentation for the
updateAfterMisfire()method on the particularTriggerimplementation you are using.
-
MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICY
static final int MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICY
Instructs thethat theSchedulerTriggerwill never be evaluated for a misfire situation, and that the scheduler will simply try to fire it as soon as it can, and then update the Trigger as if it had fired at the proper time.NOTE: if a trigger uses this instruction, and it has missed several of its scheduled firings, then several rapid firings may occur as the trigger attempt to catch back up to where it would have been. For example, a SimpleTrigger that fires every 15 seconds which has misfired for 5 minutes will fire 20 times once it gets the chance to fire.
- See Also:
- Constant Field Values
-
DEFAULT_PRIORITY
static final int DEFAULT_PRIORITY
The default value for priority.- See Also:
- Constant Field Values
-
-
Method Detail
-
getKey
TriggerKey getKey()
-
getJobKey
JobKey getJobKey()
-
getDescription
java.lang.String getDescription()
Return the description given to theTriggerinstance by its creator (if any).- Returns:
- null if no description was set.
-
getCalendarName
java.lang.String getCalendarName()
Get the name of theassociated with this Trigger.Calendar- Returns:
nullif there is no associated Calendar.
-
getJobDataMap
JobDataMap getJobDataMap()
Get theJobDataMapthat is associated with theTrigger.Changes made to this map during job execution are not re-persisted, and in fact typically result in an
IllegalStateException.
-
getPriority
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.- See Also:
DEFAULT_PRIORITY
-
mayFireAgain
boolean mayFireAgain()
-
getStartTime
java.util.Date getStartTime()
Get the time at which theTriggershould occur.
-
getEndTime
java.util.Date getEndTime()
Get the time at which theTriggershould quit repeating - regardless of any remaining repeats (based on the trigger's particular repeat settings).- See Also:
getFinalFireTime()
-
getNextFireTime
java.util.Date getNextFireTime()
Returns the next time at which theTriggeris scheduled to fire. If the trigger will not fire again,nullwill be returned. Note that the time returned can possibly be in the past, if the time that was computed for the trigger to next fire has already arrived, but the scheduler has not yet been able to fire the trigger (which would likely be due to lack of resources e.g. threads).The value returned is not guaranteed to be valid until after the
Triggerhas been added to the scheduler.
-
getPreviousFireTime
java.util.Date getPreviousFireTime()
Returns the previous time at which theTriggerfired. If the trigger has not yet fired,nullwill be returned.
-
getFireTimeAfter
java.util.Date getFireTimeAfter(java.util.Date afterTime)
Returns the next time at which theTriggerwill fire, after the given time. If the trigger will not fire after the given time,nullwill be returned.
-
getFinalFireTime
java.util.Date getFinalFireTime()
Returns the last time at which theTriggerwill fire, if the Trigger will repeat indefinitely, null will be returned.Note that the return time *may* be in the past.
-
getMisfireInstruction
int getMisfireInstruction()
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 set as this property's value.If not explicitly set, the default value is
MISFIRE_INSTRUCTION_SMART_POLICY.- See Also:
MISFIRE_INSTRUCTION_SMART_POLICY,SimpleTrigger,CronTrigger
-
getTriggerBuilder
TriggerBuilder<? extends Trigger> getTriggerBuilder()
Get aTriggerBuilderthat is configured to produce aTriggeridentical to this one.- See Also:
getScheduleBuilder()
-
getScheduleBuilder
ScheduleBuilder<? extends Trigger> getScheduleBuilder()
Get aScheduleBuilderthat is configured to produce a schedule identical to this trigger's schedule.- See Also:
getTriggerBuilder()
-
equals
boolean equals(java.lang.Object other)
Trigger equality is based upon the equality of the TriggerKey.- Overrides:
equalsin classjava.lang.Object- Returns:
- true if the key of this Trigger equals that of the given Trigger.
-
-