Class CronTriggerImpl
- All Implemented Interfaces:
Serializable,Cloneable,Comparable<Trigger>,CronTrigger,MutableTrigger,OperableTrigger,Trigger
Trigger that is used to fire a
JobDetail at given moments in time, defined with Unix 'cron-like'
definitions.- Author:
- Sharada Jambula, James House, Contributions from Mads Henderson
- 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.CronTrigger
MISFIRE_INSTRUCTION_DO_NOTHING, MISFIRE_INSTRUCTION_FIRE_ONCE_NOWFields 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 TypeMethodDescriptionclone()computeFirstFireTime(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 theCronTriggershould quit repeating - even if repeastCount isn't yet satisfied.NOT YET IMPLEMENTED: Returns the final time at which theCronTriggerwill fire.getFireTimeAfter(Date afterTime) Returns the next time at which theCronTriggerwill fire, after the given time.Returns the next time at which theTriggeris scheduled to fire.Returns the previous time at which theCronTriggerfired.Get the time at which theCronTriggershould occur.Returns the time zone for which thecronExpressionof thisCronTriggerwill be resolved.booleanDetermines whether or not theCronTriggerwill occur again.voidsetCronExpression(String cronExpression) voidsetCronExpression(CronExpression cronExpression) Set the CronExpression to the given one.voidsetEndTime(Date endTime) Set the time at which theTriggershould quit repeating - regardless of any remaining repeats (based on the trigger's particular repeat settings).voidsetNextFireTime(Date nextFireTime) Sets the next time at which theCronTriggerwill fire.voidsetPreviousFireTime(Date previousFireTime) Set the previous time at which theCronTriggerfired.voidsetStartTime(Date startTime) The time at which the trigger's scheduling should start.voidsetTimeZone(TimeZone timeZone) Sets the time zone for which thecronExpressionof thisCronTriggerwill be resolved.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 theCronTrigger's state based on the MISFIRE_INSTRUCTION_XXX that was selected when theCronTriggerwas created.protected booleanvalidateMisfireInstruction(int misfireInstruction) Methods inherited from class org.quartz.triggers.AbstractTrigger
compareTo, equals, executionComplete, getCalendarName, getDescription, getFireInstanceId, getJobDataMap, getJobName, getMisfireInstruction, getName, getPriority, hashCode, setCalendarName, setDescription, setFireInstanceId, setJobDataMap, setJobName, setMisfireInstruction, setName, setPriority, validateMethods 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
-
CronTriggerImpl
public CronTriggerImpl()Create aCronTriggerwith no settings.The start-time will also be set to the current time, and the time zone will be set the the system's default time zone.
-
-
Method Details
-
clone
- Specified by:
clonein interfaceMutableTrigger- Overrides:
clonein classAbstractTrigger
-
setCronExpression
- Throws:
ParseException
-
getCronExpression
- Specified by:
getCronExpressionin interfaceCronTrigger
-
setCronExpression
Set the CronExpression to the given one. The TimeZone on the passed-in CronExpression over-rides any that was already set on the Trigger.- Parameters:
cronExpression-
-
getStartTime
Get the time at which theCronTriggershould occur.- Specified by:
getStartTimein interfaceTrigger
-
setStartTime
Description copied from interface:MutableTriggerThe time at which the trigger's scheduling should start. May or may not be the first actual fire time of the trigger, depending upon the type of trigger and the settings of the other properties of the trigger. However the first actual first time will not be before this date.Setting a value in the past may cause a new trigger to compute a first fire time that is in the past, which may cause an immediate misfire of the trigger.
- Specified by:
setStartTimein interfaceMutableTrigger
-
getEndTime
Get the time at which theCronTriggershould quit repeating - even if repeastCount isn't yet satisfied.- Specified by:
getEndTimein interfaceTrigger- See Also:
-
setEndTime
Description copied from interface:MutableTriggerSet the time at which theTriggershould quit repeating - regardless of any remaining repeats (based on the trigger's particular repeat settings).- Specified by:
setEndTimein interfaceMutableTrigger- See Also:
-
-
invalid @see
TriggerUtils#computeEndTimeToAllowParticularNumberOfFirings(Trigger, Calendar, int)
-
-
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, org.quartz.core.Calendar, Date, Date)
-
-
getPreviousFireTime
Returns the previous time at which theCronTriggerfired. If the trigger has not yet fired,nullwill be returned.- Specified by:
getPreviousFireTimein interfaceTrigger
-
setNextFireTime
Sets the next time at which theCronTriggerwill fire. This method should not be invoked by client code.- Specified by:
setNextFireTimein interfaceOperableTrigger
-
setPreviousFireTime
Set the previous time at which theCronTriggerfired.This method should not be invoked by client code.
- Specified by:
setPreviousFireTimein interfaceOperableTrigger
-
getTimeZone
Description copied from interface:CronTriggerReturns the time zone for which thecronExpressionof thisCronTriggerwill be resolved.- Specified by:
getTimeZonein interfaceCronTrigger
-
setTimeZone
Sets the time zone for which thecronExpressionof thisCronTriggerwill be resolved.If
setCronExpression(CronExpression)is called after this method, the TimeZone setting on the CronExpression will "win". However ifsetCronExpression(String)is called after this method, the time zone applied by this method will remain in effect, since the String cron expression does not carry a time zone! -
getFireTimeAfter
Returns the next time at which theCronTriggerwill fire, after the given time. If the trigger will not fire after the given time,nullwill be returned.Note that the date returned is NOT validated against the related org.quartz.Calendar (if any)
- Specified by:
getFireTimeAfterin interfaceTrigger
-
getFinalFireTime
NOT YET IMPLEMENTED: Returns the final time at which theCronTriggerwill fire.Note that the return time *may* be in the past. and the date returned is not validated against org.quartz.calendar
- Specified by:
getFinalFireTimein interfaceTrigger
-
mayFireAgain
public boolean mayFireAgain()Determines whether or not theCronTriggerwill occur again.- Specified by:
mayFireAgainin interfaceTrigger
-
validateMisfireInstruction
protected boolean validateMisfireInstruction(int misfireInstruction) - Specified by:
validateMisfireInstructionin classAbstractTrigger
-
updateAfterMisfire
Updates theCronTrigger's state based on the MISFIRE_INSTRUCTION_XXX that was selected when theCronTriggerwas created.If the misfire instruction is set to MISFIRE_INSTRUCTION_SMART_POLICY, then the following scheme will be used:
- The instruction will be interpreted as
MISFIRE_INSTRUCTION_FIRE_ONCE_NOW
- Specified by:
updateAfterMisfirein interfaceOperableTrigger
- The instruction will be interpreted as
-
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).
-
getExpressionSummary
- Specified by:
getExpressionSummaryin interfaceCronTrigger
-
toString
- Overrides:
toStringin classAbstractTrigger
-