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
Modifier and TypeFieldDescriptionstatic final int
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
Constant that indicates autowiring bean properties by name.static final int
Constant that indicates autowiring bean properties by type.static final int
Constant that indicates autowiring a constructor.static final int
Constant that indicates no external autowiring at all.static final int
Constant that indicates dependency checking for all properties (object references as well as "simple" properties).static final int
Constant that indicates no dependency check at all.static final int
Constant that indicates dependency checking for object references.static final int
Constant that indicates dependency checking for "simple" properties.static final String
Constant that indicates the container should attempt to infer thedestroy method name
for a bean as opposed to explicit specification of a method name.static final String
The name of an attribute that can beset
on aBeanDefinition
so that bean definitions can indicate the sort order for the targeted bean.static final String
The name of an attribute that can beset
on aBeanDefinition
so that bean definitions can indicate one or more preferred constructors.static final String
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
ModifierConstructorDescriptionprotected
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
Create a new AbstractBeanDefinition with the given constructor argument values and property values. -
Method Summary
Modifier and TypeMethodDescriptionvoid
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.clone()
Public declaration of Object'sclone()
method.abstract AbstractBeanDefinition
Clone this bean definition.void
Copy the qualifiers from the supplied AbstractBeanDefinition to this bean definition.boolean
int
Return 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.int
Return 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, ornull
if 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.int
Return 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).int
getRole()
Get the role hint for thisBeanDefinition
.getScope()
Return the name of the current target scope for this bean, ornull
if not known yet.boolean
Return whether this definition specifies a bean class.boolean
Return if there are constructor argument values defined for this bean.int
hashCode()
boolean
Return if there are method overrides defined for this bean.boolean
Return if there are property values defined for this bean.boolean
hasQualifier
(String typeName) Return whether this bean has the specified qualifier.boolean
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
Return whether this bean is a candidate for getting autowired into some other bean.boolean
Return the bootstrap mode for this bean: default isfalse
for using the main pre-instantiation thread for non-lazy singleton beans and the caller thread for prototype beans.boolean
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
Indicate whether the configured destroy method is the default.boolean
Indicate whether the configured initializer method is the default.boolean
Return whether this bean is a fallback autowire candidate.boolean
Return whether this bean should be lazily initialized, i.e.boolean
Return whether to resolve constructors in lenient mode or in strict mode.boolean
Return whether to allow access to non-public constructors and methods.boolean
Return whether this bean is a primary autowire candidate.boolean
Return whether this a Prototype, with an independent instance returned for each call.boolean
Return whether this a Singleton, with a single, shared instance returned on all calls.boolean
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
Validate and prepare the given method override.void
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 isfalse
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
(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 thisBeanDefinition
.void
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>
).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
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 beset
on aBeanDefinition
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:
-
ORDER_ATTRIBUTE
The name of an attribute that can beset
on aBeanDefinition
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:
-
INFER_METHOD
Constant that indicates the container should attempt to infer thedestroy 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:
-
-
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
, anddependsOn
from the given bean definition. - Will add
constructorArgumentValues
,propertyValues
,methodOverrides
from the given bean definition to existing ones. - Will override
factoryBeanName
,factoryMethodName
,initMethodName
, anddestroyMethodName
if 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:
setBeanClassName
in 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:
getBeanClassName
in 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
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 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:
getResolvableType
in 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:
setScope
in interfaceBeanDefinition
- See Also:
-
getScope
Return the name of the current target scope for this bean, ornull
if not known yet.The default is
SCOPE_DEFAULT
.- Specified by:
getScope
in 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:
isSingleton
in 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:
isPrototype
in 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
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 interfaceBeanDefinition
-
setBackgroundInit
public void setBackgroundInit(boolean backgroundInit) Specify the bootstrap mode for this bean: default isfalse
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 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 isfalse
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 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:
isLazyInit
in 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
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:
-
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:
setDependsOn
in interfaceBeanDefinition
-
getDependsOn
Return the bean names that this bean depends on.The default is no beans to explicitly depend on.
- Specified by:
getDependsOn
in 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 tofalse
in order to disable autowiring by type for this bean.- Specified by:
setAutowireCandidate
in 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:
isAutowireCandidate
in 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 tofalse
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 interfaceBeanDefinition
- See Also:
-
isPrimary
public boolean isPrimary()Return whether this bean is a primary autowire candidate.The default is
false
.- Specified by:
isPrimary
in interfaceBeanDefinition
-
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 interfaceBeanDefinition
- See Also:
-
isFallback
public boolean isFallback()Return whether this bean is a fallback autowire candidate.The default is
false
.- Specified by:
isFallback
in 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
AutowireCandidateQualifier
objects.
-
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 tofalse
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
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 interfaceBeanDefinition
- See Also:
-
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 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:
getFactoryMethodName
in 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:
getConstructorArgumentValues
in 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:
hasConstructorArgumentValues
in 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:
getPropertyValues
in 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:
hasPropertyValues
in 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
null
in 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
null
in which case there is no initializer method.- Specified by:
setInitMethodName
in interfaceBeanDefinition
- See Also:
-
getInitMethodName
Return the name of the initializer method.Use the first one in case of multiple methods.
- Specified by:
getInitMethodName
in interfaceBeanDefinition
-
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 tofalse
for a shared setting in a defaults section (for example,bean init-method
versusbeans default-init-method
level 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
null
in 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
null
in which case there is no destroy method.- Specified by:
setDestroyMethodName
in interfaceBeanDefinition
- See Also:
-
getDestroyMethodName
Return the name of the destroy method.Use the first one in case of multiple methods.
- Specified by:
getDestroyMethodName
in interfaceBeanDefinition
-
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 tofalse
for a shared setting in a defaults section (for example,bean destroy-method
versusbeans default-destroy-method
level 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:
setRole
in 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:
getRole
in interfaceBeanDefinition
- See Also:
-
setDescription
Set a human-readable description of this bean definition.The default is no description.
- Specified by:
setDescription
in interfaceBeanDefinition
-
getDescription
Return a human-readable description of this bean definition.The default is no description.
- Specified by:
getDescription
in 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:
getResourceDescription
in interfaceBeanDefinition
- See Also:
-
setOriginatingBeanDefinition
Set the originating (for example, decorated) BeanDefinition, if any. -
getOriginatingBeanDefinition
Return the originating BeanDefinition, ornull
if none.Allows for retrieving the decorated bean definition, if any.
Note that this method returns the immediate originator. Iterate through the originator chain to find the original BeanDefinition as defined by the user.
- Specified by:
getOriginatingBeanDefinition
in 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:
equals
in classAttributeAccessorSupport
-
hashCode
public int hashCode()- Overrides:
hashCode
in classAttributeAccessorSupport
-
toString
-