org.springframework.beans.factory.support

## 类 AbstractBeanDefinitionReader

- java.lang.Object
- - org.springframework.beans.factory.support.AbstractBeanDefinitionReader

- 所有已实现的接口:
    BeanDefinitionReader, org.springframework.core.env.EnvironmentCapable
  直接已知子类:
    GroovyBeanDefinitionReader, PropertiesBeanDefinitionReader, XmlBeanDefinitionReader

      public abstract class AbstractBeanDefinitionReader
      extends Object
      implements org.springframework.core.env.EnvironmentCapable, BeanDefinitionReader

  Abstract base class for bean definition readers which implement the `BeanDefinitionReader` interface.

  Provides common properties like the bean factory to work on and the class loader to use for loading bean classes.

  从以下版本开始:
    11.12.2003
  作者:
    Juergen Hoeller, Chris Beams
  另请参阅:
    `BeanDefinitionReaderUtils`

- - ### 字段概要

    字段
    限定符和类型 | 字段和说明
    --- | ---
    `protected Log` | `logger` Logger available to subclasses

  - ### 构造器概要

    构造器
    限定符 | 构造器和说明
    --- | ---
    `protected` | `AbstractBeanDefinitionReader(BeanDefinitionRegistry registry)` Create a new AbstractBeanDefinitionReader for the given bean factory.

  - ### 方法概要

    所有方法 实例方法 具体方法
    限定符和类型 | 方法和说明
    --- | ---
    `ClassLoader` | `getBeanClassLoader()` Return the class loader to use for bean classes.
    `BeanDefinitionRegistry` | `getBeanFactory()`
    `BeanNameGenerator` | `getBeanNameGenerator()` Return the BeanNameGenerator to use for anonymous beans (without explicit bean name specified).
    `org.springframework.core.env.Environment` | `getEnvironment()`
    `BeanDefinitionRegistry` | `getRegistry()` Return the bean factory to register the bean definitions with.
    `org.springframework.core.io.ResourceLoader` | `getResourceLoader()` Return the resource loader to use for resource locations.
    `int` | `loadBeanDefinitions(org.springframework.core.io.Resource... resources)` Load bean definitions from the specified resources.
    `int` | `loadBeanDefinitions(String... locations)` Load bean definitions from the specified resource locations.
    `int` | `loadBeanDefinitions(String location)` Load bean definitions from the specified resource location.
    `int` | `loadBeanDefinitions(String location, Set<org.springframework.core.io.Resource> actualResources)` Load bean definitions from the specified resource location.
    `void` | `setBeanClassLoader(ClassLoader beanClassLoader)` Set the ClassLoader to use for bean classes.
    `void` | `setBeanNameGenerator(BeanNameGenerator beanNameGenerator)` Set the BeanNameGenerator to use for anonymous beans (without explicit bean name specified).
    `void` | `setEnvironment(org.springframework.core.env.Environment environment)` Set the Environment to use when reading bean definitions.
    `void` | `setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader)` Set the ResourceLoader to use for resource locations.

    - ### 从类继承的方法 java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

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

      `loadBeanDefinitions`

- - ### 字段详细资料

    - #### logger

          protected final Log logger

      Logger available to subclasses

  - ### 构造器详细资料

    - #### AbstractBeanDefinitionReader

          protected AbstractBeanDefinitionReader(BeanDefinitionRegistry registry)

      Create a new AbstractBeanDefinitionReader for the given bean factory.

      If the passed-in bean factory does not only implement the BeanDefinitionRegistry interface but also the ResourceLoader interface, it will be used as default ResourceLoader as well. This will usually be the case for `org.springframework.context.ApplicationContext` implementations.

      If given a plain BeanDefinitionRegistry, the default ResourceLoader will be a `PathMatchingResourcePatternResolver`.

      If the passed-in bean factory also implements `EnvironmentCapable` its environment will be used by this reader. Otherwise, the reader will initialize and use a `StandardEnvironment`. All ApplicationContext implementations are EnvironmentCapable, while normal BeanFactory implementations are not.

      参数:
        `registry` - the BeanFactory to load bean definitions into, in the form of a BeanDefinitionRegistry
      另请参阅:
        `setResourceLoader(org.springframework.core.io.ResourceLoader)`, `setEnvironment(org.springframework.core.env.Environment)`

  - ### 方法详细资料

    - #### getBeanFactory

          public final BeanDefinitionRegistry getBeanFactory()

    - #### getRegistry

          public final BeanDefinitionRegistry getRegistry()

      从接口复制的说明: `BeanDefinitionReader`
      Return the bean factory to register the bean definitions with.

      The factory is exposed through the BeanDefinitionRegistry interface, encapsulating the methods that are relevant for bean definition handling.

      指定者:
        `getRegistry` 在接口中 `BeanDefinitionReader`

    - #### setResourceLoader

          public void setResourceLoader(@Nullable
                                        org.springframework.core.io.ResourceLoader resourceLoader)

      Set the ResourceLoader to use for resource locations. If specifying a ResourcePatternResolver, the bean definition reader will be capable of resolving resource patterns to Resource arrays.

      Default is PathMatchingResourcePatternResolver, also capable of resource pattern resolving through the ResourcePatternResolver interface.

      Setting this to `null` suggests that absolute resource loading is not available for this bean definition reader.

      另请参阅:
        `ResourcePatternResolver`, `PathMatchingResourcePatternResolver`

    - #### getResourceLoader

          @Nullable
          public org.springframework.core.io.ResourceLoader getResourceLoader()

      从接口复制的说明: `BeanDefinitionReader`
      Return the resource loader to use for resource locations. Can be checked for the ResourcePatternResolver interface and cast accordingly, for loading multiple resources for a given resource pattern.

      A `null` return value suggests that absolute resource loading is not available for this bean definition reader.

      This is mainly meant to be used for importing further resources from within a bean definition resource, for example via the "import" tag in XML bean definitions. It is recommended, however, to apply such imports relative to the defining resource; only explicit full resource locations will trigger absolute resource loading.

      There is also a `loadBeanDefinitions(String)` method available, for loading bean definitions from a resource location (or location pattern). This is a convenience to avoid explicit ResourceLoader handling.

      指定者:
        `getResourceLoader` 在接口中 `BeanDefinitionReader`
      另请参阅:
        `BeanDefinitionReader.loadBeanDefinitions(String)`, `ResourcePatternResolver`

    - #### setBeanClassLoader

          public void setBeanClassLoader(@Nullable
                                         ClassLoader beanClassLoader)

      Set the ClassLoader to use for bean classes.

      Default is `null`, which suggests to not load bean classes eagerly but rather to just register bean definitions with class names, with the corresponding Classes to be resolved later (or never).

      另请参阅:
        `Thread.getContextClassLoader()`

    - #### getBeanClassLoader

          @Nullable
          public ClassLoader getBeanClassLoader()

      从接口复制的说明: `BeanDefinitionReader`
      Return the class loader to use for bean classes.

      `null` suggests to not load bean classes eagerly but rather to just register bean definitions with class names, with the corresponding Classes to be resolved later (or never).

      指定者:
        `getBeanClassLoader` 在接口中 `BeanDefinitionReader`

    - #### setEnvironment

          public void setEnvironment(org.springframework.core.env.Environment environment)

      Set the Environment to use when reading bean definitions. Most often used for evaluating profile information to determine which bean definitions should be read and which should be omitted.

    - #### getEnvironment

          public org.springframework.core.env.Environment getEnvironment()

      指定者:
        `getEnvironment` 在接口中 `org.springframework.core.env.EnvironmentCapable`

    - #### setBeanNameGenerator

          public void setBeanNameGenerator(@Nullable
                                           BeanNameGenerator beanNameGenerator)

      Set the BeanNameGenerator to use for anonymous beans (without explicit bean name specified).

      Default is a `DefaultBeanNameGenerator`.

    - #### getBeanNameGenerator

          public BeanNameGenerator getBeanNameGenerator()

      从接口复制的说明: `BeanDefinitionReader`
      Return the BeanNameGenerator to use for anonymous beans (without explicit bean name specified).
      指定者:
        `getBeanNameGenerator` 在接口中 `BeanDefinitionReader`

    - #### loadBeanDefinitions

          public int loadBeanDefinitions(org.springframework.core.io.Resource... resources)
                                  throws BeanDefinitionStoreException

      从接口复制的说明: `BeanDefinitionReader`
      Load bean definitions from the specified resources.
      指定者:
        `loadBeanDefinitions` 在接口中 `BeanDefinitionReader`
      参数:
        `resources` - the resource descriptors
      返回:
        the number of bean definitions found
      抛出:
        `BeanDefinitionStoreException` - in case of loading or parsing errors

    - #### loadBeanDefinitions

          public int loadBeanDefinitions(String location)
                                  throws BeanDefinitionStoreException

      从接口复制的说明: `BeanDefinitionReader`
      Load bean definitions from the specified resource location.

      The location can also be a location pattern, provided that the ResourceLoader of this bean definition reader is a ResourcePatternResolver.

      指定者:
        `loadBeanDefinitions` 在接口中 `BeanDefinitionReader`
      参数:
        `location` - the resource location, to be loaded with the ResourceLoader (or ResourcePatternResolver) of this bean definition reader
      返回:
        the number of bean definitions found
      抛出:
        `BeanDefinitionStoreException` - in case of loading or parsing errors
      另请参阅:
        `BeanDefinitionReader.getResourceLoader()`, `BeanDefinitionReader.loadBeanDefinitions(org.springframework.core.io.Resource)`, `BeanDefinitionReader.loadBeanDefinitions(org.springframework.core.io.Resource[])`

    - #### loadBeanDefinitions

          public int loadBeanDefinitions(String location,
                                         @Nullable
                                         Set<org.springframework.core.io.Resource> actualResources)
                                  throws BeanDefinitionStoreException

      Load bean definitions from the specified resource location.

      The location can also be a location pattern, provided that the ResourceLoader of this bean definition reader is a ResourcePatternResolver.

      参数:
        `location` - the resource location, to be loaded with the ResourceLoader (or ResourcePatternResolver) of this bean definition reader
        `actualResources` - a Set to be filled with the actual Resource objects that have been resolved during the loading process. May be `null` to indicate that the caller is not interested in those Resource objects.
      返回:
        the number of bean definitions found
      抛出:
        `BeanDefinitionStoreException` - in case of loading or parsing errors
      另请参阅:
        `getResourceLoader()`, `BeanDefinitionReader.loadBeanDefinitions(org.springframework.core.io.Resource)`, `loadBeanDefinitions(org.springframework.core.io.Resource[])`

    - #### loadBeanDefinitions

          public int loadBeanDefinitions(String... locations)
                                  throws BeanDefinitionStoreException

      从接口复制的说明: `BeanDefinitionReader`
      Load bean definitions from the specified resource locations.
      指定者:
        `loadBeanDefinitions` 在接口中 `BeanDefinitionReader`
      参数:
        `locations` - the resource locations, to be loaded with the ResourceLoader (or ResourcePatternResolver) of this bean definition reader
      返回:
        the number of bean definitions found
      抛出:
        `BeanDefinitionStoreException` - in case of loading or parsing errors