站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > Spring Framework 1.2.9 API 文档英文版

AutowireCapableBeanFactory (Spring Framework) - Spring Framework 1.2.9 API 文档英文版


org.springframework.beans.factory.config
Interface AutowireCapableBeanFactory

All Superinterfaces:
BeanFactory
All Known Subinterfaces:
ConfigurableListableBeanFactory
All Known Implementing Classes:
AbstractAutowireCapableBeanFactory, DefaultListableBeanFactory, XmlBeanFactory

public interface AutowireCapableBeanFactory
extends BeanFactory

Extension of the 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 BeanFactory or ListableBeanFactory for typical use cases.

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 or Tapestry Page objects, for example.

Note that this interface is not implemented by ApplicationContext facades, as it is hardly ever used by application code. It is available on the internal BeanFactory of a context, though, accessible through ConfigurableApplicationContext's getBeanFactory method.

To get access to an AutowireCapableBeanFactory, you can also implement the BeanFactoryAware interface, which exposes the internal BeanFactory even when running in an ApplicationContext. Simply cast the passed-in BeanFactory to AutowireCapableBeanFactory.

Since:
04.12.2003
Author:
Juergen Hoeller
See Also:
BeanFactory, ListableBeanFactory, BeanFactoryAware, ConfigurableListableBeanFactory, ConfigurableApplicationContext.getBeanFactory()

Field Summary
static int AUTOWIRE_AUTODETECT
          Constant that indicates determining an appropriate autowire strategy through introspection of the bean class.
static int AUTOWIRE_BY_NAME
          Constant that indicates autowiring bean properties by name.
static int AUTOWIRE_BY_TYPE
          Constant that indicates autowiring bean properties by type.
static int AUTOWIRE_CONSTRUCTOR
          Constant that indicates autowiring a constructor.
 
Fields inherited from interface org.springframework.beans.factory.BeanFactory
FACTORY_BEAN_PREFIX
 
Method Summary
 Object applyBeanPostProcessorsAfterInitialization(Object existingBean, String beanName)
          Apply BeanPostProcessors to the given existing bean instance, invoking their postProcessAfterInitialization methods.
 Object applyBeanPostProcessorsBeforeInitialization(Object existingBean, String beanName)
          Apply BeanPostProcessors to the given existing bean instance, invoking their postProcessBeforeInitialization methods.
 void applyBeanPropertyValues(Object existingBean, String beanName)
          Apply the property values of the bean definition with the given name to the given bean instance.
 Object autowire(Class beanClass, int autowireMode, boolean dependencyCheck)
          Create a new bean instance of the given class with the specified autowire strategy.
 void autowireBeanProperties(Object existingBean, int autowireMode, boolean dependencyCheck)
          Autowire the bean properties of the given bean instance by name or type.
 
Methods inherited from interface org.springframework.beans.factory.BeanFactory
containsBean, getAliases, getBean, getBean, getType, isSingleton
 

Field Detail

AUTOWIRE_BY_NAME

static final int AUTOWIRE_BY_NAME
Constant that indicates autowiring bean properties by name.

See Also:
autowire(java.lang.Class, int, boolean), autowireBeanProperties(java.lang.Object, int, boolean), Constant Field Values

AUTOWIRE_BY_TYPE

static final int AUTOWIRE_BY_TYPE
Constant that indicates autowiring bean properties by type.

See Also:
autowire(java.lang.Class, int, boolean), autowireBeanProperties(java.lang.Object, int, boolean), Constant Field Values

AUTOWIRE_CONSTRUCTOR

static final int AUTOWIRE_CONSTRUCTOR
Constant that indicates autowiring a constructor.

See Also:
autowire(java.lang.Class, int, boolean), Constant Field Values

AUTOWIRE_AUTODETECT

static final int AUTOWIRE_AUTODETECT
Constant that indicates determining an appropriate autowire strategy through introspection of the bean class.

See Also:
autowire(java.lang.Class, int, boolean), Constant Field Values
Method Detail

autowire

Object autowire(Class beanClass,
                int autowireMode,
                boolean dependencyCheck)
                throws BeansException
Create a new bean instance of the given class with the specified autowire strategy. All constants defined in this interface are supported here.

Parameters:
beanClass - the class of the bean to instantiate
autowireMode - by name or type, using the constants in this interface
dependencyCheck - whether to perform a dependency check for objects (not applicable to autowiring a constructor, thus ignored there)
Returns:
the new bean instance
Throws:
BeansException - if instantiation or wiring failed
See Also:
AUTOWIRE_BY_NAME, AUTOWIRE_BY_TYPE, AUTOWIRE_CONSTRUCTOR, AUTOWIRE_AUTODETECT

autowireBeanProperties

void autowireBeanProperties(Object existingBean,
                            int autowireMode,
                            boolean dependencyCheck)
                            throws BeansException
Autowire the bean properties of the given bean instance by name or type.

Parameters:
existingBean - the existing bean instance
autowireMode - by name or type, using the constants in this interface
dependencyCheck - whether to perform a dependency check for object
Throws:
BeansException - if wiring failed
See Also:
AUTOWIRE_BY_NAME, AUTOWIRE_BY_TYPE

applyBeanPropertyValues

void applyBeanPropertyValues(Object existingBean,
                             String beanName)
                             throws BeansException
Apply the property values of the bean definition with the given name to the given bean instance. The bean definition can either define a fully self-contained bean, reusing its property values, or just property values meant to be used for existing bean instances.

Note: This method does not autowire bean properties; it just applies explicitly defined property values. Use the autowireBeanProperties method to autowire an existing bean instance.

Parameters:
existingBean - the existing bean instance
beanName - the name of the bean definition in the bean factory
Throws:
NoSuchBeanDefinitionException - if there is no bean with the given name
BeansException - if applying the property values failed
See Also:
autowireBeanProperties(java.lang.Object, int, boolean)

applyBeanPostProcessorsBeforeInitialization

Object applyBeanPostProcessorsBeforeInitialization(Object existingBean,
                                                   String beanName)
                                                   throws BeansException
Apply BeanPostProcessors to the given existing bean instance, invoking their postProcessBeforeInitialization methods. The returned bean instance may be a wrapper around the original.

Parameters:
existingBean - the new bean instance
beanName - the name of the bean
Returns:
the bean instance to use, either the original or a wrapped one
Throws:
BeansException - if any post-processing failed
See Also:
BeanPostProcessor.postProcessBeforeInitialization(java.lang.Object, java.lang.String)

applyBeanPostProcessorsAfterInitialization

Object applyBeanPostProcessorsAfterInitialization(Object existingBean,
                                                  String beanName)
                                                  throws BeansException
Apply BeanPostProcessors to the given existing bean instance, invoking their postProcessAfterInitialization methods. The returned bean instance may be a wrapper around the original.

Parameters:
existingBean - the new bean instance
beanName - the name of the bean
Returns:
the bean instance to use, either the original or a wrapped one
Throws:
BeansException - if any post-processing failed
See Also:
BeanPostProcessor.postProcessAfterInitialization(java.lang.Object, java.lang.String)


Copyright (c) 2002-2007 The Spring Framework Project.