Improve target bean type detection for FactoryBeans [SPR-13986] #18558
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
status: superseded
An issue that has been superseded by another
type: enhancement
A general enhancement
Uh oh!
There was an error while loading. Please reload this page.
Oliver Drotbohm opened SPR-13986 and commented
There are a couple of
FactoryBean
implementations that produce proxy instances and the the type of the proxy to be created configured. Examples of that are theFactoryBean
implementations for remoting proxies, theJndiObjectFactoryBean
andRepositoryFactoryBeanSupport
in Spring Data.Factories that are build that way cannot be detected by target type until they're initialized which can be a problem if the
BeanDefinition
instances for them are supposed to be found e.g. in aBeanFactoryPostProcessor
.Spring Data currently deploys a
InstantiationAwareBeanPostProcessor
to predict the bean type based on theBeanDefinition
setup, interpreting a certain property value as the type which that bean definition will eventually end up in. However, the lookup issue also pops up in the context of collectingBeanDefinition
instances forEntityManager
(in the course of some code to allow constructor injection of them) in case theEntityManager
is provided by aJndiObjectFactoryBean
.While I can of course extract the relevant code in Spring Data and also provide a prediction mechanism for the
JndiObjectFactoryBean
it doesn't feel very natural to place that setup in Spring Data itself as it shouldn't really care about JNDI.So it would be cool if there was a general prediction mechanism deployed that uses an annotation on one of the
FactoryBean
's setters to identify the property as target type property and use that predicted type.Issue Links:
The text was updated successfully, but these errors were encountered: