Skip to content

Improve target bean type detection for FactoryBeans [SPR-13986] #18558

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
spring-projects-issues opened this issue Feb 26, 2016 · 1 comment
Closed
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

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Feb 26, 2016

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 the FactoryBean implementations for remoting proxies, the JndiObjectFactoryBean and RepositoryFactoryBeanSupport 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 a BeanFactoryPostProcessor.

Spring Data currently deploys a InstantiationAwareBeanPostProcessor to predict the bean type based on the BeanDefinition 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 collecting BeanDefinition instances for EntityManager (in the course of some code to allow constructor injection of them) in case the EntityManager is provided by a JndiObjectFactoryBean.

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:

@jhoeller
Copy link
Contributor

jhoeller commented Jan 8, 2024

Superseded by the introduction of FactoryBean.OBJECT_TYPE_ATTRIBUTE in #23338.

@jhoeller jhoeller closed this as completed Jan 8, 2024
@jhoeller jhoeller removed this from the 6.x Backlog milestone Jan 8, 2024
@snicoll snicoll closed this as not planned Won't fix, can't repro, duplicate, stale Jan 8, 2024
@snicoll snicoll added the status: superseded An issue that has been superseded by another label Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

No branches or pull requests

3 participants