org.springframework.beans.factory.config

## 接口 BeanDefinition

- 所有超级接口:
    org.springframework.core.AttributeAccessor, BeanMetadataElement
  所有已知子接口:
    AnnotatedBeanDefinition
  所有已知实现类:
    AbstractBeanDefinition, AnnotatedGenericBeanDefinition, ChildBeanDefinition, GenericBeanDefinition, RootBeanDefinition

      public interface BeanDefinition
      extends org.springframework.core.AttributeAccessor, BeanMetadataElement

  A BeanDefinition describes a bean instance, which has property values, constructor argument values, and further information supplied by concrete implementations.

  This is just a minimal interface: The main intention is to allow a `BeanFactoryPostProcessor` such as `PropertyPlaceholderConfigurer` to introspect and modify property values and other bean metadata.

  从以下版本开始:
    19.03.2004
  作者:
    Juergen Hoeller, Rob Harrop
  另请参阅:
    `ConfigurableListableBeanFactory.getBeanDefinition(java.lang.String)`, `RootBeanDefinition`, `ChildBeanDefinition`

- - ### 字段概要

    字段
    限定符和类型 | 字段和说明
    --- | ---
    `static int` | `ROLE_APPLICATION` Role hint indicating that a `BeanDefinition` is a major part of the application.
    `static int` | `ROLE_INFRASTRUCTURE` Role hint indicating that a `BeanDefinition` is providing an entirely background role and has no relevance to the end-user.
    `static int` | `ROLE_SUPPORT` Role hint indicating that a `BeanDefinition` is a supporting part of some larger configuration, typically an outer `ComponentDefinition`.
    `static String` | `SCOPE_PROTOTYPE` Scope identifier for the standard prototype scope: "prototype".
    `static String` | `SCOPE_SINGLETON` Scope identifier for the standard singleton scope: "singleton".

  - ### 方法概要

    所有方法 实例方法 抽象方法 默认方法
    限定符和类型 | 方法和说明
    --- | ---
    `String` | `getBeanClassName()` Return the current bean class name of this bean definition.
    `ConstructorArgumentValues` | `getConstructorArgumentValues()` Return the constructor argument values for this bean.
    `String[]` | `getDependsOn()` Return the bean names that this bean depends on.
    `String` | `getDescription()` Return a human-readable description of this bean definition.
    `String` | `getFactoryBeanName()` Return the factory bean name, if any.
    `String` | `getFactoryMethodName()` Return a factory method, if any.
    `BeanDefinition` | `getOriginatingBeanDefinition()` Return the originating BeanDefinition, or `null` if none.
    `String` | `getParentName()` Return the name of the parent definition of this bean definition, if any.
    `MutablePropertyValues` | `getPropertyValues()` Return the property values to be applied to a new instance of the bean.
    `String` | `getResourceDescription()` Return a description of the resource that this bean definition came from (for the purpose of showing context in case of errors).
    `int` | `getRole()` Get the role hint for this `BeanDefinition`.
    `String` | `getScope()` Return the name of the current target scope for this bean, or `null` if not known yet.
    `default boolean` | `hasConstructorArgumentValues()` Return if there are constructor argument values defined for this bean.
    `default boolean` | `hasPropertyValues()` Return if there are property values values defined for this bean.
    `boolean` | `isAbstract()` Return whether this bean is "abstract", that is, not meant to be instantiated.
    `boolean` | `isAutowireCandidate()` Return whether this bean is a candidate for getting autowired into some other bean.
    `boolean` | `isLazyInit()` Return whether this bean should be lazily initialized, i.e. not eagerly instantiated on startup.
    `boolean` | `isPrimary()` Return whether this bean is a primary autowire candidate.
    `boolean` | `isPrototype()` Return whether this a Prototype, with an independent instance returned for each call.
    `boolean` | `isSingleton()` Return whether this a Singleton, with a single, shared instance returned on all calls.
    `void` | `setAutowireCandidate(boolean autowireCandidate)` Set whether this bean is a candidate for getting autowired into some other bean.
    `void` | `setBeanClassName(String beanClassName)` Specify the bean class name of this bean definition.
    `void` | `setDependsOn(String... dependsOn)` Set the names of the beans that this bean depends on being initialized.
    `void` | `setFactoryBeanName(String factoryBeanName)` Specify the factory bean to use, if any.
    `void` | `setFactoryMethodName(String factoryMethodName)` Specify a factory method, if any.
    `void` | `setLazyInit(boolean lazyInit)` Set whether this bean should be lazily initialized.
    `void` | `setParentName(String parentName)` Set the name of the parent definition of this bean definition, if any.
    `void` | `setPrimary(boolean primary)` Set whether this bean is a primary autowire candidate.
    `void` | `setScope(String scope)` Override the target scope of this bean, specifying a new scope name.

    - ### 从接口继承的方法 org.springframework.core.AttributeAccessor

      `attributeNames, getAttribute, hasAttribute, removeAttribute, setAttribute`

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

      `getSource`

- - ### 字段详细资料

    - #### SCOPE_SINGLETON

          static final String SCOPE_SINGLETON

      Scope identifier for the standard singleton scope: "singleton".

      Note that extended bean factories might support further scopes.

      另请参阅:
        `setScope(java.lang.String)`, 常量字段值

    - #### SCOPE_PROTOTYPE

          static final String SCOPE_PROTOTYPE

      Scope identifier for the standard prototype scope: "prototype".

      Note that extended bean factories might support further scopes.

      另请参阅:
        `setScope(java.lang.String)`, 常量字段值

    - #### ROLE_APPLICATION

          static final int ROLE_APPLICATION

      Role hint indicating that a `BeanDefinition` is a major part of the application. Typically corresponds to a user-defined bean.
      另请参阅:
        常量字段值

    - #### ROLE_SUPPORT

          static final int ROLE_SUPPORT

      Role hint indicating that a `BeanDefinition` is a supporting part of some larger configuration, typically an outer `ComponentDefinition`. `SUPPORT` beans are considered important enough to be aware of when looking more closely at a particular `ComponentDefinition`, but not when looking at the overall configuration of an application.
      另请参阅:
        常量字段值

    - #### ROLE_INFRASTRUCTURE

          static final int ROLE_INFRASTRUCTURE

      Role hint indicating that a `BeanDefinition` is providing an entirely background role and has no relevance to the end-user. This hint is used when registering beans that are completely part of the internal workings of a `ComponentDefinition`.
      另请参阅:
        常量字段值

  - ### 方法详细资料

    - #### setParentName

          void setParentName(@Nullable
                             String parentName)

      Set the name of the parent definition of this bean definition, if any.

    - #### getParentName

          @Nullable
          String getParentName()

      Return the name of the parent definition of this bean definition, if any.

    - #### setBeanClassName

          void setBeanClassName(@Nullable
                                String beanClassName)

      Specify the bean class name of this bean definition.

      The class name can be modified during bean factory post-processing, typically replacing the original class name with a parsed variant of it.

      另请参阅:
        `setParentName(java.lang.String)`, `setFactoryBeanName(java.lang.String)`, `setFactoryMethodName(java.lang.String)`

    - #### getBeanClassName

          @Nullable
          String getBeanClassName()

      Return the current bean class name of this bean definition.

      Note that this does not have to be the actual class name used at runtime, in case of a child definition overriding/inheriting the class name from its parent. Also, this may just be the class that a factory method is called on, or it may even be empty in case of a factory bean reference that a method is called on. Hence, do not consider this to be the definitive bean type at runtime but rather only use it for parsing purposes at the individual bean definition level.

      另请参阅:
        `getParentName()`, `getFactoryBeanName()`, `getFactoryMethodName()`

    - #### setScope

          void setScope(@Nullable
                        String scope)

      Override the target scope of this bean, specifying a new scope name.
      另请参阅:
        `SCOPE_SINGLETON`, `SCOPE_PROTOTYPE`

    - #### getScope

          @Nullable
          String getScope()

      Return the name of the current target scope for this bean, or `null` if not known yet.

    - #### setLazyInit

          void setLazyInit(boolean lazyInit)

      Set whether this bean should be lazily initialized.

      If `false`, the bean will get instantiated on startup by bean factories that perform eager initialization of singletons.

    - #### isLazyInit

          boolean isLazyInit()

      Return whether this bean should be lazily initialized, i.e. not eagerly instantiated on startup. Only applicable to a singleton bean.

    - #### setDependsOn

          void setDependsOn(@Nullable
                            String... dependsOn)

      Set the names of the beans that this bean depends on being initialized. The bean factory will guarantee that these beans get initialized first.

    - #### getDependsOn

          @Nullable
          String[] getDependsOn()

      Return the bean names that this bean depends on.

    - #### setAutowireCandidate

          void setAutowireCandidate(boolean autowireCandidate)

      Set whether this bean is a candidate for getting autowired into some other bean.

      Note that this flag is designed to only affect type-based autowiring. It does not affect explicit references by name, which will get resolved even if the specified bean is not marked as an autowire candidate. As a consequence, autowiring by name will nevertheless inject a bean if the name matches.

    - #### isAutowireCandidate

          boolean isAutowireCandidate()

      Return whether this bean is a candidate for getting autowired into some other bean.

    - #### setPrimary

          void setPrimary(boolean primary)

      Set whether this bean is a primary autowire candidate.

      If this value is `true` for exactly one bean among multiple matching candidates, it will serve as a tie-breaker.

    - #### isPrimary

          boolean isPrimary()

      Return whether this bean is a primary autowire candidate.

    - #### setFactoryBeanName

          void setFactoryBeanName(@Nullable
                                  String factoryBeanName)

      Specify the factory bean to use, if any. This the name of the bean to call the specified factory method on.
      另请参阅:
        `setFactoryMethodName(java.lang.String)`

    - #### getFactoryBeanName

          @Nullable
          String getFactoryBeanName()

      Return the factory bean name, if any.

    - #### setFactoryMethodName

          void setFactoryMethodName(@Nullable
                                    String factoryMethodName)

      Specify a factory method, if any. This method will be invoked with constructor arguments, or with no arguments if none are specified. The method will be invoked on the specified factory bean, if any, or otherwise as a static method on the local bean class.
      另请参阅:
        `setFactoryBeanName(java.lang.String)`, `setBeanClassName(java.lang.String)`

    - #### getFactoryMethodName

          @Nullable
          String getFactoryMethodName()

      Return a factory method, if any.

    - #### getConstructorArgumentValues

          ConstructorArgumentValues getConstructorArgumentValues()

      Return the constructor argument values for this bean.

      The returned instance can be modified during bean factory post-processing.

      返回:
        the ConstructorArgumentValues object (never `null`)

    - #### hasConstructorArgumentValues

          default boolean hasConstructorArgumentValues()

      Return if there are constructor argument values defined for this bean.
      从以下版本开始:
        5.0.2

    - #### getPropertyValues

          MutablePropertyValues getPropertyValues()

      Return the property values to be applied to a new instance of the bean.

      The returned instance can be modified during bean factory post-processing.

      返回:
        the MutablePropertyValues object (never `null`)

    - #### hasPropertyValues

          default boolean hasPropertyValues()

      Return if there are property values values defined for this bean.
      从以下版本开始:
        5.0.2

    - #### isSingleton

          boolean isSingleton()

      Return whether this a Singleton, with a single, shared instance returned on all calls.
      另请参阅:
        `SCOPE_SINGLETON`

    - #### isPrototype

          boolean isPrototype()

      Return whether this a Prototype, with an independent instance returned for each call.
      从以下版本开始:
        3.0
      另请参阅:
        `SCOPE_PROTOTYPE`

    - #### isAbstract

          boolean isAbstract()

      Return whether this bean is "abstract", that is, not meant to be instantiated.

    - #### getRole

          int getRole()

      Get the role hint for this `BeanDefinition`. The role hint provides the frameworks as well as tools with an indication of the role and importance of a particular `BeanDefinition`.
      另请参阅:
        `ROLE_APPLICATION`, `ROLE_SUPPORT`, `ROLE_INFRASTRUCTURE`

    - #### getDescription

          @Nullable
          String getDescription()

      Return a human-readable description of this bean definition.

    - #### getResourceDescription

          @Nullable
          String getResourceDescription()

      Return a description of the resource that this bean definition came from (for the purpose of showing context in case of errors).

    - #### getOriginatingBeanDefinition

          @Nullable
          BeanDefinition getOriginatingBeanDefinition()

      Return the originating BeanDefinition, or `null` if none. Allows for retrieving the decorated bean definition, if any.

      Note that this method returns the immediate originator. Iterate through the originator chain to find the original BeanDefinition as defined by the user.