org.springframework.beans.factory.BeanFactory
interface to be implemented by bean factories that are capable of
autowiring, provided that they want to expose this functionality for
existing bean instances.
This subinterface of BeanFactory is not meant to be used in normal
application code: stick to
or org.springframework.beans.factory.BeanFactory for
typical use cases.
org.springframework.beans.factory.ListableBeanFactory
Integration code for other frameworks can leverage this interface to wire and populate existing bean instances that Spring does not control the lifecycle of. This is particularly useful for WebWork Actions and Tapestry Page objects, for example.
Note that this interface is not implemented by
facades,
as it is hardly ever used by application code. That said, it is available
from an application context too, accessible through ApplicationContext's
org.springframework.context.ApplicationContext
method.
org.springframework.context.ApplicationContext#getAutowireCapableBeanFactory()
You may also implement the
interface, which exposes the internal BeanFactory even when running in an
ApplicationContext, to get access to an AutowireCapableBeanFactory:
simply cast the passed-in BeanFactory to AutowireCapableBeanFactory.
org.springframework.beans.factory.BeanFactoryAware
org.springframework.beans.factory.BeanFactoryAwareConfigurableListableBeanFactoryorg.springframework.context.ApplicationContext#getAutowireCapableBeanFactory()Performs full initialization of the bean, including all applicable
BeanPostProcessors.
Note: This is intended for creating a fresh instance, populating annotated
fields and methods as well as applying all standard bean initialiation callbacks.
It does not</> imply traditional by-name or by-type autowiring of properties;
use for that purposes.
createBean(java.lang.Class,int,boolean)
beanClass the class of the bean to createorg.springframework.beans.BeansException if instantiation or wiring failedNote: This is essentially intended for (re-)populating annotated fields and
methods, either for new instances or for deserialized instances. It does
not imply traditional by-name or by-type autowiring of properties;
use for that purposes.
autowireBeanProperties(java.lang.Object,int,boolean)
existingBean the existing bean instanceorg.springframework.beans.BeansException if wiring failedsetBeanName
and setBeanFactory, and also applying all bean post processors
(including ones which might wrap the given raw bean).
This is effectively a superset of what provides,
fully applying the configuration specified by the corresponding bean definition.
Note: This method requires a bean definition for the given name!
initializeBean(java.lang.Object,java.lang.String)
existingBean the existing bean instancebeanName the name of the bean, to be passed to it if necessary
(a bean definition of that name has to be available)org.springframework.beans.factory.NoSuchBeanDefinitionException
if there is no bean definition with the given nameorg.springframework.beans.BeansException if the initialization failedinitializeBean(java.lang.Object,java.lang.String)descriptor the descriptor for the dependencybeanName the name of the bean which declares the present dependencynull if none foundorg.springframework.beans.BeansException in dependency resolution failedObjectresolveDependency(DependencyDescriptor descriptor, String beanName) throws BeansException;
Performs full initialization of the bean, including all applicable
BeanPostProcessors. This is effectively a superset
of what provides, adding autowire(java.lang.Class,int,boolean) behavior.
initializeBean(java.lang.Object,java.lang.String)
beanClass the class of the bean to createautowireMode by name or type, using the constants in this interfacedependencyCheck whether to perform a dependency check for objects
(not applicable to autowiring a constructor, thus ignored there)org.springframework.beans.BeansException if instantiation or wiring failedAUTOWIRE_NOAUTOWIRE_BY_NAMEAUTOWIRE_BY_TYPEAUTOWIRE_CONSTRUCTORAUTOWIRE_AUTODETECTObjectcreateBean(Class beanClass, int autowireMode, boolean dependencyCheck) throws BeansException;
AUTOWIRE_NO in order to just apply
before-instantiation callbacks (e.g. for annotation-driven injection).
Does not apply standard BeanPostProcessors
callbacks or perform any further initialization of the bean. This interface
offers distinct, fine-grained operations for those purposes, for example
. However, initializeBean(java.lang.Object,java.lang.String)
callbacks are applied, if applicable to the construction of the instance.
InstantiationAwareBeanPostProcessor
beanClass the class of the bean to instantiateautowireMode by name or type, using the constants in this interfacedependencyCheck whether to perform a dependency check for object
references in the bean instance (not applicable to autowiring a constructor,
thus ignored there)org.springframework.beans.BeansException if instantiation or wiring failedAUTOWIRE_NOAUTOWIRE_BY_NAMEAUTOWIRE_BY_TYPEAUTOWIRE_CONSTRUCTORAUTOWIRE_AUTODETECTinitializeBean(java.lang.Object,java.lang.String)applyBeanPostProcessorsBeforeInitialization(java.lang.Object,java.lang.String)applyBeanPostProcessorsAfterInitialization(java.lang.Object,java.lang.String)Objectautowire(Class beanClass, int autowireMode, boolean dependencyCheck) throws BeansException;
AUTOWIRE_NO in order to just apply
after-instantiation callbacks (e.g. for annotation-driven injection).
Does not apply standard BeanPostProcessors
callbacks or perform any further initialization of the bean. This interface
offers distinct, fine-grained operations for those purposes, for example
. However, initializeBean(java.lang.Object,java.lang.String)
callbacks are applied, if applicable to the configuration of the instance.
InstantiationAwareBeanPostProcessor
existingBean the existing bean instanceautowireMode by name or type, using the constants in this interfacedependencyCheck whether to perform a dependency check for object
references in the bean instanceorg.springframework.beans.BeansException if wiring failedAUTOWIRE_BY_NAMEAUTOWIRE_BY_TYPEAUTOWIRE_NOThis method does not autowire bean properties; it just applies
explicitly defined property values. Use the
method to autowire an existing bean instance.
Note: This method requires a bean definition for the given name!
autowireBeanProperties(java.lang.Object,int,boolean)
Does not apply standard BeanPostProcessors
callbacks or perform any further initialization of the bean. This interface
offers distinct, fine-grained operations for those purposes, for example
. However, initializeBean(java.lang.Object,java.lang.String)
callbacks are applied, if applicable to the configuration of the instance.
InstantiationAwareBeanPostProcessor
existingBean the existing bean instancebeanName the name of the bean definition in the bean factory
(a bean definition of that name has to be available)org.springframework.beans.factory.NoSuchBeanDefinitionException
if there is no bean definition with the given nameorg.springframework.beans.BeansException if applying the property values failedautowireBeanProperties(java.lang.Object,int,boolean)setBeanName and setBeanFactory,
also applying all bean post processors (including ones which
might wrap the given raw bean).
Note that no bean definition of the given name has to exist in the bean factory. The passed-in bean name will simply be used for callbacks but not checked against the registered bean definitions.
existingBean the existing bean instancebeanName the name of the bean, to be passed to it if necessary
(only passed to BeanPostProcessors)org.springframework.beans.BeansException if the initialization failedBeanPostProcessors to the given existing bean
instance, invoking their postProcessBeforeInitialization methods.
The returned bean instance may be a wrapper around the original.
existingBean the new bean instancebeanName the name of the beanorg.springframework.beans.BeansException if any post-processing failedBeanPostProcessor.postProcessBeforeInitialization(java.lang.Object,java.lang.String)BeanPostProcessors to the given existing bean
instance, invoking their postProcessAfterInitialization methods.
The returned bean instance may be a wrapper around the original.
existingBean the new bean instancebeanName the name of the beanorg.springframework.beans.BeansException if any post-processing failedBeanPostProcessor.postProcessAfterInitialization(java.lang.Object,java.lang.String)descriptor the descriptor for the dependencybeanName the name of the bean which declares the present dependencyautowiredBeanNames a Set that all names of autowired beans (used for
resolving the present dependency) are supposed to be added totypeConverter the TypeConverter to use for populating arrays and
collectionsnull if none foundorg.springframework.beans.BeansException in dependency resolution failed