Interface BeanDefinition
- All Superinterfaces:
AttributeAccessor
,BeanMetadataElement
- All Known Subinterfaces:
AnnotatedBeanDefinition
- All Known Implementing Classes:
AbstractBeanDefinition
,AnnotatedGenericBeanDefinition
,ChildBeanDefinition
,GenericBeanDefinition
,RootBeanDefinition
,ScannedGenericBeanDefinition
This is just a minimal interface: The main intention is to allow a
BeanFactoryPostProcessor
to introspect and modify property values
and other bean metadata.
- Since:
- 19.03.2004
- Author:
- Juergen Hoeller, Rob Harrop
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Role hint indicating that aBeanDefinition
is a major part of the application.static final int
Role hint indicating that aBeanDefinition
is providing an entirely background role and has no relevance to the end-user.static final int
Role hint indicating that aBeanDefinition
is a supporting part of some larger configuration, typically an outerComponentDefinition
.static final String
Scope identifier for the standard prototype scope: "prototype".static final String
Scope identifier for the standard singleton scope: "singleton". -
Method Summary
Modifier and TypeMethodDescriptionReturn the current bean class name of this bean definition.Return the constructor argument values for this bean.String[]
Return the bean names that this bean depends on.Return a human-readable description of this bean definition.Return the name of the destroy method.Return the factory bean name, if any.Return a factory method, if any.Return the name of the initializer method.Return the originating BeanDefinition, ornull
if none.Return the name of the parent definition of this bean definition, if any.Return the property values to be applied to a new instance of the bean.Return a resolvable type for this bean definition, based on the bean class or other specific metadata.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 thisBeanDefinition
.getScope()
Return the name of the current target scope for this bean, ornull
if not known yet.default boolean
Return if there are constructor argument values defined for this bean.default boolean
Return if there are property values defined for this bean.boolean
Return whether this bean is "abstract", that is, not meant to be instantiated.boolean
Return whether this bean is a candidate for getting autowired into some other bean.boolean
Return whether this bean should be lazily initialized, i.e.boolean
Return whether this bean is a primary autowire candidate.boolean
Return whether this a Prototype, with an independent instance returned for each call.boolean
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
setDescription
(String description) Set a human-readable description of this bean definition.void
setDestroyMethodName
(String destroyMethodName) Set the name of the destroy method.void
setFactoryBeanName
(String factoryBeanName) Specify the factory bean to use, if any.void
setFactoryMethodName
(String factoryMethodName) Specify a factory method, if any.void
setInitMethodName
(String initMethodName) Set the name of the initializer method.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
setRole
(int role) Set the role hint for thisBeanDefinition
.void
Override the target scope of this bean, specifying a new scope name.Methods inherited from interface org.springframework.core.AttributeAccessor
attributeNames, computeAttribute, getAttribute, hasAttribute, removeAttribute, setAttribute
Methods inherited from interface org.springframework.beans.BeanMetadataElement
getSource
-
Field Details
-
SCOPE_SINGLETON
Scope identifier for the standard singleton scope: "singleton".Note that extended bean factories might support further scopes.
-
SCOPE_PROTOTYPE
Scope identifier for the standard prototype scope: "prototype".Note that extended bean factories might support further scopes.
-
ROLE_APPLICATION
static final int ROLE_APPLICATIONRole hint indicating that aBeanDefinition
is a major part of the application. Typically corresponds to a user-defined bean.- See Also:
-
ROLE_SUPPORT
static final int ROLE_SUPPORTRole hint indicating that aBeanDefinition
is a supporting part of some larger configuration, typically an outerComponentDefinition
.SUPPORT
beans are considered important enough to be aware of when looking more closely at a particularComponentDefinition
, but not when looking at the overall configuration of an application.- See Also:
-
ROLE_INFRASTRUCTURE
static final int ROLE_INFRASTRUCTURERole hint indicating that aBeanDefinition
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 aComponentDefinition
.- See Also:
-
-
Method Details
-
setParentName
Set the name of the parent definition of this bean definition, if any. -
getParentName
Return the name of the parent definition of this bean definition, if any. -
setBeanClassName
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.
-
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.
-
setScope
Override the target scope of this bean, specifying a new scope name.- See Also:
-
getScope
Return the name of the current target scope for this bean, ornull
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
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
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
Specify the factory bean to use, if any. This the name of the bean to call the specified factory method on.- See Also:
-
getFactoryBeanName
Return the factory bean name, if any. -
setFactoryMethodName
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. -
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.
- Returns:
- the ConstructorArgumentValues object (never
null
)
-
hasConstructorArgumentValues
default boolean hasConstructorArgumentValues()Return if there are constructor argument values defined for this bean.- Since:
- 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.
- Returns:
- the MutablePropertyValues object (never
null
)
-
hasPropertyValues
default boolean hasPropertyValues()Return if there are property values defined for this bean.- Since:
- 5.0.2
-
setInitMethodName
Set the name of the initializer method.- Since:
- 5.1
-
getInitMethodName
Return the name of the initializer method.- Since:
- 5.1
-
setDestroyMethodName
Set the name of the destroy method.- Since:
- 5.1
-
getDestroyMethodName
Return the name of the destroy method.- Since:
- 5.1
-
setRole
void setRole(int role) Set the role hint for thisBeanDefinition
. The role hint provides the frameworks as well as tools an indication of the role and importance of a particularBeanDefinition
.- Since:
- 5.1
- See Also:
-
getRole
int getRole()Get the role hint for thisBeanDefinition
. The role hint provides the frameworks as well as tools an indication of the role and importance of a particularBeanDefinition
.- See Also:
-
setDescription
Set a human-readable description of this bean definition.- Since:
- 5.1
-
getDescription
Return a human-readable description of this bean definition. -
getResolvableType
ResolvableType getResolvableType()Return a resolvable type for this bean definition, based on the bean class or other specific metadata.This is typically fully resolved on a runtime-merged bean definition but not necessarily on a configuration-time definition instance.
- Returns:
- the resolvable type (potentially
ResolvableType.NONE
) - Since:
- 5.2
- See Also:
-
isSingleton
boolean isSingleton()Return whether this a Singleton, with a single, shared instance returned on all calls.- See Also:
-
isPrototype
boolean isPrototype()Return whether this a Prototype, with an independent instance returned for each call.- Since:
- 3.0
- See Also:
-
isAbstract
boolean isAbstract()Return whether this bean is "abstract", that is, not meant to be instantiated. -
getResourceDescription
Return a description of the resource that this bean definition came from (for the purpose of showing context in case of errors). -
getOriginatingBeanDefinition
Return the originating BeanDefinition, ornull
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.
-