public interface BeanDefinition extends AttributeAccessor, BeanMetadataElement
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.
ConfigurableListableBeanFactory.getBeanDefinition(java.lang.String)
,
RootBeanDefinition
,
ChildBeanDefinition
Modifier and Type | Field and Description |
---|---|
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".
|
Modifier and Type | Method and Description |
---|---|
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. |
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.
|
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)
Override 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.
|
attributeNames, getAttribute, hasAttribute, removeAttribute, setAttribute
getSource
static final String SCOPE_SINGLETON
Note that extended bean factories might support further scopes.
setScope(java.lang.String)
,
Constant Field Valuesstatic final String SCOPE_PROTOTYPE
Note that extended bean factories might support further scopes.
setScope(java.lang.String)
,
Constant Field Valuesstatic final int ROLE_APPLICATION
BeanDefinition
is a major part
of the application. Typically corresponds to a user-defined bean.static final int ROLE_SUPPORT
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.static final int ROLE_INFRASTRUCTURE
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
.String getParentName()
void setParentName(String parentName)
String getBeanClassName()
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. 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.
void setBeanClassName(String beanClassName)
The class name can be modified during bean factory post-processing, typically replacing the original class name with a parsed variant of it.
String getFactoryBeanName()
void setFactoryBeanName(String factoryBeanName)
String getFactoryMethodName()
void setFactoryMethodName(String factoryMethodName)
factoryMethodName
- static factory method name,
or null
if normal constructor creation should be usedgetBeanClassName()
String getScope()
null
if not known yet.void setScope(String scope)
SCOPE_SINGLETON
,
SCOPE_PROTOTYPE
boolean isLazyInit()
void setLazyInit(boolean lazyInit)
If false
, the bean will get instantiated on startup by bean
factories that perform eager initialization of singletons.
String[] getDependsOn()
void setDependsOn(String[] dependsOn)
boolean isAutowireCandidate()
void setAutowireCandidate(boolean autowireCandidate)
boolean isPrimary()
void setPrimary(boolean primary)
If this value is true for exactly one bean among multiple matching candidates, it will serve as a tie-breaker.
ConstructorArgumentValues getConstructorArgumentValues()
The returned instance can be modified during bean factory post-processing.
null
)MutablePropertyValues getPropertyValues()
The returned instance can be modified during bean factory post-processing.
null
)boolean isSingleton()
SCOPE_SINGLETON
boolean isPrototype()
SCOPE_PROTOTYPE
boolean isAbstract()
int getRole()
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
String getDescription()
String getResourceDescription()
BeanDefinition getOriginatingBeanDefinition()
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.