Avoid scoped destruction callbacks in case of no post-processor actually applying

Issue: SPR-13744
This commit is contained in:
Juergen Hoeller
2015-12-18 16:54:05 +01:00
parent 1502e49fa5
commit fca5365cf1
8 changed files with 107 additions and 30 deletions

View File

@@ -347,7 +347,8 @@ class PostProcessorRegistrationDelegate {
* BeanPostProcessor that detects beans which implement the ApplicationListener interface.
* This catches beans that can't reliably be detected by getBeanNamesForType.
*/
private static class ApplicationListenerDetector implements MergedBeanDefinitionPostProcessor, DestructionAwareBeanPostProcessor {
private static class ApplicationListenerDetector
implements DestructionAwareBeanPostProcessor, MergedBeanDefinitionPostProcessor {
private static final Log logger = LogFactory.getLog(ApplicationListenerDetector.class);
@@ -402,6 +403,11 @@ class PostProcessorRegistrationDelegate {
multicaster.removeApplicationListenerBean(beanName);
}
}
@Override
public boolean requiresDestruction(Object bean) {
return (bean instanceof ApplicationListener);
}
}
}