public class JobBuilder extends Object
JobBuilder
is used to instantiate JobDetail
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 withIdentity(..) a job 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);
TriggerBuilder
,
DateBuilder
,
JobDetail
Modifier | Constructor and Description |
---|---|
protected |
JobBuilder() |
Modifier and Type | Method and Description |
---|---|
JobDetail |
build()
Produce the
JobDetail instance defined by this
JobBuilder . |
static JobBuilder |
newJob()
Create a JobBuilder with which to define a
JobDetail . |
static JobBuilder |
newJob(Class<? extends Job> jobClass)
Create a JobBuilder with which to define a
JobDetail ,
and set the class name of the Job to be executed. |
JobBuilder |
ofType(Class<? extends Job> jobClazz)
Set the class which will be instantiated and executed when a
Trigger fires that is associated with this JobDetail.
|
JobBuilder |
requestRecovery()
Instructs the
Scheduler whether or not the Job
should be re-executed if a 'recovery' or 'fail-over' situation is
encountered. |
JobBuilder |
requestRecovery(boolean jobShouldRecover)
Instructs the
Scheduler whether or not the Job
should be re-executed if a 'recovery' or 'fail-over' situation is
encountered. |
JobBuilder |
setJobData(JobDataMap newJobDataMap)
|
JobBuilder |
storeDurably()
Whether or not the
Job should remain stored after it is
orphaned (no point to it). |
JobBuilder |
storeDurably(boolean jobDurability)
Whether or not the
Job should remain stored after it is
orphaned (no point to it). |
JobBuilder |
usingJobData(JobDataMap newJobDataMap)
|
JobBuilder |
usingJobData(String dataKey,
Boolean value)
Add the given key-value pair to the JobDetail's
JobDataMap . |
JobBuilder |
usingJobData(String dataKey,
Double value)
Add the given key-value pair to the JobDetail's
JobDataMap . |
JobBuilder |
usingJobData(String dataKey,
Float value)
Add the given key-value pair to the JobDetail's
JobDataMap . |
JobBuilder |
usingJobData(String dataKey,
Integer value)
Add the given key-value pair to the JobDetail's
JobDataMap . |
JobBuilder |
usingJobData(String dataKey,
Long value)
Add the given key-value pair to the JobDetail's
JobDataMap . |
JobBuilder |
usingJobData(String dataKey,
String value)
Add the given key-value pair to the JobDetail's
JobDataMap . |
JobBuilder |
withDescription(String jobDescription)
Set the given (human-meaningful) description of the Job.
|
JobBuilder |
withIdentity(JobKey jobKey)
Use a
JobKey to identify the JobDetail. |
JobBuilder |
withIdentity(String name)
Use a
JobKey with the given name and default group to
identify the JobDetail. |
JobBuilder |
withIdentity(String name,
String group)
Use a
JobKey with the given name and group to
identify the JobDetail. |
public static JobBuilder newJob()
JobDetail
.public static JobBuilder newJob(Class<? extends Job> jobClass)
JobDetail
,
and set the class name of the Job
to be executed.public JobDetail build()
JobDetail
instance defined by this
JobBuilder
.public JobBuilder withIdentity(String name)
JobKey
with the given name and default group to
identify the JobDetail.
If none of the 'withIdentity' methods are set on the JobBuilder, then a random, unique JobKey will be generated.
name
- the name element for the Job's JobKeyJobKey
,
JobDetail.getKey()
public JobBuilder withIdentity(String name, String group)
JobKey
with the given name and group to
identify the JobDetail.
If none of the 'withIdentity' methods are set on the JobBuilder, then a random, unique JobKey will be generated.
name
- the name element for the Job's JobKeygroup
- the group element for the Job's JobKeyJobKey
,
JobDetail.getKey()
public JobBuilder withIdentity(JobKey jobKey)
JobKey
to identify the JobDetail.
If none of the 'withIdentity' methods are set on the JobBuilder, then a random, unique JobKey will be generated.
jobKey
- the Job's JobKeyJobKey
,
JobDetail.getKey()
public JobBuilder withDescription(String jobDescription)
jobDescription
- the description for the JobJobDetail.getDescription()
public JobBuilder ofType(Class<? extends Job> jobClazz)
jobClazz
- a class implementing the Job interface.JobDetail.getJobClass()
public JobBuilder requestRecovery()
Scheduler
whether or not the Job
should be re-executed if a 'recovery' or 'fail-over' situation is
encountered.
If not explicitly set, the default value is false
.
JobDetail.requestsRecovery()
public JobBuilder requestRecovery(boolean jobShouldRecover)
Scheduler
whether or not the Job
should be re-executed if a 'recovery' or 'fail-over' situation is
encountered.
If not explicitly set, the default value is false
.
jobShouldRecover
- the desired settingpublic JobBuilder storeDurably()
Job
should remain stored after it is
orphaned (no Trigger
s
point to it).
If not explicitly set, the default value is false
- this method sets the value to true
.
JobDetail.isDurable()
public JobBuilder storeDurably(boolean jobDurability)
Job
should remain stored after it is
orphaned (no Trigger
s
point to it).
If not explicitly set, the default value is false
.
jobDurability
- the value to set for the durability property.JobDetail.isDurable()
public JobBuilder usingJobData(String dataKey, String value)
JobDataMap
.JobDetail.getJobDataMap()
public JobBuilder usingJobData(String dataKey, Integer value)
JobDataMap
.JobDetail.getJobDataMap()
public JobBuilder usingJobData(String dataKey, Long value)
JobDataMap
.JobDetail.getJobDataMap()
public JobBuilder usingJobData(String dataKey, Float value)
JobDataMap
.JobDetail.getJobDataMap()
public JobBuilder usingJobData(String dataKey, Double value)
JobDataMap
.JobDetail.getJobDataMap()
public JobBuilder usingJobData(String dataKey, Boolean value)
JobDataMap
.JobDetail.getJobDataMap()
public JobBuilder usingJobData(JobDataMap newJobDataMap)
JobDetail.getJobDataMap()
public JobBuilder setJobData(JobDataMap newJobDataMap)
JobDetail.getJobDataMap()
Copyright 2001-2019, Terracotta, Inc.