类 SchedulerFactoryBean

  • 所有已实现的接口:
    Aware, BeanNameAware, DisposableBean, FactoryBean<Scheduler>, InitializingBean, ApplicationContextAware, Lifecycle, Phased, ResourceLoaderAware, SmartLifecycle

    public class SchedulerFactoryBean
    extends SchedulerAccessor
    implements FactoryBean<Scheduler>, BeanNameAware, ApplicationContextAware, InitializingBean, DisposableBean, SmartLifecycle
    FactoryBean that creates and configures a Quartz Scheduler, manages its lifecycle as part of the Spring application context, and exposes the Scheduler as bean reference for dependency injection.

    Allows registration of JobDetails, Calendars and Triggers, automatically starting the scheduler on initialization and shutting it down on destruction. In scenarios that just require static registration of jobs at startup, there is no need to access the Scheduler instance itself in application code.

    For dynamic registration of jobs at runtime, use a bean reference to this SchedulerFactoryBean to get direct access to the Quartz Scheduler (org.quartz.Scheduler). This allows you to create new jobs and triggers, and also to control and monitor the entire Scheduler.

    Note that Quartz instantiates a new Job for each execution, in contrast to Timer which uses a TimerTask instance that is shared between repeated executions. Just JobDetail descriptors are shared.

    When using persistent jobs, it is strongly recommended to perform all operations on the Scheduler within Spring-managed (or plain JTA) transactions. Else, database locking will not properly work and might even break. (See setDataSource javadoc for details.)

    The preferred way to achieve transactional execution is to demarcate declarative transactions at the business facade level, which will automatically apply to Scheduler operations performed within those scopes. Alternatively, you may add transactional advice for the Scheduler itself.

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

    从以下版本开始:
    18.02.2004
    作者:
    Juergen Hoeller
    另请参阅:
    setDataSource(javax.sql.DataSource), Scheduler, SchedulerFactory, StdSchedulerFactory, TransactionProxyFactoryBean