Thomas Darimont opened SPR-13132 and commented
It would be helpful to be able to dynamically query an application context for beans that match a specific type and or are annotated with some specific qualifier annotations.
CDI offers support for this via javax.enterprise.inject.Instance. Currently the application context only offers to query beans by type. It would be great if we could support dynamic bean lookups via Instance<T> backed by the BeanRegistry.
I did a quick PoC here.
The basic idea is to provide a custom AutowireCandidateResolver that detects Instance<T> autowire targets, identifies the actual target bean type and provides some kind of Instance adapter which performs the actual bean lookup.
Reference URL: https://github.com/thomasdarimont/spring-boot-cdi-instance-example/blob/master/src/test/java/demo/SimpleCdiInstanceAdapterTests.java#L73
Issue Links:
3 votes, 7 watchers
Thomas Darimont opened SPR-13132 and commented
It would be helpful to be able to dynamically query an application context for beans that match a specific type and or are annotated with some specific qualifier annotations.
CDI offers support for this via
javax.enterprise.inject.Instance. Currently the application context only offers to query beans by type. It would be great if we could support dynamic bean lookups viaInstance<T>backed by theBeanRegistry.I did a quick PoC here.
The basic idea is to provide a custom
AutowireCandidateResolverthat detectsInstance<T>autowire targets, identifies the actual target bean type and provides some kind ofInstanceadapter which performs the actual bean lookup.Reference URL: https://github.com/thomasdarimont/spring-boot-cdi-instance-example/blob/master/src/test/java/demo/SimpleCdiInstanceAdapterTests.java#L73
Issue Links:
3 votes, 7 watchers