Package org.quartz.triggers
Class SimpleTriggerImpl
java.lang.Object
org.quartz.triggers.AbstractTrigger
org.quartz.triggers.SimpleTriggerImpl
- All Implemented Interfaces:
Serializable,Cloneable,Comparable<Trigger>,MutableTrigger,OperableTrigger,SimpleTrigger,Trigger
A concrete
Trigger that is used to fire a
JobDetail at a given moment in time, and optionally repeated at a
specified interval.- Author:
- James House, contributions by Lieven Govaerts of Ebitec Nv, Belgium.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.quartz.triggers.Trigger
Trigger.CompletedExecutionInstruction, Trigger.TriggerTimeComparator -
Field Summary
Fields inherited from class org.quartz.triggers.AbstractTrigger
endTime, nextFireTime, previousFireTime, startTimeFields inherited from interface org.quartz.triggers.SimpleTrigger
MISFIRE_INSTRUCTION_FIRE_NOW, MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_EXISTING_COUNT, MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_REMAINING_COUNT, MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_EXISTING_REPEAT_COUNT, MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_REMAINING_REPEAT_COUNT, REPEAT_INDEFINITELY, serialVersionUIDFields inherited from interface org.quartz.triggers.Trigger
DEFAULT_PRIORITY, MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICY, MISFIRE_INSTRUCTION_SMART_POLICY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncomputeFirstFireTime(Calendar calendar) Called by the scheduler at the time aTriggeris first added to the scheduler, in order to have theTriggercompute its first fire time, based on any associated calendar.Get the time at which theSimpleTriggershould quit repeating - even if repeastCount isn't yet satisfied.Returns the final time at which theSimpleTriggerwill fire, if repeatCount is REPEAT_INDEFINITELY, null will be returned.getFireTimeAfter(Date afterTime) Returns the next time at which theSimpleTriggerwill fire, after the given time.Returns the next time at which theTriggeris scheduled to fire.Returns the previous time at which theSimpleTriggerfired.intGet the the number of times theSimpleTriggershould repeat, after which it will be automatically deleted.longGet the the time interval (in milliseconds) at which theSimpleTriggershould repeat.Get the time at which theSimpleTriggershould occur.intGet the number of times theSimpleTriggerhas already fired.booleanDetermines whether or not theSimpleTriggerwill occur again.voidsetEndTime(Date endTime) Set the time at which theSimpleTriggershould quit repeating (and be automatically deleted).voidsetNextFireTime(Date nextFireTime) Set the next time at which theSimpleTriggershould fire.voidsetPreviousFireTime(Date previousFireTime) Set the previous time at which theSimpleTriggerfired.voidsetRepeatCount(int repeatCount) Set the the number of time theSimpleTriggershould repeat, after which it will be automatically deleted.voidsetRepeatInterval(long repeatInterval) Set the the time interval (in milliseconds) at which theSimpleTriggershould repeat.voidsetStartTime(Date startTime) Set the time at which theSimpleTriggershould occur.voidsetTimesTriggered(int timesTriggered) Set the number of times theSimpleTriggerhas already fired.toString()voidCalled when thehas decided to 'fire' the trigger (execute the associatedSchedulerJob), in order to give theTriggera chance to update itself for its next triggering (if any).voidUpdates theSimpleTrigger's state based on the MISFIRE_INSTRUCTION_XXX that was selected when theSimpleTriggerwas created.voidvalidate()Validates whether the properties of theJobDetailare valid for submission into aScheduler.protected booleanvalidateMisfireInstruction(int misfireInstruction) Methods inherited from class org.quartz.triggers.AbstractTrigger
clone, compareTo, equals, executionComplete, getCalendarName, getDescription, getFireInstanceId, getJobDataMap, getJobName, getMisfireInstruction, getName, getPriority, hashCode, setCalendarName, setDescription, setFireInstanceId, setJobDataMap, setJobName, setMisfireInstruction, setName, setPriorityMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Comparable
compareToMethods inherited from interface org.quartz.triggers.Trigger
equals, getCalendarName, getDescription, getJobDataMap, getJobName, getMisfireInstruction, getName, getPriority
-
Constructor Details
-
SimpleTriggerImpl
public SimpleTriggerImpl()Create aSimpleTriggerwith no settings.
-
-
Method Details
-
getStartTime
Get the time at which theSimpleTriggershould occur.- Specified by:
getStartTimein interfaceTrigger
-
setStartTime
Set the time at which theSimpleTriggershould occur.- Specified by:
setStartTimein interfaceMutableTrigger- Throws:
IllegalArgumentException- if startTime isnull.
-
getEndTime
Get the time at which theSimpleTriggershould quit repeating - even if repeastCount isn't yet satisfied.- Specified by:
getEndTimein interfaceTrigger- See Also:
-
setEndTime
Set the time at which theSimpleTriggershould quit repeating (and be automatically deleted).- Specified by:
setEndTimein interfaceMutableTrigger- Throws:
IllegalArgumentException- if endTime is before start time.- See Also:
-
-
invalid @see
TriggerUtils#computeEndTimeToAllowParticularNumberOfFirings(Trigger, Calendar, int)
-
-
getRepeatCount
public int getRepeatCount()Description copied from interface:SimpleTriggerGet the the number of times theSimpleTriggershould repeat, after which it will be automatically deleted.- Specified by:
getRepeatCountin interfaceSimpleTrigger- See Also:
-
setRepeatCount
public void setRepeatCount(int repeatCount) Set the the number of time theSimpleTriggershould repeat, after which it will be automatically deleted.- Throws:
IllegalArgumentException- if repeatCount is invalid input: '<' 0- See Also:
-
getRepeatInterval
public long getRepeatInterval()Description copied from interface:SimpleTriggerGet the the time interval (in milliseconds) at which theSimpleTriggershould repeat.- Specified by:
getRepeatIntervalin interfaceSimpleTrigger
-
setRepeatInterval
public void setRepeatInterval(long repeatInterval) Set the the time interval (in milliseconds) at which theSimpleTriggershould repeat.- Throws:
IllegalArgumentException- if repeatInterval is invalid input: '<'= 0
-
getTimesTriggered
public int getTimesTriggered()Get the number of times theSimpleTriggerhas already fired.- Specified by:
getTimesTriggeredin interfaceSimpleTrigger
-
setTimesTriggered
public void setTimesTriggered(int timesTriggered) Set the number of times theSimpleTriggerhas already fired. -
validateMisfireInstruction
protected boolean validateMisfireInstruction(int misfireInstruction) - Specified by:
validateMisfireInstructionin classAbstractTrigger
-
updateAfterMisfire
Updates theSimpleTrigger's state based on the MISFIRE_INSTRUCTION_XXX that was selected when theSimpleTriggerwas created.If the misfire instruction is set to MISFIRE_INSTRUCTION_SMART_POLICY, then the following scheme will be used:
- If the Repeat Count is
0, then the instruction will be interpreted asMISFIRE_INSTRUCTION_FIRE_NOW. - If the Repeat Count is
REPEAT_INDEFINITELY, then the instruction will be interpreted asMISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_REMAINING_COUNT. WARNING: using MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_REMAINING_COUNT with a trigger that has a non-null end-time may cause the trigger to never fire again if the end-time arrived during the misfire time span. - If the Repeat Count is
> 0, then the instruction will be interpreted asMISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_EXISTING_REPEAT_COUNT.
If the misfire instruction is set to
Trigger.MISFIRE_INSTRUCTION_SKIP_TO_NEXT_FIRE_AFTER_CURRENT_DATEthen the behavior will be identical to- Specified by:
updateAfterMisfirein interfaceOperableTrigger
- If the Repeat Count is
-
triggered
Called when thehas decided to 'fire' the trigger (execute the associatedSchedulerJob), in order to give theTriggera chance to update itself for its next triggering (if any).- Specified by:
triggeredin interfaceOperableTrigger- See Also:
-
computeFirstFireTime
Called by the scheduler at the time aTriggeris first added to the scheduler, in order to have theTriggercompute its first fire time, based on any associated calendar.After this method has been called,
getNextFireTime()should return a valid answer.- Specified by:
computeFirstFireTimein interfaceOperableTrigger- Returns:
- the first time at which the
Triggerwill be fired by the scheduler, which is also the same valuegetNextFireTime()will return (until after the first firing of theTrigger).
-
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.- Specified by:
getNextFireTimein interfaceTrigger- See Also:
-
-
invalid @see
TriggerUtils#computeFireTimesBetween(Trigger, Calendar, Date, Date)
-
-
getPreviousFireTime
Returns the previous time at which theSimpleTriggerfired. If the trigger has not yet fired,nullwill be returned.- Specified by:
getPreviousFireTimein interfaceTrigger
-
setNextFireTime
Set the next time at which theSimpleTriggershould fire.This method should not be invoked by client code.
- Specified by:
setNextFireTimein interfaceOperableTrigger
-
setPreviousFireTime
Set the previous time at which theSimpleTriggerfired.This method should not be invoked by client code.
- Specified by:
setPreviousFireTimein interfaceOperableTrigger
-
getFireTimeAfter
Returns the next time at which theSimpleTriggerwill fire, after the given time. If the trigger will not fire after the given time,nullwill be returned.- Specified by:
getFireTimeAfterin interfaceTrigger
-
getFinalFireTime
Returns the final time at which theSimpleTriggerwill fire, if repeatCount is REPEAT_INDEFINITELY, null will be returned.Note that the return time may be in the past.
- Specified by:
getFinalFireTimein interfaceTrigger
-
mayFireAgain
public boolean mayFireAgain()Determines whether or not theSimpleTriggerwill occur again.- Specified by:
mayFireAgainin interfaceTrigger
-
validate
Validates whether the properties of theJobDetailare valid for submission into aScheduler.- Specified by:
validatein interfaceOperableTrigger- Overrides:
validatein classAbstractTrigger- Throws:
IllegalStateException- if a required property (such as Name, Group, Class) is not set.SchedulerException
-
toString
- Overrides:
toStringin classAbstractTrigger
-