public class CronScheduleBuilder extends Object implements IScheduleBuilder<CronTrigger>
CronScheduleBuilder is a IScheduleBuilder that defines
CronExpression-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 (dailyAtHourAndMinute (10, 0))
.startAt (futureDate (10, MINUTES))
.build ();
scheduler.scheduleJob (job, trigger);
| Modifier | Constructor and Description |
|---|---|
protected |
CronScheduleBuilder(CronExpression aCronExpression) |
| Modifier and Type | Method and Description |
|---|---|
static CronScheduleBuilder |
atHourAndMinuteOnGivenDaysOfWeek(int hour,
int minute,
DayOfWeek... 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.
|
CronTrigger |
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(CronExpression cronExpression)
Create a CronScheduleBuilder with the given cron-expression.
|
static CronScheduleBuilder |
cronSchedule(String cronExpression)
Create a CronScheduleBuilder with the given cron-expression string - which
is presumed to b e valid cron expression (and hence only a RuntimeException
will be thrown if it is not).
|
static CronScheduleBuilder |
cronScheduleNonvalidatedExpression(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(TimeZone timezone)
The
TimeZone 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(DayOfWeek 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 the
ITrigger.EMisfireInstruction.MISFIRE_INSTRUCTION_DO_NOTHING instruction. |
CronScheduleBuilder |
withMisfireHandlingInstructionFireAndProceed()
If the Trigger misfires, use the
ITrigger.EMisfireInstruction.MISFIRE_INSTRUCTION_FIRE_ONCE_NOW instruction. |
CronScheduleBuilder |
withMisfireHandlingInstructionIgnoreMisfires()
If the Trigger misfires, use the
ITrigger.EMisfireInstruction.MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICY
instruction. |
protected CronScheduleBuilder(@Nonnull CronExpression aCronExpression)
@Nonnull public CronTrigger build()
build in interface IScheduleBuilder<CronTrigger>TriggerBuilder.withSchedule(IScheduleBuilder)@Nonnull public static CronScheduleBuilder cronSchedule(String cronExpression)
cronExpression - the cron expression string to base the schedule on.RuntimeException - wrapping a ParseException if the expression is invalidCronExpression@Nonnull public static CronScheduleBuilder cronScheduleNonvalidatedExpression(String cronExpression) throws ParseException
cronExpression - the cron expression string to base the schedule on.ParseException - if the expression is invalidCronExpression@Nonnull public static CronScheduleBuilder cronSchedule(CronExpression cronExpression)
cronExpression - the cron expression to base the schedule on.CronExpression@Nonnull public static CronScheduleBuilder dailyAtHourAndMinute(int hour, int minute)
hour - the hour of day to fireminute - the minute of the given hour to fireCronExpression@Nonnull public static CronScheduleBuilder atHourAndMinuteOnGivenDaysOfWeek(int hour, int minute, DayOfWeek... daysOfWeek)
daysOfWeek - the dasy of the week to firehour - the hour of day to fireminute - the minute of the given hour to fireCronExpression@Nonnull public static CronScheduleBuilder weeklyOnDayAndHourAndMinute(DayOfWeek dayOfWeek, int hour, int minute)
dayOfWeek - the day of the week to firehour - the hour of day to fireminute - the minute of the given hour to fireCronExpression@Nonnull public static CronScheduleBuilder monthlyOnDayAndHourAndMinute(int dayOfMonth, int hour, int minute)
dayOfMonth - the day of the month to firehour - the hour of day to fireminute - the minute of the given hour to fireCronExpression@Nonnull public CronScheduleBuilder inTimeZone(TimeZone timezone)
TimeZone in which to base the schedule.timezone - the time-zone for the schedule.CronExpression.getTimeZone()@Nonnull public CronScheduleBuilder withMisfireHandlingInstructionIgnoreMisfires()
ITrigger.EMisfireInstruction.MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICY
instruction.ITrigger.EMisfireInstruction.MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICY@Nonnull public CronScheduleBuilder withMisfireHandlingInstructionDoNothing()
ITrigger.EMisfireInstruction.MISFIRE_INSTRUCTION_DO_NOTHING instruction.ITrigger.EMisfireInstruction.MISFIRE_INSTRUCTION_DO_NOTHING@Nonnull public CronScheduleBuilder withMisfireHandlingInstructionFireAndProceed()
ITrigger.EMisfireInstruction.MISFIRE_INSTRUCTION_FIRE_ONCE_NOW instruction.ITrigger.EMisfireInstruction.MISFIRE_INSTRUCTION_FIRE_ONCE_NOWCopyright © 2016–2021 Philip Helger. All rights reserved.