Class CronTriggerImpl
- java.lang.Object
-
- org.quartz.impl.triggers.AbstractTrigger<CronTrigger>
-
- org.quartz.impl.triggers.CronTriggerImpl
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,java.lang.Comparable<Trigger>,CronTrigger,CoreTrigger,MutableTrigger,OperableTrigger,Trigger
public class CronTriggerImpl extends AbstractTrigger<CronTrigger> implements CronTrigger, CoreTrigger
A concrete
that is used to fire aTriggerat given moments in time, defined with Unix 'cron-like' definitions.JobDetail- Author:
- Sharada Jambula, James House, Contributions from Mads Henderson
- 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 Modifier and Type Field Description protected static intYEAR_TO_GIVEUP_SCHEDULING_AT-
Fields inherited from interface org.quartz.CronTrigger
MISFIRE_INSTRUCTION_DO_NOTHING, MISFIRE_INSTRUCTION_FIRE_ONCE_NOW
-
Fields inherited from interface org.quartz.Trigger
DEFAULT_PRIORITY, MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICY, MISFIRE_INSTRUCTION_SMART_POLICY
-
-
Constructor Summary
Constructors Constructor Description CronTriggerImpl()Create aCronTriggerwith no settings.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectclone()java.util.DatecomputeFirstFireTime(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.java.lang.StringgetCronExpression()java.util.DategetEndTime()Get the time at which theCronTriggershould quit repeating - even if repeatCount isn't yet satisfied.java.lang.StringgetExpressionSummary()java.util.DategetFinalFireTime()NOT YET IMPLEMENTED: Returns the final time at which theCronTriggerwill fire.java.util.DategetFireTimeAfter(java.util.Date afterTime)Returns the next time at which theCronTriggerwill fire, after the given time.java.util.DategetNextFireTime()Returns the next time at which theTriggeris scheduled to fire.java.util.DategetPreviousFireTime()Returns the previous time at which theCronTriggerfired.ScheduleBuilder<CronTrigger>getScheduleBuilder()Get aScheduleBuilderthat is configured to produce a schedule identical to this trigger's schedule.java.util.DategetStartTime()Get the time at which theCronTriggershould occur.protected java.util.DategetTimeAfter(java.util.Date afterTime)protected java.util.DategetTimeBefore(java.util.Date eTime)NOT YET IMPLEMENTED: Returns the time before the given time that thisCronTriggerwill fire.java.util.TimeZonegetTimeZone()Returns the time zone for which thecronExpressionof thisCronTriggerwill be resolved.booleanhasAdditionalProperties()Used by extensions of CronTrigger to imply that there are additional properties, specifically so that extensions can choose whether to be stored as a serialized blob, or as a flattened CronTrigger table.booleanmayFireAgain()Determines whether or not theCronTriggerwill occur again.voidsetCronExpression(java.lang.String cronExpression)voidsetCronExpression(CronExpression cronExpression)Set the CronExpression to the given one.voidsetEndTime(java.util.Date endTime)Set the time at which theTriggershould quit repeating - regardless of any remaining repeats (based on the trigger's particular repeat settings).voidsetNextFireTime(java.util.Date nextFireTime)Sets the next time at which theCronTriggerwill fire.voidsetPreviousFireTime(java.util.Date previousFireTime)Set the previous time at which theCronTriggerfired.voidsetStartTime(java.util.Date startTime)The time at which the trigger's scheduling should start.voidsetTimeZone(java.util.TimeZone timeZone)Sets the time zone for which thecronExpressionof thisCronTriggerwill be resolved.voidtriggered(Calendar calendar)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).voidupdateAfterMisfire(Calendar cal)Updates theCronTrigger's state based on the MISFIRE_INSTRUCTION_XXX that was selected when theCronTriggerwas created.voidupdateWithNewCalendar(Calendar calendar, long misfireThreshold)This method should not be used by the Quartz client.protected booleanvalidateMisfireInstruction(int misfireInstruction)booleanwillFireOn(java.util.Calendar test)Determines whether the date and (optionally) time of the given Calendar instance falls on a scheduled fire-time of this trigger.booleanwillFireOn(java.util.Calendar test, boolean dayOnly)Determines whether the date and (optionally) time of the given Calendar instance falls on a scheduled fire-time of this trigger.-
Methods inherited from class org.quartz.impl.triggers.AbstractTrigger
compareTo, equals, executionComplete, getCalendarName, getDescription, getFireInstanceId, getFullJobName, getFullName, getGroup, getJobDataMap, getJobGroup, getJobKey, getJobName, getKey, getMisfireInstruction, getName, getPriority, getTriggerBuilder, hashCode, setCalendarName, setDescription, setFireInstanceId, setGroup, setJobDataMap, setJobGroup, setJobKey, setJobName, setKey, setMisfireInstruction, setName, setPriority, toString, validate
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.quartz.CronTrigger
getTriggerBuilder
-
Methods inherited from interface org.quartz.Trigger
compareTo, equals, getCalendarName, getDescription, getJobDataMap, getJobKey, getKey, getMisfireInstruction, getPriority
-
-
-
-
Method Detail
-
clone
public java.lang.Object clone()
- Specified by:
clonein interfaceMutableTrigger- Overrides:
clonein classAbstractTrigger<CronTrigger>
-
setCronExpression
public void setCronExpression(java.lang.String cronExpression) throws java.text.ParseException- Throws:
java.text.ParseException
-
getCronExpression
public java.lang.String getCronExpression()
- Specified by:
getCronExpressionin interfaceCronTrigger
-
setCronExpression
public void setCronExpression(CronExpression cronExpression)
Set the CronExpression to the given one. The TimeZone on the passed-in CronExpression over-rides any that was already set on the Trigger.
-
getStartTime
public java.util.Date getStartTime()
Get the time at which the
CronTriggershould occur.- Specified by:
getStartTimein interfaceTrigger
-
setStartTime
public void setStartTime(java.util.Date startTime)
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
public java.util.Date getEndTime()
Get the time at which the
CronTriggershould quit repeating - even if repeatCount isn't yet satisfied.- Specified by:
getEndTimein interfaceTrigger- See Also:
getFinalFireTime()
-
setEndTime
public void setEndTime(java.util.Date endTime)
Description copied from interface:MutableTriggerSet the time at which the
Triggershould quit repeating - regardless of any remaining repeats (based on the trigger's particular repeat settings).- Specified by:
setEndTimein interfaceMutableTrigger- See Also:
TriggerUtils.computeEndTimeToAllowParticularNumberOfFirings(org.quartz.spi.OperableTrigger, org.quartz.Calendar, int)
-
getNextFireTime
public java.util.Date getNextFireTime()
Returns the next time at which the
Triggeris 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:
TriggerUtils.computeFireTimesBetween(org.quartz.spi.OperableTrigger, org.quartz.Calendar, java.util.Date, java.util.Date)
-
getPreviousFireTime
public java.util.Date getPreviousFireTime()
Returns the previous time at which the
CronTriggerfired. If the trigger has not yet fired,nullwill be returned.- Specified by:
getPreviousFireTimein interfaceTrigger
-
setNextFireTime
public void setNextFireTime(java.util.Date nextFireTime)
Sets the next time at which the
CronTriggerwill fire. This method should not be invoked by client code.- Specified by:
setNextFireTimein interfaceOperableTrigger
-
setPreviousFireTime
public void setPreviousFireTime(java.util.Date previousFireTime)
Set the previous time at which the
CronTriggerfired.This method should not be invoked by client code.
- Specified by:
setPreviousFireTimein interfaceOperableTrigger
-
getTimeZone
public java.util.TimeZone getTimeZone()
Description copied from interface:CronTriggerReturns the time zone for which the
cronExpressionof thisCronTriggerwill be resolved.- Specified by:
getTimeZonein interfaceCronTrigger
-
setTimeZone
public void setTimeZone(java.util.TimeZone timeZone)
Sets the time zone for which the
cronExpressionof thisCronTriggerwill be resolved.If
setCronExpression(CronExpression)is called after this method, the TimeZon 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
public java.util.Date getFireTimeAfter(java.util.Date afterTime)
Returns the next time at which the
CronTriggerwill 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
public java.util.Date getFinalFireTime()
NOT YET IMPLEMENTED: Returns the final time at which the
CronTriggerwill 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 the
CronTriggerwill occur again.- Specified by:
mayFireAgainin interfaceTrigger
-
validateMisfireInstruction
protected boolean validateMisfireInstruction(int misfireInstruction)
- Specified by:
validateMisfireInstructionin classAbstractTrigger<CronTrigger>
-
updateAfterMisfire
public void updateAfterMisfire(Calendar cal)
Updates the
CronTrigger'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
-
willFireOn
public boolean willFireOn(java.util.Calendar test)
Determines whether the date and (optionally) time of the given Calendar instance falls on a scheduled fire-time of this trigger.
Equivalent to calling
willFireOn(cal, false).- Parameters:
test- the date to compare- See Also:
willFireOn(Calendar, boolean)
-
willFireOn
public boolean willFireOn(java.util.Calendar test, boolean dayOnly)Determines whether the date and (optionally) time of the given Calendar instance falls on a scheduled fire-time of this trigger.
Note that the value returned is NOT validated against the related org.quartz.Calendar (if any)
- Parameters:
test- the date to comparedayOnly- if set to true, the method will only determine if the trigger will fire during the day represented by the given Calendar (hours, minutes and seconds will be ignored).- See Also:
willFireOn(Calendar)
-
triggered
public void triggered(Calendar calendar)
Called when the
has 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:
AbstractTrigger.executionComplete(JobExecutionContext, JobExecutionException)
-
updateWithNewCalendar
public void updateWithNewCalendar(Calendar calendar, long misfireThreshold)
Description copied from interface:OperableTriggerThis method should not be used by the Quartz client.
To be implemented by the concrete class.
The implementation should update the
Trigger's state based on the given new version of the associatedCalendar(the state should be updated so that it's next fire time is appropriate given the Calendar's new settings).- Specified by:
updateWithNewCalendarin interfaceOperableTrigger- See Also:
OperableTrigger.updateWithNewCalendar(org.quartz.Calendar, long)
-
computeFirstFireTime
public java.util.Date computeFirstFireTime(Calendar calendar)
Called by the scheduler at the time a
Triggeris 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
public java.lang.String getExpressionSummary()
- Specified by:
getExpressionSummaryin interfaceCronTrigger
-
hasAdditionalProperties
public boolean hasAdditionalProperties()
Used by extensions of CronTrigger to imply that there are additional properties, specifically so that extensions can choose whether to be stored as a serialized blob, or as a flattened CronTrigger table.- Specified by:
hasAdditionalPropertiesin interfaceCoreTrigger
-
getScheduleBuilder
public ScheduleBuilder<CronTrigger> getScheduleBuilder()
Get aScheduleBuilderthat is configured to produce a schedule identical to this trigger's schedule.- Specified by:
getScheduleBuilderin interfaceTrigger- Specified by:
getScheduleBuilderin classAbstractTrigger<CronTrigger>- See Also:
AbstractTrigger.getTriggerBuilder()
-
getTimeAfter
protected java.util.Date getTimeAfter(java.util.Date afterTime)
-
getTimeBefore
protected java.util.Date getTimeBefore(java.util.Date eTime)
NOT YET IMPLEMENTED: Returns the time before the given time that thisCronTriggerwill fire.
-
-