Class CronTriggerBuilder

java.lang.Object
org.quartz.builders.TriggerBuilder
org.quartz.builders.CronTriggerBuilder

public class CronTriggerBuilder extends TriggerBuilder
CronScheduleBuilder is a
invalid @link
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);

 
  • Method Details

    • cronTriggerBuilder

      public static CronTriggerBuilder cronTriggerBuilder(String cronExpression) throws ParseException
      Create a CronScheduleBuilder with the given cron-expression.
      Parameters:
      cronExpression - the cron expression to base the schedule on.
      Returns:
      the new CronScheduleBuilder
      Throws:
      ParseException
      See Also:
    • instantiate

      public OperableTrigger instantiate()
      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:
      instantiate in class TriggerBuilder
    • inTimeZone

      public CronTriggerBuilder inTimeZone(TimeZone tz)
      The TimeZone in which to base the schedule.
      Parameters:
      tz - the time-zone for the schedule.
      Returns:
      the updated CronScheduleBuilder
      See Also:
    • withMisfireHandlingInstructionDoNothing

      public CronTriggerBuilder withMisfireHandlingInstructionDoNothing()
      If the Trigger misfires, use the CronTrigger.MISFIRE_INSTRUCTION_DO_NOTHING instruction.
      Returns:
      the updated CronScheduleBuilder
      See Also:
    • withMisfireHandlingInstructionFireAndProceed

      public CronTriggerBuilder withMisfireHandlingInstructionFireAndProceed()
      If the Trigger misfires, use the CronTrigger.MISFIRE_INSTRUCTION_FIRE_ONCE_NOW instruction.
      Returns:
      the updated CronScheduleBuilder
      See Also:
    • withIdentity

      public CronTriggerBuilder withIdentity(String name)
      Description copied from class: TriggerBuilder
      Use the given TriggerKey to identify the Trigger.

      If none of the 'withIdentity' methods are set on the TriggerBuilder, then a random, unique TriggerKey will be generated.

      Overrides:
      withIdentity in class TriggerBuilder
      Parameters:
      name - the TriggerKey for the Trigger to be built
      Returns:
      the updated TriggerBuilder
    • withDescription

      public CronTriggerBuilder withDescription(String description)
      Description copied from class: TriggerBuilder
      Set the given (human-meaningful) description of the Trigger.
      Overrides:
      withDescription in class TriggerBuilder
      Parameters:
      description - the description for the Trigger
      Returns:
      the updated TriggerBuilder
    • withPriority

      public CronTriggerBuilder withPriority(int priority)
      Description copied from class: TriggerBuilder
      Set the Trigger's priority. When more than one Trigger have the same fire time, the scheduler will fire the one with the highest priority first.
      Overrides:
      withPriority in class TriggerBuilder
      Parameters:
      priority - the priority for the Trigger
      Returns:
      the updated TriggerBuilder
    • modifiedByCalendar

      public CronTriggerBuilder modifiedByCalendar(String calendarName)
      Description copied from class: TriggerBuilder
      Set the name of the Calendar that should be applied to this Trigger's schedule.
      Overrides:
      modifiedByCalendar in class TriggerBuilder
      Parameters:
      calendarName - the name of the Calendar to reference.
      Returns:
      the updated TriggerBuilder
    • startNow

      public CronTriggerBuilder startNow()
      Description copied from class: TriggerBuilder
      Set the time the Trigger should start at to the current moment - the trigger may or may not fire at this time - depending upon the schedule configured for the Trigger.
      Overrides:
      startNow in class TriggerBuilder
      Returns:
      the updated TriggerBuilder
    • startAt

      public CronTriggerBuilder startAt(Date startTime)
      Description copied from class: TriggerBuilder
      Set the time the Trigger should start at - the trigger may or may not fire at this time - depending upon the schedule configured for the Trigger. However the Trigger will NOT fire before this time, regardless of the Trigger's schedule.
      Overrides:
      startAt in class TriggerBuilder
      Parameters:
      startTime - the start time for the Trigger.
      Returns:
      the updated TriggerBuilder
    • endAt

      public CronTriggerBuilder endAt(Date endTime)
      Description copied from class: TriggerBuilder
      Set the time at which the Trigger will no longer fire - even if it's schedule has remaining repeats.
      Overrides:
      endAt in class TriggerBuilder
      Parameters:
      endTime - the end time for the Trigger. If null, the end time is indefinite.
      Returns:
      the updated TriggerBuilder
    • forJob

      public CronTriggerBuilder forJob(String jobName)
      Description copied from class: TriggerBuilder
      Set the identity of the Job which should be fired by the produced Trigger.
      Overrides:
      forJob in class TriggerBuilder
      Parameters:
      jobName - the identity of the Job to fire.
      Returns:
      the updated TriggerBuilder
    • usingJobData

      public CronTriggerBuilder usingJobData(JobDataMap newJobDataMap)
      Description copied from class: TriggerBuilder
      Set the Trigger's JobDataMap.
      Overrides:
      usingJobData in class TriggerBuilder
      Returns:
      the updated TriggerBuilder