Package org.springframework.beans.factory.support

# Class AbstractBeanDefinition

java.lang.Object
org.springframework.core.AttributeAccessorSupport
org.springframework.beans.BeanMetadataAttributeAccessor
org.springframework.beans.factory.support.AbstractBeanDefinition

All Implemented Interfaces:
  `Serializable`, `Cloneable`, `BeanMetadataElement`, `BeanDefinition`, `org.springframework.core.AttributeAccessor`

Direct Known Subclasses:
  `ChildBeanDefinition`, `GenericBeanDefinition`, `RootBeanDefinition`

public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccessor implements BeanDefinition, Cloneable
Base class for concrete, full-fledged `BeanDefinition` classes, factoring out common properties of `GenericBeanDefinition`, `RootBeanDefinition`, and `ChildBeanDefinition`.

The autowire constants match the ones defined in the `AutowireCapableBeanFactory` interface.

Author:
  Rod Johnson, Juergen Hoeller, Rob Harrop, Mark Fisher, Sebastien Deleuze
See Also:
  - `GenericBeanDefinition`
  - `RootBeanDefinition`
  - `ChildBeanDefinition`
  - Serialized Form

## Field Summary

Fields
Modifier and Type
Field
Description
`static final int`
`AUTOWIRE_AUTODETECT`
Deprecated.
as of Spring 3.0: If you are using mixed autowiring strategies, use annotation-based autowiring for clearer demarcation of autowiring needs.
`static final int`
`AUTOWIRE_BY_NAME`
Constant that indicates autowiring bean properties by name.
`static final int`
`AUTOWIRE_BY_TYPE`
Constant that indicates autowiring bean properties by type.
`static final int`
`AUTOWIRE_CONSTRUCTOR`
Constant that indicates autowiring a constructor.
`static final int`
`AUTOWIRE_NO`
Constant that indicates no external autowiring at all.
`static final int`
`DEPENDENCY_CHECK_ALL`
Constant that indicates dependency checking for all properties (object references as well as "simple" properties).
`static final int`
`DEPENDENCY_CHECK_NONE`
Constant that indicates no dependency check at all.
`static final int`
`DEPENDENCY_CHECK_OBJECTS`
Constant that indicates dependency checking for object references.
`static final int`
`DEPENDENCY_CHECK_SIMPLE`
Constant that indicates dependency checking for "simple" properties.
`static final String`
`INFER_METHOD`
Constant that indicates the container should attempt to infer the `destroy method name` for a bean as opposed to explicit specification of a method name.
`static final String`
`ORDER_ATTRIBUTE`
The name of an attribute that can be `set` on a `BeanDefinition` so that bean definitions can indicate the sort order for the targeted bean.
`static final String`
`PREFERRED_CONSTRUCTORS_ATTRIBUTE`
The name of an attribute that can be `set` on a `BeanDefinition` so that bean definitions can indicate one or more preferred constructors.
`static final String`
`SCOPE_DEFAULT`
Constant for the default scope name: `""`, equivalent to singleton status unless overridden from a parent bean definition (if applicable).

### Fields inherited from interface org.springframework.beans.factory.config.BeanDefinition

`ROLE_APPLICATION, ROLE_INFRASTRUCTURE, ROLE_SUPPORT, SCOPE_PROTOTYPE, SCOPE_SINGLETON`

## Constructor Summary

Constructors
Modifier
Constructor
Description
`protected`
`AbstractBeanDefinition()`
Create a new AbstractBeanDefinition with default settings.
`protected`
`AbstractBeanDefinition(BeanDefinition original)`
Create a new AbstractBeanDefinition as a deep copy of the given bean definition.
`protected`
`AbstractBeanDefinition(ConstructorArgumentValues cargs, MutablePropertyValues pvs)`
Create a new AbstractBeanDefinition with the given constructor argument values and property values.

## Method Summary

Modifier and Type
Method
Description
`void`
`addQualifier(AutowireCandidateQualifier qualifier)`
Register a qualifier to be used for autowire candidate resolution, keyed by the qualifier's type name.
`void`
`applyDefaults(BeanDefinitionDefaults defaults)`
Apply the provided default values to this bean.
`Object`
`clone()`
Public declaration of Object's `clone()` method.
`abstract AbstractBeanDefinition`
`cloneBeanDefinition()`
Clone this bean definition.
`void`
`copyQualifiersFrom(AbstractBeanDefinition source)`
Copy the qualifiers from the supplied AbstractBeanDefinition to this bean definition.
`boolean`
`equals(Object other)`
`int`
`getAutowireMode()`
Return the autowire mode as specified in the bean definition.
`Class<?>`
`getBeanClass()`
Return the specified class of the bean definition (assuming it is resolved already).
`String`
`getBeanClassName()`
Return the current bean class name of this bean definition.
`ConstructorArgumentValues`
`getConstructorArgumentValues()`
Return the constructor argument values for this bean.
`int`
`getDependencyCheck()`
Return the dependency check code.
`String[]`
`getDependsOn()`
Return the bean names that this bean depends on.
`String`
`getDescription()`
Return a human-readable description of this bean definition.
`String`
`getDestroyMethodName()`
Return the name of the destroy method.
`String[]`
`getDestroyMethodNames()`
Return the names of the destroy methods.
`String`
`getFactoryBeanName()`
Return the factory bean name, if any.
`String`
`getFactoryMethodName()`
Return a factory method, if any.
`String`
`getInitMethodName()`
Return the name of the initializer method.
`String[]`
`getInitMethodNames()`
Return the names of the initializer methods.
`Supplier<?>`
`getInstanceSupplier()`
Return a callback for creating an instance of the bean, if any.
`Boolean`
`getLazyInit()`
Return whether this bean should be lazily initialized, i.e.
`MethodOverrides`
`getMethodOverrides()`
Return information about methods to be overridden by the IoC container.
`BeanDefinition`
`getOriginatingBeanDefinition()`
Return the originating BeanDefinition, or `null` if none.
`MutablePropertyValues`
`getPropertyValues()`
Return the property values to be applied to a new instance of the bean.
`AutowireCandidateQualifier`
`getQualifier(String typeName)`
Return the qualifier mapped to the provided type name.
`Set<AutowireCandidateQualifier>`
`getQualifiers()`
Return all registered qualifiers.
`org.springframework.core.ResolvableType`
`getResolvableType()`
Return a resolvable type for this bean definition, based on the bean class or other specific metadata.
`int`
`getResolvedAutowireMode()`
Return the resolved autowire code, (resolving AUTOWIRE_AUTODETECT to AUTOWIRE_CONSTRUCTOR or AUTOWIRE_BY_TYPE).
`org.springframework.core.io.Resource`
`getResource()`
Return the resource that this bean definition came from.
`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`
`hasBeanClass()`
Return whether this definition specifies a bean class.
`boolean`
`hasConstructorArgumentValues()`
Return if there are constructor argument values defined for this bean.
`int`
`hashCode()`
`boolean`
`hasMethodOverrides()`
Return if there are method overrides defined for this bean.
`boolean`
`hasPropertyValues()`
Return if there are property values defined for this bean.
`boolean`
`hasQualifier(String typeName)`
Return whether this bean has the specified qualifier.
`boolean`
`isAbstract()`
Return whether this bean is "abstract", that is, not meant to be instantiated itself but rather just serving as parent for concrete child bean definitions.
`boolean`
`isAutowireCandidate()`
Return whether this bean is a candidate for getting autowired into some other bean.
`boolean`
`isBackgroundInit()`
Return the bootstrap mode for this bean: default is `false` for using the main pre-instantiation thread for non-lazy singleton beans and the caller thread for prototype beans.
`boolean`
`isDefaultCandidate()`
Return whether this bean is a candidate for getting autowired into some other bean based on the plain type, without any further indications such as a qualifier match?
`boolean`
`isEnforceDestroyMethod()`
Indicate whether the configured destroy method is the default.
`boolean`
`isEnforceInitMethod()`
Indicate whether the configured initializer method is the default.
`boolean`
`isFallback()`
Return whether this bean is a fallback autowire candidate.
`boolean`
`isLazyInit()`
Return whether this bean should be lazily initialized, i.e.
`boolean`
`isLenientConstructorResolution()`
Return whether to resolve constructors in lenient mode or in strict mode.
`boolean`
`isNonPublicAccessAllowed()`
Return whether to allow access to non-public constructors and methods.
`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.
`boolean`
`isSynthetic()`
Return whether this bean definition is 'synthetic', that is, not defined by the application itself.
`void`
`overrideFrom(BeanDefinition other)`
Override settings in this bean definition (presumably a copied parent from a parent-child inheritance relationship) from the given bean definition (presumably the child).
`protected void`
`prepareMethodOverride(MethodOverride mo)`
Validate and prepare the given method override.
`void`
`prepareMethodOverrides()`
Validate and prepare the method overrides defined for this bean.
`Class<?>`
`resolveBeanClass(ClassLoader classLoader)`
Determine the class of the wrapped bean, resolving it from a specified class name if necessary.
`void`
`setAbstract(boolean abstractFlag)`
Set if this bean is "abstract", i.e.
`void`
`setAutowireCandidate(boolean autowireCandidate)`
Set whether this bean is a candidate for getting autowired into some other bean.
`void`
`setAutowireMode(int autowireMode)`
Set the autowire mode.
`void`
`setBackgroundInit(boolean backgroundInit)`
Specify the bootstrap mode for this bean: default is `false` for using the main pre-instantiation thread for non-lazy singleton beans and the caller thread for prototype beans.
`void`
`setBeanClass(Class<?> beanClass)`
Specify the class for this bean.
`void`
`setBeanClassName(String beanClassName)`
Specify the bean class name of this bean definition.
`void`
`setConstructorArgumentValues(ConstructorArgumentValues constructorArgumentValues)`
Specify constructor argument values for this bean.
`void`
`setDefaultCandidate(boolean defaultCandidate)`
Set whether this bean is a candidate for getting autowired into some other bean based on the plain type, without any further indications such as a qualifier match.
`void`
`setDependencyCheck(int dependencyCheck)`
Set the dependency check code.
`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`
`setDestroyMethodNames(String... destroyMethodNames)`
Specify the names of multiple destroy methods.
`void`
`setEnforceDestroyMethod(boolean enforceDestroyMethod)`
Specify whether the configured destroy method is the default.
`void`
`setEnforceInitMethod(boolean enforceInitMethod)`
Specify whether the configured initializer method is the default.
`void`
`setFactoryBeanName(String factoryBeanName)`
Specify the factory bean to use, if any.
`void`
`setFactoryMethodName(String factoryMethodName)`
Specify a factory method, if any.
`void`
`setFallback(boolean fallback)`
Set whether this bean is a fallback autowire candidate.
`void`
`setInitMethodName(String initMethodName)`
Set the name of the initializer method.
`void`
`setInitMethodNames(String... initMethodNames)`
Specify the names of multiple initializer methods.
`void`
`setInstanceSupplier(Supplier<?> instanceSupplier)`
Specify a callback for creating an instance of the bean, as an alternative to a declaratively specified factory method.
`void`
`setLazyInit(boolean lazyInit)`
Set whether this bean should be lazily initialized.
`void`
`setLenientConstructorResolution(boolean lenientConstructorResolution)`
Specify whether to resolve constructors in lenient mode (`true`, which is the default) or to switch to strict resolution (throwing an exception in case of ambiguous constructors that all match when converting the arguments, whereas lenient mode would use the one with the 'closest' type matches).
`void`
`setMethodOverrides(MethodOverrides methodOverrides)`
Specify method overrides for the bean, if any.
`void`
`setNonPublicAccessAllowed(boolean nonPublicAccessAllowed)`
Specify whether to allow access to non-public constructors and methods, for the case of externalized metadata pointing to those.
`void`
`setOriginatingBeanDefinition(BeanDefinition originatingBd)`
Set the originating (for example, decorated) BeanDefinition, if any.
`void`
`setPrimary(boolean primary)`
Set whether this bean is a primary autowire candidate.
`void`
`setPropertyValues(MutablePropertyValues propertyValues)`
Specify property values for this bean, if any.
`void`
`setResource(org.springframework.core.io.Resource resource)`
Set the resource that this bean definition came from (for the purpose of showing context in case of errors).
`void`
`setResourceDescription(String resourceDescription)`
Set a description of the resource that this bean definition came from (for the purpose of showing context in case of errors).
`void`
`setRole(int role)`
Set the role hint for this `BeanDefinition`.
`void`
`setScope(String scope)`
Override the target scope of this bean, specifying a new scope name.
`void`
`setSynthetic(boolean synthetic)`
Set whether this bean definition is 'synthetic', that is, not defined by the application itself (for example, an infrastructure bean such as a helper for auto-proxying, created through `<aop:config>`).
`String`
`toString()`
`void`
`validate()`
Validate this bean definition.

### Methods inherited from class org.springframework.beans.BeanMetadataAttributeAccessor

`addMetadataAttribute, getAttribute, getMetadataAttribute, getSource, removeAttribute, setAttribute, setSource`

### Methods inherited from class org.springframework.core.AttributeAccessorSupport

`attributeNames, computeAttribute, copyAttributesFrom, hasAttribute`

### Methods inherited from class java.lang.Object

`finalize, getClass, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface org.springframework.core.AttributeAccessor

`attributeNames, computeAttribute, getAttribute, hasAttribute, removeAttribute, setAttribute`

### Methods inherited from interface org.springframework.beans.factory.config.BeanDefinition

`getParentName, setParentName`

### Methods inherited from interface org.springframework.beans.BeanMetadataElement

`getSource`

## Field Details

### SCOPE_DEFAULT

public static final String SCOPE_DEFAULT
Constant for the default scope name: `""`, equivalent to singleton status unless overridden from a parent bean definition (if applicable).

See Also:
  - Constant Field Values

### AUTOWIRE_NO

public static final int AUTOWIRE_NO
Constant that indicates no external autowiring at all.

See Also:
  - `setAutowireMode(int)`
  - Constant Field Values

### AUTOWIRE_BY_NAME

public static final int AUTOWIRE_BY_NAME
Constant that indicates autowiring bean properties by name.

See Also:
  - `setAutowireMode(int)`
  - Constant Field Values

### AUTOWIRE_BY_TYPE

public static final int AUTOWIRE_BY_TYPE
Constant that indicates autowiring bean properties by type.

See Also:
  - `setAutowireMode(int)`
  - Constant Field Values

### AUTOWIRE_CONSTRUCTOR

public static final int AUTOWIRE_CONSTRUCTOR
Constant that indicates autowiring a constructor.

See Also:
  - `setAutowireMode(int)`
  - Constant Field Values

### AUTOWIRE_AUTODETECT

@Deprecated public static final int AUTOWIRE_AUTODETECT
Deprecated.
as of Spring 3.0: If you are using mixed autowiring strategies, use annotation-based autowiring for clearer demarcation of autowiring needs.
Constant that indicates determining an appropriate autowire strategy through introspection of the bean class.

See Also:
  - `setAutowireMode(int)`
  - Constant Field Values

### DEPENDENCY_CHECK_NONE

public static final int DEPENDENCY_CHECK_NONE
Constant that indicates no dependency check at all.

See Also:
  - `setDependencyCheck(int)`
  - Constant Field Values

### DEPENDENCY_CHECK_OBJECTS

public static final int DEPENDENCY_CHECK_OBJECTS
Constant that indicates dependency checking for object references.

See Also:
  - `setDependencyCheck(int)`
  - Constant Field Values

### DEPENDENCY_CHECK_SIMPLE

public static final int DEPENDENCY_CHECK_SIMPLE
Constant that indicates dependency checking for "simple" properties.

See Also:
  - `setDependencyCheck(int)`
  - `BeanUtils.isSimpleProperty(java.lang.Class<?>)`
  - Constant Field Values

### DEPENDENCY_CHECK_ALL

public static final int DEPENDENCY_CHECK_ALL
Constant that indicates dependency checking for all properties (object references as well as "simple" properties).

See Also:
  - `setDependencyCheck(int)`
  - Constant Field Values

### PREFERRED_CONSTRUCTORS_ATTRIBUTE

public static final String PREFERRED_CONSTRUCTORS_ATTRIBUTE
The name of an attribute that can be `set` on a `BeanDefinition` so that bean definitions can indicate one or more preferred constructors. This is analogous to `@Autowired` annotated constructors on the bean class.

The attribute value may be a single `Constructor` reference or an array thereof.

Since:
  6.1
See Also:
  - `Autowired`
  - `RootBeanDefinition.getPreferredConstructors()`
  - Constant Field Values

### ORDER_ATTRIBUTE

public static final String ORDER_ATTRIBUTE
The name of an attribute that can be `set` on a `BeanDefinition` so that bean definitions can indicate the sort order for the targeted bean. This is analogous to the `@Order` annotation.

Since:
  6.1.2
See Also:
  - `Order`
  - `Ordered`
  - Constant Field Values

### INFER_METHOD

public static final String INFER_METHOD
Constant that indicates the container should attempt to infer the `destroy method name` for a bean as opposed to explicit specification of a method name. The value "(inferred)" is specifically designed to include characters otherwise illegal in a method name, ensuring no possibility of collisions with legitimately named methods having the same name.

Currently, the method names detected during destroy method inference are "close" and "shutdown", if present on the specific bean class.

See Also:
  - Constant Field Values

## Constructor Details

### AbstractBeanDefinition

protected AbstractBeanDefinition()
Create a new AbstractBeanDefinition with default settings.

### AbstractBeanDefinition

protected AbstractBeanDefinition(@Nullable ConstructorArgumentValues cargs, @Nullable MutablePropertyValues pvs)
Create a new AbstractBeanDefinition with the given constructor argument values and property values.

### AbstractBeanDefinition

protected AbstractBeanDefinition(BeanDefinition original)
Create a new AbstractBeanDefinition as a deep copy of the given bean definition.

Parameters:
  `original` - the original bean definition to copy from

## Method Details

### overrideFrom

public void overrideFrom(BeanDefinition other)
Override settings in this bean definition (presumably a copied parent from a parent-child inheritance relationship) from the given bean definition (presumably the child).

- Will override beanClass if specified in the given bean definition.
- Will always take `abstract`, `scope`, `lazyInit`, `autowireMode`, `dependencyCheck`, and `dependsOn` from the given bean definition.
- Will add `constructorArgumentValues`, `propertyValues`, `methodOverrides` from the given bean definition to existing ones.
- Will override `factoryBeanName`, `factoryMethodName`, `initMethodName`, and `destroyMethodName` if specified in the given bean definition.

### applyDefaults

public void applyDefaults(BeanDefinitionDefaults defaults)
Apply the provided default values to this bean.

Parameters:
  `defaults` - the default settings to apply
Since:
  2.5

### setBeanClassName

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

Specified by:
  `setBeanClassName` in interface `BeanDefinition`
See Also:
  - `setBeanClass(Class)`

### getBeanClassName

@Nullable public 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.

Specified by:
  `getBeanClassName` in interface `BeanDefinition`
See Also:
  - `getBeanClass()`

### setBeanClass

public void setBeanClass(@Nullable Class<?> beanClass)
Specify the class for this bean.

See Also:
  - `setBeanClassName(String)`

### getBeanClass

public Class<?> getBeanClass() throws IllegalStateException
Return the specified class of the bean definition (assuming it is resolved already).

NOTE: This is an initial class reference as declared in the bean metadata definition, potentially combined with a declared factory method or a `FactoryBean` which may lead to a different runtime type of the bean, or not being set at all in case of an instance-level factory method (which is resolved via `getFactoryBeanName()` instead). Do not use this for runtime type introspection of arbitrary bean definitions. The recommended way to find out about the actual runtime type of a particular bean is a `BeanFactory.getType(java.lang.String)` call for the specified bean name; this takes all of the above cases into account and returns the type of object that a `BeanFactory.getBean(java.lang.String)` call is going to return for the same bean name.

Returns:
  the resolved bean class (never `null`)
Throws:
  `IllegalStateException` - if the bean definition does not define a bean class, or a specified bean class name has not been resolved into an actual Class yet
See Also:
  - `getBeanClassName()`
  - `hasBeanClass()`
  - `setBeanClass(Class)`
  - `resolveBeanClass(ClassLoader)`

### hasBeanClass

public boolean hasBeanClass()
Return whether this definition specifies a bean class.

See Also:
  - `getBeanClass()`
  - `setBeanClass(Class)`
  - `resolveBeanClass(ClassLoader)`

### resolveBeanClass

@Nullable public Class<?> resolveBeanClass(@Nullable ClassLoader classLoader) throws ClassNotFoundException
Determine the class of the wrapped bean, resolving it from a specified class name if necessary. Will also reload a specified Class from its name when called with the bean class already resolved.

Parameters:
  `classLoader` - the ClassLoader to use for resolving a (potential) class name
Returns:
  the resolved bean class
Throws:
  `ClassNotFoundException` - if the class name could be resolved

### getResolvableType

public org.springframework.core.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.

This implementation delegates to `getBeanClass()`.

Specified by:
  `getResolvableType` in interface `BeanDefinition`
Returns:
  the resolvable type (potentially `ResolvableType.NONE`)
See Also:
  - `ConfigurableBeanFactory.getMergedBeanDefinition(java.lang.String)`

### setScope

public void setScope(@Nullable String scope)
Override the target scope of this bean, specifying a new scope name.

The default is singleton status, although this is only applied once a bean definition becomes active in the containing factory. A bean definition may eventually inherit its scope from a parent bean definition. For this reason, the default scope name is an empty string (i.e., `""`), with singleton status being assumed until a resolved scope is set.

Specified by:
  `setScope` in interface `BeanDefinition`
See Also:
  - `BeanDefinition.SCOPE_SINGLETON`
  - `BeanDefinition.SCOPE_PROTOTYPE`

### getScope

@Nullable public String getScope()
Return the name of the current target scope for this bean, or `null` if not known yet.

The default is `SCOPE_DEFAULT`.

Specified by:
  `getScope` in interface `BeanDefinition`

### isSingleton

public boolean isSingleton()
Return whether this a Singleton, with a single, shared instance returned on all calls.

The default is `true`.

Specified by:
  `isSingleton` in interface `BeanDefinition`
See Also:
  - `BeanDefinition.SCOPE_SINGLETON`

### isPrototype

public boolean isPrototype()
Return whether this a Prototype, with an independent instance returned for each call.

The default is `false`.

Specified by:
  `isPrototype` in interface `BeanDefinition`
See Also:
  - `BeanDefinition.SCOPE_PROTOTYPE`

### setAbstract

public void setAbstract(boolean abstractFlag)
Set if this bean is "abstract", i.e. not meant to be instantiated itself but rather just serving as parent for concrete child bean definitions.

The default is "false". Specify `true` to tell the bean factory to not try to instantiate that particular bean in any case.

### isAbstract

public boolean isAbstract()
Return whether this bean is "abstract", that is, not meant to be instantiated itself but rather just serving as parent for concrete child bean definitions.

The default is `false`.

Specified by:
  `isAbstract` in interface `BeanDefinition`

### setBackgroundInit

public void setBackgroundInit(boolean backgroundInit)
Specify the bootstrap mode for this bean: default is `false` for using the main pre-instantiation thread for non-lazy singleton beans and the caller thread for prototype beans.

Set this flag to `true` to allow for instantiating this bean on a background thread. For a non-lazy singleton, a background pre-instantiation thread can be used then, while still enforcing the completion at the end of `DefaultListableBeanFactory.preInstantiateSingletons()`. For a lazy singleton, a background pre-instantiation thread can be used as well - with completion allowed at a later point, enforcing it when actually accessed.

Note that this flag may be ignored by bean factories not set up for background bootstrapping, always applying single-threaded bootstrapping for non-lazy singleton beans.

Since:
  6.2
See Also:
  - `setLazyInit(boolean)`
  - `DefaultListableBeanFactory.setBootstrapExecutor(java.util.concurrent.Executor)`

### isBackgroundInit

public boolean isBackgroundInit()
Return the bootstrap mode for this bean: default is `false` for using the main pre-instantiation thread for non-lazy singleton beans and the caller thread for prototype beans.

Since:
  6.2

### setLazyInit

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

The default is `false`.

Specified by:
  `setLazyInit` in interface `BeanDefinition`

### isLazyInit

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

The default is `false`.

Specified by:
  `isLazyInit` in interface `BeanDefinition`

### getLazyInit

@Nullable public Boolean getLazyInit()
Return whether this bean should be lazily initialized, i.e. not eagerly instantiated on startup. Only applicable to a singleton bean.

Returns:
  the lazy-init flag if explicitly set, or `null` otherwise
Since:
  5.2

### setAutowireMode

public void setAutowireMode(int autowireMode)
Set the autowire mode. This determines whether any automagical detection and setting of bean references will happen. The default is AUTOWIRE_NO which means there won't be convention-based autowiring by name or type (however, there may still be explicit annotation-driven autowiring).

Parameters:
  `autowireMode` - the autowire mode to set. Must be one of the constants defined in this class.
See Also:
  - `AUTOWIRE_NO`
  - `AUTOWIRE_BY_NAME`
  - `AUTOWIRE_BY_TYPE`
  - `AUTOWIRE_CONSTRUCTOR`
  - `AUTOWIRE_AUTODETECT`

### getAutowireMode

public int getAutowireMode()
Return the autowire mode as specified in the bean definition.

### getResolvedAutowireMode

public int getResolvedAutowireMode()
Return the resolved autowire code, (resolving AUTOWIRE_AUTODETECT to AUTOWIRE_CONSTRUCTOR or AUTOWIRE_BY_TYPE).

See Also:
  - `AUTOWIRE_AUTODETECT`
  - `AUTOWIRE_CONSTRUCTOR`
  - `AUTOWIRE_BY_TYPE`

### setDependencyCheck

public void setDependencyCheck(int dependencyCheck)
Set the dependency check code.

Parameters:
  `dependencyCheck` - the code to set. Must be one of the four constants defined in this class.
See Also:
  - `DEPENDENCY_CHECK_NONE`
  - `DEPENDENCY_CHECK_OBJECTS`
  - `DEPENDENCY_CHECK_SIMPLE`
  - `DEPENDENCY_CHECK_ALL`

### getDependencyCheck

public int getDependencyCheck()
Return the dependency check code.

### setDependsOn

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

Note that dependencies are normally expressed through bean properties or constructor arguments. This property should just be necessary for other kinds of dependencies like statics (*ugh*) or database preparation on startup.

The default is no beans to explicitly depend on.

Specified by:
  `setDependsOn` in interface `BeanDefinition`

### getDependsOn

@Nullable public String[] getDependsOn()
Return the bean names that this bean depends on.

The default is no beans to explicitly depend on.

Specified by:
  `getDependsOn` in interface `BeanDefinition`

### setAutowireCandidate

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

The default is `true`, allowing injection by type at any injection point. Switch this to `false` in order to disable autowiring by type for this bean.

Specified by:
  `setAutowireCandidate` in interface `BeanDefinition`
See Also:
  - `AUTOWIRE_BY_TYPE`
  - `AUTOWIRE_BY_NAME`

### isAutowireCandidate

public boolean isAutowireCandidate()
Return whether this bean is a candidate for getting autowired into some other bean.

The default is `true`.

Specified by:
  `isAutowireCandidate` in interface `BeanDefinition`

### setDefaultCandidate

public void setDefaultCandidate(boolean defaultCandidate)
Set whether this bean is a candidate for getting autowired into some other bean based on the plain type, without any further indications such as a qualifier match.

The default is `true`, allowing injection by type at any injection point. Switch this to `false` in order to restrict injection by default, effectively enforcing an additional indication such as a qualifier match.

Since:
  6.2

### isDefaultCandidate

public boolean isDefaultCandidate()
Return whether this bean is a candidate for getting autowired into some other bean based on the plain type, without any further indications such as a qualifier match?

The default is `true`.

Since:
  6.2

### setPrimary

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

The default is `false`.

Specified by:
  `setPrimary` in interface `BeanDefinition`
See Also:
  - `BeanDefinition.setFallback(boolean)`

### isPrimary

public boolean isPrimary()
Return whether this bean is a primary autowire candidate.

The default is `false`.

Specified by:
  `isPrimary` in interface `BeanDefinition`

### setFallback

public void setFallback(boolean fallback)
Set whether this bean is a fallback autowire candidate.

If this value is `true` for all beans but one among multiple matching candidates, the remaining bean will be selected.

The default is `false`.

Specified by:
  `setFallback` in interface `BeanDefinition`
See Also:
  - `BeanDefinition.setPrimary(boolean)`

### isFallback

public boolean isFallback()
Return whether this bean is a fallback autowire candidate.

The default is `false`.

Specified by:
  `isFallback` in interface `BeanDefinition`

### addQualifier

public void addQualifier(AutowireCandidateQualifier qualifier)
Register a qualifier to be used for autowire candidate resolution, keyed by the qualifier's type name.

See Also:
  - `AutowireCandidateQualifier.getTypeName()`

### hasQualifier

public boolean hasQualifier(String typeName)
Return whether this bean has the specified qualifier.

### getQualifier

@Nullable public AutowireCandidateQualifier getQualifier(String typeName)
Return the qualifier mapped to the provided type name.

### getQualifiers

public Set<AutowireCandidateQualifier> getQualifiers()
Return all registered qualifiers.

Returns:
  the Set of `AutowireCandidateQualifier` objects.

### copyQualifiersFrom

public void copyQualifiersFrom(AbstractBeanDefinition source)
Copy the qualifiers from the supplied AbstractBeanDefinition to this bean definition.

Parameters:
  `source` - the AbstractBeanDefinition to copy from

### setInstanceSupplier

public void setInstanceSupplier(@Nullable Supplier<?> instanceSupplier)
Specify a callback for creating an instance of the bean, as an alternative to a declaratively specified factory method.

If such a callback is set, it will override any other constructor or factory method metadata. However, bean property population and potential annotation-driven injection will still apply as usual.

Since:
  5.0
See Also:
  - `setConstructorArgumentValues(ConstructorArgumentValues)`
  - `setPropertyValues(MutablePropertyValues)`

### getInstanceSupplier

@Nullable public Supplier<?> getInstanceSupplier()
Return a callback for creating an instance of the bean, if any.

Since:
  5.0

### setNonPublicAccessAllowed

public void setNonPublicAccessAllowed(boolean nonPublicAccessAllowed)
Specify whether to allow access to non-public constructors and methods, for the case of externalized metadata pointing to those. The default is `true`; switch this to `false` for public access only.

This applies to constructor resolution, factory method resolution, and also init/destroy methods. Bean property accessors have to be public in any case and are not affected by this setting.

Note that annotation-driven configuration will still access non-public members as far as they have been annotated. This setting applies to externalized metadata in this bean definition only.

### isNonPublicAccessAllowed

public boolean isNonPublicAccessAllowed()
Return whether to allow access to non-public constructors and methods.

### setLenientConstructorResolution

public void setLenientConstructorResolution(boolean lenientConstructorResolution)
Specify whether to resolve constructors in lenient mode (`true`, which is the default) or to switch to strict resolution (throwing an exception in case of ambiguous constructors that all match when converting the arguments, whereas lenient mode would use the one with the 'closest' type matches).

### isLenientConstructorResolution

public boolean isLenientConstructorResolution()
Return whether to resolve constructors in lenient mode or in strict mode.

### setFactoryBeanName

public void setFactoryBeanName(@Nullable String factoryBeanName)
Specify the factory bean to use, if any. This is the name of the bean to call the specified factory method on.

A factory bean name is only necessary for instance-based factory methods. For static factory methods, the method will be derived from the bean class.

Specified by:
  `setFactoryBeanName` in interface `BeanDefinition`
See Also:
  - `setBeanClass(java.lang.Class<?>)`

### getFactoryBeanName

@Nullable public String getFactoryBeanName()
Return the factory bean name, if any.

This will be `null` for static factory methods which will be derived from the bean class instead.

Specified by:
  `getFactoryBeanName` in interface `BeanDefinition`
See Also:
  - `getBeanClass()`

### setFactoryMethodName

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

Specified by:
  `setFactoryMethodName` in interface `BeanDefinition`
See Also:
  - `RootBeanDefinition.setUniqueFactoryMethodName(java.lang.String)`
  - `RootBeanDefinition.setNonUniqueFactoryMethodName(java.lang.String)`
  - `RootBeanDefinition.setResolvedFactoryMethod(java.lang.reflect.Method)`

### getFactoryMethodName

@Nullable public String getFactoryMethodName()
Return a factory method, if any.

Specified by:
  `getFactoryMethodName` in interface `BeanDefinition`
See Also:
  - `RootBeanDefinition.getResolvedFactoryMethod()`

### setConstructorArgumentValues

public void setConstructorArgumentValues(ConstructorArgumentValues constructorArgumentValues)
Specify constructor argument values for this bean.

### getConstructorArgumentValues

public ConstructorArgumentValues getConstructorArgumentValues()
Return the constructor argument values for this bean.

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

Specified by:
  `getConstructorArgumentValues` in interface `BeanDefinition`
Returns:
  the ConstructorArgumentValues object (never `null`)
See Also:
  - `setConstructorArgumentValues(org.springframework.beans.factory.config.ConstructorArgumentValues)`

### hasConstructorArgumentValues

public boolean hasConstructorArgumentValues()
Return if there are constructor argument values defined for this bean.

Specified by:
  `hasConstructorArgumentValues` in interface `BeanDefinition`
See Also:
  - `setConstructorArgumentValues(org.springframework.beans.factory.config.ConstructorArgumentValues)`

### setPropertyValues

public void setPropertyValues(MutablePropertyValues propertyValues)
Specify property values for this bean, if any.

### getPropertyValues

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

Specified by:
  `getPropertyValues` in interface `BeanDefinition`
Returns:
  the MutablePropertyValues object (never `null`)
See Also:
  - `setPropertyValues(org.springframework.beans.MutablePropertyValues)`

### hasPropertyValues

public boolean hasPropertyValues()
Return if there are property values defined for this bean.

Specified by:
  `hasPropertyValues` in interface `BeanDefinition`
See Also:
  - `setPropertyValues(org.springframework.beans.MutablePropertyValues)`

### setMethodOverrides

public void setMethodOverrides(MethodOverrides methodOverrides)
Specify method overrides for the bean, if any.

### getMethodOverrides

public MethodOverrides getMethodOverrides()
Return information about methods to be overridden by the IoC container. This will be empty if there are no method overrides.

Never returns `null`.

### hasMethodOverrides

public boolean hasMethodOverrides()
Return if there are method overrides defined for this bean.

Since:
  5.0.2

### setInitMethodNames

public void setInitMethodNames(@Nullable String... initMethodNames)
Specify the names of multiple initializer methods.

The default is `null` in which case there are no initializer methods.

Since:
  6.0
See Also:
  - `setInitMethodName(java.lang.String)`

### getInitMethodNames

@Nullable public String[] getInitMethodNames()
Return the names of the initializer methods.

Since:
  6.0

### setInitMethodName

public void setInitMethodName(@Nullable String initMethodName)
Set the name of the initializer method.

The default is `null` in which case there is no initializer method.

Specified by:
  `setInitMethodName` in interface `BeanDefinition`
See Also:
  - `setInitMethodNames(java.lang.String...)`

### getInitMethodName

@Nullable public String getInitMethodName()
Return the name of the initializer method.

Use the first one in case of multiple methods.

Specified by:
  `getInitMethodName` in interface `BeanDefinition`

### setEnforceInitMethod

public void setEnforceInitMethod(boolean enforceInitMethod)
Specify whether the configured initializer method is the default.

The default value is `true` for a locally specified init method but switched to `false` for a shared setting in a defaults section (for example, `bean init-method` versus `beans default-init-method` level in XML) which might not apply to all contained bean definitions.

See Also:
  - `setInitMethodName(java.lang.String)`
  - `applyDefaults(org.springframework.beans.factory.support.BeanDefinitionDefaults)`

### isEnforceInitMethod

public boolean isEnforceInitMethod()
Indicate whether the configured initializer method is the default.

See Also:
  - `getInitMethodName()`

### setDestroyMethodNames

public void setDestroyMethodNames(@Nullable String... destroyMethodNames)
Specify the names of multiple destroy methods.

The default is `null` in which case there are no destroy methods.

Since:
  6.0
See Also:
  - `setDestroyMethodName(java.lang.String)`

### getDestroyMethodNames

@Nullable public String[] getDestroyMethodNames()
Return the names of the destroy methods.

Since:
  6.0

### setDestroyMethodName

public void setDestroyMethodName(@Nullable String destroyMethodName)
Set the name of the destroy method.

The default is `null` in which case there is no destroy method.

Specified by:
  `setDestroyMethodName` in interface `BeanDefinition`
See Also:
  - `setDestroyMethodNames(java.lang.String...)`

### getDestroyMethodName

@Nullable public String getDestroyMethodName()
Return the name of the destroy method.

Use the first one in case of multiple methods.

Specified by:
  `getDestroyMethodName` in interface `BeanDefinition`

### setEnforceDestroyMethod

public void setEnforceDestroyMethod(boolean enforceDestroyMethod)
Specify whether the configured destroy method is the default.

The default value is `true` for a locally specified destroy method but switched to `false` for a shared setting in a defaults section (for example, `bean destroy-method` versus `beans default-destroy-method` level in XML) which might not apply to all contained bean definitions.

See Also:
  - `setDestroyMethodName(java.lang.String)`
  - `applyDefaults(org.springframework.beans.factory.support.BeanDefinitionDefaults)`

### isEnforceDestroyMethod

public boolean isEnforceDestroyMethod()
Indicate whether the configured destroy method is the default.

See Also:
  - `getDestroyMethodName()`

### setSynthetic

public void setSynthetic(boolean synthetic)
Set whether this bean definition is 'synthetic', that is, not defined by the application itself (for example, an infrastructure bean such as a helper for auto-proxying, created through `<aop:config>`).

### isSynthetic

public boolean isSynthetic()
Return whether this bean definition is 'synthetic', that is, not defined by the application itself.

### setRole

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

The default is `BeanDefinition.ROLE_APPLICATION`.

Specified by:
  `setRole` in interface `BeanDefinition`
See Also:
  - `BeanDefinition.ROLE_APPLICATION`
  - `BeanDefinition.ROLE_SUPPORT`
  - `BeanDefinition.ROLE_INFRASTRUCTURE`

### getRole

public int getRole()
Get 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`.

The default is `BeanDefinition.ROLE_APPLICATION`.

Specified by:
  `getRole` in interface `BeanDefinition`
See Also:
  - `BeanDefinition.ROLE_APPLICATION`
  - `BeanDefinition.ROLE_SUPPORT`
  - `BeanDefinition.ROLE_INFRASTRUCTURE`

### setDescription

public void setDescription(@Nullable String description)
Set a human-readable description of this bean definition.

The default is no description.

Specified by:
  `setDescription` in interface `BeanDefinition`

### getDescription

@Nullable public String getDescription()
Return a human-readable description of this bean definition.

The default is no description.

Specified by:
  `getDescription` in interface `BeanDefinition`

### setResource

public void setResource(@Nullable org.springframework.core.io.Resource resource)
Set the resource that this bean definition came from (for the purpose of showing context in case of errors).

### getResource

@Nullable public org.springframework.core.io.Resource getResource()
Return the resource that this bean definition came from.

### setResourceDescription

public void setResourceDescription(@Nullable String resourceDescription)
Set a description of the resource that this bean definition came from (for the purpose of showing context in case of errors).

### getResourceDescription

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

Specified by:
  `getResourceDescription` in interface `BeanDefinition`
See Also:
  - `setResourceDescription(java.lang.String)`

### setOriginatingBeanDefinition

public void setOriginatingBeanDefinition(BeanDefinition originatingBd)
Set the originating (for example, decorated) BeanDefinition, if any.

### getOriginatingBeanDefinition

@Nullable public 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.

Specified by:
  `getOriginatingBeanDefinition` in interface `BeanDefinition`
See Also:
  - `setOriginatingBeanDefinition(org.springframework.beans.factory.config.BeanDefinition)`

### validate

public void validate() throws BeanDefinitionValidationException
Validate this bean definition.

Throws:
  `BeanDefinitionValidationException` - in case of validation failure

### prepareMethodOverrides

public void prepareMethodOverrides() throws BeanDefinitionValidationException
Validate and prepare the method overrides defined for this bean. Checks for existence of a method with the specified name.

Throws:
  `BeanDefinitionValidationException` - in case of validation failure

### prepareMethodOverride

protected void prepareMethodOverride(MethodOverride mo) throws BeanDefinitionValidationException
Validate and prepare the given method override. Checks for existence of a method with the specified name, marking it as not overloaded if none found.

Parameters:
  `mo` - the MethodOverride object to validate
Throws:
  `BeanDefinitionValidationException` - in case of validation failure

### clone

public Object clone()
Public declaration of Object's `clone()` method. Delegates to `cloneBeanDefinition()`.

Overrides:
  `clone` in class `Object`
See Also:
  - `Object.clone()`

### cloneBeanDefinition

public abstract AbstractBeanDefinition cloneBeanDefinition()
Clone this bean definition. To be implemented by concrete subclasses.

Returns:
  the cloned bean definition object

### equals

public boolean equals(@Nullable Object other)

Overrides:
  `equals` in class `org.springframework.core.AttributeAccessorSupport`

### hashCode

public int hashCode()

Overrides:
  `hashCode` in class `org.springframework.core.AttributeAccessorSupport`

### toString

public String toString()

Overrides:
  `toString` in class `Object`