Package org.quartz
Class SimpleScheduleBuilder
- java.lang.Object
-
- org.quartz.ScheduleBuilder<SimpleTrigger>
-
- org.quartz.SimpleScheduleBuilder
-
public class SimpleScheduleBuilder extends ScheduleBuilder<SimpleTrigger>
SimpleScheduleBuilder
is aScheduleBuilder
that defines strict/literal interval-based schedules forTrigger
s.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 variousScheduleBuilder
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(simpleSchedule() .withIntervalInHours(1) .repeatForever()) .startAt(futureDate(10, MINUTES)) .build(); scheduler.scheduleJob(job, trigger);
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
SimpleScheduleBuilder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.SimpleScheduleBuilder
repeatForever()
Specify that the trigger will repeat indefinitely.static SimpleScheduleBuilder
repeatHourlyForever()
Create a SimpleScheduleBuilder set to repeat forever with a 1 hour interval.static SimpleScheduleBuilder
repeatHourlyForever(int hours)
Create a SimpleScheduleBuilder set to repeat forever with an interval of the given number of hours.static SimpleScheduleBuilder
repeatHourlyForTotalCount(int count)
Create a SimpleScheduleBuilder set to repeat the given number of times - 1 with a 1 hour interval.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.static SimpleScheduleBuilder
repeatMinutelyForever()
Create a SimpleScheduleBuilder set to repeat forever with a 1 minute interval.static SimpleScheduleBuilder
repeatMinutelyForever(int minutes)
Create a SimpleScheduleBuilder set to repeat forever with an interval of the given number of minutes.static SimpleScheduleBuilder
repeatMinutelyForTotalCount(int count)
Create a SimpleScheduleBuilder set to repeat the given number of times - 1 with a 1 minute interval.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.static SimpleScheduleBuilder
repeatSecondlyForever()
Create a SimpleScheduleBuilder set to repeat forever with a 1 second interval.static SimpleScheduleBuilder
repeatSecondlyForever(int seconds)
Create a SimpleScheduleBuilder set to repeat forever with an interval of the given number of seconds.static SimpleScheduleBuilder
repeatSecondlyForTotalCount(int count)
Create a SimpleScheduleBuilder set to repeat the given number of times - 1 with a 1 second interval.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.static SimpleScheduleBuilder
simpleSchedule()
Create a SimpleScheduleBuilder.SimpleScheduleBuilder
withIntervalInHours(int intervalInHours)
Specify a repeat interval in minutes - which will then be multiplied by 60 * 60 * 1000 to produce milliseconds.SimpleScheduleBuilder
withIntervalInMilliseconds(long intervalInMillis)
Specify a repeat interval in milliseconds.SimpleScheduleBuilder
withIntervalInMinutes(int intervalInMinutes)
Specify a repeat interval in minutes - which will then be multiplied by 60 * 1000 to produce milliseconds.SimpleScheduleBuilder
withIntervalInSeconds(int intervalInSeconds)
Specify a repeat interval in seconds - which will then be multiplied by 1000 to produce milliseconds.SimpleScheduleBuilder
withMisfireHandlingInstructionFireNow()
If the Trigger misfires, use theSimpleTrigger.MISFIRE_INSTRUCTION_FIRE_NOW
instruction.SimpleScheduleBuilder
withMisfireHandlingInstructionIgnoreMisfires()
If the Trigger misfires, use theTrigger.MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICY
instruction.SimpleScheduleBuilder
withMisfireHandlingInstructionNextWithExistingCount()
If the Trigger misfires, use theSimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_EXISTING_COUNT
instruction.SimpleScheduleBuilder
withMisfireHandlingInstructionNextWithRemainingCount()
If the Trigger misfires, use theSimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_REMAINING_COUNT
instruction.SimpleScheduleBuilder
withMisfireHandlingInstructionNowWithExistingCount()
If the Trigger misfires, use theSimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_EXISTING_REPEAT_COUNT
instruction.SimpleScheduleBuilder
withMisfireHandlingInstructionNowWithRemainingCount()
If the Trigger misfires, use theSimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_REMAINING_REPEAT_COUNT
instruction.SimpleScheduleBuilder
withRepeatCount(int triggerRepeatCount)
Specify a the number of time the trigger will repeat - 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:
build
in 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 a the number of time the trigger will repeat - total number of firings will be this number + 1.- Parameters:
triggerRepeatCount
- the number of seconds at which the trigger should repeat.- 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_POLICY
instruction.- 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_NOW
instruction.- 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_COUNT
instruction.- 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_COUNT
instruction.- 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_COUNT
instruction.- 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_COUNT
instruction.- Returns:
- the updated SimpleScheduleBuilder
- See Also:
SimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_REMAINING_REPEAT_COUNT
-
-