Static BeanFactory implementation
which allows to register existing singleton instances programmatically.
Does not have support for prototype beans or aliases.

Serves as example for a simple implementation of the
ListableBeanFactory interface,
managing existing bean instances rather than creating new ones based on bean
definitions, and not implementing any extended SPI interfaces (such as
ConfigurableBeanFactory).

findAnnotationOnBean(String beanName,
Class<A> annotationType)
Find a Annotation of annotationType on the specified
bean, traversing its interfaces and super classes if no annotation can be
found on the given class itself.

getBeanNamesForType(Class type)
Return the names of beans matching the given type (including subclasses),
judging from either bean definitions or the value of getObjectType
in the case of FactoryBeans.

getBeanNamesForType(Class type,
boolean includeNonSingletons,
boolean includeFactoryBeans)
Return the names of beans matching the given type (including subclasses),
judging from either bean definitions or the value of getObjectType
in the case of FactoryBeans.

getBeansOfType(Class<T> type)
Return the bean instances that match the given object type (including
subclasses), judging from either bean definitions or the value of
getObjectType in the case of FactoryBeans.

getBeansOfType(Class<T> type,
boolean includeNonSingletons,
boolean includeFactoryBeans)
Return the bean instances that match the given object type (including
subclasses), judging from either bean definitions or the value of
getObjectType in the case of FactoryBeans.

getBean

Return an instance, which may be shared or independent, of the specified bean.

Behaves the same as BeanFactory.getBean(String), but provides a measure of type
safety by throwing a BeanNotOfRequiredTypeException if the bean is not of the
required type. This means that ClassCastException can't be thrown on casting
the result correctly, as can happen with BeanFactory.getBean(String).

Translates aliases back to the corresponding canonical bean name.
Will ask the parent factory if the bean cannot be found in this factory instance.

requiredType - type the bean must match. Can be an interface or superclass
of the actual class, or null for any match. For example, if the value
is Object.class, this method will succeed whatever the class of the
returned instance.

requiredType - type the bean must match; can be an interface or superclass.
null is disallowed.

This method goes into ListableBeanFactory by-type lookup territory
but may also be translated into a conventional by-name lookup based on the name
of the given type. For more extensive retrieval operations across sets of beans,
use ListableBeanFactory and/or BeanFactoryUtils.

containsBean

Does this bean factory contain a bean definition or externally registered singleton
instance with the given name?

If the given name is an alias, it will be translated back to the corresponding
canonical bean name.

If this factory is hierarchical, will ask any parent factory if the bean cannot
be found in this factory instance.

If a bean definition or singleton instance matching the given name is found,
this method will return true whether the named bean definition is concrete
or abstract, lazy or eager, in scope or not. Therefore, note that a true
return value from this method does not necessarily indicate that BeanFactory.getBean(java.lang.String)
will be able to obtain an instance for the same name.

Note: This method returning false does not clearly indicate
independent instances. It indicates non-singleton instances, which may correspond
to a scoped bean as well. Use the BeanFactory.isPrototype(java.lang.String) operation to explicitly
check for independent instances.

Translates aliases back to the corresponding canonical bean name.
Will ask the parent factory if the bean cannot be found in this factory instance.

Note: This method returning false does not clearly indicate
a singleton object. It indicates non-independent instances, which may correspond
to a scoped bean as well. Use the BeanFactory.isSingleton(java.lang.String) operation to explicitly
check for a shared singleton instance.

Translates aliases back to the corresponding canonical bean name.
Will ask the parent factory if the bean cannot be found in this factory instance.

isTypeMatch

Check whether the bean with the given name matches the specified type.
More specifically, check whether a BeanFactory.getBean(java.lang.String) call for the given name
would return an object that is assignable to the specified target type.

Translates aliases back to the corresponding canonical bean name.
Will ask the parent factory if the bean cannot be found in this factory instance.

getBeanNamesForType

Return the names of beans matching the given type (including subclasses),
judging from either bean definitions or the value of getObjectType
in the case of FactoryBeans.

NOTE: This method introspects top-level beans only. It does not
check nested beans which might match the specified type as well.

Does consider objects created by FactoryBeans, which means that FactoryBeans
will get initialized. If the object created by the FactoryBean doesn't match,
the raw FactoryBean itself will be matched against the type.

Does not consider any hierarchy this factory may participate in.
Use BeanFactoryUtils' beanNamesForTypeIncludingAncestors
to include beans in ancestor factories too.

Note: Does not ignore singleton beans that have been registered
by other means than bean definitions.

This version of getBeanNamesForType matches all kinds of beans,
be it singletons, prototypes, or FactoryBeans. In most implementations, the
result will be the same as for getBeanNamesOfType(type, true, true).

Bean names returned by this method should always return bean names in the
order of definition in the backend configuration, as far as possible.

getBeanNamesForType

Return the names of beans matching the given type (including subclasses),
judging from either bean definitions or the value of getObjectType
in the case of FactoryBeans.

NOTE: This method introspects top-level beans only. It does not
check nested beans which might match the specified type as well.

Does consider objects created by FactoryBeans if the "allowEagerInit" flag is set,
which means that FactoryBeans will get initialized. If the object created by the
FactoryBean doesn't match, the raw FactoryBean itself will be matched against the
type. If "allowEagerInit" is not set, only raw FactoryBeans will be checked
(which doesn't require initialization of each FactoryBean).

Does not consider any hierarchy this factory may participate in.
Use BeanFactoryUtils' beanNamesForTypeIncludingAncestors
to include beans in ancestor factories too.

Note: Does not ignore singleton beans that have been registered
by other means than bean definitions.

Bean names returned by this method should always return bean names in the
order of definition in the backend configuration, as far as possible.

includeNonSingletons - whether to include prototype or scoped beans too
or just singletons (also applies to FactoryBeans)

includeFactoryBeans - whether to initialize lazy-init singletons and
objects created by FactoryBeans (or by factory methods with a
"factory-bean" reference) for the type check. Note that FactoryBeans need to be
eagerly initialized to determine their type: So be aware that passing in "true"
for this flag will initialize FactoryBeans and "factory-bean" references.

Returns:

the names of beans (or objects created by FactoryBeans) matching
the given object type (including subclasses), or an empty array if none

getBeansOfType

Return the bean instances that match the given object type (including
subclasses), judging from either bean definitions or the value of
getObjectType in the case of FactoryBeans.

NOTE: This method introspects top-level beans only. It does not
check nested beans which might match the specified type as well.

Does consider objects created by FactoryBeans, which means that FactoryBeans
will get initialized. If the object created by the FactoryBean doesn't match,
the raw FactoryBean itself will be matched against the type.

Does not consider any hierarchy this factory may participate in.
Use BeanFactoryUtils' beansOfTypeIncludingAncestors
to include beans in ancestor factories too.

Note: Does not ignore singleton beans that have been registered
by other means than bean definitions.

This version of getBeansOfType matches all kinds of beans, be it
singletons, prototypes, or FactoryBeans. In most implementations, the
result will be the same as for getBeansOfType(type, true, true).

The Map returned by this method should always return bean names and
corresponding bean instances in the order of definition in the
backend configuration, as far as possible.

getBeansOfType

Return the bean instances that match the given object type (including
subclasses), judging from either bean definitions or the value of
getObjectType in the case of FactoryBeans.

NOTE: This method introspects top-level beans only. It does not
check nested beans which might match the specified type as well.

Does consider objects created by FactoryBeans if the "allowEagerInit" flag is set,
which means that FactoryBeans will get initialized. If the object created by the
FactoryBean doesn't match, the raw FactoryBean itself will be matched against the
type. If "allowEagerInit" is not set, only raw FactoryBeans will be checked
(which doesn't require initialization of each FactoryBean).

Does not consider any hierarchy this factory may participate in.
Use BeanFactoryUtils' beansOfTypeIncludingAncestors
to include beans in ancestor factories too.

Note: Does not ignore singleton beans that have been registered
by other means than bean definitions.

The Map returned by this method should always return bean names and
corresponding bean instances in the order of definition in the
backend configuration, as far as possible.

type - the class or interface to match, or null for all concrete beans

includeNonSingletons - whether to include prototype or scoped beans too
or just singletons (also applies to FactoryBeans)

includeFactoryBeans - whether to initialize lazy-init singletons and
objects created by FactoryBeans (or by factory methods with a
"factory-bean" reference) for the type check. Note that FactoryBeans need to be
eagerly initialized to determine their type: So be aware that passing in "true"
for this flag will initialize FactoryBeans and "factory-bean" references.

Returns:

a Map with the matching beans, containing the bean names as
keys and the corresponding bean instances as values