public class CronTriggerImpl extends AbstractTrigger<CronTrigger> implements CronTrigger, CoreTrigger
A concrete that is used to fire a Trigger
at given moments in time, defined with Unix 'cron-like' definitions.
JobDetail
Trigger.CompletedExecutionInstruction, Trigger.TriggerState, Trigger.TriggerTimeComparator| Modifier and Type | Field and Description |
|---|---|
protected static int |
YEAR_TO_GIVEUP_SCHEDULING_AT |
MISFIRE_INSTRUCTION_DO_NOTHING, MISFIRE_INSTRUCTION_FIRE_ONCE_NOWDEFAULT_PRIORITY, MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICY, MISFIRE_INSTRUCTION_SMART_POLICY| Constructor and Description |
|---|
CronTriggerImpl()
Create a
CronTrigger with no settings. |
| Modifier and Type | Method and Description |
|---|---|
java.lang.Object |
clone() |
java.util.Date |
computeFirstFireTime(Calendar calendar)
Called by the scheduler at the time a
Trigger is first
added to the scheduler, in order to have the Trigger
compute its first fire time, based on any associated calendar. |
java.lang.String |
getCronExpression() |
java.util.Date |
getEndTime()
Get the time at which the
CronTrigger should quit
repeating - even if repeatCount isn't yet satisfied. |
java.lang.String |
getExpressionSummary() |
java.util.Date |
getFinalFireTime()
NOT YET IMPLEMENTED: Returns the final time at which the
CronTrigger will fire. |
java.util.Date |
getFireTimeAfter(java.util.Date afterTime)
Returns the next time at which the
CronTrigger will fire,
after the given time. |
java.util.Date |
getNextFireTime()
Returns the next time at which the
Trigger is scheduled to fire. |
java.util.Date |
getPreviousFireTime()
Returns the previous time at which the
CronTrigger
fired. |
ScheduleBuilder<CronTrigger> |
getScheduleBuilder()
Get a
ScheduleBuilder that is configured to produce a
schedule identical to this trigger's schedule. |
java.util.Date |
getStartTime()
Get the time at which the
CronTrigger should occur. |
protected java.util.Date |
getTimeAfter(java.util.Date afterTime) |
protected java.util.Date |
getTimeBefore(java.util.Date eTime)
NOT YET IMPLEMENTED: Returns the time before the given time
that this
CronTrigger will fire. |
java.util.TimeZone |
getTimeZone()
Returns the time zone for which the
cronExpression of
this CronTrigger will be resolved. |
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.
|
boolean |
mayFireAgain()
Determines whether or not the
CronTrigger will occur
again. |
void |
setCronExpression(CronExpression cronExpression)
Set the CronExpression to the given one.
|
void |
setCronExpression(java.lang.String cronExpression) |
void |
setEndTime(java.util.Date endTime)
Set the time at which the
Trigger should quit repeating -
regardless of any remaining repeats (based on the trigger's particular
repeat settings). |
void |
setNextFireTime(java.util.Date nextFireTime)
Sets the next time at which the
CronTrigger will fire. |
void |
setPreviousFireTime(java.util.Date previousFireTime)
Set the previous time at which the
CronTrigger fired. |
void |
setStartTime(java.util.Date startTime)
The time at which the trigger's scheduling should start.
|
void |
setTimeZone(java.util.TimeZone timeZone)
Sets the time zone for which the
cronExpression of this
CronTrigger will be resolved. |
void |
triggered(Calendar calendar)
Called when the
has decided to 'fire'
the trigger (execute the associated Job), in order to
give the Trigger a chance to update itself for its next
triggering (if any). |
void |
updateAfterMisfire(Calendar cal)
Updates the
CronTrigger's state based on the
MISFIRE_INSTRUCTION_XXX that was selected when the CronTrigger
was created. |
void |
updateWithNewCalendar(Calendar calendar,
long misfireThreshold)
This method should not be used by the Quartz client.
|
protected boolean |
validateMisfireInstruction(int misfireInstruction) |
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.
|
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.
|
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, validatefinalize, getClass, notify, notifyAll, wait, wait, waitgetTriggerBuildercompareTo, equals, getCalendarName, getDescription, getJobDataMap, getJobKey, getKey, getMisfireInstruction, getPrioritypublic CronTriggerImpl()
Create a CronTrigger with no settings.
The start-time will also be set to the current time, and the time zone will be set the system's default time zone.
public java.lang.Object clone()
clone in interface MutableTriggerclone in class AbstractTrigger<CronTrigger>public void setCronExpression(java.lang.String cronExpression)
throws java.text.ParseException
java.text.ParseExceptionpublic java.lang.String getCronExpression()
getCronExpression in interface CronTriggerpublic void setCronExpression(CronExpression cronExpression)
public java.util.Date getStartTime()
Get the time at which the CronTrigger should occur.
getStartTime in interface Triggerpublic void setStartTime(java.util.Date startTime)
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.
setStartTime in interface MutableTriggerpublic java.util.Date getEndTime()
Get the time at which the CronTrigger should quit
repeating - even if repeatCount isn't yet satisfied.
getEndTime in interface TriggergetFinalFireTime()public void setEndTime(java.util.Date endTime)
MutableTrigger
Set the time at which the Trigger should quit repeating -
regardless of any remaining repeats (based on the trigger's particular
repeat settings).
setEndTime in interface MutableTriggerTriggerUtils.computeEndTimeToAllowParticularNumberOfFirings(org.quartz.spi.OperableTrigger, org.quartz.Calendar, int)public java.util.Date getNextFireTime()
Returns the next time at which the Trigger 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.
getNextFireTime in interface TriggerTriggerUtils.computeFireTimesBetween(org.quartz.spi.OperableTrigger, org.quartz.Calendar, java.util.Date, java.util.Date)public java.util.Date getPreviousFireTime()
Returns the previous time at which the CronTrigger
fired. If the trigger has not yet fired, null will be
returned.
getPreviousFireTime in interface Triggerpublic void setNextFireTime(java.util.Date nextFireTime)
Sets the next time at which the CronTrigger will fire.
This method should not be invoked by client code.
setNextFireTime in interface OperableTriggerpublic void setPreviousFireTime(java.util.Date previousFireTime)
Set the previous time at which the CronTrigger fired.
This method should not be invoked by client code.
setPreviousFireTime in interface OperableTriggerpublic java.util.TimeZone getTimeZone()
CronTrigger
Returns the time zone for which the cronExpression of
this CronTrigger will be resolved.
getTimeZone in interface CronTriggerpublic void setTimeZone(java.util.TimeZone timeZone)
Sets the time zone for which the cronExpression of this
CronTrigger will be resolved.
If setCronExpression(CronExpression) is called after this
method, the TimeZon setting on the CronExpression will "win". However
if setCronExpression(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!
public java.util.Date getFireTimeAfter(java.util.Date afterTime)
Returns the next time at which the CronTrigger will fire,
after the given time. If the trigger will not fire after the given time,
null will be returned.
Note that the date returned is NOT validated against the related org.quartz.Calendar (if any)
getFireTimeAfter in interface Triggerpublic java.util.Date getFinalFireTime()
NOT YET IMPLEMENTED: Returns the final time at which the
CronTrigger will fire.
Note that the return time *may* be in the past. and the date returned is not validated against org.quartz.calendar
getFinalFireTime in interface Triggerpublic boolean mayFireAgain()
Determines whether or not the CronTrigger will occur
again.
mayFireAgain in interface Triggerprotected boolean validateMisfireInstruction(int misfireInstruction)
validateMisfireInstruction in class AbstractTrigger<CronTrigger>public void updateAfterMisfire(Calendar cal)
Updates the CronTrigger's state based on the
MISFIRE_INSTRUCTION_XXX that was selected when the CronTrigger
was created.
If the misfire instruction is set to MISFIRE_INSTRUCTION_SMART_POLICY, then the following scheme will be used:
MISFIRE_INSTRUCTION_FIRE_ONCE_NOW
updateAfterMisfire in interface OperableTriggerpublic 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).
test - the date to comparewillFireOn(Calendar, boolean)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)
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).willFireOn(Calendar)public void triggered(Calendar calendar)
Called when the has decided to 'fire'
the trigger (execute the associated SchedulerJob), in order to
give the Trigger a chance to update itself for its next
triggering (if any).
triggered in interface OperableTriggerAbstractTrigger.executionComplete(JobExecutionContext, JobExecutionException)public void updateWithNewCalendar(Calendar calendar, long misfireThreshold)
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 associated Calendar
(the state should be updated so that it's next fire time is appropriate
given the Calendar's new settings).
updateWithNewCalendar in interface OperableTriggerOperableTrigger.updateWithNewCalendar(org.quartz.Calendar, long)public java.util.Date computeFirstFireTime(Calendar calendar)
Called by the scheduler at the time a Trigger is first
added to the scheduler, in order to have the Trigger
compute its first fire time, based on any associated calendar.
After this method has been called, getNextFireTime()
should return a valid answer.
computeFirstFireTime in interface OperableTriggerTrigger will be fired
by the scheduler, which is also the same value getNextFireTime()
will return (until after the first firing of the Trigger).public java.lang.String getExpressionSummary()
getExpressionSummary in interface CronTriggerpublic boolean hasAdditionalProperties()
hasAdditionalProperties in interface CoreTriggerpublic ScheduleBuilder<CronTrigger> getScheduleBuilder()
ScheduleBuilder that is configured to produce a
schedule identical to this trigger's schedule.getScheduleBuilder in interface TriggergetScheduleBuilder in class AbstractTrigger<CronTrigger>AbstractTrigger.getTriggerBuilder()protected java.util.Date getTimeAfter(java.util.Date afterTime)
protected java.util.Date getTimeBefore(java.util.Date eTime)
CronTrigger will fire.Copyright IBM Corp. 2024, 2025