public interface

BeanDefinition

implements BeanMetadataElement AttributeAccessor
org.springframework.beans.factory.config.BeanDefinition
Known Indirect Subclasses

Class Overview

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.

Summary

Constants
int ROLE_APPLICATION Role hint indicating that a BeanDefinition is a major part of the application.
int ROLE_INFRASTRUCTURE Role hint indicating that a BeanDefinition is providing an entirely background role and has no relevance to the end-user.
int ROLE_SUPPORT Role hint indicating that a BeanDefinition is a supporting part of some larger configuration, typically an outer ComponentDefinition.
String SCOPE_PROTOTYPE Scope identifier for the standard prototype scope: "prototype".
String SCOPE_SINGLETON Scope identifier for the standard singleton scope: "singleton".
Public Methods
abstract String getBeanClassName()
Return the current bean class name of this bean definition.
abstract ConstructorArgumentValues getConstructorArgumentValues()
Return the constructor argument values for this bean.
abstract String[] getDependsOn()
Return the bean names that this bean depends on.
abstract String getDescription()
Return a human-readable description of this bean definition.
abstract String getFactoryBeanName()
Return the factory bean name, if any.
abstract String getFactoryMethodName()
Return a factory method, if any.
abstract BeanDefinition getOriginatingBeanDefinition()
Return the originating BeanDefinition, or null if none.
abstract String getParentName()
Return the name of the parent definition of this bean definition, if any.
abstract MutablePropertyValues getPropertyValues()
Return the property values to be applied to a new instance of the bean.
abstract String getResourceDescription()
Return a description of the resource that this bean definition came from (for the purpose of showing context in case of errors).
abstract int getRole()
Get the role hint for this BeanDefinition.
abstract String getScope()
Return the name of the current target scope for this bean, or null if not known yet.
abstract boolean isAbstract()
Return whether this bean is "abstract", that is, not meant to be instantiated.
abstract boolean isAutowireCandidate()
Return whether this bean is a candidate for getting autowired into some other bean.
abstract boolean isLazyInit()
Return whether this bean should be lazily initialized, i.e.
abstract boolean isPrimary()
Return whether this bean is a primary autowire candidate.
abstract boolean isPrototype()
Return whether this a Prototype, with an independent instance returned for each call.
abstract boolean isSingleton()
Return whether this a Singleton, with a single, shared instance returned on all calls.
abstract void setAutowireCandidate(boolean autowireCandidate)
Set whether this bean is a candidate for getting autowired into some other bean.
abstract void setBeanClassName(String beanClassName)
Override the bean class name of this bean definition.
abstract void setDependsOn(String[] dependsOn)
Set the names of the beans that this bean depends on being initialized.
abstract void setFactoryBeanName(String factoryBeanName)
Specify the factory bean to use, if any.
abstract void setFactoryMethodName(String factoryMethodName)
Specify a factory method, if any.
abstract void setLazyInit(boolean lazyInit)
Set whether this bean should be lazily initialized.
abstract void setParentName(String parentName)
Set the name of the parent definition of this bean definition, if any.
abstract void setPrimary(boolean primary)
Set whether this bean is a primary autowire candidate.
abstract void setScope(String scope)
Override the target scope of this bean, specifying a new scope name.
[Expand]
Inherited Methods
From interface org.springframework.beans.BeanMetadataElement
From interface org.springframework.core.AttributeAccessor

Constants

public static final int ROLE_APPLICATION

Also: SpringBeans

Role hint indicating that a BeanDefinition is a major part of the application. Typically corresponds to a user-defined bean.

Constant Value: 0 (0x00000000)

public static final int ROLE_INFRASTRUCTURE

Also: SpringBeans

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.

Constant Value: 2 (0x00000002)

public static final int ROLE_SUPPORT

Also: SpringBeans

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.

Constant Value: 1 (0x00000001)

public static final String SCOPE_PROTOTYPE

Also: SpringBeans

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

Note that extended bean factories might support further scopes.

See Also
Constant Value: "prototype"

public static final String SCOPE_SINGLETON

Also: SpringBeans

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

Note that extended bean factories might support further scopes.

See Also
Constant Value: "singleton"

Public Methods

public abstract String getBeanClassName ()

Also: SpringBeans

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. 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.

public abstract ConstructorArgumentValues getConstructorArgumentValues ()

Also: SpringBeans

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)

public abstract String[] getDependsOn ()

Also: SpringBeans

Return the bean names that this bean depends on.

public abstract String getDescription ()

Also: SpringBeans

Return a human-readable description of this bean definition.

public abstract String getFactoryBeanName ()

Also: SpringBeans

Return the factory bean name, if any.

public abstract String getFactoryMethodName ()

Also: SpringBeans

Return a factory method, if any.

public abstract BeanDefinition getOriginatingBeanDefinition ()

Also: SpringBeans

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.

public abstract String getParentName ()

Also: SpringBeans

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

public abstract MutablePropertyValues getPropertyValues ()

Also: SpringBeans

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)

public abstract String getResourceDescription ()

Also: SpringBeans

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

public abstract int getRole ()

Also: SpringBeans

Get the role hint for this BeanDefinition. The role hint provides tools with an indication of the importance of a particular BeanDefinition.

public abstract String getScope ()

Also: SpringBeans

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

public abstract boolean isAbstract ()

Also: SpringBeans

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

public abstract boolean isAutowireCandidate ()

Also: SpringBeans

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

public abstract boolean isLazyInit ()

Also: SpringBeans

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

public abstract boolean isPrimary ()

Also: SpringBeans

Return 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.

public abstract boolean isPrototype ()

Also: SpringBeans

Return whether this a Prototype, with an independent instance returned for each call.

See Also

public abstract boolean isSingleton ()

Also: SpringBeans

Return whether this a Singleton, with a single, shared instance returned on all calls.

See Also

public abstract void setAutowireCandidate (boolean autowireCandidate)

Also: SpringBeans

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

public abstract void setBeanClassName (String beanClassName)

Also: SpringBeans

Override 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.

public abstract void setDependsOn (String[] dependsOn)

Also: SpringBeans

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

public abstract void setFactoryBeanName (String factoryBeanName)

Also: SpringBeans

Specify the factory bean to use, if any.

public abstract void setFactoryMethodName (String factoryMethodName)

Also: SpringBeans

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.

Parameters
factoryMethodName static factory method name, or null if normal constructor creation should be used

public abstract void setLazyInit (boolean lazyInit)

Also: SpringBeans

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.

public abstract void setParentName (String parentName)

Also: SpringBeans

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

public abstract void setPrimary (boolean primary)

Also: SpringBeans

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.

public abstract void setScope (String scope)

Also: SpringBeans

Override the target scope of this bean, specifying a new scope name.