org.quartz
Class CronScheduleBuilder

java.lang.Object
  extended by org.quartz.ScheduleBuilder<CronTrigger>
      extended by org.quartz.CronScheduleBuilder

public class CronScheduleBuilder
extends ScheduleBuilder<CronTrigger>

CronScheduleBuilder is a ScheduleBuilder 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(simpleSchedule()
                 .withIntervalInHours(1)
                 .repeatForever())
             .startAt(futureDate(10, MINUTES))
             .build();
         
         scheduler.scheduleJob(job, trigger);
 

See Also:
CronExpression, CronTrigger, ScheduleBuilder, SimpleScheduleBuilder, CalendarIntervalScheduleBuilder, TriggerBuilder

Method Summary
 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.
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 tz)
          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(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 the CronTrigger.MISFIRE_INSTRUCTION_DO_NOTHING instruction.
 CronScheduleBuilder withMisfireHandlingInstructionFireAndProceed()
          If the Trigger misfires, use the CronTrigger.MISFIRE_INSTRUCTION_FIRE_ONCE_NOW instruction.
 CronScheduleBuilder withMisfireHandlingInstructionIgnoreMisfires()
          If the Trigger misfires, use the Trigger.MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICY instruction.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 class ScheduleBuilder<CronTrigger>
See Also:
TriggerBuilder.withSchedule(ScheduleBuilder)

cronSchedule

public static CronScheduleBuilder cronSchedule(java.lang.String cronExpression)
                                        throws java.text.ParseException
Create a CronScheduleBuilder with the given cron-expression.

Parameters:
cronExpression - the cron expression to base the schedule on.
Returns:
the new CronScheduleBuilder
Throws:
java.text.ParseException
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 fire
minute - the minute of the given hour to fire
Returns:
the new CronScheduleBuilder
Throws:
java.text.ParseException
See Also:
CronExpression

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 fire
hour - the hour of day to fire
minute - the minute of the given hour to fire
Returns:
the new CronScheduleBuilder
Throws:
java.text.ParseException
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 fire
hour - the hour of day to fire
minute - the minute of the given hour to fire
Returns:
the new CronScheduleBuilder
Throws:
java.text.ParseException
See Also:
CronExpression

inTimeZone

public CronScheduleBuilder inTimeZone(java.util.TimeZone tz)
The TimeZone in which to base the schedule.

Parameters:
tz - the time-zone for the schedule.
Returns:
the updated CronScheduleBuilder
See Also:
CronExpression.getTimeZone()

withMisfireHandlingInstructionIgnoreMisfires

public CronScheduleBuilder withMisfireHandlingInstructionIgnoreMisfires()
If the Trigger misfires, use the Trigger.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 the CronTrigger.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 the CronTrigger.MISFIRE_INSTRUCTION_FIRE_ONCE_NOW instruction.

Returns:
the updated CronScheduleBuilder
See Also:
CronTrigger.MISFIRE_INSTRUCTION_FIRE_ONCE_NOW


Copyright 2001-2019, Terracotta, Inc.