Class JobBuilder

java.lang.Object
org.quartz.builders.JobBuilder

public class JobBuilder extends Object
JobBuilder is used to instantiate JobDetails.

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 Details

    • newJobBuilder

      public static JobBuilder newJobBuilder()
      Create a JobBuilder with which to define a JobDetail.
      Returns:
      a new JobBuilder
    • newJobBuilder

      public static JobBuilder newJobBuilder(Class<? extends Job> jobClass)
      Create a JobBuilder with which to define a JobDetail, and set the class name of the Job to be executed.
      Returns:
      a new JobBuilder
    • build

      public JobDetail build()
      Produce the JobDetail instance defined by this JobBuilder.
      Returns:
      the defined JobDetail.
    • withIdentity

      public JobBuilder withIdentity(String key)
      Use a String 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

      public JobBuilder withDescription(String description)
      Set the given (human-meaningful) description of the Job.
      Parameters:
      description - the description for the Job
      Returns:
      the updated JobBuilder
      See Also:
    • ofType

      public JobBuilder ofType(Class<? extends Job> jobClass)
      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

      public JobBuilder isConcurrencyAllowed(boolean 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

      public JobBuilder usingJobData(JobDataMap newJobDataMap)
      Set the JobDetail's JobDataMap
      Returns:
      the updated JobBuilder
      See Also: