Package org.quartz.builders
Class TriggerBuilder
java.lang.Object
org.quartz.builders.TriggerBuilder
- Direct Known Subclasses:
CronTriggerBuilder
,SimpleTriggerBuilder
TriggerBuilder
is used to instantiate Trigger
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 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);
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Produce theOperableTrigger
.Set the time at which the Trigger will no longer fire - even if it's schedule has remaining repeats.Set the identity of the Job which should be fired by the produced Trigger.abstract OperableTrigger
modifiedByCalendar
(String calendarName) Set the name of theCalendar
that should be applied to this Trigger's schedule.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.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.usingJobData
(JobDataMap newJobDataMap) Set the Trigger'sJobDataMap
.withDescription
(String description) Set the given (human-meaningful) description of the Trigger.withIdentity
(String name) Use the given TriggerKey to identify the Trigger.withPriority
(int priority) Set the Trigger's priority.withTriggerImplementation
(OperableTrigger operableTrigger) Set theinvalid @link
ScheduleBuilder
-
Constructor Details
-
TriggerBuilder
public TriggerBuilder()
-
-
Method Details
-
instantiate
-
build
Produce theOperableTrigger
.- Returns:
- a OperableTrigger that meets the specifications of the builder.
-
withIdentity
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:
name
- the TriggerKey for the Trigger to be built- Returns:
- the updated TriggerBuilder
-
withDescription
Set the given (human-meaningful) description of the Trigger.- Parameters:
description
- the description for the Trigger- Returns:
- the updated TriggerBuilder
-
withPriority
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:
priority
- the priority for the Trigger- Returns:
- the updated TriggerBuilder
-
modifiedByCalendar
Set the name of theCalendar
that should be applied to this Trigger's schedule.- Parameters:
calendarName
- the name of the Calendar to reference.- Returns:
- the updated TriggerBuilder
-
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 TriggerBuilder
-
startAt
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:
startTime
- the start time for the Trigger.- Returns:
- the updated TriggerBuilder
-
endAt
Set the time at which the Trigger will no longer fire - even if it's schedule has remaining repeats.- Parameters:
endTime
- the end time for the Trigger. If null, the end time is indefinite.- Returns:
- the updated TriggerBuilder
-
withTriggerImplementation
Set theinvalid @link
ScheduleBuilder
The particular
SchedulerBuilder
used will dictate the concrete type of Trigger that is produced by the TriggerBuilder.- Parameters:
scheduleBuilder
- the SchedulerBuilder to use.- Returns:
- the updated TriggerBuilder
-
forJob
Set the identity of the Job which should be fired by the produced Trigger.- Parameters:
jobName
- the identity of the Job to fire.- Returns:
- the updated TriggerBuilder
-
usingJobData
Set the Trigger'sJobDataMap
.- Returns:
- the updated TriggerBuilder
-