org.springframework.beans.factory.config

## 接口 AutowireCapableBeanFactory

- 所有超级接口:
    BeanFactory
  所有已知子接口:
    ConfigurableListableBeanFactory
  所有已知实现类:
    AbstractAutowireCapableBeanFactory, DefaultListableBeanFactory, XmlBeanFactory

      public interface AutowireCapableBeanFactory
      extends BeanFactory

- - ### 字段概要

    字段
    限定符和类型 | 字段和说明
    --- | ---
    `static int` | `AUTOWIRE_AUTODETECT` 已过时。 as of Spring 3.0: If you are using mixed autowiring strategies, prefer annotation-based autowiring for clearer demarcation of autowiring needs.
    `static int` | `AUTOWIRE_BY_NAME` 属性注入(setter) byName
    `static int` | `AUTOWIRE_BY_TYPE` 属性设置byType
    `static int` | `AUTOWIRE_CONSTRUCTOR` 构造器注入模式
    `static int` | `AUTOWIRE_NO` no 不使用自动装配。

    - ### 从接口继承的字段 org.springframework.beans.factory.BeanFactory

      `FACTORY_BEAN_PREFIX`

  - ### 方法概要

    所有方法 实例方法 抽象方法
    限定符和类型 | 方法和说明
    --- | ---
    `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)` Instantiate a new bean instance of the given class with the specified autowire strategy.
    `void` | `autowireBean(Object existingBean)` Populate the given bean instance through applying after-instantiation callbacks and bean property post-processing (e.g. for annotation-driven injection).
    `void` | `autowireBeanProperties(Object existingBean, int autowireMode, boolean dependencyCheck)` Autowire the bean properties of the given bean instance by name or type.
    `Object` | `configureBean(Object existingBean, String beanName)` Configure the given raw bean: autowiring bean properties, applying bean property values, applying factory callbacks such as `setBeanName` and `setBeanFactory`, and also applying all bean post processors (including ones which might wrap the given raw bean).
    `Object` | `createBean(Class<?> beanClass, int autowireMode, boolean dependencyCheck)` Fully create a new bean instance of the given class with the specified autowire strategy.
    `<T> T` | `createBean(Class<T> beanClass)` 根据class对象创建bean Performs full initialization of the bean, including all applicable `BeanPostProcessors`.
    `void` | `destroyBean(Object existingBean)` Destroy the given bean instance (typically coming from `createBean(java.lang.Class<T>)`), applying the `DisposableBean` contract as well as registered `DestructionAwareBeanPostProcessors`.
    `Object` | `initializeBean(Object existingBean, String beanName)` Initialize the given raw bean, applying factory callbacks such as `setBeanName` and `setBeanFactory`, also applying all bean post processors (including ones which might wrap the given raw bean).
    `Object` | `resolveDependency(DependencyDescriptor descriptor, String requestingBeanName)` Resolve the specified dependency against the beans defined in this factory.
    `Object` | `resolveDependency(DependencyDescriptor descriptor, String requestingBeanName, Set<String> autowiredBeanNames, TypeConverter typeConverter)` Resolve the specified dependency against the beans defined in this factory.
    `<T> NamedBeanHolder<T>` | `resolveNamedBean(Class<T> requiredType)` Resolve the bean instance that uniquely matches the given object type, if any, including its bean name.

    - ### 从接口继承的方法 org.springframework.beans.factory.BeanFactory

      `containsBean, getAliases, getBean, getBean, getBean, getBean, getBean, getType, isPrototype, isSingleton, isTypeMatch, isTypeMatch`

- - ### 字段详细资料

    - #### AUTOWIRE_NO

          static final int AUTOWIRE_NO

      no 不使用自动装配。必须通过ref元素指定依赖，这是默认设置。由于显式指定协作者可以使配置更灵活、 更清晰，因此对于较大的部署配置，推荐采用该设置。 public class People { private Book book; }
      另请参阅:
        常量字段值

    - #### AUTOWIRE_BY_NAME

          static final int AUTOWIRE_BY_NAME

      属性注入(setter) byName
      另请参阅:
        `createBean(java.lang.Class<T>)`, `autowire(java.lang.Class<?>, int, boolean)`, `autowireBeanProperties(java.lang.Object, int, boolean)`, 常量字段值

    - #### AUTOWIRE_BY_TYPE

          static final int AUTOWIRE_BY_TYPE

      属性设置byType
      另请参阅:
        `autowireBeanProperties(java.lang.Object, int, boolean)`, 常量字段值

    - #### AUTOWIRE_CONSTRUCTOR

          static final int AUTOWIRE_CONSTRUCTOR

      构造器注入模式
      另请参阅:
        `createBean(java.lang.Class<T>)`, `autowire(java.lang.Class<?>, int, boolean)`, 常量字段值

    - #### AUTOWIRE_AUTODETECT

          @Deprecated
          static final int AUTOWIRE_AUTODETECT

      已过时。 as of Spring 3.0: If you are using mixed autowiring strategies, prefer annotation-based autowiring for clearer demarcation of autowiring needs.
      表明通过Bean的class的内部来自动装配 Spring3.0被弃用。
      另请参阅:
        `createBean(java.lang.Class<T>)`, `autowire(java.lang.Class<?>, int, boolean)`, 常量字段值

  - ### 方法详细资料

    - #### createBean

          <T> T createBean(Class<T> beanClass)
                    throws BeansException

      根据class对象创建bean

      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 initialization callbacks. It does not imply traditional by-name or by-type autowiring of properties; use `createBean(Class, int, boolean)` for those purposes.

      参数:
        `beanClass` - the class of the bean to create
      返回:
        the new bean instance
      抛出:
        `BeansException` - if instantiation or wiring failed

    - #### autowireBean

          void autowireBean(Object existingBean)
                     throws BeansException

      Populate the given bean instance through applying after-instantiation callbacks and bean property post-processing (e.g. for annotation-driven injection).

      Note: 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 `autowireBeanProperties(java.lang.Object, int, boolean)` for those purposes.

      参数:
        `existingBean` - the existing bean instance
      抛出:
        `BeansException` - if wiring failed

    - #### configureBean

          Object configureBean(Object existingBean,
                               String beanName)
                        throws BeansException

      Configure the given raw bean: autowiring bean properties, applying bean property values, applying factory callbacks such as `setBeanName` 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 `initializeBean(java.lang.Object, java.lang.String)` provides, fully applying the configuration specified by the corresponding bean definition. Note: This method requires a bean definition for the given name!

      参数:
        `existingBean` - the existing bean instance
        `beanName` - the name of the bean, to be passed to it if necessary (a bean definition of that name has to be available)
      返回:
        the bean instance to use, either the original or a wrapped one
      抛出:
        `NoSuchBeanDefinitionException` - if there is no bean definition with the given name
        `BeansException` - if the initialization failed
      另请参阅:
        `initializeBean(java.lang.Object, java.lang.String)`

    - #### createBean

          Object createBean(Class<?> beanClass,
                            int autowireMode,
                            boolean dependencyCheck)
                     throws BeansException

      Fully create a new bean instance of the given class with the specified autowire strategy. All constants defined in this interface are supported here.

      Performs full initialization of the bean, including all applicable `BeanPostProcessors`. This is effectively a superset of what `autowire(java.lang.Class<?>, int, boolean)` provides, adding `initializeBean(java.lang.Object, java.lang.String)` behavior.

      参数:
        `beanClass` - the class of the bean to create
        `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)
      返回:
        the new bean instance
      抛出:
        `BeansException` - if instantiation or wiring failed
      另请参阅:
        `AUTOWIRE_NO`, `AUTOWIRE_BY_NAME`, `AUTOWIRE_BY_TYPE`, `AUTOWIRE_CONSTRUCTOR`

    - #### autowire

          Object autowire(Class<?> beanClass,
                          int autowireMode,
                          boolean dependencyCheck)
                   throws BeansException

      Instantiate a new bean instance of the given class with the specified autowire strategy. All constants defined in this interface are supported here. Can also be invoked with `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 `initializeBean(java.lang.Object, java.lang.String)`. However, `InstantiationAwareBeanPostProcessor` callbacks are applied, if applicable to the construction of the instance.

      参数:
        `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 object references in the bean instance (not applicable to autowiring a constructor, thus ignored there)
      返回:
        the new bean instance
      抛出:
        `BeansException` - if instantiation or wiring failed
      另请参阅:
        `AUTOWIRE_NO`, `AUTOWIRE_BY_NAME`, `AUTOWIRE_BY_TYPE`, `AUTOWIRE_CONSTRUCTOR`, `AUTOWIRE_AUTODETECT`, `initializeBean(java.lang.Object, java.lang.String)`, `applyBeanPostProcessorsBeforeInitialization(java.lang.Object, java.lang.String)`, `applyBeanPostProcessorsAfterInitialization(java.lang.Object, java.lang.String)`

    - #### autowireBeanProperties

          void autowireBeanProperties(Object existingBean,
                                      int autowireMode,
                                      boolean dependencyCheck)
                               throws BeansException

      Autowire the bean properties of the given bean instance by name or type. Can also be invoked with `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 `initializeBean(java.lang.Object, java.lang.String)`. However, `InstantiationAwareBeanPostProcessor` callbacks are applied, if applicable to the configuration of the instance.

      参数:
        `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 references in the bean instance
      抛出:
        `BeansException` - if wiring failed
      另请参阅:
        `AUTOWIRE_BY_NAME`, `AUTOWIRE_BY_TYPE`, `AUTOWIRE_NO`

    - #### 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.

      This method does not autowire bean properties; it just applies explicitly defined property values. Use the `autowireBeanProperties(java.lang.Object, int, boolean)` method to autowire an existing bean instance. Note: This method requires a bean definition for the given name!

      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 `initializeBean(java.lang.Object, java.lang.String)`. However, `InstantiationAwareBeanPostProcessor` callbacks are applied, if applicable to the configuration of the instance.

      参数:
        `existingBean` - the existing bean instance
        `beanName` - the name of the bean definition in the bean factory (a bean definition of that name has to be available)
      抛出:
        `NoSuchBeanDefinitionException` - if there is no bean definition with the given name
        `BeansException` - if applying the property values failed
      另请参阅:
        `autowireBeanProperties(java.lang.Object, int, boolean)`

    - #### initializeBean

          Object initializeBean(Object existingBean,
                                String beanName)
                         throws BeansException

      Initialize the given raw bean, applying factory callbacks such as `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 instance
        `beanName` - the name of the bean, to be passed to it if necessary (only passed to `BeanPostProcessors`)
      返回:
        the bean instance to use, either the original or a wrapped one
      抛出:
        `BeansException` - if the initialization failed

    - #### 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.
      参数:
        `existingBean` - the existing bean instance
        `beanName` - the name of the bean, to be passed to it if necessary (only passed to `BeanPostProcessors`)
      返回:
        the bean instance to use, either the original or a wrapped one
      抛出:
        `BeansException` - if any post-processing failed
      另请参阅:
        `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.
      参数:
        `existingBean` - the existing bean instance
        `beanName` - the name of the bean, to be passed to it if necessary (only passed to `BeanPostProcessors`)
      返回:
        the bean instance to use, either the original or a wrapped one
      抛出:
        `BeansException` - if any post-processing failed
      另请参阅:
        `BeanPostProcessor.postProcessAfterInitialization(java.lang.Object, java.lang.String)`

    - #### destroyBean

          void destroyBean(Object existingBean)

      Destroy the given bean instance (typically coming from `createBean(java.lang.Class<T>)`), applying the `DisposableBean` contract as well as registered `DestructionAwareBeanPostProcessors`.

      Any exception that arises during destruction should be caught and logged instead of propagated to the caller of this method.

      参数:
        `existingBean` - the bean instance to destroy

    - #### resolveNamedBean

          <T> NamedBeanHolder<T> resolveNamedBean(Class<T> requiredType)
                                           throws BeansException

      Resolve the bean instance that uniquely matches the given object type, if any, including its bean name.

      This is effectively a variant of `BeanFactory.getBean(Class)` which preserves the bean name of the matching instance.

      参数:
        `requiredType` - type the bean must match; can be an interface or superclass
      返回:
        the bean name plus bean instance
      抛出:
        `NoSuchBeanDefinitionException` - if no matching bean was found
        `NoUniqueBeanDefinitionException` - if more than one matching bean was found
        `BeansException` - if the bean could not be created
      从以下版本开始:
        4.3.3
      另请参阅:
        `BeanFactory.getBean(Class)`

    - #### resolveDependency

          @Nullable
          Object resolveDependency(DependencyDescriptor descriptor,
                                              @Nullable
                                              String requestingBeanName)
                                       throws BeansException

      Resolve the specified dependency against the beans defined in this factory.
      参数:
        `descriptor` - the descriptor for the dependency (field/method/constructor)
        `requestingBeanName` - the name of the bean which declares the given dependency
      返回:
        the resolved object, or `null` if none found
      抛出:
        `NoSuchBeanDefinitionException` - if no matching bean was found
        `NoUniqueBeanDefinitionException` - if more than one matching bean was found
        `BeansException` - if dependency resolution failed for any other reason
      从以下版本开始:
        2.5
      另请参阅:
        `resolveDependency(DependencyDescriptor, String, Set, TypeConverter)`

    - #### resolveDependency

          @Nullable
          Object resolveDependency(DependencyDescriptor descriptor,
                                              @Nullable
                                              String requestingBeanName,
                                              @Nullable
                                              Set<String> autowiredBeanNames,
                                              @Nullable
                                              TypeConverter typeConverter)
                                       throws BeansException

      Resolve the specified dependency against the beans defined in this factory.
      参数:
        `descriptor` - the descriptor for the dependency (field/method/constructor)
        `requestingBeanName` - the name of the bean which declares the given dependency
        `autowiredBeanNames` - a Set that all names of autowired beans (used for resolving the given dependency) are supposed to be added to
        `typeConverter` - the TypeConverter to use for populating arrays and collections
      返回:
        the resolved object, or `null` if none found
      抛出:
        `NoSuchBeanDefinitionException` - if no matching bean was found
        `NoUniqueBeanDefinitionException` - if more than one matching bean was found
        `BeansException` - if dependency resolution failed for any other reason
      从以下版本开始:
        2.5
      另请参阅:
        `DependencyDescriptor`