spring-framework / org.springframework.scheduling.quartz

Package org.springframework.scheduling.quartz

Types

AdaptableJobFactory

open class AdaptableJobFactory : JobFactory

JobFactory implementation that supports java.lang.Runnable objects as well as standard Quartz org.quartz.Job instances.

Compatible with Quartz 2.1.4 and higher, as of Spring 4.1.

CronTriggerFactoryBean

open class CronTriggerFactoryBean : FactoryBean<CronTrigger>, BeanNameAware, InitializingBean

A Spring FactoryBean for creating a Quartz org.quartz.CronTrigger instance, supporting bean-style usage for trigger configuration.

CronTrigger(Impl) itself is already a JavaBean but lacks sensible defaults. This class uses the Spring bean name as job name, the Quartz default group ("DEFAULT") as job group, the current time as start time, and indefinite repetition, if not specified.

This class will also register the trigger with the job name and group of a given org.quartz.JobDetail. This allows SchedulerFactoryBean to automatically register a trigger for the corresponding JobDetail, instead of registering the JobDetail separately.

DelegatingJob

open class DelegatingJob : Job

Simple Quartz org.quartz.Job adapter that delegates to a given java.lang.Runnable instance.

Typically used in combination with property injection on the Runnable instance, receiving parameters from the Quartz JobDataMap that way instead of via the JobExecutionContext.

JobDetailFactoryBean

open class JobDetailFactoryBean : FactoryBean<JobDetail>, BeanNameAware, ApplicationContextAware, InitializingBean

A Spring FactoryBean for creating a Quartz org.quartz.JobDetail instance, supporting bean-style usage for JobDetail configuration.

JobDetail(Impl) itself is already a JavaBean but lacks sensible defaults. This class uses the Spring bean name as job name, and the Quartz default group ("DEFAULT") as job group if not specified.

LocalDataSourceJobStore

open class LocalDataSourceJobStore : JobStoreCMT

Subclass of Quartz's JobStoreCMT class that delegates to a Spring-managed DataSource instead of using a Quartz-managed connection pool. This JobStore will be used if SchedulerFactoryBean's "dataSource" property is set.

Supports both transactional and non-transactional DataSource access. With a non-XA DataSource and local Spring transactions, a single DataSource argument is sufficient. In case of an XA DataSource and global JTA transactions, SchedulerFactoryBean's "nonTransactionalDataSource" property should be set, passing in a non-XA DataSource that will not participate in global transactions.

Operations performed by this JobStore will properly participate in any kind of Spring-managed transaction, as it uses Spring's DataSourceUtils connection handling methods that are aware of a current transaction.

Note that all Quartz Scheduler operations that affect the persistent job store should usually be performed within active transactions, as they assume to get proper locks etc.

LocalTaskExecutorThreadPool

open class LocalTaskExecutorThreadPool : ThreadPool

Quartz ThreadPool adapter that delegates to a Spring-managed TaskExecutor instance, specified on SchedulerFactoryBean.

MethodInvokingJobDetailFactoryBean

open class MethodInvokingJobDetailFactoryBean : ArgumentConvertingMethodInvoker, FactoryBean<JobDetail>, BeanNameAware, BeanClassLoaderAware, BeanFactoryAware, InitializingBean

org.springframework.beans.factory.FactoryBean that exposes a org.quartz.JobDetail object which delegates job execution to a specified (static or non-static) method. Avoids the need for implementing a one-line Quartz Job that just invokes an existing service method on a Spring-managed target bean.

Inherits common configuration properties from the MethodInvoker base class, such as "targetObject" and "targetMethod", adding support for lookup of the target bean by name through the "targetBeanName" property (as alternative to specifying a "targetObject" directly, allowing for non-singleton target objects).

Supports both concurrently running jobs and non-currently running jobs through the "concurrent" property. Jobs created by this MethodInvokingJobDetailFactoryBean are by default volatile and durable (according to Quartz terminology).

NOTE: JobDetails created via this FactoryBean are not serializable and thus not suitable for persistent job stores. You need to implement your own Quartz Job as a thin wrapper for each case where you want a persistent job to delegate to a specific service method.

Compatible with Quartz 2.1.4 and higher, as of Spring 4.1.

QuartzJobBean

abstract class QuartzJobBean : Job

Simple implementation of the Quartz Job interface, applying the passed-in JobDataMap and also the SchedulerContext as bean property values. This is appropriate because a new Job instance will be created for each execution. JobDataMap entries will override SchedulerContext entries with the same keys.

For example, let's assume that the JobDataMap contains a key "myParam" with value "5": The Job implementation can then expose a bean property "myParam" of type int to receive such a value, i.e. a method "setMyParam(int)". This will also work for complex types like business objects etc.

Note that the preferred way to apply dependency injection to Job instances is via a JobFactory: that is, to specify SpringBeanJobFactory as Quartz JobFactory (typically via SchedulerFactoryBean#setJobFactory SchedulerFactoryBean's "jobFactory" property}). This allows to implement dependency-injected Quartz Jobs without a dependency on Spring base classes.

ResourceLoaderClassLoadHelper

open class ResourceLoaderClassLoadHelper : ClassLoadHelper

Wrapper that adapts from the Quartz ClassLoadHelper interface onto Spring's ResourceLoader interface. Used by default when the SchedulerFactoryBean runs in a Spring ApplicationContext.

SchedulerAccessorBean

open class SchedulerAccessorBean : SchedulerAccessor, BeanFactoryAware, InitializingBean

Spring bean-style class for accessing a Quartz Scheduler, i.e. for registering jobs, triggers and listeners on a given org.quartz.Scheduler instance.

Compatible with Quartz 2.1.4 and higher, as of Spring 4.1.

SimpleThreadPoolTaskExecutor

open class SimpleThreadPoolTaskExecutor : SimpleThreadPool, AsyncListenableTaskExecutor, SchedulingTaskExecutor, InitializingBean, DisposableBean

Subclass of Quartz's SimpleThreadPool that implements Spring's org.springframework.core.task.TaskExecutor interface and listens to Spring lifecycle callbacks.

Can be shared between a Quartz Scheduler (specified as "taskExecutor") and other TaskExecutor users, or even used completely independent of a Quartz Scheduler (as plain TaskExecutor backend).

SimpleTriggerFactoryBean

open class SimpleTriggerFactoryBean : FactoryBean<SimpleTrigger>, BeanNameAware, InitializingBean

A Spring FactoryBean for creating a Quartz org.quartz.SimpleTrigger instance, supporting bean-style usage for trigger configuration.

SimpleTrigger(Impl) itself is already a JavaBean but lacks sensible defaults. This class uses the Spring bean name as job name, the Quartz default group ("DEFAULT") as job group, the current time as start time, and indefinite repetition, if not specified.

This class will also register the trigger with the job name and group of a given org.quartz.JobDetail. This allows SchedulerFactoryBean to automatically register a trigger for the corresponding JobDetail, instead of registering the JobDetail separately.

SpringBeanJobFactory

open class SpringBeanJobFactory : AdaptableJobFactory, SchedulerContextAware

Subclass of AdaptableJobFactory that also supports Spring-style dependency injection on bean properties. This is essentially the direct equivalent of Spring's QuartzJobBean in the shape of a Quartz org.quartz.spi.JobFactory.

Applies scheduler context, job data map and trigger data map entries as bean property values. If no matching bean property is found, the entry is by default simply ignored. This is analogous to QuartzJobBean's behavior.

Compatible with Quartz 2.1.4 and higher, as of Spring 4.1.

Exceptions

JobMethodInvocationFailedException

open class JobMethodInvocationFailedException : NestedRuntimeException

Unchecked exception that wraps an exception thrown from a target method. Propagated to the Quartz scheduler from a Job that reflectively invokes an arbitrary target method.