public class ChildBeanDefinition extends AbstractBeanDefinition
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.
GenericBeanDefinition
,
RootBeanDefinition
,
Serialized FormModifier and Type | Field and Description |
---|---|
private java.lang.String |
parentName |
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, SCOPE_DEFAULT
ROLE_APPLICATION, ROLE_INFRASTRUCTURE, ROLE_SUPPORT, SCOPE_PROTOTYPE, SCOPE_SINGLETON
Constructor and Description |
---|
ChildBeanDefinition(ChildBeanDefinition original)
Create a new ChildBeanDefinition as deep copy of the given
bean definition.
|
ChildBeanDefinition(java.lang.String parentName)
Create a new ChildBeanDefinition for the given parent, to be
configured through its bean properties and configuration methods.
|
ChildBeanDefinition(java.lang.String parentName,
java.lang.Class<?> beanClass,
ConstructorArgumentValues cargs,
MutablePropertyValues pvs)
Create a new ChildBeanDefinition for the given parent,
providing constructor arguments and property values.
|
ChildBeanDefinition(java.lang.String parentName,
ConstructorArgumentValues cargs,
MutablePropertyValues pvs)
Create a new ChildBeanDefinition for the given parent.
|
ChildBeanDefinition(java.lang.String parentName,
MutablePropertyValues pvs)
Create a new ChildBeanDefinition for the given parent.
|
ChildBeanDefinition(java.lang.String parentName,
java.lang.String beanClassName,
ConstructorArgumentValues cargs,
MutablePropertyValues pvs)
Create a new ChildBeanDefinition for the given parent,
providing constructor arguments and property values.
|
Modifier and Type | Method and Description |
---|---|
AbstractBeanDefinition |
cloneBeanDefinition()
Clone this bean definition.
|
boolean |
equals(java.lang.Object other) |
java.lang.String |
getParentName()
Return the name of the parent definition of this bean definition, if any.
|
int |
hashCode() |
void |
setParentName(java.lang.String parentName)
Set the name of the parent definition of this bean definition, if any.
|
java.lang.String |
toString() |
void |
validate()
Validate this bean definition.
|
addQualifier, applyDefaults, clone, copyQualifiersFrom, getAutowireMode, getBeanClass, getBeanClassName, getConstructorArgumentValues, getDependencyCheck, getDependsOn, getDescription, getDestroyMethodName, getFactoryBeanName, getFactoryMethodName, getInitMethodName, getInstanceSupplier, getLazyInit, getMethodOverrides, getOriginatingBeanDefinition, getPropertyValues, getQualifier, getQualifiers, getResolvedAutowireMode, getResource, getResourceDescription, getRole, getScope, hasBeanClass, hasConstructorArgumentValues, hasMethodOverrides, hasPropertyValues, hasQualifier, isAbstract, isAutowireCandidate, isEnforceDestroyMethod, isEnforceInitMethod, isLazyInit, isLenientConstructorResolution, isNonPublicAccessAllowed, isPrimary, isPrototype, isSingleton, isSynthetic, overrideFrom, prepareMethodOverride, prepareMethodOverrides, resolveBeanClass, setAbstract, setAutowireCandidate, setAutowireMode, setBeanClass, setBeanClassName, setConstructorArgumentValues, setDependencyCheck, setDependsOn, setDescription, setDestroyMethodName, setEnforceDestroyMethod, setEnforceInitMethod, setFactoryBeanName, setFactoryMethodName, setInitMethodName, setInstanceSupplier, setLazyInit, setLenientConstructorResolution, setMethodOverrides, setNonPublicAccessAllowed, setOriginatingBeanDefinition, setPrimary, setPropertyValues, setResource, setResourceDescription, setRole, setScope, setSynthetic
addMetadataAttribute, getAttribute, getMetadataAttribute, getSource, removeAttribute, setAttribute, setSource
attributeNames, copyAttributesFrom, hasAttribute
finalize, getClass, notify, notifyAll, wait, wait, wait
attributeNames, getAttribute, hasAttribute, removeAttribute, setAttribute
getSource
@Nullable private java.lang.String parentName
public ChildBeanDefinition(java.lang.String parentName)
parentName
- the name of the parent beanAbstractBeanDefinition.setBeanClass(java.lang.Class<?>)
,
AbstractBeanDefinition.setScope(java.lang.String)
,
AbstractBeanDefinition.setConstructorArgumentValues(org.springframework.beans.factory.config.ConstructorArgumentValues)
,
AbstractBeanDefinition.setPropertyValues(org.springframework.beans.MutablePropertyValues)
public ChildBeanDefinition(java.lang.String parentName, MutablePropertyValues pvs)
parentName
- the name of the parent beanpvs
- the additional property values of the childpublic ChildBeanDefinition(java.lang.String parentName, ConstructorArgumentValues cargs, MutablePropertyValues pvs)
parentName
- the name of the parent beancargs
- the constructor argument values to applypvs
- the additional property values of the childpublic ChildBeanDefinition(java.lang.String parentName, java.lang.Class<?> beanClass, ConstructorArgumentValues cargs, MutablePropertyValues pvs)
parentName
- the name of the parent beanbeanClass
- the class of the bean to instantiatecargs
- the constructor argument values to applypvs
- the property values to applypublic ChildBeanDefinition(java.lang.String parentName, java.lang.String beanClassName, ConstructorArgumentValues cargs, MutablePropertyValues pvs)
parentName
- the name of the parent beanbeanClassName
- the name of the class to instantiatecargs
- the constructor argument values to applypvs
- the property values to applypublic ChildBeanDefinition(ChildBeanDefinition original)
original
- the original bean definition to copy frompublic void setParentName(@Nullable java.lang.String parentName)
BeanDefinition
@Nullable public java.lang.String getParentName()
BeanDefinition
public void validate() throws BeanDefinitionValidationException
AbstractBeanDefinition
validate
in class AbstractBeanDefinition
BeanDefinitionValidationException
- in case of validation failurepublic AbstractBeanDefinition cloneBeanDefinition()
AbstractBeanDefinition
cloneBeanDefinition
in class AbstractBeanDefinition
public boolean equals(java.lang.Object other)
equals
in class AbstractBeanDefinition
public int hashCode()
hashCode
in class AbstractBeanDefinition
public java.lang.String toString()
toString
in class AbstractBeanDefinition