org.springframework.beans.factory.config

## 接口 ConfigurableBeanFactory

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

      public interface ConfigurableBeanFactory
      extends HierarchicalBeanFactory, SingletonBeanRegistry

  Configuration interface to be implemented by most bean factories. Provides facilities to configure a bean factory, in addition to the bean factory client methods in the `BeanFactory` interface.

  This bean factory interface is not meant to be used in normal application code: Stick to `BeanFactory` or `ListableBeanFactory` for typical needs. This extended interface is just meant to allow for framework-internal plug'n'play and for special access to bean factory configuration methods.

  从以下版本开始:
    03.11.2003
  作者:
    Juergen Hoeller
  另请参阅:
    `BeanFactory`, `ListableBeanFactory`, `ConfigurableListableBeanFactory`

- - ### 字段概要

    字段
    限定符和类型 | 字段和说明
    --- | ---
    `static String` | `SCOPE_PROTOTYPE` Scope identifier for the standard prototype scope: "prototype".
    `static String` | `SCOPE_SINGLETON` Scope identifier for the standard singleton scope: "singleton".

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

      `FACTORY_BEAN_PREFIX`

  - ### 方法概要

    所有方法 实例方法 抽象方法
    限定符和类型 | 方法和说明
    --- | ---
    `void` | `addBeanPostProcessor(BeanPostProcessor beanPostProcessor)` Add a new BeanPostProcessor that will get applied to beans created by this factory.
    `void` | `addEmbeddedValueResolver(org.springframework.util.StringValueResolver valueResolver)` Add a String resolver for embedded values such as annotation attributes.
    `void` | `addPropertyEditorRegistrar(PropertyEditorRegistrar registrar)` Add a PropertyEditorRegistrar to be applied to all bean creation processes.
    `void` | `copyConfigurationFrom(ConfigurableBeanFactory otherFactory)` Copy all relevant configuration from the given other factory.
    `void` | `copyRegisteredEditorsTo(PropertyEditorRegistry registry)` Initialize the given PropertyEditorRegistry with the custom editors that have been registered with this BeanFactory.
    `void` | `destroyBean(String beanName, Object beanInstance)` Destroy the given bean instance (usually a prototype instance obtained from this factory) according to its bean definition.
    `void` | `destroyScopedBean(String beanName)` Destroy the specified scoped bean in the current target scope, if any.
    `void` | `destroySingletons()` Destroy all singleton beans in this factory, including inner beans that have been registered as disposable.
    `AccessControlContext` | `getAccessControlContext()` Provides a security access control context relevant to this factory.
    `ClassLoader` | `getBeanClassLoader()` Return this factory's class loader for loading bean classes (only `null` if even the system ClassLoader isn't accessible).
    `BeanExpressionResolver` | `getBeanExpressionResolver()` Return the resolution strategy for expressions in bean definition values.
    `int` | `getBeanPostProcessorCount()` Return the current number of registered BeanPostProcessors, if any.
    `org.springframework.core.convert.ConversionService` | `getConversionService()` Return the associated ConversionService, if any.
    `String[]` | `getDependenciesForBean(String beanName)` Return the names of all beans that the specified bean depends on, if any.
    `String[]` | `getDependentBeans(String beanName)` Return the names of all beans which depend on the specified bean, if any.
    `BeanDefinition` | `getMergedBeanDefinition(String beanName)` Return a merged BeanDefinition for the given bean name, merging a child bean definition with its parent if necessary.
    `Scope` | `getRegisteredScope(String scopeName)` Return the Scope implementation for the given scope name, if any.
    `String[]` | `getRegisteredScopeNames()` Return the names of all currently registered scopes.
    `ClassLoader` | `getTempClassLoader()` Return the temporary ClassLoader to use for type matching purposes, if any.
    `TypeConverter` | `getTypeConverter()` Obtain a type converter as used by this BeanFactory.
    `boolean` | `hasEmbeddedValueResolver()` Determine whether an embedded value resolver has been registered with this bean factory, to be applied through `resolveEmbeddedValue(String)`.
    `boolean` | `isCacheBeanMetadata()` Return whether to cache bean metadata such as given bean definitions (in merged fashion) and resolved bean classes.
    `boolean` | `isCurrentlyInCreation(String beanName)` Determine whether the specified bean is currently in creation.
    `boolean` | `isFactoryBean(String name)` Determine whether the bean with the given name is a FactoryBean.
    `void` | `registerAlias(String beanName, String alias)` Given a bean name, create an alias.
    `void` | `registerCustomEditor(Class<?> requiredType, Class<? extends PropertyEditor> propertyEditorClass)` Register the given custom property editor for all properties of the given type.
    `void` | `registerDependentBean(String beanName, String dependentBeanName)` Register a dependent bean for the given bean, to be destroyed before the given bean is destroyed.
    `void` | `registerScope(String scopeName, Scope scope)` Register the given scope, backed by the given Scope implementation.
    `void` | `resolveAliases(org.springframework.util.StringValueResolver valueResolver)` Resolve all alias target names and aliases registered in this factory, applying the given StringValueResolver to them.
    `String` | `resolveEmbeddedValue(String value)` Resolve the given embedded value, e.g. an annotation attribute.
    `void` | `setBeanClassLoader(ClassLoader beanClassLoader)` Set the class loader to use for loading bean classes.
    `void` | `setBeanExpressionResolver(BeanExpressionResolver resolver)` Specify the resolution strategy for expressions in bean definition values.
    `void` | `setCacheBeanMetadata(boolean cacheBeanMetadata)` Set whether to cache bean metadata such as given bean definitions (in merged fashion) and resolved bean classes.
    `void` | `setConversionService(org.springframework.core.convert.ConversionService conversionService)` Specify a Spring 3.0 ConversionService to use for converting property values, as an alternative to JavaBeans PropertyEditors.
    `void` | `setCurrentlyInCreation(String beanName, boolean inCreation)` Explicitly control the current in-creation status of the specified bean.
    `void` | `setParentBeanFactory(BeanFactory parentBeanFactory)` Set the parent of this bean factory.
    `void` | `setTempClassLoader(ClassLoader tempClassLoader)` Specify a temporary ClassLoader to use for type matching purposes.
    `void` | `setTypeConverter(TypeConverter typeConverter)` Set a custom type converter that this BeanFactory should use for converting bean property values, constructor argument values, etc.

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

      `containsLocalBean, getParentBeanFactory`

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

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

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

      `containsSingleton, getSingleton, getSingletonCount, getSingletonMutex, getSingletonNames, registerSingleton`

- - ### 字段详细资料

    - #### SCOPE_SINGLETON

          static final String SCOPE_SINGLETON

      Scope identifier for the standard singleton scope: "singleton". Custom scopes can be added via `registerScope`.
      另请参阅:
        `registerScope(java.lang.String, org.springframework.beans.factory.config.Scope)`, 常量字段值

    - #### SCOPE_PROTOTYPE

          static final String SCOPE_PROTOTYPE

      Scope identifier for the standard prototype scope: "prototype". Custom scopes can be added via `registerScope`.
      另请参阅:
        `registerScope(java.lang.String, org.springframework.beans.factory.config.Scope)`, 常量字段值

  - ### 方法详细资料

    - #### setParentBeanFactory

          void setParentBeanFactory(BeanFactory parentBeanFactory)
                             throws IllegalStateException

      Set the parent of this bean factory.

      Note that the parent cannot be changed: It should only be set outside a constructor if it isn't available at the time of factory instantiation.

      参数:
        `parentBeanFactory` - the parent BeanFactory
      抛出:
        `IllegalStateException` - if this factory is already associated with a parent BeanFactory
      另请参阅:
        `HierarchicalBeanFactory.getParentBeanFactory()`

    - #### setBeanClassLoader

          void setBeanClassLoader(@Nullable
                                  ClassLoader beanClassLoader)

      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.

      参数:
        `beanClassLoader` - the class loader to use, or `null` to suggest the default class loader

    - #### getBeanClassLoader

          @Nullable
          ClassLoader getBeanClassLoader()

      Return this factory's class loader for loading bean classes (only `null` if even the system ClassLoader isn't accessible).
      另请参阅:
        `ClassUtils.forName(String, ClassLoader)`

    - #### setTempClassLoader

          void setTempClassLoader(@Nullable
                                  ClassLoader tempClassLoader)

      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.

      从以下版本开始:
        2.5

    - #### getTempClassLoader

          @Nullable
          ClassLoader getTempClassLoader()

      Return the temporary ClassLoader to use for type matching purposes, if any.
      从以下版本开始:
        2.5

    - #### setCacheBeanMetadata

          void setCacheBeanMetadata(boolean cacheBeanMetadata)

      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.

    - #### isCacheBeanMetadata

          boolean isCacheBeanMetadata()

      Return whether to cache bean metadata such as given bean definitions (in merged fashion) and resolved bean classes.

    - #### setBeanExpressionResolver

          void setBeanExpressionResolver(@Nullable
                                         BeanExpressionResolver resolver)

      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.

      从以下版本开始:
        3.0

    - #### getBeanExpressionResolver

          @Nullable
          BeanExpressionResolver getBeanExpressionResolver()

      Return the resolution strategy for expressions in bean definition values.
      从以下版本开始:
        3.0

    - #### setConversionService

          void setConversionService(@Nullable
                                    org.springframework.core.convert.ConversionService conversionService)

      Specify a Spring 3.0 ConversionService to use for converting property values, as an alternative to JavaBeans PropertyEditors.
      从以下版本开始:
        3.0

    - #### getConversionService

          @Nullable
          org.springframework.core.convert.ConversionService getConversionService()

      Return the associated ConversionService, if any.
      从以下版本开始:
        3.0

    - #### addPropertyEditorRegistrar

          void addPropertyEditorRegistrar(PropertyEditorRegistrar registrar)

      Add a PropertyEditorRegistrar to be applied to all bean creation processes.

      Such a registrar creates new PropertyEditor instances and registers them on the given registry, fresh for each bean creation attempt. This avoids the need for synchronization on custom editors; hence, it is generally preferable to use this method instead of `registerCustomEditor(java.lang.Class<?>, java.lang.Class<? extends java.beans.PropertyEditor>)`.

      参数:
        `registrar` - the PropertyEditorRegistrar to register

    - #### registerCustomEditor

          void registerCustomEditor(Class<?> requiredType,
                                    Class<? extends PropertyEditor> propertyEditorClass)

      Register the given custom property editor for all properties of the given type. To be invoked during factory configuration.

      Note that this method will register a shared custom editor instance; access to that instance will be synchronized for thread-safety. It is generally preferable to use `addPropertyEditorRegistrar(org.springframework.beans.PropertyEditorRegistrar)` instead of this method, to avoid for the need for synchronization on custom editors.

      参数:
        `requiredType` - type of the property
        `propertyEditorClass` - the `PropertyEditor` class to register

    - #### copyRegisteredEditorsTo

          void copyRegisteredEditorsTo(PropertyEditorRegistry registry)

      Initialize the given PropertyEditorRegistry with the custom editors that have been registered with this BeanFactory.
      参数:
        `registry` - the PropertyEditorRegistry to initialize

    - #### setTypeConverter

          void setTypeConverter(TypeConverter typeConverter)

      Set a custom type converter that this BeanFactory should use for converting bean property values, constructor argument values, etc.

      This will override the default PropertyEditor mechanism and hence make any custom editors or custom editor registrars irrelevant.

      从以下版本开始:
        2.5
      另请参阅:
        `addPropertyEditorRegistrar(org.springframework.beans.PropertyEditorRegistrar)`, `registerCustomEditor(java.lang.Class<?>, java.lang.Class<? extends java.beans.PropertyEditor>)`

    - #### getTypeConverter

          TypeConverter getTypeConverter()

      Obtain a type converter as used by this BeanFactory. This may be a fresh instance for each call, since TypeConverters are usually not thread-safe.

      If the default PropertyEditor mechanism is active, the returned TypeConverter will be aware of all custom editors that have been registered.

      从以下版本开始:
        2.5

    - #### addEmbeddedValueResolver

          void addEmbeddedValueResolver(org.springframework.util.StringValueResolver valueResolver)

      Add a String resolver for embedded values such as annotation attributes.
      参数:
        `valueResolver` - the String resolver to apply to embedded values
      从以下版本开始:
        3.0

    - #### hasEmbeddedValueResolver

          boolean hasEmbeddedValueResolver()

      Determine whether an embedded value resolver has been registered with this bean factory, to be applied through `resolveEmbeddedValue(String)`.
      从以下版本开始:
        4.3

    - #### resolveEmbeddedValue

          @Nullable
          String resolveEmbeddedValue(String value)

      Resolve the given embedded value, e.g. an annotation attribute.
      参数:
        `value` - the value to resolve
      返回:
        the resolved value (may be the original value as-is)
      从以下版本开始:
        3.0

    - #### addBeanPostProcessor

          void addBeanPostProcessor(BeanPostProcessor beanPostProcessor)

      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.

      参数:
        `beanPostProcessor` - the post-processor to register

    - #### getBeanPostProcessorCount

          int getBeanPostProcessorCount()

      Return the current number of registered BeanPostProcessors, if any.

    - #### registerScope

          void registerScope(String scopeName,
                             Scope scope)

      Register the given scope, backed by the given Scope implementation.
      参数:
        `scopeName` - the scope identifier
        `scope` - the backing Scope implementation

    - #### getRegisteredScopeNames

          String[] getRegisteredScopeNames()

      Return the names of all currently registered scopes.

      This will only return the names of explicitly registered scopes. Built-in scopes such as "singleton" and "prototype" won't be exposed.

      返回:
        the array of scope names, or an empty array if none
      另请参阅:
        `registerScope(java.lang.String, org.springframework.beans.factory.config.Scope)`

    - #### getRegisteredScope

          @Nullable
          Scope getRegisteredScope(String scopeName)

      Return the Scope implementation for the given scope name, if any.

      This will only return explicitly registered scopes. Built-in scopes such as "singleton" and "prototype" won't be exposed.

      参数:
        `scopeName` - the name of the scope
      返回:
        the registered Scope implementation, or `null` if none
      另请参阅:
        `registerScope(java.lang.String, org.springframework.beans.factory.config.Scope)`

    - #### getAccessControlContext

          AccessControlContext getAccessControlContext()

      Provides a security access control context relevant to this factory.
      返回:
        the applicable AccessControlContext (never `null`)
      从以下版本开始:
        3.0

    - #### copyConfigurationFrom

          void copyConfigurationFrom(ConfigurableBeanFactory otherFactory)

      Copy all relevant configuration from the given other factory.

      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.

      参数:
        `otherFactory` - the other BeanFactory to copy from

    - #### registerAlias

          void registerAlias(String beanName,
                             String alias)
                      throws BeanDefinitionStoreException

      Given a bean name, create an alias. We typically use this method to support names that are illegal within XML ids (used for bean names).

      Typically invoked during factory configuration, but can also be used for runtime registration of aliases. Therefore, a factory implementation should synchronize alias access.

      参数:
        `beanName` - the canonical name of the target bean
        `alias` - the alias to be registered for the bean
      抛出:
        `BeanDefinitionStoreException` - if the alias is already in use

    - #### resolveAliases

          void resolveAliases(org.springframework.util.StringValueResolver valueResolver)

      Resolve all alias target names and aliases registered in this factory, applying the given StringValueResolver to them.

      The value resolver may for example resolve placeholders in target bean names and even in alias names.

      参数:
        `valueResolver` - the StringValueResolver to apply
      从以下版本开始:
        2.5

    - #### getMergedBeanDefinition

          BeanDefinition getMergedBeanDefinition(String beanName)
                                          throws NoSuchBeanDefinitionException

      Return a merged BeanDefinition for the given bean name, merging a child bean definition with its parent if necessary. Considers bean definitions in ancestor factories as well.
      参数:
        `beanName` - the name of the bean to retrieve the merged definition for
      返回:
        a (potentially merged) BeanDefinition for the given bean
      抛出:
        `NoSuchBeanDefinitionException` - if there is no bean definition with the given name
      从以下版本开始:
        2.5

    - #### isFactoryBean

          boolean isFactoryBean(String name)
                         throws NoSuchBeanDefinitionException

      Determine whether the bean with the given name is a FactoryBean.
      参数:
        `name` - the name of the bean to check
      返回:
        whether the bean is a FactoryBean (`false` means the bean exists but is not a FactoryBean)
      抛出:
        `NoSuchBeanDefinitionException` - if there is no bean with the given name
      从以下版本开始:
        2.5

    - #### setCurrentlyInCreation

          void setCurrentlyInCreation(String beanName,
                                      boolean inCreation)

      Explicitly control the current in-creation status of the specified bean. For container-internal use only.
      参数:
        `beanName` - the name of the bean
        `inCreation` - whether the bean is currently in creation
      从以下版本开始:
        3.1

    - #### isCurrentlyInCreation

          boolean isCurrentlyInCreation(String beanName)

      Determine whether the specified bean is currently in creation.
      参数:
        `beanName` - the name of the bean
      返回:
        whether the bean is currently in creation
      从以下版本开始:
        2.5

    - #### registerDependentBean

          void registerDependentBean(String beanName,
                                     String dependentBeanName)

      Register a dependent bean for the given bean, to be destroyed before the given bean is destroyed.
      参数:
        `beanName` - the name of the bean
        `dependentBeanName` - the name of the dependent bean
      从以下版本开始:
        2.5

    - #### getDependentBeans

          String[] getDependentBeans(String beanName)

      Return the names of all beans which depend on the specified bean, if any.
      参数:
        `beanName` - the name of the bean
      返回:
        the array of dependent bean names, or an empty array if none
      从以下版本开始:
        2.5

    - #### getDependenciesForBean

          String[] getDependenciesForBean(String beanName)

      Return the names of all beans that the specified bean depends on, if any.
      参数:
        `beanName` - the name of the bean
      返回:
        the array of names of beans which the bean depends on, or an empty array if none
      从以下版本开始:
        2.5

    - #### destroyBean

          void destroyBean(String beanName,
                           Object beanInstance)

      Destroy the given bean instance (usually a prototype instance obtained from this factory) according to its bean definition.

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

      参数:
        `beanName` - the name of the bean definition
        `beanInstance` - the bean instance to destroy

    - #### destroyScopedBean

          void destroyScopedBean(String beanName)

      Destroy the specified scoped bean in the current target scope, if any.

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

      参数:
        `beanName` - the name of the scoped bean

    - #### destroySingletons

          void destroySingletons()

      Destroy all singleton beans in this factory, including inner beans that have been registered as disposable. To be called on shutdown of a factory.

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