You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"Application contexts can auto-detect BeanFactoryPostProcessor beans in their bean definitions and apply them before any other beans get created. "
Thus @Bean BeanFactoryPostProcessor getSomeName(){ return new BeanFactoryPostProcessorImpl();} in a @Configuration class should cause the BeanFactoryPostProcessor run in the AnnotationConfigApplicationContext. Doesn't work. The callback method is never called. The bean is created, but only after other beans have been created.
This breaks the documented contract for an ApplicationContext.
Also there is problem with BeanFactoryPostprocessors registered in XML context included using @ImportResource annotation.
The problem is with an example in 3.11.3.2 chapter of reference doc:
does not work @ImportResource is processed by last call to {invokeBeanFactoryPostProcessors} in {org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(ConfigurableListableBeanFactory)}, so to invoke bean factory postprocessors defined in XML included with @ImportResource, there is a need for one more {invokeBeanFactoryPostProcessors} call..
Fixed through introducing a BeanDefinitionRegistryPostProcessor which gets invoked against the BeanDefinitionRegistry - before BeanFactoryPostProcessors get retrieved and applied. Any bean definitions registered by a BeanDefinitionRegistryPostProcessor are eligible for being run as BeanFactoryPostProcessors in the next phase. ConfigurationClassPostProcessors takes advantage of exactly that benefit, processing @Bean method in the BeanDefinitionRegistryPostProcessor phase now.
Dave King opened SPR-6455 and commented
The documentation in several places says:
"Application contexts can auto-detect BeanFactoryPostProcessor beans in their bean definitions and apply them before any other beans get created. "
Thus
@Bean
BeanFactoryPostProcessor getSomeName(){ return new BeanFactoryPostProcessorImpl();} in a@Configuration
class should cause the BeanFactoryPostProcessor run in the AnnotationConfigApplicationContext. Doesn't work. The callback method is never called. The bean is created, but only after other beans have been created.This breaks the documented contract for an ApplicationContext.
Affects: 3.0 RC2
Reference URL: http://forum.springsource.org/showthread.php?t=81044
Issue Links:
@Value
does not work with AnnotationConfigApplicationContext@ImportResource
in JavaConfigReferenced from: commits 6b2b5c4, 8ab9da4
3 votes, 5 watchers
The text was updated successfully, but these errors were encountered: