Package org.quartz
Class SimpleScheduleBuilder
- java.lang.Object
-
- org.quartz.ScheduleBuilder<SimpleTrigger>
-
- org.quartz.SimpleScheduleBuilder
-
public class SimpleScheduleBuilder extends ScheduleBuilder<SimpleTrigger>
SimpleScheduleBuilderis aScheduleBuilderthat defines strict/literal 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(simpleSchedule() .withIntervalInHours(1) .repeatForever()) .startAt(futureDate(10, MINUTES)) .build(); scheduler.scheduleJob(job, trigger);
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedSimpleScheduleBuilder()
-
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.SimpleScheduleBuilderrepeatForever()Specify that the trigger will repeat indefinitely.static SimpleScheduleBuilderrepeatHourlyForever()Create a SimpleScheduleBuilder set to repeat forever with a 1 hour interval.static SimpleScheduleBuilderrepeatHourlyForever(int hours)Create a SimpleScheduleBuilder set to repeat forever with an interval of the given number of hours.static SimpleScheduleBuilderrepeatHourlyForTotalCount(int count)Create a SimpleScheduleBuilder set to repeat the given number of times - 1 with a 1 hour interval.static SimpleScheduleBuilderrepeatHourlyForTotalCount(int count, int hours)Create a SimpleScheduleBuilder set to repeat the given number of times - 1 with an interval of the given number of hours.static SimpleScheduleBuilderrepeatMinutelyForever()Create a SimpleScheduleBuilder set to repeat forever with a 1 minute interval.static SimpleScheduleBuilderrepeatMinutelyForever(int minutes)Create a SimpleScheduleBuilder set to repeat forever with an interval of the given number of minutes.static SimpleScheduleBuilderrepeatMinutelyForTotalCount(int count)Create a SimpleScheduleBuilder set to repeat the given number of times - 1 with a 1 minute interval.static SimpleScheduleBuilderrepeatMinutelyForTotalCount(int count, int minutes)Create a SimpleScheduleBuilder set to repeat the given number of times - 1 with an interval of the given number of minutes.static SimpleScheduleBuilderrepeatSecondlyForever()Create a SimpleScheduleBuilder set to repeat forever with a 1 second interval.static SimpleScheduleBuilderrepeatSecondlyForever(int seconds)Create a SimpleScheduleBuilder set to repeat forever with an interval of the given number of seconds.static SimpleScheduleBuilderrepeatSecondlyForTotalCount(int count)Create a SimpleScheduleBuilder set to repeat the given number of times - 1 with a 1 second interval.static SimpleScheduleBuilderrepeatSecondlyForTotalCount(int count, int seconds)Create a SimpleScheduleBuilder set to repeat the given number of times - 1 with an interval of the given number of seconds.static SimpleScheduleBuildersimpleSchedule()Create a SimpleScheduleBuilder.SimpleScheduleBuilderwithIntervalInHours(int intervalInHours)Specify a repeat interval in minutes - which will then be multiplied by 60 * 60 * 1000 to produce milliseconds.SimpleScheduleBuilderwithIntervalInMilliseconds(long intervalInMillis)Specify a repeat interval in milliseconds.SimpleScheduleBuilderwithIntervalInMinutes(int intervalInMinutes)Specify a repeat interval in minutes - which will then be multiplied by 60 * 1000 to produce milliseconds.SimpleScheduleBuilderwithIntervalInSeconds(int intervalInSeconds)Specify a repeat interval in seconds - which will then be multiplied by 1000 to produce milliseconds.SimpleScheduleBuilderwithMisfireHandlingInstructionFireNow()If the Trigger misfires, use theSimpleTrigger.MISFIRE_INSTRUCTION_FIRE_NOWinstruction.SimpleScheduleBuilderwithMisfireHandlingInstructionIgnoreMisfires()If the Trigger misfires, use theTrigger.MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICYinstruction.SimpleScheduleBuilderwithMisfireHandlingInstructionNextWithExistingCount()If the Trigger misfires, use theSimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_EXISTING_COUNTinstruction.SimpleScheduleBuilderwithMisfireHandlingInstructionNextWithRemainingCount()If the Trigger misfires, use theSimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_REMAINING_COUNTinstruction.SimpleScheduleBuilderwithMisfireHandlingInstructionNowWithExistingCount()If the Trigger misfires, use theSimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_EXISTING_REPEAT_COUNTinstruction.SimpleScheduleBuilderwithMisfireHandlingInstructionNowWithRemainingCount()If the Trigger misfires, use theSimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_REMAINING_REPEAT_COUNTinstruction.SimpleScheduleBuilderwithRepeatCount(int triggerRepeatCount)Specify the number of times the trigger will repeat - the total number of firings will be this number + 1.
-
-
-
Method Detail
-
simpleSchedule
public static SimpleScheduleBuilder simpleSchedule()
Create a SimpleScheduleBuilder.- Returns:
- the new SimpleScheduleBuilder
-
repeatMinutelyForever
public static SimpleScheduleBuilder repeatMinutelyForever()
Create a SimpleScheduleBuilder set to repeat forever with a 1 minute interval.- Returns:
- the new SimpleScheduleBuilder
-
repeatMinutelyForever
public static SimpleScheduleBuilder repeatMinutelyForever(int minutes)
Create a SimpleScheduleBuilder set to repeat forever with an interval of the given number of minutes.- Returns:
- the new SimpleScheduleBuilder
-
repeatSecondlyForever
public static SimpleScheduleBuilder repeatSecondlyForever()
Create a SimpleScheduleBuilder set to repeat forever with a 1 second interval.- Returns:
- the new SimpleScheduleBuilder
-
repeatSecondlyForever
public static SimpleScheduleBuilder repeatSecondlyForever(int seconds)
Create a SimpleScheduleBuilder set to repeat forever with an interval of the given number of seconds.- Returns:
- the new SimpleScheduleBuilder
-
repeatHourlyForever
public static SimpleScheduleBuilder repeatHourlyForever()
Create a SimpleScheduleBuilder set to repeat forever with a 1 hour interval.- Returns:
- the new SimpleScheduleBuilder
-
repeatHourlyForever
public static SimpleScheduleBuilder repeatHourlyForever(int hours)
Create a SimpleScheduleBuilder set to repeat forever with an interval of the given number of hours.- Returns:
- the new SimpleScheduleBuilder
-
repeatMinutelyForTotalCount
public static SimpleScheduleBuilder repeatMinutelyForTotalCount(int count)
Create a SimpleScheduleBuilder set to repeat the given number of times - 1 with a 1 minute interval.Note: Total count = 1 (at start time) + repeat count
- Returns:
- the new SimpleScheduleBuilder
-
repeatMinutelyForTotalCount
public static SimpleScheduleBuilder repeatMinutelyForTotalCount(int count, int minutes)
Create a SimpleScheduleBuilder set to repeat the given number of times - 1 with an interval of the given number of minutes.Note: Total count = 1 (at start time) + repeat count
- Returns:
- the new SimpleScheduleBuilder
-
repeatSecondlyForTotalCount
public static SimpleScheduleBuilder repeatSecondlyForTotalCount(int count)
Create a SimpleScheduleBuilder set to repeat the given number of times - 1 with a 1 second interval.Note: Total count = 1 (at start time) + repeat count
- Returns:
- the new SimpleScheduleBuilder
-
repeatSecondlyForTotalCount
public static SimpleScheduleBuilder repeatSecondlyForTotalCount(int count, int seconds)
Create a SimpleScheduleBuilder set to repeat the given number of times - 1 with an interval of the given number of seconds.Note: Total count = 1 (at start time) + repeat count
- Returns:
- the new SimpleScheduleBuilder
-
repeatHourlyForTotalCount
public static SimpleScheduleBuilder repeatHourlyForTotalCount(int count)
Create a SimpleScheduleBuilder set to repeat the given number of times - 1 with a 1 hour interval.Note: Total count = 1 (at start time) + repeat count
- Returns:
- the new SimpleScheduleBuilder
-
repeatHourlyForTotalCount
public static SimpleScheduleBuilder repeatHourlyForTotalCount(int count, int hours)
Create a SimpleScheduleBuilder set to repeat the given number of times - 1 with an interval of the given number of hours.Note: Total count = 1 (at start time) + repeat count
- Returns:
- the new SimpleScheduleBuilder
-
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<SimpleTrigger>- See Also:
TriggerBuilder.withSchedule(ScheduleBuilder)
-
withIntervalInMilliseconds
public SimpleScheduleBuilder withIntervalInMilliseconds(long intervalInMillis)
Specify a repeat interval in milliseconds.- Parameters:
intervalInMillis- the number of seconds at which the trigger should repeat.- Returns:
- the updated SimpleScheduleBuilder
- See Also:
SimpleTrigger.getRepeatInterval(),withRepeatCount(int)
-
withIntervalInSeconds
public SimpleScheduleBuilder withIntervalInSeconds(int intervalInSeconds)
Specify a repeat interval in seconds - which will then be multiplied by 1000 to produce milliseconds.- Parameters:
intervalInSeconds- the number of seconds at which the trigger should repeat.- Returns:
- the updated SimpleScheduleBuilder
- See Also:
SimpleTrigger.getRepeatInterval(),withRepeatCount(int)
-
withIntervalInMinutes
public SimpleScheduleBuilder withIntervalInMinutes(int intervalInMinutes)
Specify a repeat interval in minutes - which will then be multiplied by 60 * 1000 to produce milliseconds.- Parameters:
intervalInMinutes- the number of seconds at which the trigger should repeat.- Returns:
- the updated SimpleScheduleBuilder
- See Also:
SimpleTrigger.getRepeatInterval(),withRepeatCount(int)
-
withIntervalInHours
public SimpleScheduleBuilder withIntervalInHours(int intervalInHours)
Specify a repeat interval in minutes - which will then be multiplied by 60 * 60 * 1000 to produce milliseconds.- Parameters:
intervalInHours- the number of seconds at which the trigger should repeat.- Returns:
- the updated SimpleScheduleBuilder
- See Also:
SimpleTrigger.getRepeatInterval(),withRepeatCount(int)
-
withRepeatCount
public SimpleScheduleBuilder withRepeatCount(int triggerRepeatCount)
Specify the number of times the trigger will repeat - the total number of firings will be this number + 1.- Parameters:
triggerRepeatCount- the number of times the trigger should repeat after the initial firing.- Returns:
- the updated SimpleScheduleBuilder
- See Also:
SimpleTrigger.getRepeatCount(),repeatForever()
-
repeatForever
public SimpleScheduleBuilder repeatForever()
Specify that the trigger will repeat indefinitely.- Returns:
- the updated SimpleScheduleBuilder
- See Also:
SimpleTrigger.getRepeatCount(),SimpleTrigger.REPEAT_INDEFINITELY,withIntervalInMilliseconds(long),withIntervalInSeconds(int),withIntervalInMinutes(int),withIntervalInHours(int)
-
withMisfireHandlingInstructionIgnoreMisfires
public SimpleScheduleBuilder withMisfireHandlingInstructionIgnoreMisfires()
If the Trigger misfires, use theTrigger.MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICYinstruction.- Returns:
- the updated SimpleScheduleBuilder
- See Also:
Trigger.MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICY
-
withMisfireHandlingInstructionFireNow
public SimpleScheduleBuilder withMisfireHandlingInstructionFireNow()
If the Trigger misfires, use theSimpleTrigger.MISFIRE_INSTRUCTION_FIRE_NOWinstruction.- Returns:
- the updated SimpleScheduleBuilder
- See Also:
SimpleTrigger.MISFIRE_INSTRUCTION_FIRE_NOW
-
withMisfireHandlingInstructionNextWithExistingCount
public SimpleScheduleBuilder withMisfireHandlingInstructionNextWithExistingCount()
If the Trigger misfires, use theSimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_EXISTING_COUNTinstruction.- Returns:
- the updated SimpleScheduleBuilder
- See Also:
SimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_EXISTING_COUNT
-
withMisfireHandlingInstructionNextWithRemainingCount
public SimpleScheduleBuilder withMisfireHandlingInstructionNextWithRemainingCount()
If the Trigger misfires, use theSimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_REMAINING_COUNTinstruction.- Returns:
- the updated SimpleScheduleBuilder
- See Also:
SimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_REMAINING_COUNT
-
withMisfireHandlingInstructionNowWithExistingCount
public SimpleScheduleBuilder withMisfireHandlingInstructionNowWithExistingCount()
If the Trigger misfires, use theSimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_EXISTING_REPEAT_COUNTinstruction.- Returns:
- the updated SimpleScheduleBuilder
- See Also:
SimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_EXISTING_REPEAT_COUNT
-
withMisfireHandlingInstructionNowWithRemainingCount
public SimpleScheduleBuilder withMisfireHandlingInstructionNowWithRemainingCount()
If the Trigger misfires, use theSimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_REMAINING_REPEAT_COUNTinstruction.- Returns:
- the updated SimpleScheduleBuilder
- See Also:
SimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_REMAINING_REPEAT_COUNT
-
-