Class AbstractBeanDefinition
- All Implemented Interfaces:
Serializable,Cloneable,BeanMetadataElement,BeanDefinition,AttributeAccessor
- Direct Known Subclasses:
ChildBeanDefinition,GenericBeanDefinition,RootBeanDefinition
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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDeprecated.as of Spring 3.0: If you are using mixed autowiring strategies, use annotation-based autowiring for clearer demarcation of autowiring needs.static final intConstant that indicates autowiring bean properties by name.static final intConstant that indicates autowiring bean properties by type.static final intConstant that indicates autowiring a constructor.static final intConstant that indicates no external autowiring at all.static final intConstant that indicates dependency checking for all properties (object references as well as "simple" properties).static final intConstant that indicates no dependency check at all.static final intConstant that indicates dependency checking for object references.static final intConstant that indicates dependency checking for "simple" properties.static final StringConstant that indicates the container should attempt to infer thedestroy method namefor a bean as opposed to explicit specification of a method name.static final StringThe name of an attribute that can beseton aBeanDefinitionso that bean definitions can indicate the sort order for the targeted bean.static final StringThe name of an attribute that can beseton aBeanDefinitionso that bean definitions can indicate one or more preferred constructors.static final StringConstant 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
ConstructorsModifierConstructorDescriptionprotectedCreate a new AbstractBeanDefinition with default settings.protectedAbstractBeanDefinition(BeanDefinition original) Create a new AbstractBeanDefinition as a deep copy of the given bean definition.protectedCreate a new AbstractBeanDefinition with the given constructor argument values and property values. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddQualifier(AutowireCandidateQualifier qualifier) Register a qualifier to be used for autowire candidate resolution, keyed by the qualifier's type name.voidapplyDefaults(BeanDefinitionDefaults defaults) Apply the provided default values to this bean.clone()Public declaration of Object'sclone()method.abstract AbstractBeanDefinitionClone this bean definition.voidCopy the qualifiers from the supplied AbstractBeanDefinition to this bean definition.booleanintReturn the autowire mode as specified in the bean definition.Class<?>Return the specified class of the bean definition (assuming it is resolved already).Return the current bean class name of this bean definition.Return the constructor argument values for this bean.intReturn the dependency check code.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.String[]Return the names of the destroy methods.Return the factory bean name, if any.Return a factory method, if any.Return the name of the initializer method.String[]Return the names of the initializer methods.Supplier<?>Return a callback for creating an instance of the bean, if any.Return whether this bean should be lazily initialized, i.e.Return information about methods to be overridden by the IoC container.Return the originating BeanDefinition, ornullif none.Return the property values to be applied to a new instance of the bean.getQualifier(String typeName) Return the qualifier mapped to the provided type name.Return all registered qualifiers.Return a resolvable type for this bean definition, based on the bean class or other specific metadata.intReturn the resolved autowire code, (resolving AUTOWIRE_AUTODETECT to AUTOWIRE_CONSTRUCTOR or AUTOWIRE_BY_TYPE).Return the resource that this bean definition came from.Return a description of the resource that this bean definition came from (for the purpose of showing context in case of errors).intgetRole()Get the role hint for thisBeanDefinition.getScope()Return the name of the current target scope for this bean, ornullif not known yet.booleanReturn whether this definition specifies a bean class.booleanReturn if there are constructor argument values defined for this bean.inthashCode()booleanReturn if there are method overrides defined for this bean.booleanReturn if there are property values defined for this bean.booleanhasQualifier(String typeName) Return whether this bean has the specified qualifier.booleanReturn whether this bean is "abstract", that is, not meant to be instantiated itself but rather just serving as parent for concrete child bean definitions.booleanReturn whether this bean is a candidate for getting autowired into some other bean.booleanReturn the bootstrap mode for this bean: default isfalsefor using the main pre-instantiation thread for non-lazy singleton beans and the caller thread for prototype beans.booleanReturn 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?booleanIndicate whether the configured destroy method is the default.booleanIndicate whether the configured initializer method is the default.booleanReturn whether this bean is a fallback autowire candidate.booleanReturn whether this bean should be lazily initialized, i.e.booleanReturn whether to resolve constructors in lenient mode or in strict mode.booleanReturn whether to allow access to non-public constructors and methods.booleanReturn whether this bean is a primary autowire candidate.booleanReturn whether this a Prototype, with an independent instance returned for each call.booleanReturn whether this a Singleton, with a single, shared instance returned on all calls.booleanReturn whether this bean definition is 'synthetic', that is, not defined by the application itself.voidoverrideFrom(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 voidValidate and prepare the given method override.voidValidate 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.voidsetAbstract(boolean abstractFlag) Set if this bean is "abstract", i.e.voidsetAutowireCandidate(boolean autowireCandidate) Set whether this bean is a candidate for getting autowired into some other bean.voidsetAutowireMode(int autowireMode) Set the autowire mode.voidsetBackgroundInit(boolean backgroundInit) Specify the bootstrap mode for this bean: default isfalsefor using the main pre-instantiation thread for non-lazy singleton beans and the caller thread for prototype beans.voidsetBeanClass(Class<?> beanClass) Specify the class for this bean.voidsetBeanClassName(String beanClassName) Specify the bean class name of this bean definition.voidsetConstructorArgumentValues(ConstructorArgumentValues constructorArgumentValues) Specify constructor argument values for this bean.voidsetDefaultCandidate(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.voidsetDependencyCheck(int dependencyCheck) Set the dependency check code.voidsetDependsOn(String... dependsOn) Set the names of the beans that this bean depends on being initialized.voidsetDescription(String description) Set a human-readable description of this bean definition.voidsetDestroyMethodName(String destroyMethodName) Set the name of the destroy method.voidsetDestroyMethodNames(String... destroyMethodNames) Specify the names of multiple destroy methods.voidsetEnforceDestroyMethod(boolean enforceDestroyMethod) Specify whether the configured destroy method is the default.voidsetEnforceInitMethod(boolean enforceInitMethod) Specify whether the configured initializer method is the default.voidsetFactoryBeanName(String factoryBeanName) Specify the factory bean to use, if any.voidsetFactoryMethodName(String factoryMethodName) Specify a factory method, if any.voidsetFallback(boolean fallback) Set whether this bean is a fallback autowire candidate.voidsetInitMethodName(String initMethodName) Set the name of the initializer method.voidsetInitMethodNames(String... initMethodNames) Specify the names of multiple initializer methods.voidsetInstanceSupplier(Supplier<?> instanceSupplier) Specify a callback for creating an instance of the bean, as an alternative to a declaratively specified factory method.voidsetLazyInit(boolean lazyInit) Set whether this bean should be lazily initialized.voidsetLenientConstructorResolution(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).voidsetMethodOverrides(MethodOverrides methodOverrides) Specify method overrides for the bean, if any.voidsetNonPublicAccessAllowed(boolean nonPublicAccessAllowed) Specify whether to allow access to non-public constructors and methods, for the case of externalized metadata pointing to those.voidsetOriginatingBeanDefinition(BeanDefinition originatingBd) Set the originating (for example, decorated) BeanDefinition, if any.voidsetPrimary(boolean primary) Set whether this bean is a primary autowire candidate.voidsetPropertyValues(MutablePropertyValues propertyValues) Specify property values for this bean, if any.voidsetResource(Resource resource) Set the resource that this bean definition came from (for the purpose of showing context in case of errors).voidsetResourceDescription(String resourceDescription) Set a description of the resource that this bean definition came from (for the purpose of showing context in case of errors).voidsetRole(int role) Set the role hint for thisBeanDefinition.voidOverride the target scope of this bean, specifying a new scope name.voidsetSynthetic(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>).toString()voidvalidate()Validate this bean definition.Methods inherited from class org.springframework.beans.BeanMetadataAttributeAccessor
addMetadataAttribute, getAttribute, getMetadataAttribute, getSource, removeAttribute, setAttribute, setSourceMethods inherited from class org.springframework.core.AttributeAccessorSupport
attributeNames, computeAttribute, copyAttributesFrom, hasAttributeMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.core.AttributeAccessor
attributeNames, computeAttribute, getAttribute, hasAttribute, removeAttribute, setAttributeMethods inherited from interface org.springframework.beans.factory.config.BeanDefinition
getParentName, setParentNameMethods inherited from interface org.springframework.beans.BeanMetadataElement
getSource
-
Field Details
-
SCOPE_DEFAULT
Constant for the default scope name:"", equivalent to singleton status unless overridden from a parent bean definition (if applicable).- See Also:
-
AUTOWIRE_NO
public static final int AUTOWIRE_NOConstant that indicates no external autowiring at all.- See Also:
-
AUTOWIRE_BY_NAME
public static final int AUTOWIRE_BY_NAMEConstant that indicates autowiring bean properties by name.- See Also:
-
AUTOWIRE_BY_TYPE
public static final int AUTOWIRE_BY_TYPEConstant that indicates autowiring bean properties by type.- See Also:
-
AUTOWIRE_CONSTRUCTOR
public static final int AUTOWIRE_CONSTRUCTORConstant that indicates autowiring a constructor.- See Also:
-
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:
-
DEPENDENCY_CHECK_NONE
public static final int DEPENDENCY_CHECK_NONEConstant that indicates no dependency check at all.- See Also:
-
DEPENDENCY_CHECK_OBJECTS
public static final int DEPENDENCY_CHECK_OBJECTSConstant that indicates dependency checking for object references.- See Also:
-
DEPENDENCY_CHECK_SIMPLE
public static final int DEPENDENCY_CHECK_SIMPLEConstant that indicates dependency checking for "simple" properties. -
DEPENDENCY_CHECK_ALL
public static final int DEPENDENCY_CHECK_ALLConstant that indicates dependency checking for all properties (object references as well as "simple" properties).- See Also:
-
PREFERRED_CONSTRUCTORS_ATTRIBUTE
The name of an attribute that can beseton aBeanDefinitionso that bean definitions can indicate one or more preferred constructors. This is analogous to@Autowiredannotated constructors on the bean class.The attribute value may be a single
Constructorreference or an array thereof.- Since:
- 6.1
- See Also:
-
ORDER_ATTRIBUTE
The name of an attribute that can beseton aBeanDefinitionso that bean definitions can indicate the sort order for the targeted bean. This is analogous to the@Orderannotation.- Since:
- 6.1.2
- See Also:
-
INFER_METHOD
Constant that indicates the container should attempt to infer thedestroy method namefor 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:
-
-
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
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
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, anddependsOnfrom the given bean definition. - Will add
constructorArgumentValues,propertyValues,methodOverridesfrom the given bean definition to existing ones. - Will override
factoryBeanName,factoryMethodName,initMethodName, anddestroyMethodNameif specified in the given bean definition.
-
applyDefaults
Apply the provided default values to this bean.- Parameters:
defaults- the default settings to apply- Since:
- 2.5
-
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.
- Specified by:
setBeanClassNamein interfaceBeanDefinition- See Also:
-
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:
getBeanClassNamein interfaceBeanDefinition- See Also:
-
setBeanClass
Specify the class for this bean.- See Also:
-
getBeanClass
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
FactoryBeanwhich 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 viagetFactoryBeanName()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 aBeanFactory.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 aBeanFactory.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:
-
hasBeanClass
public boolean hasBeanClass()Return whether this definition specifies a bean class. -
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
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:
getResolvableTypein interfaceBeanDefinition- Returns:
- the resolvable type (potentially
ResolvableType.NONE) - See Also:
-
setScope
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:
setScopein interfaceBeanDefinition- See Also:
-
getScope
Return the name of the current target scope for this bean, ornullif not known yet.The default is
SCOPE_DEFAULT.- Specified by:
getScopein interfaceBeanDefinition
-
isSingleton
public boolean isSingleton()Return whether this a Singleton, with a single, shared instance returned on all calls.The default is
true.- Specified by:
isSingletonin interfaceBeanDefinition- See Also:
-
isPrototype
public boolean isPrototype()Return whether this a Prototype, with an independent instance returned for each call.The default is
false.- Specified by:
isPrototypein interfaceBeanDefinition- See Also:
-
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
trueto 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:
isAbstractin interfaceBeanDefinition
-
setBackgroundInit
public void setBackgroundInit(boolean backgroundInit) Specify the bootstrap mode for this bean: default isfalsefor using the main pre-instantiation thread for non-lazy singleton beans and the caller thread for prototype beans.Set this flag to
trueto 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 ofDefaultListableBeanFactory.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.
-
isBackgroundInit
public boolean isBackgroundInit()Return the bootstrap mode for this bean: default isfalsefor 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:
setLazyInitin interfaceBeanDefinition
-
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:
isLazyInitin interfaceBeanDefinition
-
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
nullotherwise - 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:
-
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). -
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:
-
getDependencyCheck
public int getDependencyCheck()Return the dependency check code. -
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.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:
setDependsOnin interfaceBeanDefinition
-
getDependsOn
Return the bean names that this bean depends on.The default is no beans to explicitly depend on.
- Specified by:
getDependsOnin interfaceBeanDefinition
-
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 tofalsein order to disable autowiring by type for this bean.- Specified by:
setAutowireCandidatein interfaceBeanDefinition- See Also:
-
isAutowireCandidate
public boolean isAutowireCandidate()Return whether this bean is a candidate for getting autowired into some other bean.The default is
true.- Specified by:
isAutowireCandidatein interfaceBeanDefinition
-
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 tofalsein 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
truefor exactly one bean among multiple matching candidates, it will serve as a tie-breaker.The default is
false.- Specified by:
setPrimaryin interfaceBeanDefinition- See Also:
-
isPrimary
public boolean isPrimary()Return whether this bean is a primary autowire candidate.The default is
false.- Specified by:
isPrimaryin interfaceBeanDefinition
-
setFallback
public void setFallback(boolean fallback) Set whether this bean is a fallback autowire candidate.If this value is
truefor all beans but one among multiple matching candidates, the remaining bean will be selected.The default is
false.- Specified by:
setFallbackin interfaceBeanDefinition- See Also:
-
isFallback
public boolean isFallback()Return whether this bean is a fallback autowire candidate.The default is
false.- Specified by:
isFallbackin interfaceBeanDefinition
-
addQualifier
Register a qualifier to be used for autowire candidate resolution, keyed by the qualifier's type name.- See Also:
-
hasQualifier
Return whether this bean has the specified qualifier. -
getQualifier
Return the qualifier mapped to the provided type name. -
getQualifiers
Return all registered qualifiers.- Returns:
- the Set of
AutowireCandidateQualifierobjects.
-
copyQualifiersFrom
Copy the qualifiers from the supplied AbstractBeanDefinition to this bean definition.- Parameters:
source- the AbstractBeanDefinition to copy from
-
setInstanceSupplier
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.
-
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 istrue; switch this tofalsefor 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
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:
setFactoryBeanNamein interfaceBeanDefinition- See Also:
-
getFactoryBeanName
Return the factory bean name, if any.This will be
nullfor static factory methods which will be derived from the bean class instead.- Specified by:
getFactoryBeanNamein interfaceBeanDefinition- See Also:
-
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.- Specified by:
getFactoryMethodNamein interfaceBeanDefinition- See Also:
-
setConstructorArgumentValues
Specify constructor argument values for this bean. -
getConstructorArgumentValues
Return the constructor argument values for this bean.The returned instance can be modified during bean factory post-processing.
- Specified by:
getConstructorArgumentValuesin interfaceBeanDefinition- Returns:
- the ConstructorArgumentValues object (never
null) - See Also:
-
hasConstructorArgumentValues
public boolean hasConstructorArgumentValues()Return if there are constructor argument values defined for this bean.- Specified by:
hasConstructorArgumentValuesin interfaceBeanDefinition- See Also:
-
setPropertyValues
Specify property values for this bean, if any. -
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:
getPropertyValuesin interfaceBeanDefinition- Returns:
- the MutablePropertyValues object (never
null) - See Also:
-
hasPropertyValues
public boolean hasPropertyValues()Return if there are property values defined for this bean.- Specified by:
hasPropertyValuesin interfaceBeanDefinition- See Also:
-
setMethodOverrides
Specify method overrides for the bean, if any. -
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
Specify the names of multiple initializer methods.The default is
nullin which case there are no initializer methods.- Since:
- 6.0
- See Also:
-
getInitMethodNames
Return the names of the initializer methods.- Since:
- 6.0
-
setInitMethodName
Set the name of the initializer method.The default is
nullin which case there is no initializer method.- Specified by:
setInitMethodNamein interfaceBeanDefinition- See Also:
-
getInitMethodName
Return the name of the initializer method.Use the first one in case of multiple methods.
- Specified by:
getInitMethodNamein interfaceBeanDefinition
-
setEnforceInitMethod
public void setEnforceInitMethod(boolean enforceInitMethod) Specify whether the configured initializer method is the default.The default value is
truefor a locally specified init method but switched tofalsefor a shared setting in a defaults section (for example,bean init-methodversusbeans default-init-methodlevel in XML) which might not apply to all contained bean definitions. -
isEnforceInitMethod
public boolean isEnforceInitMethod()Indicate whether the configured initializer method is the default.- See Also:
-
setDestroyMethodNames
Specify the names of multiple destroy methods.The default is
nullin which case there are no destroy methods.- Since:
- 6.0
- See Also:
-
getDestroyMethodNames
Return the names of the destroy methods.- Since:
- 6.0
-
setDestroyMethodName
Set the name of the destroy method.The default is
nullin which case there is no destroy method.- Specified by:
setDestroyMethodNamein interfaceBeanDefinition- See Also:
-
getDestroyMethodName
Return the name of the destroy method.Use the first one in case of multiple methods.
- Specified by:
getDestroyMethodNamein interfaceBeanDefinition
-
setEnforceDestroyMethod
public void setEnforceDestroyMethod(boolean enforceDestroyMethod) Specify whether the configured destroy method is the default.The default value is
truefor a locally specified destroy method but switched tofalsefor a shared setting in a defaults section (for example,bean destroy-methodversusbeans default-destroy-methodlevel in XML) which might not apply to all contained bean definitions. -
isEnforceDestroyMethod
public boolean isEnforceDestroyMethod()Indicate whether the configured destroy method is the default.- See Also:
-
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 thisBeanDefinition. The role hint provides the frameworks as well as tools an indication of the role and importance of a particularBeanDefinition.The default is
BeanDefinition.ROLE_APPLICATION.- Specified by:
setRolein interfaceBeanDefinition- See Also:
-
getRole
public 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.The default is
BeanDefinition.ROLE_APPLICATION.- Specified by:
getRolein interfaceBeanDefinition- See Also:
-
setDescription
Set a human-readable description of this bean definition.The default is no description.
- Specified by:
setDescriptionin interfaceBeanDefinition
-
getDescription
Return a human-readable description of this bean definition.The default is no description.
- Specified by:
getDescriptionin interfaceBeanDefinition
-
setResource
Set the resource that this bean definition came from (for the purpose of showing context in case of errors). -
getResource
Return the resource that this bean definition came from. -
setResourceDescription
Set a description of the resource that this bean definition came from (for the purpose of showing context in case of errors). -
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:
getResourceDescriptionin interfaceBeanDefinition- See Also:
-
setOriginatingBeanDefinition
Set the originating (for example, decorated) BeanDefinition, if any. -
getOriginatingBeanDefinition
Return the originating BeanDefinition, ornullif 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:
getOriginatingBeanDefinitionin interfaceBeanDefinition- See Also:
-
validate
Validate this bean definition.- Throws:
BeanDefinitionValidationException- in case of validation failure
-
prepareMethodOverrides
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
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 declaration of Object'sclone()method. Delegates tocloneBeanDefinition(). -
cloneBeanDefinition
Clone this bean definition. To be implemented by concrete subclasses.- Returns:
- the cloned bean definition object
-
equals
- Overrides:
equalsin classAttributeAccessorSupport
-
hashCode
public int hashCode()- Overrides:
hashCodein classAttributeAccessorSupport
-
toString
-