spring-context-support

org.springframework.scheduling.quartz
Class JobDetailBean

java.lang.Object
  extended by org.quartz.JobDetail
      extended by org.springframework.scheduling.quartz.JobDetailBean
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContextAware

public class JobDetailBean
extends org.quartz.JobDetail
implements org.springframework.beans.factory.BeanNameAware, org.springframework.context.ApplicationContextAware, org.springframework.beans.factory.InitializingBean

Convenience subclass of Quartz's JobDetail class, making bean-style usage easier.

JobDetail 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.

NOTE: This convenience subclass does not work against Quartz 2.0. Use Quartz 2.0's native JobDetailImpl class or the new Quartz 2.0 builder API instead. Alternatively, switch to Spring's JobDetailFactoryBean which largely is a drop-in replacement for this class and its properties and consistently works against Quartz 1.x as well as Quartz 2.0/2.1.

Since:
18.02.2004
Author:
Juergen Hoeller
See Also:
JobDetail.setName(java.lang.String), JobDetail.setGroup(java.lang.String), BeanNameAware, Scheduler.DEFAULT_GROUP, Serialized Form

Constructor Summary
JobDetailBean()
           
 
Method Summary
 void afterPropertiesSet()
           
 java.lang.Class getJobClass()
          Overridden to support any job class, to allow a custom JobFactory to adapt the given job class to the Quartz Job interface.
 void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
           
 void setApplicationContextJobDataKey(java.lang.String applicationContextJobDataKey)
          Set the key of an ApplicationContext reference to expose in the JobDataMap, for example "applicationContext".
 void setBeanName(java.lang.String beanName)
           
 void setJobClass(java.lang.Class jobClass)
          Overridden to support any job class, to allow a custom JobFactory to adapt the given job class to the Quartz Job interface.
 void setJobDataAsMap(java.util.Map jobDataAsMap)
          Register objects in the JobDataMap via a given Map.
 void setJobListenerNames(java.lang.String[] names)
          Set a list of JobListener names for this job, referring to non-global JobListeners registered with the Scheduler.
 
Methods inherited from class org.quartz.JobDetail
addJobListener, clone, equals, getDescription, getFullName, getGroup, getJobDataMap, getJobListenerNames, getKey, getName, hashCode, isDurable, isStateful, isVolatile, removeJobListener, requestsRecovery, setDescription, setDurability, setGroup, setJobDataMap, setName, setRequestsRecovery, setVolatility, toString, validate
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JobDetailBean

public JobDetailBean()
Method Detail

setJobClass

public void setJobClass(java.lang.Class jobClass)
Overridden to support any job class, to allow a custom JobFactory to adapt the given job class to the Quartz Job interface.

Overrides:
setJobClass in class org.quartz.JobDetail
See Also:
SchedulerFactoryBean.setJobFactory(org.quartz.spi.JobFactory)

getJobClass

public java.lang.Class getJobClass()
Overridden to support any job class, to allow a custom JobFactory to adapt the given job class to the Quartz Job interface.

Overrides:
getJobClass in class org.quartz.JobDetail

setJobDataAsMap

public void setJobDataAsMap(java.util.Map jobDataAsMap)
Register objects in the JobDataMap via a given Map.

These objects will be available to this Job only, in contrast to objects in the SchedulerContext.

Note: When using persistent Jobs whose JobDetail will be kept in the database, do not put Spring-managed beans or an ApplicationContext reference into the JobDataMap but rather into the SchedulerContext.

Parameters:
jobDataAsMap - Map with String keys and any objects as values (for example Spring-managed beans)
See Also:
SchedulerFactoryBean.setSchedulerContextAsMap(java.util.Map)

setJobListenerNames

public void setJobListenerNames(java.lang.String[] names)
Set a list of JobListener names for this job, referring to non-global JobListeners registered with the Scheduler.

A JobListener name always refers to the name returned by the JobListener implementation.

See Also:
SchedulerAccessor.setJobListeners(org.quartz.JobListener[]), JobListener.getName()

setBeanName

public void setBeanName(java.lang.String beanName)
Specified by:
setBeanName in interface org.springframework.beans.factory.BeanNameAware

setApplicationContext

public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
Specified by:
setApplicationContext in interface org.springframework.context.ApplicationContextAware

setApplicationContextJobDataKey

public void setApplicationContextJobDataKey(java.lang.String applicationContextJobDataKey)
Set the key of an ApplicationContext reference to expose in the JobDataMap, for example "applicationContext". Default is none. Only applicable when running in a Spring ApplicationContext.

In case of a QuartzJobBean, the reference will be applied to the Job instance as bean property. An "applicationContext" attribute will correspond to a "setApplicationContext" method in that scenario.

Note that BeanFactory callback interfaces like ApplicationContextAware are not automatically applied to Quartz Job instances, because Quartz itself is responsible for the lifecycle of its Jobs.

Note: When using persistent job stores where JobDetail contents will be kept in the database, do not put an ApplicationContext reference into the JobDataMap but rather into the SchedulerContext.

See Also:
SchedulerFactoryBean.setApplicationContextSchedulerContextKey(java.lang.String), ApplicationContext

afterPropertiesSet

public void afterPropertiesSet()
Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean

spring-context-support