public class CalendarIntervalTrigger extends AbstractTrigger<CalendarIntervalTrigger> implements ICalendarIntervalTrigger
A concrete that is used to
fire a ITrigger based upon repeating
calendar time intervals.
IJobDetail
The trigger will fire every N (see setRepeatInterval(int) ) units of
calendar time (see setRepeatIntervalUnit(EIntervalUnit)) as
specified in the trigger's definition. This trigger can achieve schedules
that are not possible with ISimpleTrigger (e.g
because months are not a fixed number of seconds) or
ICronTrigger (e.g. because "every 5 months" is not
an even divisor of 12).
If you use an interval unit of MONTH then care should be taken
when setting a startTime value that is on a day near the end of
the month. For example, if you choose a start time that occurs on January
31st, and have a trigger with unit MONTH and interval
1, then the next fire time will be February 28th, and the next
time after that will be March 28th - and essentially each subsequent firing
will occur on the 28th of the month, even if a 31st day exists. If you want a
trigger that always fires on the last day of the month - regardless of the
number of days in the month, you should use CronTrigger.
ITrigger,
ICronTrigger,
ISimpleTrigger,
TriggerUtilsITrigger.ECompletedExecutionInstruction, ITrigger.EMisfireInstruction, ITrigger.ETriggerStateDEFAULT_PRIORITY| Constructor and Description |
|---|
CalendarIntervalTrigger()
Create a
DateIntervalTrigger with no settings. |
CalendarIntervalTrigger(CalendarIntervalTrigger aOther) |
CalendarIntervalTrigger(String name,
Date startTime,
Date endTime,
EIntervalUnit intervalUnit,
int repeatInterval)
Create a
DateIntervalTrigger that will occur at the given
time, and repeat at the the given interval until the given end time. |
CalendarIntervalTrigger(String name,
EIntervalUnit intervalUnit,
int repeatInterval)
Create a
DateIntervalTrigger that will occur immediately, and
repeat at the the given interval. |
CalendarIntervalTrigger(String name,
String group,
Date startTime,
Date endTime,
EIntervalUnit intervalUnit,
int repeatInterval)
Create a
DateIntervalTrigger that will occur at the given
time, and repeat at the the given interval until the given end time. |
CalendarIntervalTrigger(String name,
String group,
EIntervalUnit intervalUnit,
int repeatInterval)
Create a
DateIntervalTrigger that will occur immediately, and
repeat at the the given interval. |
CalendarIntervalTrigger(String name,
String group,
String jobName,
String jobGroup,
Date startTime,
Date endTime,
EIntervalUnit intervalUnit,
int repeatInterval)
Create a
DateIntervalTrigger that will occur at the given
time, fire the identified Job and repeat at the the given
interval until the given end time. |
| 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.
|
CalendarIntervalTrigger |
getClone() |
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). |
Date |
getFinalFireTime()
Returns the final time at which the
DateIntervalTrigger will
fire, if there is no end time set, null will be returned. |
Date |
getFireTimeAfter(Date afterTime)
Returns the next time at which the
DateIntervalTrigger will
fire, after the given time. |
protected Date |
getFireTimeAfter(Date aAfterTime,
boolean ignoreEndTime) |
Date |
getNextFireTime()
Returns the next time at which the
Trigger is scheduled to
fire. |
Date |
getPreviousFireTime()
Returns the previous time at which the
DateIntervalTrigger
fired. |
int |
getRepeatInterval()
Get the the time interval that will be added to the
DateIntervalTrigger's fire time (in the set repeat interval
unit) in order to calculate the time of the next trigger repeat. |
EIntervalUnit |
getRepeatIntervalUnit() |
CalendarIntervalScheduleBuilder |
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. |
int |
getTimesTriggered()
Get the number of times the
DateIntervalTrigger has already
fired. |
TimeZone |
getTimeZone()
Gets the time zone within which time calculations related to this trigger
will be performed.
|
int |
hashCode() |
boolean |
isPreserveHourOfDayAcrossDaylightSavings()
If intervals are a day or greater, this property (set to true) will cause
the firing of the trigger to always occur at the same time of day, (the
time of day of the startTime) regardless of daylight saving time
transitions.
|
boolean |
isSkipDayIfHourDoesNotExist()
If intervals are a day or greater, and
preserveHourOfDayAcrossDaylightSavings property is set to true, and the
hour of the day does not exist on a given day for which the trigger would
fire, the day will be skipped and the trigger advanced a second interval if
this property is set to true.
|
boolean |
mayFireAgain()
Determines whether or not the
DateIntervalTrigger will occur
again. |
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)
Set the next time at which the
DateIntervalTrigger should
fire. |
void |
setPreserveHourOfDayAcrossDaylightSavings(boolean preserveHourOfDayAcrossDaylightSavings) |
void |
setPreviousFireTime(Date previousFireTime)
Set the previous time at which the
DateIntervalTrigger fired. |
void |
setRepeatInterval(int repeatInterval)
set the the time interval that will be added to the
DateIntervalTrigger's fire time (in the set repeat interval
unit) in order to calculate the time of the next trigger repeat. |
void |
setRepeatIntervalUnit(EIntervalUnit intervalUnit)
Set the interval unit - the time unit on with the interval applies.
|
void |
setSkipDayIfHourDoesNotExist(boolean skipDayIfHourDoesNotExist) |
void |
setStartTime(Date startTime)
The time at which the trigger's scheduling should start.
|
void |
setTimesTriggered(int timesTriggered)
Set the number of times the
DateIntervalTrigger has already
fired. |
void |
setTimeZone(TimeZone timeZone)
Sets the time zone within which time calculations related to this trigger
will be performed.
|
void |
triggered(ICalendar calendar)
Called when the
Scheduler 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
DateIntervalTrigger's state based on the
MISFIRE_INSTRUCTION_XXX that was selected when the
DateIntervalTrigger was created. |
void |
updateWithNewCalendar(ICalendar calendar,
long misfireThreshold)
This method should not be used by the Quartz client.
|
void |
validate()
Validates whether the properties of the
JobDetail are valid
for submission into a Scheduler. |
protected boolean |
validateMisfireInstruction(ITrigger.EMisfireInstruction misfireInstruction) |
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, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitgetTriggerBuildercompareTo, getCalendarName, getDescription, getJobDataMap, getJobKey, getKey, getMisfireInstruction, getPrioritypublic CalendarIntervalTrigger(@Nonnull CalendarIntervalTrigger aOther)
public CalendarIntervalTrigger()
DateIntervalTrigger with no settings.public CalendarIntervalTrigger(String name, EIntervalUnit intervalUnit, int repeatInterval)
DateIntervalTrigger that will occur immediately, and
repeat at the the given interval.public CalendarIntervalTrigger(String name, String group, EIntervalUnit intervalUnit, int repeatInterval)
Create a DateIntervalTrigger that will occur immediately, and
repeat at the the given interval.
public CalendarIntervalTrigger(String name, Date startTime, Date endTime, EIntervalUnit intervalUnit, int repeatInterval)
Create a DateIntervalTrigger that will occur at the given
time, and repeat at the the given interval until the given end time.
startTime - A Date set to the time for the Trigger to
fire.endTime - A Date set to the time for the Trigger to
quit repeat firing.intervalUnit - The repeat interval unit (minutes, days, months, etc).repeatInterval - The number of milliseconds to pause between the repeat firing.public CalendarIntervalTrigger(String name, String group, Date startTime, Date endTime, EIntervalUnit intervalUnit, int repeatInterval)
Create a DateIntervalTrigger that will occur at the given
time, and repeat at the the given interval until the given end time.
startTime - A Date set to the time for the Trigger to
fire.endTime - A Date set to the time for the Trigger to
quit repeat firing.intervalUnit - The repeat interval unit (minutes, days, months, etc).repeatInterval - The number of milliseconds to pause between the repeat firing.public CalendarIntervalTrigger(String name, String group, String jobName, String jobGroup, Date startTime, Date endTime, EIntervalUnit intervalUnit, int repeatInterval)
Create a DateIntervalTrigger that will occur at the given
time, fire the identified Job and repeat at the the given
interval until the given end time.
startTime - A Date set to the time for the Trigger to
fire.endTime - A Date set to the time for the Trigger to
quit repeat firing.intervalUnit - The repeat interval unit (minutes, days, months, etc).repeatInterval - The number of milliseconds to pause between the repeat firing.public final Date getStartTime()
ITriggerTrigger should occur.getStartTime in interface ITriggernull depending on the implementationpublic final void setStartTime(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 EIntervalUnit getRepeatIntervalUnit()
getRepeatIntervalUnit in interface ICalendarIntervalTriggerpublic void setRepeatIntervalUnit(EIntervalUnit intervalUnit)
Set the interval unit - the time unit on with the interval applies.
public int getRepeatInterval()
ICalendarIntervalTrigger
Get the the time interval that will be added to the
DateIntervalTrigger's fire time (in the set repeat interval
unit) in order to calculate the time of the next trigger repeat.
getRepeatInterval in interface ICalendarIntervalTriggerpublic void setRepeatInterval(int repeatInterval)
set the the time interval that will be added to the
DateIntervalTrigger's fire time (in the set repeat interval
unit) in order to calculate the time of the next trigger repeat.
IllegalArgumentException - if repeatInterval is < 0public TimeZone getTimeZone()
ICalendarIntervalTriggerGets the time zone within which time calculations related to this trigger will be performed.
If null, the system default TimeZone will be used.
getTimeZone in interface ICalendarIntervalTriggerpublic void setTimeZone(TimeZone timeZone)
Sets the time zone within which time calculations related to this trigger will be performed.
timeZone - the desired TimeZone, or null for the system default.public boolean isPreserveHourOfDayAcrossDaylightSavings()
For example, without the property set, your trigger may have a start time of 9:00 am on March 1st, and a repeat interval of 2 days. But after the daylight saving transition occurs, the trigger may start firing at 8:00 am every other day.
If however, the time of day does not exist on a given day to fire (e.g. 2:00 am in the United States on the days of daylight saving transition), the trigger will go ahead and fire one hour off on that day, and then resume the normal hour on other days. If you wish for the trigger to never fire at the "wrong" hour, then you should set the property skipDayIfHourDoesNotExist.
isPreserveHourOfDayAcrossDaylightSavings in interface ICalendarIntervalTriggerisSkipDayIfHourDoesNotExist(),
getStartTime(),
getTimeZone()public void setPreserveHourOfDayAcrossDaylightSavings(boolean preserveHourOfDayAcrossDaylightSavings)
public boolean isSkipDayIfHourDoesNotExist()
CAUTION! If you enable this property, and your hour of day happens to be that of daylight savings transition (e.g. 2:00 am in the United States) and the trigger's interval would have had the trigger fire on that day, then you may actually completely miss a firing on the day of transition if that hour of day does not exist on that day! In such a case the next fire time of the trigger will be computed as double (if the interval is 2 days, then a span of 4 days between firings will occur).
isSkipDayIfHourDoesNotExist in interface ICalendarIntervalTriggerisPreserveHourOfDayAcrossDaylightSavings()public void setSkipDayIfHourDoesNotExist(boolean skipDayIfHourDoesNotExist)
public int getTimesTriggered()
ICalendarIntervalTrigger
Get the number of times the DateIntervalTrigger has already
fired.
getTimesTriggered in interface ICalendarIntervalTriggerpublic void setTimesTriggered(int timesTriggered)
Set the number of times the DateIntervalTrigger has already
fired.
protected boolean validateMisfireInstruction(ITrigger.EMisfireInstruction misfireInstruction)
validateMisfireInstruction in class AbstractTrigger<CalendarIntervalTrigger>public void updateAfterMisfire(ICalendar cal)
Updates the DateIntervalTrigger's state based on the
MISFIRE_INSTRUCTION_XXX that was selected when the
DateIntervalTrigger 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 void triggered(ICalendar calendar)
Scheduler 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).triggered in interface IOperableTriggerAbstractTrigger.executionComplete(IJobExecutionContext, 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(com.helger.quartz.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 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 ITriggerTriggerUtils.computeFireTimesBetween(com.helger.quartz.spi.IOperableTrigger,
ICalendar, Date, Date)public Date getPreviousFireTime()
Returns the previous time at which the DateIntervalTrigger
fired. If the trigger has not yet fired, null will be
returned.
getPreviousFireTime in interface ITriggerpublic void setNextFireTime(Date nextFireTime)
Set the next time at which the DateIntervalTrigger should
fire.
This method should not be invoked by client code.
setNextFireTime in interface IOperableTriggerpublic void setPreviousFireTime(Date previousFireTime)
Set the previous time at which the DateIntervalTrigger fired.
This method should not be invoked by client code.
setPreviousFireTime in interface IOperableTriggerpublic Date getFireTimeAfter(Date afterTime)
Returns the next time at which the DateIntervalTrigger will
fire, after the given time. If the trigger will not fire after the given
time, null will be returned.
getFireTimeAfter in interface ITriggerpublic Date getFinalFireTime()
Returns the final time at which the DateIntervalTrigger will
fire, if there is no end time set, null will be returned.
Note that the return time may be in the past.
getFinalFireTime in interface ITriggerpublic boolean mayFireAgain()
Determines whether or not the DateIntervalTrigger will occur
again.
mayFireAgain in interface ITriggerpublic void validate()
throws SchedulerException
Validates whether the properties of the JobDetail are valid
for submission into a Scheduler.
validate in interface IOperableTriggervalidate in class AbstractTrigger<CalendarIntervalTrigger>IllegalStateException - if a required property (such as Name, Group, Class) is not set.SchedulerExceptionpublic CalendarIntervalScheduleBuilder getScheduleBuilder()
IScheduleBuilder that is configured to
produce a schedule identical to this trigger's schedule.getScheduleBuilder in interface ITriggergetScheduleBuilder in class AbstractTrigger<CalendarIntervalTrigger>AbstractTrigger.getTriggerBuilder()@Nonnull @ReturnsMutableCopy public CalendarIntervalTrigger getClone()
getClone in interface com.helger.commons.lang.ICloneable<CalendarIntervalTrigger>getClone in interface ITriggergetClone in interface IMutableTriggergetClone in interface IOperableTriggerpublic boolean equals(Object o)
AbstractTriggerequals in interface ITriggerequals in class AbstractTrigger<CalendarIntervalTrigger>public int hashCode()
hashCode in class AbstractTrigger<CalendarIntervalTrigger>Copyright © 2016–2021 Philip Helger. All rights reserved.