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, startTime
Fields 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, serialVersionUID
Fields inherited from interface org.quartz.triggers.Trigger
DEFAULT_PRIORITY, MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICY, MISFIRE_INSTRUCTION_SMART_POLICY
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncomputeFirstFireTime
(Calendar calendar) Called by the scheduler at the time aTrigger
is first added to the scheduler, in order to have theTrigger
compute its first fire time, based on any associated calendar.Get the time at which theSimpleTrigger
should quit repeating - even if repeastCount isn't yet satisfied.Returns the final time at which theSimpleTrigger
will fire, if repeatCount is REPEAT_INDEFINITELY, null will be returned.getFireTimeAfter
(Date afterTime) Returns the next time at which theSimpleTrigger
will fire, after the given time.Returns the next time at which theTrigger
is scheduled to fire.Returns the previous time at which theSimpleTrigger
fired.int
Get the the number of times theSimpleTrigger
should repeat, after which it will be automatically deleted.long
Get the the time interval (in milliseconds) at which theSimpleTrigger
should repeat.Get the time at which theSimpleTrigger
should occur.int
Get the number of times theSimpleTrigger
has already fired.boolean
Determines whether or not theSimpleTrigger
will occur again.void
setEndTime
(Date endTime) Set the time at which theSimpleTrigger
should quit repeating (and be automatically deleted).void
setNextFireTime
(Date nextFireTime) Set the next time at which theSimpleTrigger
should fire.void
setPreviousFireTime
(Date previousFireTime) Set the previous time at which theSimpleTrigger
fired.void
setRepeatCount
(int repeatCount) Set the the number of time theSimpleTrigger
should repeat, after which it will be automatically deleted.void
setRepeatInterval
(long repeatInterval) Set the the time interval (in milliseconds) at which theSimpleTrigger
should repeat.void
setStartTime
(Date startTime) Set the time at which theSimpleTrigger
should occur.void
setTimesTriggered
(int timesTriggered) Set the number of times theSimpleTrigger
has already fired.toString()
void
Called when the
has decided to 'fire' the trigger (execute the associatedScheduler
Job
), in order to give theTrigger
a chance to update itself for its next triggering (if any).void
Updates theSimpleTrigger
's state based on the MISFIRE_INSTRUCTION_XXX that was selected when theSimpleTrigger
was created.void
validate()
Validates whether the properties of theJobDetail
are valid for submission into aScheduler
.protected boolean
validateMisfireInstruction
(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, setPriority
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Comparable
compareTo
Methods inherited from interface org.quartz.triggers.Trigger
equals, getCalendarName, getDescription, getJobDataMap, getJobName, getMisfireInstruction, getName, getPriority
-
Constructor Details
-
SimpleTriggerImpl
public SimpleTriggerImpl()Create aSimpleTrigger
with no settings.
-
-
Method Details
-
getStartTime
Get the time at which theSimpleTrigger
should occur.- Specified by:
getStartTime
in interfaceTrigger
-
setStartTime
Set the time at which theSimpleTrigger
should occur.- Specified by:
setStartTime
in interfaceMutableTrigger
- Throws:
IllegalArgumentException
- if startTime isnull
.
-
getEndTime
Get the time at which theSimpleTrigger
should quit repeating - even if repeastCount isn't yet satisfied.- Specified by:
getEndTime
in interfaceTrigger
- See Also:
-
setEndTime
Set the time at which theSimpleTrigger
should quit repeating (and be automatically deleted).- Specified by:
setEndTime
in 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:SimpleTrigger
Get the the number of times theSimpleTrigger
should repeat, after which it will be automatically deleted.- Specified by:
getRepeatCount
in interfaceSimpleTrigger
- See Also:
-
setRepeatCount
public void setRepeatCount(int repeatCount) Set the the number of time theSimpleTrigger
should 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:SimpleTrigger
Get the the time interval (in milliseconds) at which theSimpleTrigger
should repeat.- Specified by:
getRepeatInterval
in interfaceSimpleTrigger
-
setRepeatInterval
public void setRepeatInterval(long repeatInterval) Set the the time interval (in milliseconds) at which theSimpleTrigger
should repeat.- Throws:
IllegalArgumentException
- if repeatInterval is invalid input: '<'= 0
-
getTimesTriggered
public int getTimesTriggered()Get the number of times theSimpleTrigger
has already fired.- Specified by:
getTimesTriggered
in interfaceSimpleTrigger
-
setTimesTriggered
public void setTimesTriggered(int timesTriggered) Set the number of times theSimpleTrigger
has already fired. -
validateMisfireInstruction
protected boolean validateMisfireInstruction(int misfireInstruction) - Specified by:
validateMisfireInstruction
in classAbstractTrigger
-
updateAfterMisfire
Updates theSimpleTrigger
's state based on the MISFIRE_INSTRUCTION_XXX that was selected when theSimpleTrigger
was 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_DATE
then the behavior will be identical to- Specified by:
updateAfterMisfire
in interfaceOperableTrigger
- If the Repeat Count is
-
triggered
Called when the
has decided to 'fire' the trigger (execute the associatedScheduler
Job
), in order to give theTrigger
a chance to update itself for its next triggering (if any).- Specified by:
triggered
in interfaceOperableTrigger
- See Also:
-
computeFirstFireTime
Called by the scheduler at the time aTrigger
is first added to the scheduler, in order to have theTrigger
compute its first fire time, based on any associated calendar.After this method has been called,
getNextFireTime()
should return a valid answer.- Specified by:
computeFirstFireTime
in interfaceOperableTrigger
- Returns:
- the first time at which the
Trigger
will 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 theTrigger
is scheduled to fire. If the trigger will not fire again,null
will 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
Trigger
has been added to the scheduler.- Specified by:
getNextFireTime
in interfaceTrigger
- See Also:
-
-
invalid @see
TriggerUtils#computeFireTimesBetween(Trigger, Calendar, Date, Date)
-
-
getPreviousFireTime
Returns the previous time at which theSimpleTrigger
fired. If the trigger has not yet fired,null
will be returned.- Specified by:
getPreviousFireTime
in interfaceTrigger
-
setNextFireTime
Set the next time at which theSimpleTrigger
should fire.This method should not be invoked by client code.
- Specified by:
setNextFireTime
in interfaceOperableTrigger
-
setPreviousFireTime
Set the previous time at which theSimpleTrigger
fired.This method should not be invoked by client code.
- Specified by:
setPreviousFireTime
in interfaceOperableTrigger
-
getFireTimeAfter
Returns the next time at which theSimpleTrigger
will fire, after the given time. If the trigger will not fire after the given time,null
will be returned.- Specified by:
getFireTimeAfter
in interfaceTrigger
-
getFinalFireTime
Returns the final time at which theSimpleTrigger
will fire, if repeatCount is REPEAT_INDEFINITELY, null will be returned.Note that the return time may be in the past.
- Specified by:
getFinalFireTime
in interfaceTrigger
-
mayFireAgain
public boolean mayFireAgain()Determines whether or not theSimpleTrigger
will occur again.- Specified by:
mayFireAgain
in interfaceTrigger
-
validate
Validates whether the properties of theJobDetail
are valid for submission into aScheduler
.- Specified by:
validate
in interfaceOperableTrigger
- Overrides:
validate
in classAbstractTrigger
- Throws:
IllegalStateException
- if a required property (such as Name, Group, Class) is not set.SchedulerException
-
toString
- Overrides:
toString
in classAbstractTrigger
-