Abstract base class for BeanFactory
implementations, providing the full capabilities of the
ConfigurableBeanFactory SPI.
Does not assume a listable bean factory: can therefore also be used
as base class for bean factory implementations which obtain bean definitions
from some backend resource (where bean definition access is an expensive operation).

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.

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.

setBeanClassLoader

Set the class loader to use for loading bean classes.
Default is the thread context class loader.

Note that this class loader will only apply to bean definitions
that do not carry a resolved bean class yet. This is the case as of
Spring 2.0 by default: Bean definitions only carry bean class names,
to be resolved once the factory processes the bean definition.

setTempClassLoader

Specify a temporary ClassLoader to use for type matching purposes.
Default is none, simply using the standard bean ClassLoader.

A temporary ClassLoader is usually just specified if
load-time weaving is involved, to make sure that actual bean
classes are loaded as lazily as possible. The temporary loader is
then removed once the BeanFactory completes its bootstrap phase.

setCacheBeanMetadata

Set whether to cache bean metadata such as given bean definitions
(in merged fashion) and resolved bean classes. Default is on.

Turn this flag off to enable hot-refreshing of bean definition objects
and in particular bean classes. If this flag is off, any creation of a bean
instance will re-query the bean class loader for newly resolved classes.

setBeanExpressionResolver

Specify the resolution strategy for expressions in bean definition values.

There is no expression support active in a BeanFactory by default.
An ApplicationContext will typically set a standard expression strategy
here, supporting "#{...}" expressions in a Unified EL compatible style.

addBeanPostProcessor

Add a new BeanPostProcessor that will get applied to beans created
by this factory. To be invoked during factory configuration.

Note: Post-processors submitted here will be applied in the order of
registration; any ordering semantics expressed through implementing the
Ordered interface will be ignored. Note
that autodetected post-processors (e.g. as beans in an ApplicationContext)
will always be applied after programmatically registered ones.

copyConfigurationFrom

Should include all standard configuration settings as well as
BeanPostProcessors, Scopes, and factory-specific internal settings.
Should not include any metadata of actual bean definitions,
such as BeanDefinition objects and bean name aliases.

This implementation is simplistic in that it is not able to
handle factory methods and InstantiationAwareBeanPostProcessors.
It only predicts the bean type correctly for a standard bean.
To be overridden in subclasses, applying more sophisticated type detection.

Parameters:

beanName - the name of the bean

mbd - the merged bean definition to determine the type for

typesToMatch - the types to match in case of internal type matching purposes
(also signals that the returned Class will never be exposed to application code)

getTypeForFactoryBean

Determine the bean type for the given FactoryBean definition, as far as possible.
Only called if there is no singleton instance registered for the target bean already.

The default implementation creates the FactoryBean via getBean
to call its getObjectType method. Subclasses are encouraged to optimize
this, typically by just instantiating the FactoryBean but not populating it yet,
trying whether its getObjectType method already returns a type.
If no type found, a full FactoryBean creation as performed by this implementation
should be used as fallback.

registerDisposableBeanIfNecessary

Add the given bean to the list of disposable beans in this factory,
registering its DisposableBean interface and/or the given destroy method
to be called on factory shutdown (if applicable). Only applies to singletons.

containsBeanDefinition

Check if this bean factory contains a bean definition with the given name.
Does not consider any hierarchy this factory may participate in.
Invoked by containsBean when no cached singleton instance is found.

Depending on the nature of the concrete bean factory implementation,
this operation might be expensive (for example, because of directory lookups
in external registries). However, for listable bean factories, this usually
just amounts to a local hash lookup: The operation is therefore part of the
public interface there. The same implementation can serve for both this
template method and the public interface method in that case.

getBeanDefinition

Return the bean definition for the given bean name.
Subclasses should normally implement caching, as this method is invoked
by this class every time bean definition metadata is needed.

Depending on the nature of the concrete bean factory implementation,
this operation might be expensive (for example, because of directory lookups
in external registries). However, for listable bean factories, this usually
just amounts to a local hash lookup: The operation is therefore part of the
public interface there. The same implementation can serve for both this
template method and the public interface method in that case.