接口 BeanDefinition

    • 方法详细资料

      • 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()
      • 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.
      • 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.
      • 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 defined for this bean.
        从以下版本开始:
        5.0.2
      • setRole

        void setRole​(int role)
        Set the role hint for this BeanDefinition. The role hint provides the frameworks as well as tools an indication of the role and importance of a particular BeanDefinition.
        从以下版本开始:
        5.1
        另请参阅:
        ROLE_APPLICATION, ROLE_SUPPORT, ROLE_INFRASTRUCTURE
      • setDescription

        void setDescription​(@Nullable
                            String description)
        Set a human-readable description of this bean definition.
        从以下版本开始:
        5.1
      • 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.
      • 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.