Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.quartz
Class TriggerBuilder<T extends Trigger>

    java.lang.Object
      org.quartz.TriggerBuilder<T>

    public class TriggerBuilder<T extends Trigger>

extends Object

`TriggerBuilder` is used to instantiate `Trigger`s.

The builder will always try to keep itself in a valid state, with reasonable defaults set for calling build() at any point. For instance if you do not invoke withSchedule(..) method, a default schedule of firing once immediately will be used. As another example, if you do not invoked withIdentity(..) a trigger name will be generated for you.

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:JobBuilder,
    ScheduleBuilder,
    DateBuilder,
    Trigger

    Method Summary

     T
    build()

              Produce the Trigger.

     TriggerBuilder<T>
    endAt(Date triggerEndTime)

              Set the time at which the Trigger will no longer fire - even if it's
     schedule has remaining repeats.

     TriggerBuilder<T>
    forJob(JobDetail jobDetail)

              Set the identity of the Job which should be fired by the produced
     Trigger, by extracting the JobKey from the given job.

     TriggerBuilder<T>
    forJob(JobKey keyOfJobToFire)

              Set the identity of the Job which should be fired by the produced
     Trigger.

     TriggerBuilder<T>
    forJob(String jobName)

              Set the identity of the Job which should be fired by the produced
     Trigger - a JobKey will be produced with the given
     name and default group.

     TriggerBuilder<T>
    forJob(String jobName,
           String jobGroup)

              Set the identity of the Job which should be fired by the produced
     Trigger - a JobKey will be produced with the given
     name and group.

     TriggerBuilder<T>
    modifiedByCalendar(String calName)

              Set the name of the Calendar that should be applied to this
     Trigger's schedule.

    static TriggerBuilder<Trigger>
    newTrigger()

              Create a new TriggerBuilder with which to define a
     specification for a Trigger.

     TriggerBuilder<T>
    startAt(Date triggerStartTime)

              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.

     TriggerBuilder<T>
    startNow()

              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.

     TriggerBuilder<T>
    usingJobData(JobDataMap newJobDataMap)

              Set the Trigger's JobDataMap, adding any values to it
     that were already set on this TriggerBuilder using any of the
     other 'usingJobData' methods.

     TriggerBuilder<T>
    usingJobData(String dataKey,
                 Boolean value)

              Add the given key-value pair to the Trigger's JobDataMap.

     TriggerBuilder<T>
    usingJobData(String dataKey,
                 Double value)

              Add the given key-value pair to the Trigger's JobDataMap.

     TriggerBuilder<T>
    usingJobData(String dataKey,
                 Float value)

              Add the given key-value pair to the Trigger's JobDataMap.

     TriggerBuilder<T>
    usingJobData(String dataKey,
                 Integer value)

              Add the given key-value pair to the Trigger's JobDataMap.

     TriggerBuilder<T>
    usingJobData(String dataKey,
                 Long value)

              Add the given key-value pair to the Trigger's JobDataMap.

     TriggerBuilder<T>
    usingJobData(String dataKey,
                 String value)

              Add the given key-value pair to the Trigger's JobDataMap.

     TriggerBuilder<T>
    withDescription(String triggerDescription)

              Set the given (human-meaningful) description of the Trigger.

     TriggerBuilder<T>
    withIdentity(String name)

              Use a TriggerKey with the given name and default group to
     identify the Trigger.

     TriggerBuilder<T>
    withIdentity(String name,
                 String group)

              Use a TriggerKey with the given name and group to
     identify the Trigger.

     TriggerBuilder<T>
    withIdentity(TriggerKey triggerKey)

              Use the given TriggerKey to identify the Trigger.

     TriggerBuilder<T>
    withPriority(int triggerPriority)

              Set the Trigger's priority.

    <SBT extends T>

    TriggerBuilder<SBT>

    withSchedule(ScheduleBuilder<SBT> schedBuilder)

              Set the ScheduleBuilder that will be used to define the
     Trigger's schedule.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Method Detail

    newTrigger

    public static TriggerBuilder<Trigger> newTrigger()

    Create a new TriggerBuilder with which to define a
     specification for a Trigger.

    Returns:the new TriggerBuilder

    build

    public T build()

    Produce the Trigger.

    Returns:a Trigger that meets the specifications of the builder.

    withIdentity

    public TriggerBuilder<T> withIdentity(String name)

    Use a TriggerKey with the given name and default group to
     identify the Trigger.

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

    Parameters:name - the name element for the Trigger's TriggerKey
    Returns:the updated TriggerBuilderSee Also:TriggerKey,
    Trigger.getKey()

    withIdentity

    public TriggerBuilder<T> withIdentity(String name,
                                          String group)

    Use a TriggerKey with the given name and group to
     identify the Trigger.

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

    Parameters:name - the name element for the Trigger's TriggerKeygroup - the group element for the Trigger's TriggerKey
    Returns:the updated TriggerBuilderSee Also:TriggerKey,
    Trigger.getKey()

    withIdentity

    public TriggerBuilder<T> withIdentity(TriggerKey triggerKey)

    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.

    Parameters:triggerKey - the TriggerKey for the Trigger to be built
    Returns:the updated TriggerBuilderSee Also:TriggerKey,
    Trigger.getKey()

    withDescription

    public TriggerBuilder<T> withDescription(String triggerDescription)

    Set the given (human-meaningful) description of the Trigger.

    Parameters:triggerDescription - the description for the Trigger
    Returns:the updated TriggerBuilderSee Also:Trigger.getDescription()

    withPriority

    public TriggerBuilder<T> withPriority(int triggerPriority)

    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.

    Parameters:triggerPriority - the priority for the Trigger
    Returns:the updated TriggerBuilderSee Also:Trigger.DEFAULT_PRIORITY,
    Trigger.getPriority()

    modifiedByCalendar

    public TriggerBuilder<T> modifiedByCalendar(String calName)

    Set the name of the Calendar that should be applied to this
     Trigger's schedule.

    Parameters:calName - the name of the Calendar to reference.
    Returns:the updated TriggerBuilderSee Also:Calendar,
    Trigger.getCalendarName()

    startAt

    public TriggerBuilder<T> startAt(Date triggerStartTime)

    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.

    Parameters:triggerStartTime - the start time for the Trigger.
    Returns:the updated TriggerBuilderSee Also:Trigger.getStartTime(),
    DateBuilder

    startNow

    public TriggerBuilder<T> startNow()

    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.

    Returns:the updated TriggerBuilderSee Also:Trigger.getStartTime()

    endAt

    public TriggerBuilder<T> endAt(Date triggerEndTime)

    Set the time at which the Trigger will no longer fire - even if it's
     schedule has remaining repeats.

    Parameters:triggerEndTime - the end time for the Trigger.  If null, the end time is indefinite.
    Returns:the updated TriggerBuilderSee Also:Trigger.getEndTime(),
    DateBuilder

    withSchedule

    public <SBT extends T> TriggerBuilder<SBT> withSchedule(ScheduleBuilder<SBT> schedBuilder)

    Set the ScheduleBuilder that will be used to define the
     Trigger's schedule.

     The particular SchedulerBuilder used will dictate
     the concrete type of Trigger that is produced by the TriggerBuilder.

    Parameters:schedBuilder - the SchedulerBuilder to use.
    Returns:the updated TriggerBuilderSee Also:ScheduleBuilder,
    SimpleScheduleBuilder,
    CronScheduleBuilder,
    CalendarIntervalScheduleBuilder

    forJob

    public TriggerBuilder<T> forJob(JobKey keyOfJobToFire)

    Set the identity of the Job which should be fired by the produced
     Trigger.

    Parameters:keyOfJobToFire - the identity of the Job to fire.
    Returns:the updated TriggerBuilderSee Also:Trigger.getJobKey()

    forJob

    public TriggerBuilder<T> forJob(String jobName)

    Set the identity of the Job which should be fired by the produced
     Trigger - a JobKey will be produced with the given
     name and default group.

    Parameters:jobName - the name of the job (in default group) to fire.
    Returns:the updated TriggerBuilderSee Also:Trigger.getJobKey()

    forJob

    public TriggerBuilder<T> forJob(String jobName,
                                    String jobGroup)

    Set the identity of the Job which should be fired by the produced
     Trigger - a JobKey will be produced with the given
     name and group.

    Parameters:jobName - the name of the job to fire.jobGroup - the group of the job to fire.
    Returns:the updated TriggerBuilderSee Also:Trigger.getJobKey()

    forJob

    public TriggerBuilder<T> forJob(JobDetail jobDetail)

    Set the identity of the Job which should be fired by the produced
     Trigger, by extracting the JobKey from the given job.

    Parameters:jobDetail - the Job to fire.
    Returns:the updated TriggerBuilderSee Also:Trigger.getJobKey()

    usingJobData

    public TriggerBuilder<T> usingJobData(String dataKey,
                                          String value)

    Add the given key-value pair to the Trigger's JobDataMap.

    Returns:the updated TriggerBuilderSee Also:Trigger.getJobDataMap()

    usingJobData

    public TriggerBuilder<T> usingJobData(String dataKey,
                                          Integer value)

    Add the given key-value pair to the Trigger's JobDataMap.

    Returns:the updated TriggerBuilderSee Also:Trigger.getJobDataMap()

    usingJobData

    public TriggerBuilder<T> usingJobData(String dataKey,
                                          Long value)

    Add the given key-value pair to the Trigger's JobDataMap.

    Returns:the updated TriggerBuilderSee Also:Trigger.getJobDataMap()

    usingJobData

    public TriggerBuilder<T> usingJobData(String dataKey,
                                          Float value)

    Add the given key-value pair to the Trigger's JobDataMap.

    Returns:the updated TriggerBuilderSee Also:Trigger.getJobDataMap()

    usingJobData

    public TriggerBuilder<T> usingJobData(String dataKey,
                                          Double value)

    Add the given key-value pair to the Trigger's JobDataMap.

    Returns:the updated TriggerBuilderSee Also:Trigger.getJobDataMap()

    usingJobData

    public TriggerBuilder<T> usingJobData(String dataKey,
                                          Boolean value)

    Add the given key-value pair to the Trigger's JobDataMap.

    Returns:the updated TriggerBuilderSee Also:Trigger.getJobDataMap()

    usingJobData

    public TriggerBuilder<T> usingJobData(JobDataMap newJobDataMap)

    Set the Trigger's JobDataMap, adding any values to it
     that were already set on this TriggerBuilder using any of the
     other 'usingJobData' methods.

    Returns:the updated TriggerBuilderSee Also:Trigger.getJobDataMap()

          Overview
          Package
        Class
          Use
          Tree
          Deprecated
          Index
          Help

     PREV CLASS
     NEXT CLASS

      FRAMES
     NO FRAMES

      SUMMARY: NESTED | FIELD | CONSTR | METHOD

    DETAIL: FIELD | CONSTR | METHOD

    Copyright 2001-2016, Terracotta, Inc.