Package org.quartz
Class CronScheduleBuilder
- java.lang.Object
-
- org.quartz.ScheduleBuilder<CronTrigger>
-
- org.quartz.CronScheduleBuilder
-
public class CronScheduleBuilder extends ScheduleBuilder<CronTrigger>
CronScheduleBuilder
is aScheduleBuilder
that definesCronExpression
-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(dailyAtHourAndMinute(10, 0)) .startAt(futureDate(10, MINUTES)).build(); scheduler.scheduleJob(job, trigger);
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
CronScheduleBuilder(CronExpression cronExpression)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static CronScheduleBuilder
atHourAndMinuteOnGivenDaysOfWeek(int hour, int minute, java.lang.Integer... daysOfWeek)
Create a CronScheduleBuilder with a cron-expression that sets the schedule to fire at the given day at the given time (hour and minute) on the given days of the week.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.static CronScheduleBuilder
cronSchedule(java.lang.String cronExpression)
Create a CronScheduleBuilder with the given cron-expression string - which is presumed to be a valid cron expression (and hence only a RuntimeException will be thrown if it is not).static CronScheduleBuilder
cronSchedule(CronExpression cronExpression)
Create a CronScheduleBuilder with the given cron-expression.static CronScheduleBuilder
cronScheduleNonvalidatedExpression(java.lang.String cronExpression)
Create a CronScheduleBuilder with the given cron-expression string - which may not be a valid cron expression (and hence a ParseException will be thrown if it is not).static CronScheduleBuilder
dailyAtHourAndMinute(int hour, int minute)
Create a CronScheduleBuilder with a cron-expression that sets the schedule to fire every day at the given time (hour and minute).CronScheduleBuilder
inTimeZone(java.util.TimeZone timezone)
TheTimeZone
in which to base the schedule.static CronScheduleBuilder
monthlyOnDayAndHourAndMinute(int dayOfMonth, int hour, int minute)
Create a CronScheduleBuilder with a cron-expression that sets the schedule to fire one per month on the given day of month at the given time (hour and minute).static CronScheduleBuilder
weeklyOnDayAndHourAndMinute(int dayOfWeek, int hour, int minute)
Create a CronScheduleBuilder with a cron-expression that sets the schedule to fire one per week on the given day at the given time (hour and minute).CronScheduleBuilder
withMisfireHandlingInstructionDoNothing()
If the Trigger misfires, use theCronTrigger.MISFIRE_INSTRUCTION_DO_NOTHING
instruction.CronScheduleBuilder
withMisfireHandlingInstructionFireAndProceed()
If the Trigger misfires, use theCronTrigger.MISFIRE_INSTRUCTION_FIRE_ONCE_NOW
instruction.CronScheduleBuilder
withMisfireHandlingInstructionIgnoreMisfires()
If the Trigger misfires, use theTrigger.MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICY
instruction.
-
-
-
Constructor Detail
-
CronScheduleBuilder
protected CronScheduleBuilder(CronExpression cronExpression)
-
-
Method Detail
-
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<CronTrigger>
- See Also:
TriggerBuilder.withSchedule(ScheduleBuilder)
-
cronSchedule
public static CronScheduleBuilder cronSchedule(java.lang.String cronExpression)
Create a CronScheduleBuilder with the given cron-expression string - which is presumed to be a valid cron expression (and hence only a RuntimeException will be thrown if it is not).- Parameters:
cronExpression
- the cron expression string to base the schedule on.- Returns:
- the new CronScheduleBuilder
- Throws:
java.lang.RuntimeException
- wrapping a ParseException if the expression is invalid- See Also:
CronExpression
-
cronScheduleNonvalidatedExpression
public static CronScheduleBuilder cronScheduleNonvalidatedExpression(java.lang.String cronExpression) throws java.text.ParseException
Create a CronScheduleBuilder with the given cron-expression string - which may not be a valid cron expression (and hence a ParseException will be thrown if it is not).- Parameters:
cronExpression
- the cron expression string to base the schedule on.- Returns:
- the new CronScheduleBuilder
- Throws:
java.text.ParseException
- if the expression is invalid- See Also:
CronExpression
-
cronSchedule
public static CronScheduleBuilder cronSchedule(CronExpression cronExpression)
Create a CronScheduleBuilder with the given cron-expression.- Parameters:
cronExpression
- the cron expression to base the schedule on.- Returns:
- the new CronScheduleBuilder
- See Also:
CronExpression
-
dailyAtHourAndMinute
public static CronScheduleBuilder dailyAtHourAndMinute(int hour, int minute)
Create a CronScheduleBuilder with a cron-expression that sets the schedule to fire every day at the given time (hour and minute).- Parameters:
hour
- the hour of day to fireminute
- the minute of the given hour to fire- Returns:
- the new CronScheduleBuilder
- See Also:
CronExpression
-
atHourAndMinuteOnGivenDaysOfWeek
public static CronScheduleBuilder atHourAndMinuteOnGivenDaysOfWeek(int hour, int minute, java.lang.Integer... daysOfWeek)
Create a CronScheduleBuilder with a cron-expression that sets the schedule to fire at the given day at the given time (hour and minute) on the given days of the week.- Parameters:
daysOfWeek
- the dasy of the week to firehour
- the hour of day to fireminute
- the minute of the given hour to fire- Returns:
- the new CronScheduleBuilder
- See Also:
CronExpression
,DateBuilder.MONDAY
,DateBuilder.TUESDAY
,DateBuilder.WEDNESDAY
,DateBuilder.THURSDAY
,DateBuilder.FRIDAY
,DateBuilder.SATURDAY
,DateBuilder.SUNDAY
-
weeklyOnDayAndHourAndMinute
public static CronScheduleBuilder weeklyOnDayAndHourAndMinute(int dayOfWeek, int hour, int minute)
Create a CronScheduleBuilder with a cron-expression that sets the schedule to fire one per week on the given day at the given time (hour and minute).- Parameters:
dayOfWeek
- the day of the week to firehour
- the hour of day to fireminute
- the minute of the given hour to fire- Returns:
- the new CronScheduleBuilder
- See Also:
CronExpression
,DateBuilder.MONDAY
,DateBuilder.TUESDAY
,DateBuilder.WEDNESDAY
,DateBuilder.THURSDAY
,DateBuilder.FRIDAY
,DateBuilder.SATURDAY
,DateBuilder.SUNDAY
-
monthlyOnDayAndHourAndMinute
public static CronScheduleBuilder monthlyOnDayAndHourAndMinute(int dayOfMonth, int hour, int minute)
Create a CronScheduleBuilder with a cron-expression that sets the schedule to fire one per month on the given day of month at the given time (hour and minute).- Parameters:
dayOfMonth
- the day of the month to firehour
- the hour of day to fireminute
- the minute of the given hour to fire- Returns:
- the new CronScheduleBuilder
- See Also:
CronExpression
-
inTimeZone
public CronScheduleBuilder inTimeZone(java.util.TimeZone timezone)
TheTimeZone
in which to base the schedule.- Parameters:
timezone
- the time-zone for the schedule.- Returns:
- the updated CronScheduleBuilder
- See Also:
CronExpression.getTimeZone()
-
withMisfireHandlingInstructionIgnoreMisfires
public CronScheduleBuilder withMisfireHandlingInstructionIgnoreMisfires()
If the Trigger misfires, use theTrigger.MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICY
instruction.- Returns:
- the updated CronScheduleBuilder
- See Also:
Trigger.MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICY
-
withMisfireHandlingInstructionDoNothing
public CronScheduleBuilder withMisfireHandlingInstructionDoNothing()
If the Trigger misfires, use theCronTrigger.MISFIRE_INSTRUCTION_DO_NOTHING
instruction.- Returns:
- the updated CronScheduleBuilder
- See Also:
CronTrigger.MISFIRE_INSTRUCTION_DO_NOTHING
-
withMisfireHandlingInstructionFireAndProceed
public CronScheduleBuilder withMisfireHandlingInstructionFireAndProceed()
If the Trigger misfires, use theCronTrigger.MISFIRE_INSTRUCTION_FIRE_ONCE_NOW
instruction.- Returns:
- the updated CronScheduleBuilder
- See Also:
CronTrigger.MISFIRE_INSTRUCTION_FIRE_ONCE_NOW
-
-