Class ChildBeanDefinition
- All Implemented Interfaces:
Serializable
,Cloneable
,BeanMetadataElement
,BeanDefinition
,AttributeAccessor
A child bean definition will inherit constructor argument values, property values and method overrides from the parent, with the option to add new values. If init method, destroy method and/or static factory method are specified, they will override the corresponding parent settings. The remaining settings will always be taken from the child definition: depends on, autowire mode, dependency check, singleton, lazy init.
NOTE: Since Spring 2.5, the preferred way to register bean
definitions programmatically is the GenericBeanDefinition
class,
which allows to dynamically define parent dependencies through the
GenericBeanDefinition.setParentName(java.lang.String)
method. This effectively
supersedes the ChildBeanDefinition class for most use cases.
- Author:
- Rod Johnson, Juergen Hoeller
- See Also:
-
Field Summary
Fields inherited from class org.springframework.beans.factory.support.AbstractBeanDefinition
AUTOWIRE_AUTODETECT, AUTOWIRE_BY_NAME, AUTOWIRE_BY_TYPE, AUTOWIRE_CONSTRUCTOR, AUTOWIRE_NO, DEPENDENCY_CHECK_ALL, DEPENDENCY_CHECK_NONE, DEPENDENCY_CHECK_OBJECTS, DEPENDENCY_CHECK_SIMPLE, INFER_METHOD, ORDER_ATTRIBUTE, PREFERRED_CONSTRUCTORS_ATTRIBUTE, SCOPE_DEFAULT
Fields inherited from interface org.springframework.beans.factory.config.BeanDefinition
ROLE_APPLICATION, ROLE_INFRASTRUCTURE, ROLE_SUPPORT, SCOPE_PROTOTYPE, SCOPE_SINGLETON
-
Constructor Summary
ConstructorDescriptionChildBeanDefinition
(String parentName) Create a new ChildBeanDefinition for the given parent, to be configured through its bean properties and configuration methods.ChildBeanDefinition
(String parentName, Class<?> beanClass, ConstructorArgumentValues cargs, MutablePropertyValues pvs) Create a new ChildBeanDefinition for the given parent, providing constructor arguments and property values.ChildBeanDefinition
(String parentName, String beanClassName, ConstructorArgumentValues cargs, MutablePropertyValues pvs) Create a new ChildBeanDefinition for the given parent, providing constructor arguments and property values.ChildBeanDefinition
(String parentName, ConstructorArgumentValues cargs, MutablePropertyValues pvs) Create a new ChildBeanDefinition for the given parent.ChildBeanDefinition
(String parentName, MutablePropertyValues pvs) Create a new ChildBeanDefinition for the given parent.ChildBeanDefinition
(ChildBeanDefinition original) Create a new ChildBeanDefinition as deep copy of the given bean definition. -
Method Summary
Modifier and TypeMethodDescriptionClone this bean definition.boolean
Return the name of the parent definition of this bean definition, if any.int
hashCode()
void
setParentName
(String parentName) Set the name of the parent definition of this bean definition, if any.toString()
void
validate()
Validate this bean definition.Methods inherited from class org.springframework.beans.factory.support.AbstractBeanDefinition
addQualifier, applyDefaults, clone, copyQualifiersFrom, getAutowireMode, getBeanClass, getBeanClassName, getConstructorArgumentValues, getDependencyCheck, getDependsOn, getDescription, getDestroyMethodName, getDestroyMethodNames, getFactoryBeanName, getFactoryMethodName, getInitMethodName, getInitMethodNames, getInstanceSupplier, getLazyInit, getMethodOverrides, getOriginatingBeanDefinition, getPropertyValues, getQualifier, getQualifiers, getResolvableType, getResolvedAutowireMode, getResource, getResourceDescription, getRole, getScope, hasBeanClass, hasConstructorArgumentValues, hasMethodOverrides, hasPropertyValues, hasQualifier, isAbstract, isAutowireCandidate, isBackgroundInit, isDefaultCandidate, isEnforceDestroyMethod, isEnforceInitMethod, isFallback, isLazyInit, isLenientConstructorResolution, isNonPublicAccessAllowed, isPrimary, isPrototype, isSingleton, isSynthetic, overrideFrom, prepareMethodOverride, prepareMethodOverrides, resolveBeanClass, setAbstract, setAutowireCandidate, setAutowireMode, setBackgroundInit, setBeanClass, setBeanClassName, setConstructorArgumentValues, setDefaultCandidate, setDependencyCheck, setDependsOn, setDescription, setDestroyMethodName, setDestroyMethodNames, setEnforceDestroyMethod, setEnforceInitMethod, setFactoryBeanName, setFactoryMethodName, setFallback, setInitMethodName, setInitMethodNames, setInstanceSupplier, setLazyInit, setLenientConstructorResolution, setMethodOverrides, setNonPublicAccessAllowed, setOriginatingBeanDefinition, setPrimary, setPropertyValues, setResource, setResourceDescription, setRole, setScope, setSynthetic
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.BeanMetadataElement
getSource
-
Constructor Details
-
ChildBeanDefinition
Create a new ChildBeanDefinition for the given parent, to be configured through its bean properties and configuration methods.- Parameters:
parentName
- the name of the parent bean- See Also:
-
AbstractBeanDefinition.setBeanClass(java.lang.Class<?>)
AbstractBeanDefinition.setScope(java.lang.String)
AbstractBeanDefinition.setConstructorArgumentValues(org.springframework.beans.factory.config.ConstructorArgumentValues)
AbstractBeanDefinition.setPropertyValues(org.springframework.beans.MutablePropertyValues)
-
ChildBeanDefinition
Create a new ChildBeanDefinition for the given parent.- Parameters:
parentName
- the name of the parent beanpvs
- the additional property values of the child
-
ChildBeanDefinition
public ChildBeanDefinition(String parentName, ConstructorArgumentValues cargs, MutablePropertyValues pvs) Create a new ChildBeanDefinition for the given parent.- Parameters:
parentName
- the name of the parent beancargs
- the constructor argument values to applypvs
- the additional property values of the child
-
ChildBeanDefinition
public ChildBeanDefinition(String parentName, Class<?> beanClass, ConstructorArgumentValues cargs, MutablePropertyValues pvs) Create a new ChildBeanDefinition for the given parent, providing constructor arguments and property values.- Parameters:
parentName
- the name of the parent beanbeanClass
- the class of the bean to instantiatecargs
- the constructor argument values to applypvs
- the property values to apply
-
ChildBeanDefinition
public ChildBeanDefinition(String parentName, String beanClassName, ConstructorArgumentValues cargs, MutablePropertyValues pvs) Create a new ChildBeanDefinition for the given parent, providing constructor arguments and property values. Takes a bean class name to avoid eager loading of the bean class.- Parameters:
parentName
- the name of the parent beanbeanClassName
- the name of the class to instantiatecargs
- the constructor argument values to applypvs
- the property values to apply
-
ChildBeanDefinition
Create a new ChildBeanDefinition as deep copy of the given bean definition.- Parameters:
original
- the original bean definition to copy from
-
-
Method Details
-
setParentName
Description copied from interface:BeanDefinition
Set the name of the parent definition of this bean definition, if any. -
getParentName
Description copied from interface:BeanDefinition
Return the name of the parent definition of this bean definition, if any. -
validate
Description copied from class:AbstractBeanDefinition
Validate this bean definition.- Overrides:
validate
in classAbstractBeanDefinition
- Throws:
BeanDefinitionValidationException
- in case of validation failure
-
cloneBeanDefinition
Description copied from class:AbstractBeanDefinition
Clone this bean definition. To be implemented by concrete subclasses.- Specified by:
cloneBeanDefinition
in classAbstractBeanDefinition
- Returns:
- the cloned bean definition object
-
equals
- Overrides:
equals
in classAbstractBeanDefinition
-
hashCode
public int hashCode()- Overrides:
hashCode
in classAbstractBeanDefinition
-
toString
- Overrides:
toString
in classAbstractBeanDefinition
-