Skip to content

Allow filtering bean instances returned by ObjectProvider#stream() #34318

Closed
@odrotbohm

Description

@odrotbohm

The implementations of ObjectProvider.stream() look up all bean names for the type referenced and subsequently look up the bean instance itself. This means that a call to ….stream() ultimately causes all bean instances to be initialized. It would be nice if there was a way to be selective about which of those instances I want to get by being able to filter on the bean name before instantiation.

My particular use case is to exclude beans of a particular type, so the filter being a BiPredicate<String, Class<?>> would prevent my code from having to obtain a reference to a BeanFactory to obtain the bean definition's type. That said, a simple stream(Predicate<String> beanNameFilter) would work as well.

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions