public class JobRegistryBeanPostProcessor extends Object implements org.springframework.beans.factory.config.BeanPostProcessor, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean
BeanPostProcessor that registers Job beans with a
JobRegistry. Include a bean of this type along with your job
configuration, and use the same JobRegistry as a JobLocator
when you need to locate a Job to launch.| Constructor and Description |
|---|
JobRegistryBeanPostProcessor() |
| Modifier and Type | Method and Description |
|---|---|
void |
afterPropertiesSet()
Make sure the registry is set before use.
|
void |
destroy()
De-register all the
Job instances that were regsistered by this
post processor. |
protected String |
getGroupName(org.springframework.beans.factory.config.BeanDefinition beanDefinition,
Job job)
Determine a group name for the job to be registered.
|
Object |
postProcessAfterInitialization(Object bean,
String beanName)
If the bean is an instance of
Job then register it. |
Object |
postProcessBeforeInitialization(Object bean,
String beanName)
Do nothing.
|
void |
setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory) |
void |
setGroupName(String groupName)
The group name for jobs registered by this component.
|
void |
setJobRegistry(JobRegistry jobRegistry)
Injection setter for
JobRegistry. |
public void setGroupName(String groupName)
JobRegistry: child contexts can then
define an instance with a unique group name to avoid clashes between job
names.groupName - the groupName to setpublic void setJobRegistry(JobRegistry jobRegistry)
JobRegistry.jobRegistry - the jobConfigurationRegistry to setpublic void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)
throws org.springframework.beans.BeansException
setBeanFactory in interface org.springframework.beans.factory.BeanFactoryAwareorg.springframework.beans.BeansExceptionpublic void afterPropertiesSet()
throws Exception
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBeanExceptionInitializingBean.afterPropertiesSet()public void destroy()
throws Exception
Job instances that were regsistered by this
post processor.destroy in interface org.springframework.beans.factory.DisposableBeanExceptionDisposableBean.destroy()public Object postProcessAfterInitialization(Object bean, String beanName) throws org.springframework.beans.BeansException
Job then register it.postProcessAfterInitialization in interface org.springframework.beans.factory.config.BeanPostProcessororg.springframework.beans.FatalBeanException - if there is a DuplicateJobException.org.springframework.beans.BeansExceptionBeanPostProcessor.postProcessAfterInitialization(java.lang.Object,
java.lang.String)protected String getGroupName(org.springframework.beans.factory.config.BeanDefinition beanDefinition, Job job)
groupName
configured. Provides an extension point for specialised subclasses.beanDefinition - the bean definition for the jobjob - the jobpublic Object postProcessBeforeInitialization(Object bean, String beanName) throws org.springframework.beans.BeansException
postProcessBeforeInitialization in interface org.springframework.beans.factory.config.BeanPostProcessororg.springframework.beans.BeansExceptionBeanPostProcessor.postProcessBeforeInitialization(java.lang.Object,
java.lang.String)Copyright © 2013. All rights reserved.