Package org.quartz.builders
Class CronTriggerBuilder
java.lang.Object
org.quartz.builders.TriggerBuilder
org.quartz.builders.CronTriggerBuilder
CronScheduleBuilder
is a
invalid @link
ScheduleBuilder
CronExpression
-based schedules for 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);
-
Method Summary
Modifier and TypeMethodDescriptionstatic CronTriggerBuilder
cronTriggerBuilder
(String cronExpression) Create a CronScheduleBuilder with the given cron-expression.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.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.inTimeZone
(TimeZone tz) TheTimeZone
in which to base the schedule.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.If the Trigger misfires, use theCronTrigger.MISFIRE_INSTRUCTION_DO_NOTHING
instruction.If the Trigger misfires, use theCronTrigger.MISFIRE_INSTRUCTION_FIRE_ONCE_NOW
instruction.withPriority
(int priority) Set the Trigger's priority.Methods inherited from class org.quartz.builders.TriggerBuilder
build, withTriggerImplementation
-
Method Details
-
cronTriggerBuilder
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
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 classTriggerBuilder
-
inTimeZone
TheTimeZone
in which to base the schedule.- Parameters:
tz
- the time-zone for the schedule.- Returns:
- the updated CronScheduleBuilder
- See Also:
-
withMisfireHandlingInstructionDoNothing
If the Trigger misfires, use theCronTrigger.MISFIRE_INSTRUCTION_DO_NOTHING
instruction.- Returns:
- the updated CronScheduleBuilder
- See Also:
-
withMisfireHandlingInstructionFireAndProceed
If the Trigger misfires, use theCronTrigger.MISFIRE_INSTRUCTION_FIRE_ONCE_NOW
instruction.- Returns:
- the updated CronScheduleBuilder
- See Also:
-
withIdentity
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 classTriggerBuilder
- Parameters:
name
- the TriggerKey for the Trigger to be built- Returns:
- the updated TriggerBuilder
-
withDescription
Description copied from class:TriggerBuilder
Set the given (human-meaningful) description of the Trigger.- Overrides:
withDescription
in classTriggerBuilder
- Parameters:
description
- the description for the Trigger- Returns:
- the updated TriggerBuilder
-
withPriority
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 classTriggerBuilder
- Parameters:
priority
- the priority for the Trigger- Returns:
- the updated TriggerBuilder
-
modifiedByCalendar
Description copied from class:TriggerBuilder
Set the name of theCalendar
that should be applied to this Trigger's schedule.- Overrides:
modifiedByCalendar
in classTriggerBuilder
- Parameters:
calendarName
- the name of the Calendar to reference.- Returns:
- the updated TriggerBuilder
-
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 classTriggerBuilder
- Returns:
- the updated TriggerBuilder
-
startAt
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 classTriggerBuilder
- Parameters:
startTime
- the start time for the Trigger.- Returns:
- the updated TriggerBuilder
-
endAt
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 classTriggerBuilder
- Parameters:
endTime
- the end time for the Trigger. If null, the end time is indefinite.- Returns:
- the updated TriggerBuilder
-
forJob
Description copied from class:TriggerBuilder
Set the identity of the Job which should be fired by the produced Trigger.- Overrides:
forJob
in classTriggerBuilder
- Parameters:
jobName
- the identity of the Job to fire.- Returns:
- the updated TriggerBuilder
-
usingJobData
Description copied from class:TriggerBuilder
Set the Trigger'sJobDataMap
.- Overrides:
usingJobData
in classTriggerBuilder
- Returns:
- the updated TriggerBuilder
-