Moved the injection of the TaskBatchListner to the postProcessAfterInitialization from postProcessBeforeInitialization

Because when using FactoryBeans  the TaskBatchListener postprocessing isn't fired when using before initialization
This commit is contained in:
Glenn Renfro
2017-04-10 14:37:04 -04:00
parent 450de51d0c
commit bbb0d68ce6
2 changed files with 61 additions and 14 deletions

View File

@@ -44,13 +44,17 @@ public class TaskBatchExecutionListenerBeanPostProcessor implements BeanPostProc
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName)
throws BeansException {
return bean;
}
@Override
public Object postProcessAfterInitialization(Object bean, String beanName)
throws BeansException {
if(jobNames.size() > 0) {
if(!jobNames.contains(beanName)) {
return bean;
}
}
int length = this.applicationContext
.getBeanNamesForType(TaskBatchExecutionListener.class).length;
@@ -60,17 +64,9 @@ public class TaskBatchExecutionListenerBeanPostProcessor implements BeanPostProc
"have exactly 1 instance of the TaskBatchExecutionListener but has " +
length);
}
((AbstractJob) bean).registerJobExecutionListener(
this.applicationContext.getBean(TaskBatchExecutionListener.class));
}
return bean;
}
@Override
public Object postProcessAfterInitialization(Object bean, String beanName)
throws BeansException {
return bean;
}