spring-context-support

org.springframework.scheduling.quartz
Class JobDetailFactoryBean

java.lang.Object
  extended by org.springframework.scheduling.quartz.JobDetailFactoryBean
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.FactoryBean<org.quartz.JobDetail>, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContextAware

public class JobDetailFactoryBean
extends java.lang.Object
implements org.springframework.beans.factory.FactoryBean<org.quartz.JobDetail>, org.springframework.beans.factory.BeanNameAware, org.springframework.context.ApplicationContextAware, org.springframework.beans.factory.InitializingBean

A Spring FactoryBean for creating a 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.

NOTE: This FactoryBean works against both Quartz 1.x and Quartz 2.0/2.1, in contrast to the older JobDetailBean class.

Since:
3.1
Author:
Juergen Hoeller
See Also:
setName(java.lang.String), setGroup(java.lang.String), BeanNameAware, Scheduler.DEFAULT_GROUP

Constructor Summary
JobDetailFactoryBean()
           
 
Method Summary
 void afterPropertiesSet()
           
 org.quartz.JobDataMap getJobDataMap()
          Return the job's JobDataMap.
 org.quartz.JobDetail getObject()
           
 java.lang.Class<?> getObjectType()
           
 boolean isSingleton()
           
 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 setDescription(java.lang.String description)
          Set a textual description for this job.
 void setDurability(boolean durability)
          Specify the job's durability, i.e.
 void setGroup(java.lang.String group)
          Specify the job's group.
 void setJobClass(java.lang.Class jobClass)
          Specify the job's implementation class.
 void setJobDataAsMap(java.util.Map<java.lang.String,?> jobDataAsMap)
          Register objects in the JobDataMap via a given Map.
 void setJobDataMap(org.quartz.JobDataMap jobDataMap)
          Set the job's JobDataMap.
 void setName(java.lang.String name)
          Specify the job's name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JobDetailFactoryBean

public JobDetailFactoryBean()
Method Detail

setName

public void setName(java.lang.String name)
Specify the job's name.


setGroup

public void setGroup(java.lang.String group)
Specify the job's group.


setJobClass

public void setJobClass(java.lang.Class jobClass)
Specify the job's implementation class.


setJobDataMap

public void setJobDataMap(org.quartz.JobDataMap jobDataMap)
Set the job's JobDataMap.

See Also:
setJobDataAsMap(java.util.Map)

getJobDataMap

public org.quartz.JobDataMap getJobDataMap()
Return the job's JobDataMap.


setJobDataAsMap

public void setJobDataAsMap(java.util.Map<java.lang.String,?> 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)

setDurability

public void setDurability(boolean durability)
Specify the job's durability, i.e. whether it should remain stored in the job store even if no triggers point to it anymore.


setDescription

public void setDescription(java.lang.String description)
Set a textual description for this job.


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

getObject

public org.quartz.JobDetail getObject()
Specified by:
getObject in interface org.springframework.beans.factory.FactoryBean<org.quartz.JobDetail>

getObjectType

public java.lang.Class<?> getObjectType()
Specified by:
getObjectType in interface org.springframework.beans.factory.FactoryBean<org.quartz.JobDetail>

isSingleton

public boolean isSingleton()
Specified by:
isSingleton in interface org.springframework.beans.factory.FactoryBean<org.quartz.JobDetail>

spring-context-support