Package org.quartz.builders
Class JobBuilder
java.lang.Object
org.quartz.builders.JobBuilder
JobBuilder
is used to instantiate JobDetail
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);
- Author:
- timmolter
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Produce theJobDetail
instance defined by thisJobBuilder
.isConcurrencyAllowed
(boolean isConcurrencyAllowed) The default behavior is to veto any job is currently running concurrent.static JobBuilder
Create a JobBuilder with which to define aJobDetail
.static JobBuilder
newJobBuilder
(Class<? extends Job> jobClass) Create a JobBuilder with which to define aJobDetail
, and set the class name of theJob
to be executed.Set the class which will be instantiated and executed when a Trigger fires that is associated with this JobDetail.usingJobData
(JobDataMap newJobDataMap) Set the JobDetail'sJobDataMap
withDescription
(String description) Set the given (human-meaningful) description of the Job.withIdentity
(String key) Use aString
to identify the JobDetail.
-
Method Details
-
newJobBuilder
Create a JobBuilder with which to define aJobDetail
.- Returns:
- a new JobBuilder
-
newJobBuilder
Create a JobBuilder with which to define aJobDetail
, and set the class name of theJob
to be executed.- Returns:
- a new JobBuilder
-
build
Produce theJobDetail
instance defined by thisJobBuilder
.- Returns:
- the defined JobDetail.
-
withIdentity
Use aString
to identify the JobDetail.If none of the 'withIdentity' methods are set on the JobBuilder, then a random, unique JobKey will be generated.
- Parameters:
key
- the Job's JobKey- Returns:
- the updated JobBuilder
-
withDescription
Set the given (human-meaningful) description of the Job.- Parameters:
description
- the description for the Job- Returns:
- the updated JobBuilder
- See Also:
-
ofType
Set the class which will be instantiated and executed when a Trigger fires that is associated with this JobDetail.- Parameters:
jobClass
- a class implementing the Job interface.- Returns:
- the updated JobBuilder
- See Also:
-
isConcurrencyAllowed
The default behavior is to veto any job is currently running concurrent. However, concurrent jobs can be created by setting the 'Concurrency' to true- Parameters:
isConcurrencyAllowed
-- Returns:
- the updated JobBuilder
-
usingJobData
Set the JobDetail'sJobDataMap
- Returns:
- the updated JobBuilder
- See Also:
-