Class CalendarIntervalScheduleBuilder
- java.lang.Object
-
- org.quartz.ScheduleBuilder<CalendarIntervalTrigger>
-
- org.quartz.CalendarIntervalScheduleBuilder
-
public class CalendarIntervalScheduleBuilder extends ScheduleBuilder<CalendarIntervalTrigger>
CalendarIntervalScheduleBuilderis aScheduleBuilderthat defines calendar time (day, week, month, year) interval-based schedules forTriggers.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,TriggerKeyand the variousScheduleBuilderimplementations.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);
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedCalendarIntervalScheduleBuilder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description MutableTriggerbuild()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 CalendarIntervalScheduleBuildercalendarIntervalSchedule()Create a CalendarIntervalScheduleBuilder.CalendarIntervalScheduleBuilderinTimeZone(java.util.TimeZone timezone)TheTimeZonein which to base the schedule.CalendarIntervalScheduleBuilderpreserveHourOfDayAcrossDaylightSavings(boolean preserveHourOfDay)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.CalendarIntervalScheduleBuilderskipDayIfHourDoesNotExist(boolean skipDay)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.CalendarIntervalScheduleBuilderwithInterval(int timeInterval, DateBuilder.IntervalUnit unit)Specify the time unit and interval for the Trigger to be produced.CalendarIntervalScheduleBuilderwithIntervalInDays(int intervalInDays)Specify an interval in the IntervalUnit.DAY that the produced Trigger will repeat at.CalendarIntervalScheduleBuilderwithIntervalInHours(int intervalInHours)Specify an interval in the IntervalUnit.HOUR that the produced Trigger will repeat at.CalendarIntervalScheduleBuilderwithIntervalInMinutes(int intervalInMinutes)Specify an interval in the IntervalUnit.MINUTE that the produced Trigger will repeat at.CalendarIntervalScheduleBuilderwithIntervalInMonths(int intervalInMonths)Specify an interval in the IntervalUnit.MONTH that the produced Trigger will repeat at.CalendarIntervalScheduleBuilderwithIntervalInSeconds(int intervalInSeconds)Specify an interval in the IntervalUnit.SECOND that the produced Trigger will repeat at.CalendarIntervalScheduleBuilderwithIntervalInWeeks(int intervalInWeeks)Specify an interval in the IntervalUnit.WEEK that the produced Trigger will repeat at.CalendarIntervalScheduleBuilderwithIntervalInYears(int intervalInYears)Specify an interval in the IntervalUnit.YEAR that the produced Trigger will repeat at.CalendarIntervalScheduleBuilderwithMisfireHandlingInstructionDoNothing()If the Trigger misfires, use theCalendarIntervalTrigger.MISFIRE_INSTRUCTION_DO_NOTHINGinstruction.CalendarIntervalScheduleBuilderwithMisfireHandlingInstructionFireAndProceed()If the Trigger misfires, use theCalendarIntervalTrigger.MISFIRE_INSTRUCTION_FIRE_ONCE_NOWinstruction.CalendarIntervalScheduleBuilderwithMisfireHandlingInstructionIgnoreMisfires()If the Trigger misfires, use theTrigger.MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICYinstruction.
-
-
-
Method Detail
-
calendarIntervalSchedule
public static CalendarIntervalScheduleBuilder calendarIntervalSchedule()
Create a CalendarIntervalScheduleBuilder.- Returns:
- the new CalendarIntervalScheduleBuilder
-
build
public MutableTrigger 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.- Specified by:
buildin classScheduleBuilder<CalendarIntervalTrigger>- See Also:
TriggerBuilder.withSchedule(ScheduleBuilder)
-
withInterval
public CalendarIntervalScheduleBuilder withInterval(int timeInterval, DateBuilder.IntervalUnit unit)
Specify the time unit and interval for the Trigger to be produced.- Parameters:
timeInterval- the interval at which the trigger should repeat.unit- the time unit (IntervalUnit) of the interval. Cannot be less than IntervalUnit.SECOND .- Returns:
- the updated CalendarIntervalScheduleBuilder
- Throws:
java.lang.IllegalArgumentException- if unit is null or is IntervalUnit.MILLISECOND- See Also:
CalendarIntervalTrigger.getRepeatInterval(),CalendarIntervalTrigger.getRepeatIntervalUnit()
-
withIntervalInSeconds
public CalendarIntervalScheduleBuilder withIntervalInSeconds(int intervalInSeconds)
Specify an interval in the IntervalUnit.SECOND that the produced Trigger will repeat at.- Parameters:
intervalInSeconds- the number of seconds at which the trigger should repeat.- Returns:
- the updated CalendarIntervalScheduleBuilder
- See Also:
CalendarIntervalTrigger.getRepeatInterval(),CalendarIntervalTrigger.getRepeatIntervalUnit()
-
withIntervalInMinutes
public CalendarIntervalScheduleBuilder withIntervalInMinutes(int intervalInMinutes)
Specify an interval in the IntervalUnit.MINUTE that the produced Trigger will repeat at.- Parameters:
intervalInMinutes- the number of minutes at which the trigger should repeat.- Returns:
- the updated CalendarIntervalScheduleBuilder
- See Also:
CalendarIntervalTrigger.getRepeatInterval(),CalendarIntervalTrigger.getRepeatIntervalUnit()
-
withIntervalInHours
public CalendarIntervalScheduleBuilder withIntervalInHours(int intervalInHours)
Specify an interval in the IntervalUnit.HOUR that the produced Trigger will repeat at.- Parameters:
intervalInHours- the number of hours at which the trigger should repeat.- Returns:
- the updated CalendarIntervalScheduleBuilder
- See Also:
CalendarIntervalTrigger.getRepeatInterval(),CalendarIntervalTrigger.getRepeatIntervalUnit()
-
withIntervalInDays
public CalendarIntervalScheduleBuilder withIntervalInDays(int intervalInDays)
Specify an interval in the IntervalUnit.DAY that the produced Trigger will repeat at.- Parameters:
intervalInDays- the number of days at which the trigger should repeat.- Returns:
- the updated CalendarIntervalScheduleBuilder
- See Also:
CalendarIntervalTrigger.getRepeatInterval(),CalendarIntervalTrigger.getRepeatIntervalUnit()
-
withIntervalInWeeks
public CalendarIntervalScheduleBuilder withIntervalInWeeks(int intervalInWeeks)
Specify an interval in the IntervalUnit.WEEK that the produced Trigger will repeat at.- Parameters:
intervalInWeeks- the number of weeks at which the trigger should repeat.- Returns:
- the updated CalendarIntervalScheduleBuilder
- See Also:
CalendarIntervalTrigger.getRepeatInterval(),CalendarIntervalTrigger.getRepeatIntervalUnit()
-
withIntervalInMonths
public CalendarIntervalScheduleBuilder withIntervalInMonths(int intervalInMonths)
Specify an interval in the IntervalUnit.MONTH that the produced Trigger will repeat at.- Parameters:
intervalInMonths- the number of months at which the trigger should repeat.- Returns:
- the updated CalendarIntervalScheduleBuilder
- See Also:
CalendarIntervalTrigger.getRepeatInterval(),CalendarIntervalTrigger.getRepeatIntervalUnit()
-
withIntervalInYears
public CalendarIntervalScheduleBuilder withIntervalInYears(int intervalInYears)
Specify an interval in the IntervalUnit.YEAR that the produced Trigger will repeat at.- Parameters:
intervalInYears- the number of years at which the trigger should repeat.- Returns:
- the updated CalendarIntervalScheduleBuilder
- See Also:
CalendarIntervalTrigger.getRepeatInterval(),CalendarIntervalTrigger.getRepeatIntervalUnit()
-
withMisfireHandlingInstructionIgnoreMisfires
public CalendarIntervalScheduleBuilder withMisfireHandlingInstructionIgnoreMisfires()
If the Trigger misfires, use theTrigger.MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICYinstruction.- Returns:
- the updated CronScheduleBuilder
- See Also:
Trigger.MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICY
-
withMisfireHandlingInstructionDoNothing
public CalendarIntervalScheduleBuilder withMisfireHandlingInstructionDoNothing()
If the Trigger misfires, use theCalendarIntervalTrigger.MISFIRE_INSTRUCTION_DO_NOTHINGinstruction.- Returns:
- the updated CalendarIntervalScheduleBuilder
- See Also:
CalendarIntervalTrigger.MISFIRE_INSTRUCTION_DO_NOTHING
-
withMisfireHandlingInstructionFireAndProceed
public CalendarIntervalScheduleBuilder withMisfireHandlingInstructionFireAndProceed()
If the Trigger misfires, use theCalendarIntervalTrigger.MISFIRE_INSTRUCTION_FIRE_ONCE_NOWinstruction.- Returns:
- the updated CalendarIntervalScheduleBuilder
- See Also:
CalendarIntervalTrigger.MISFIRE_INSTRUCTION_FIRE_ONCE_NOW
-
inTimeZone
public CalendarIntervalScheduleBuilder inTimeZone(java.util.TimeZone timezone)
TheTimeZonein which to base the schedule.- Parameters:
timezone- the time-zone for the schedule.- Returns:
- the updated CalendarIntervalScheduleBuilder
- See Also:
CalendarIntervalTrigger.getTimeZone()
-
preserveHourOfDayAcrossDaylightSavings
public CalendarIntervalScheduleBuilder preserveHourOfDayAcrossDaylightSavings(boolean preserveHourOfDay)
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. Default value is false.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.
-
skipDayIfHourDoesNotExist
public CalendarIntervalScheduleBuilder skipDayIfHourDoesNotExist(boolean skipDay)
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. Defaults to false.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).
-
-