LazyInitTargetSource works for @Bean targets as well

Issue: SPR-10508
Issue: SPR-8080
This commit is contained in:
Juergen Hoeller
2014-09-02 22:13:35 +02:00
parent b64f680f19
commit 8c9274e017
4 changed files with 243 additions and 3 deletions

View File

@@ -296,7 +296,7 @@ class ConfigurationClassEnhancer {
}
}
if (isCurrentlyInvokedFactoryMethod(beanMethod) && !beanFactory.containsSingleton(beanName)) {
if (isCurrentlyInvokedFactoryMethod(beanMethod)) {
// The factory is calling the bean method in order to instantiate and register the bean
// (i.e. via a getBean() call) -> invoke the super implementation of the method to actually
// create the bean instance.
@@ -306,7 +306,7 @@ class ConfigurationClassEnhancer {
"result in a failure to process annotations such as @Autowired, " +
"@Resource and @PostConstruct within the method's declaring " +
"@Configuration class. Add the 'static' modifier to this method to avoid " +
"these container lifecycle issues; see @Bean Javadoc for complete details",
"these container lifecycle issues; see @Bean javadoc for complete details",
beanMethod.getDeclaringClass().getSimpleName(), beanMethod.getName()));
}
return cglibMethodProxy.invokeSuper(enhancedConfigInstance, beanMethodArgs);