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
{{ message }}
Repository navigation
Programmatic ObjectProvider retrieval through BeanFactory API [SPR-17075] #21613
After several discussions around #21511, #16046 and #13532, it turns out that programmatic retrieval of an ObjectProvider handle - as opposed to it just being obtainable through annotation-driven injection - would significantly enrich functional bean definitions.
So as of 5.1, BeanFactory.getBeanProvider provides a convenient and powerful enough entry point for the time being. Stream access to multiple matching beans is covered in #16046 now; just programmatic bean retrieval with qualifiers is left to #13532 still.
I've introduced getBeanProvider(Class) and getBeanProvider(ResolvableType), also narrowing getBean(String, Class) and isTypeMatch(String, Class) to a non-null Class argument and enriching NoUniqueBeanDefinitionException with a full ResolvableType.
In addition, ObjectProvider supports iterable/stream access for collection-style resolution of multiple matching beans now: see #16046.
Activity
spring-projects-issues commentedon Jul 23, 2018
Dave Syer commented
Can we also have a version of this method that takes a
TypeorResolvableType?spring-projects-issues commentedon Jul 23, 2018
Juergen Hoeller commented
Good idea! I'll give
getBeanProvider(ResolvableType) a try as well; sits nicely next to the existinggetBeanNamesForType(ResolvableType)...spring-projects-issues commentedon Jul 23, 2018
Juergen Hoeller commented
I've introduced
getBeanProvider(Class)andgetBeanProvider(ResolvableType), also narrowinggetBean(String, Class)andisTypeMatch(String, Class)to a non-nullClassargument and enrichingNoUniqueBeanDefinitionExceptionwith a fullResolvableType.In addition,
ObjectProvidersupports iterable/stream access for collection-style resolution of multiple matching beans now: see #16046.