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 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 Summary
Modifier and TypeMethodDescriptionstatic CronTriggerBuildercronTriggerBuilder(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) TheTimeZonein which to base the schedule.modifiedByCalendar(String calendarName) Set the name of theCalendarthat 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_NOTHINGinstruction.If the Trigger misfires, use theCronTrigger.MISFIRE_INSTRUCTION_FIRE_ONCE_NOWinstruction.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:
instantiatein classTriggerBuilder
-
inTimeZone
TheTimeZonein 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_NOTHINGinstruction.- Returns:
- the updated CronScheduleBuilder
- See Also:
-
withMisfireHandlingInstructionFireAndProceed
If the Trigger misfires, use theCronTrigger.MISFIRE_INSTRUCTION_FIRE_ONCE_NOWinstruction.- Returns:
- the updated CronScheduleBuilder
- See Also:
-
withIdentity
Description copied from class:TriggerBuilderUse 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:
withIdentityin classTriggerBuilder- Parameters:
name- the TriggerKey for the Trigger to be built- Returns:
- the updated TriggerBuilder
-
withDescription
Description copied from class:TriggerBuilderSet the given (human-meaningful) description of the Trigger.- Overrides:
withDescriptionin classTriggerBuilder- Parameters:
description- the description for the Trigger- Returns:
- the updated TriggerBuilder
-
withPriority
Description copied from class:TriggerBuilderSet 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:
withPriorityin classTriggerBuilder- Parameters:
priority- the priority for the Trigger- Returns:
- the updated TriggerBuilder
-
modifiedByCalendar
Description copied from class:TriggerBuilderSet the name of theCalendarthat should be applied to this Trigger's schedule.- Overrides:
modifiedByCalendarin classTriggerBuilder- Parameters:
calendarName- the name of the Calendar to reference.- Returns:
- the updated TriggerBuilder
-
startNow
Description copied from class:TriggerBuilderSet 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:
startNowin classTriggerBuilder- Returns:
- the updated TriggerBuilder
-
startAt
Description copied from class:TriggerBuilderSet 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:
startAtin classTriggerBuilder- Parameters:
startTime- the start time for the Trigger.- Returns:
- the updated TriggerBuilder
-
endAt
Description copied from class:TriggerBuilderSet the time at which the Trigger will no longer fire - even if it's schedule has remaining repeats.- Overrides:
endAtin 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:TriggerBuilderSet the identity of the Job which should be fired by the produced Trigger.- Overrides:
forJobin classTriggerBuilder- Parameters:
jobName- the identity of the Job to fire.- Returns:
- the updated TriggerBuilder
-
usingJobData
Description copied from class:TriggerBuilderSet the Trigger'sJobDataMap.- Overrides:
usingJobDatain classTriggerBuilder- Returns:
- the updated TriggerBuilder
-