Skip to content

Programmatic ObjectProvider retrieval through BeanFactory API [SPR-17075] #21613

Closed

Description

@spring-projects-issues

Juergen Hoeller opened SPR-17075 and commented

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.


Issue Links:

Activity

  1. spring-projects-issues commented on Jul 23, 2018

    @spring-projects-issues
    CollaboratorAuthor

    Dave Syer commented

    Can we also have a version of this method that takes a Type or ResolvableType?

  2. spring-projects-issues commented on Jul 23, 2018

    @spring-projects-issues
    CollaboratorAuthor

    Juergen Hoeller commented

    Good idea! I'll give getBeanProvider(ResolvableType) a try as well; sits nicely next to the existing getBeanNamesForType(ResolvableType)...

  3. spring-projects-issues commented on Jul 23, 2018

    @spring-projects-issues
    CollaboratorAuthor

    Juergen Hoeller commented

    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.

  4. added
    type: enhancement
    in: core
    on Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: coretype: enhancement

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions