public class JobDetailFactoryBean extends Object implements org.springframework.beans.factory.FactoryBean<JobDetail>, org.springframework.beans.factory.BeanNameAware, org.springframework.context.ApplicationContextAware, org.springframework.beans.factory.InitializingBean
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.
setName(java.lang.String)
,
setGroup(java.lang.String)
,
BeanNameAware
,
Scheduler.DEFAULT_GROUP
Constructor and Description |
---|
JobDetailFactoryBean() |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet() |
JobDataMap |
getJobDataMap()
Return the job's JobDataMap.
|
JobDetail |
getObject() |
Class<?> |
getObjectType() |
boolean |
isSingleton() |
void |
setApplicationContext(org.springframework.context.ApplicationContext applicationContext) |
void |
setApplicationContextJobDataKey(String applicationContextJobDataKey)
Set the key of an ApplicationContext reference to expose in the JobDataMap,
for example "applicationContext".
|
void |
setBeanName(String beanName) |
void |
setDescription(String description)
Set a textual description for this job.
|
void |
setDurability(boolean durability)
Specify the job's durability, i.e.
|
void |
setGroup(String group)
Specify the job's group.
|
void |
setJobClass(Class<? extends Job> jobClass)
Specify the job's implementation class.
|
void |
setJobDataAsMap(Map<String,?> jobDataAsMap)
Register objects in the JobDataMap via a given Map.
|
void |
setJobDataMap(JobDataMap jobDataMap)
Set the job's JobDataMap.
|
void |
setName(String name)
Specify the job's name.
|
void |
setRequestsRecovery(boolean requestsRecovery)
Set the recovery flag for this job, i.e.
|
public void setName(String name)
public void setGroup(String group)
public void setJobClass(Class<? extends Job> jobClass)
public void setJobDataMap(JobDataMap jobDataMap)
public JobDataMap getJobDataMap()
public void setJobDataAsMap(Map<String,?> jobDataAsMap)
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.
jobDataAsMap
- Map with String keys and any objects as values
(for example Spring-managed beans)SchedulerFactoryBean.setSchedulerContextAsMap(java.util.Map<java.lang.String, ?>)
public void setDurability(boolean durability)
public void setRequestsRecovery(boolean requestsRecovery)
public void setDescription(String description)
public void setBeanName(String beanName)
setBeanName
in interface org.springframework.beans.factory.BeanNameAware
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
setApplicationContext
in interface org.springframework.context.ApplicationContextAware
public void setApplicationContextJobDataKey(String applicationContextJobDataKey)
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.
SchedulerFactoryBean.setApplicationContextSchedulerContextKey(java.lang.String)
,
ApplicationContext
public void afterPropertiesSet()
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
@Nullable public JobDetail getObject()
getObject
in interface org.springframework.beans.factory.FactoryBean<JobDetail>
public Class<?> getObjectType()
getObjectType
in interface org.springframework.beans.factory.FactoryBean<JobDetail>
public boolean isSingleton()
isSingleton
in interface org.springframework.beans.factory.FactoryBean<JobDetail>