public class CronTrigger extends AbstractTrigger<CronTrigger> implements ICronTrigger
ITrigger that is used to
fire a IJobDetail at given moments in
time, defined with Unix 'cron-like' definitions.ITrigger.ECompletedExecutionInstruction, ITrigger.EMisfireInstruction, ITrigger.ETriggerState| Modifier and Type | Field and Description |
|---|---|
protected static int |
YEAR_TO_GIVEUP_SCHEDULING_AT |
DEFAULT_PRIORITY| Constructor and Description |
|---|
CronTrigger()
Create a
CronTrigger with no settings. |
CronTrigger(CronTrigger aOther) |
| Modifier and Type | Method and Description |
|---|---|
Date |
computeFirstFireTime(ICalendar 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. |
boolean |
equals(Object o)
Trigger equality is based upon the equality of the TriggerKey.
|
CronTrigger |
getClone() |
String |
getCronExpression() |
Date |
getEndTime()
Get the time at which the
Trigger should quit repeating -
regardless of any remaining repeats (based on the trigger's particular
repeat settings). |
String |
getExpressionSummary() |
Date |
getFinalFireTime()
NOT YET IMPLEMENTED: Returns the final time at which the
CronTrigger will fire. |
Date |
getFireTimeAfter(Date aAfterTime)
Returns the next time at which the
CronTrigger will fire,
after the given time. |
Date |
getNextFireTime()
Returns the next time at which the
Trigger is scheduled to
fire. |
Date |
getPreviousFireTime()
Returns the previous time at which the
Trigger fired. |
IScheduleBuilder<CronTrigger> |
getScheduleBuilder()
Get a
IScheduleBuilder that is configured to produce a schedule
identical to this trigger's schedule. |
Date |
getStartTime()
Get the time at which the
Trigger should occur. |
protected Date |
getTimeAfter(Date afterTime) |
protected Date |
getTimeBefore(Date eTime)
NOT YET IMPLEMENTED: Returns the time before the given time that this
CronTrigger will fire. |
TimeZone |
getTimeZone()
Returns the time zone for which the
cronExpression of this
ICronTrigger will be resolved. |
int |
hashCode() |
boolean |
mayFireAgain()
Determines whether or not the
CronTrigger will occur again. |
void |
setCronExpression(CronExpression cronExpression)
Set the CronExpression to the given one.
|
void |
setCronExpression(String cronExpression) |
void |
setEndTime(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(Date nextFireTime) |
void |
setPreviousFireTime(Date previousFireTime) |
void |
setStartTime(Date startTime)
The time at which the trigger's scheduling should start.
|
void |
setTimeZone(TimeZone timeZone)
Sets the time zone for which the
cronExpression of this
CronTrigger will be resolved. |
void |
triggered(ICalendar 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(ICalendar cal)
Updates the
CronTrigger's state based on the
MISFIRE_INSTRUCTION_XXX that was selected when the CronTrigger
was created. |
void |
updateWithNewCalendar(ICalendar calendar,
long misfireThreshold)
This method should not be used by the Quartz client.
|
protected boolean |
validateMisfireInstruction(ITrigger.EMisfireInstruction misfireInstruction) |
boolean |
willFireOn(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(Calendar aTest,
boolean dayOnly)
Determines whether the date and (optionally) time of the given Calendar
instance falls on a scheduled fire-time of this trigger.
|
compareTo, executionComplete, getCalendarName, getDescription, getFireInstanceId, getFullJobName, getFullName, getGroup, getJobDataMap, getJobGroup, getJobKey, getJobName, getKey, getMisfireInstruction, getName, getPriority, getTriggerBuilder, setCalendarName, setDescription, setFireInstanceId, setGroup, setJobDataMap, setJobGroup, setJobKey, setJobName, setKey, setMisfireInstruction, setName, setPriority, toString, validateclone, finalize, getClass, notify, notifyAll, wait, wait, waitgetTriggerBuildercompareTo, getCalendarName, getDescription, getJobDataMap, getJobKey, getKey, getMisfireInstruction, getPrioritypublic CronTrigger(@Nonnull CronTrigger aOther)
public CronTrigger()
CronTrigger with no settings.@Nullable public String getCronExpression()
getCronExpression in interface ICronTriggerpublic void setCronExpression(@Nonnull String cronExpression) throws ParseException
ParseExceptionpublic void setCronExpression(@Nonnull CronExpression cronExpression)
@Nullable public final Date getStartTime()
ITriggerTrigger should occur.getStartTime in interface ITriggernull depending on the implementationpublic final void setStartTime(@Nonnull Date startTime)
IMutableTriggersetStartTime in interface IMutableTriggerstartTime - start time@Nullable public final Date getEndTime()
ITriggerTrigger should quit repeating -
regardless of any remaining repeats (based on the trigger's particular
repeat settings).getEndTime in interface ITriggernull.ITrigger.getFinalFireTime()public final void setEndTime(@Nullable Date endTime)
IMutableTrigger
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 IMutableTriggerTriggerUtils.computeEndTimeToAllowParticularNumberOfFirings(IOperableTrigger,com.helger.quartz.ICalendar,int)public Date getNextFireTime()
ITriggerTrigger 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 ITriggerTriggerUtils.computeFireTimesBetween(com.helger.quartz.spi.IOperableTrigger,
ICalendar, Date, Date)public void setNextFireTime(Date nextFireTime)
setNextFireTime in interface IOperableTriggerpublic Date getPreviousFireTime()
ITriggerTrigger fired. If the
trigger has not yet fired, null will be returned.getPreviousFireTime in interface ITriggerpublic void setPreviousFireTime(Date previousFireTime)
setPreviousFireTime in interface IOperableTrigger@Nonnull public TimeZone getTimeZone()
ICronTrigger
Returns the time zone for which the cronExpression of this
ICronTrigger will be resolved.
getTimeZone in interface ICronTriggerpublic void setTimeZone(@Nullable TimeZone timeZone)
cronExpression of this
CronTrigger will be resolved.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 Date getFireTimeAfter(@Nullable Date aAfterTime)
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
ICalendar (if any)
getFireTimeAfter in interface ITriggeraAfterTime - after timepublic 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 ICalendar
getFinalFireTime in interface ITriggerpublic boolean mayFireAgain()
CronTrigger will occur again.mayFireAgain in interface ITriggerprotected boolean validateMisfireInstruction(ITrigger.EMisfireInstruction misfireInstruction)
validateMisfireInstruction in class AbstractTrigger<CronTrigger>public void updateAfterMisfire(ICalendar 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_NOWupdateAfterMisfire in interface IOperableTriggerpublic boolean willFireOn(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(Calendar aTest, 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
ICalendar (if any)
aTest - 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(ICalendar calendar)
Called when the has
decided to 'fire' the trigger (execute the associated ISchedulerJob), in
order to give the Trigger a chance to update itself for its
next triggering (if any).
triggered in interface IOperableTriggerAbstractTrigger.executionComplete(com.helger.quartz.IJobExecutionContext,
com.helger.quartz.JobExecutionException)public void updateWithNewCalendar(ICalendar calendar, long misfireThreshold)
IOperableTriggerTrigger'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 IOperableTriggerIOperableTrigger.updateWithNewCalendar(ICalendar, long)public Date computeFirstFireTime(ICalendar 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 IOperableTriggerTrigger will be fired by
the scheduler, which is also the same value
getNextFireTime() will return (until after the first
firing of the Trigger).public String getExpressionSummary()
getExpressionSummary in interface ICronTriggerpublic IScheduleBuilder<CronTrigger> getScheduleBuilder()
IScheduleBuilder that is configured to produce a schedule
identical to this trigger's schedule.getScheduleBuilder in interface ITriggergetScheduleBuilder in class AbstractTrigger<CronTrigger>AbstractTrigger.getTriggerBuilder()@Nullable protected Date getTimeBefore(Date eTime)
CronTrigger will fire.@Nonnull @ReturnsMutableCopy public CronTrigger getClone()
getClone in interface com.helger.commons.lang.ICloneable<CronTrigger>getClone in interface ITriggergetClone in interface IMutableTriggergetClone in interface IOperableTriggerpublic boolean equals(Object o)
AbstractTriggerequals in interface ITriggerequals in class AbstractTrigger<CronTrigger>public int hashCode()
hashCode in class AbstractTrigger<CronTrigger>Copyright © 2016–2021 Philip Helger. All rights reserved.