BeanFactoryUtils class abstract final

Helpers that list beans across a whole hierarchy of factories, and that handle the & prefix of factory bean names.

The listing methods of ListableBeanFactory see only the factory's own beans. When contexts are nested (a child context on top of a shared parent), code that must find every bean of a type, wherever it is declared, uses these helpers. A bean hides the beans with the same name in its ancestors. Applications with a single context do not need them.

// In a child context: the greeters of the child and of its parents.
final names = BeanFactoryUtils.beanNamesForTypeIncludingAncestors(
  childContext,
  Greeter,
);
final greeters =
    BeanFactoryUtils.beansOfTypeIncludingAncestors<Greeter>(childContext);

Spring (Java):

String[] names = BeanFactoryUtils.beanNamesForTypeIncludingAncestors(
    childContext, Greeter.class);
Map<String, Greeter> greeters =
    BeanFactoryUtils.beansOfTypeIncludingAncestors(
        childContext, Greeter.class);

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

beanNamesForTypeIncludingAncestors(ListableBeanFactory factory, Type type, {bool includeNonSingletons = true}) → List<String>
The names of the beans of type in factory and its ancestors, without creating them: factory's own names first (as ListableBeanFactory.getBeanNamesForType lists them), then the parents' names that no factory below declares.
beansOfTypeIncludingAncestors<T extends Object>(ListableBeanFactory factory, {bool includeNonSingletons = true}) → Map<String, T>
The beans of T in factory and its ancestors, by name, created if needed. A bean hides a parent's bean with the same name.
isFactoryDereference(String name) → bool
Whether name asks for a factory bean itself, that is, starts with &.
transformedBeanName(String name) → String
name without its leading & characters: the bean name that &name refers to.