public class CalendarIntervalScheduleBuilder extends Object implements IScheduleBuilder<CalendarIntervalTrigger>
CalendarIntervalScheduleBuilder is a IScheduleBuilder
that defines calendar time (day, week, month, year) interval-based schedules
for Triggers.
Quartz provides a builder-style API for constructing scheduling-related
entities via a Domain-Specific Language (DSL). The DSL can best be utilized
through the usage of static imports of the methods on the classes
TriggerBuilder, JobBuilder,
DateBuilder, JobKey, TriggerKey and
the various ScheduleBuilder implementations.
Client code can then use the DSL to write code such as this:
JobDetail job = newJob (MyJob.class).withIdentity ("myJob").build ();
Trigger trigger = newTrigger ().withIdentity (triggerKey ("myTrigger", "myTriggerGroup"))
.withSchedule (withIntervalInDays (3))
.startAt (futureDate (10, MINUTES))
.build ();
scheduler.scheduleJob (job, trigger);
| Modifier | Constructor and Description |
|---|---|
protected |
CalendarIntervalScheduleBuilder() |
| Modifier and Type | Method and Description |
|---|---|
CalendarIntervalTrigger |
build()
Build the actual Trigger -- NOT intended to be invoked by end users, but
will rather be invoked by a TriggerBuilder which this ScheduleBuilder is
given to.
|
static CalendarIntervalScheduleBuilder |
calendarIntervalSchedule()
Create a CalendarIntervalScheduleBuilder.
|
CalendarIntervalScheduleBuilder |
inTimeZone(TimeZone timezone)
The
TimeZone in which to base the schedule. |
CalendarIntervalScheduleBuilder |
preserveHourOfDayAcrossDaylightSavings(boolean bPreserveHourOfDay)
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.
|
CalendarIntervalScheduleBuilder |
skipDayIfHourDoesNotExist(boolean bSkipDay)
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.
|
CalendarIntervalScheduleBuilder |
withInterval(int timeInterval,
EIntervalUnit unit)
Specify the time unit and interval for the Trigger to be produced.
|
CalendarIntervalScheduleBuilder |
withIntervalInDays(int intervalInDays)
Specify an interval in the IntervalUnit.DAY that the produced Trigger will
repeat at.
|
CalendarIntervalScheduleBuilder |
withIntervalInHours(int intervalInHours)
Specify an interval in the IntervalUnit.HOUR that the produced Trigger will
repeat at.
|
CalendarIntervalScheduleBuilder |
withIntervalInMinutes(int intervalInMinutes)
Specify an interval in the IntervalUnit.MINUTE that the produced Trigger
will repeat at.
|
CalendarIntervalScheduleBuilder |
withIntervalInMonths(int intervalInMonths)
Specify an interval in the IntervalUnit.MONTH that the produced Trigger
will repeat at.
|
CalendarIntervalScheduleBuilder |
withIntervalInSeconds(int intervalInSeconds)
Specify an interval in the IntervalUnit.SECOND that the produced Trigger
will repeat at.
|
CalendarIntervalScheduleBuilder |
withIntervalInWeeks(int intervalInWeeks)
Specify an interval in the IntervalUnit.WEEK that the produced Trigger will
repeat at.
|
CalendarIntervalScheduleBuilder |
withIntervalInYears(int intervalInYears)
Specify an interval in the IntervalUnit.YEAR that the produced Trigger will
repeat at.
|
CalendarIntervalScheduleBuilder |
withMisfireHandlingInstructionDoNothing()
If the Trigger misfires, use the
ITrigger.EMisfireInstruction.MISFIRE_INSTRUCTION_DO_NOTHING instruction. |
CalendarIntervalScheduleBuilder |
withMisfireHandlingInstructionFireAndProceed()
If the Trigger misfires, use the
ITrigger.EMisfireInstruction.MISFIRE_INSTRUCTION_FIRE_ONCE_NOW instruction. |
CalendarIntervalScheduleBuilder |
withMisfireHandlingInstructionIgnoreMisfires()
If the Trigger misfires, use the
ITrigger.EMisfireInstruction.MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICY
instruction. |
@Nonnull public static CalendarIntervalScheduleBuilder calendarIntervalSchedule()
@Nonnull public CalendarIntervalTrigger build()
build in interface IScheduleBuilder<CalendarIntervalTrigger>TriggerBuilder.withSchedule(IScheduleBuilder)@Nonnull public CalendarIntervalScheduleBuilder withInterval(int timeInterval, @Nonnull EIntervalUnit unit)
timeInterval - the interval at which the trigger should repeat.unit - the time unit (IntervalUnit) of the interval.ICalendarIntervalTrigger.getRepeatInterval(),
ICalendarIntervalTrigger.getRepeatIntervalUnit()@Nonnull public CalendarIntervalScheduleBuilder withIntervalInSeconds(int intervalInSeconds)
intervalInSeconds - the number of seconds at which the trigger should repeat.ICalendarIntervalTrigger.getRepeatInterval(),
ICalendarIntervalTrigger.getRepeatIntervalUnit()@Nonnull public CalendarIntervalScheduleBuilder withIntervalInMinutes(int intervalInMinutes)
intervalInMinutes - the number of minutes at which the trigger should repeat.ICalendarIntervalTrigger.getRepeatInterval(),
ICalendarIntervalTrigger.getRepeatIntervalUnit()@Nonnull public CalendarIntervalScheduleBuilder withIntervalInHours(int intervalInHours)
intervalInHours - the number of hours at which the trigger should repeat.ICalendarIntervalTrigger.getRepeatInterval(),
ICalendarIntervalTrigger.getRepeatIntervalUnit()@Nonnull public CalendarIntervalScheduleBuilder withIntervalInDays(int intervalInDays)
intervalInDays - the number of days at which the trigger should repeat.ICalendarIntervalTrigger.getRepeatInterval(),
ICalendarIntervalTrigger.getRepeatIntervalUnit()@Nonnull public CalendarIntervalScheduleBuilder withIntervalInWeeks(int intervalInWeeks)
intervalInWeeks - the number of weeks at which the trigger should repeat.ICalendarIntervalTrigger.getRepeatInterval(),
ICalendarIntervalTrigger.getRepeatIntervalUnit()@Nonnull public CalendarIntervalScheduleBuilder withIntervalInMonths(int intervalInMonths)
intervalInMonths - the number of months at which the trigger should repeat.ICalendarIntervalTrigger.getRepeatInterval(),
ICalendarIntervalTrigger.getRepeatIntervalUnit()@Nonnull public CalendarIntervalScheduleBuilder withIntervalInYears(int intervalInYears)
intervalInYears - the number of years at which the trigger should repeat.ICalendarIntervalTrigger.getRepeatInterval(),
ICalendarIntervalTrigger.getRepeatIntervalUnit()@Nonnull public CalendarIntervalScheduleBuilder withMisfireHandlingInstructionIgnoreMisfires()
ITrigger.EMisfireInstruction.MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICY
instruction.ITrigger.EMisfireInstruction.MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICY@Nonnull public CalendarIntervalScheduleBuilder withMisfireHandlingInstructionDoNothing()
ITrigger.EMisfireInstruction.MISFIRE_INSTRUCTION_DO_NOTHING instruction.ITrigger.EMisfireInstruction.MISFIRE_INSTRUCTION_DO_NOTHING@Nonnull public CalendarIntervalScheduleBuilder withMisfireHandlingInstructionFireAndProceed()
ITrigger.EMisfireInstruction.MISFIRE_INSTRUCTION_FIRE_ONCE_NOW instruction.ITrigger.EMisfireInstruction.MISFIRE_INSTRUCTION_FIRE_ONCE_NOW@Nonnull public CalendarIntervalScheduleBuilder inTimeZone(TimeZone timezone)
TimeZone in which to base the schedule.timezone - the time-zone for the schedule.ICalendarIntervalTrigger.getTimeZone()@Nonnull public CalendarIntervalScheduleBuilder preserveHourOfDayAcrossDaylightSavings(boolean bPreserveHourOfDay)
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.
bPreserveHourOfDay - true to enableskipDayIfHourDoesNotExist(boolean),
inTimeZone(TimeZone),
TriggerBuilder.startAt(java.util.Date)@Nonnull public CalendarIntervalScheduleBuilder skipDayIfHourDoesNotExist(boolean bSkipDay)
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).
bSkipDay - true to enablepreserveHourOfDayAcrossDaylightSavings(boolean)Copyright © 2016–2021 Philip Helger. All rights reserved.