Top Description Fields Constructors Methods
org.springframework.beans.factory.support

public Class ChildBeanDefinition

extends AbstractBeanDefinition
Class Inheritance
Annotations
@SuppressWarnings:serial
Imports
org.springframework.beans.MutablePropertyValues, org.springframework.beans.factory.config.ConstructorArgumentValues, org.springframework.lang.Nullable, org.springframework.util.ObjectUtils

Bean definition for beans which inherit settings from their parent. Child bean definitions have a fixed dependency on a parent bean definition.

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 method. This effectively supersedes the ChildBeanDefinition class for most use cases.

Authors
Rod Johnson, Juergen Hoeller
See Also
GenericBeanDefinition, RootBeanDefinition

Field Summary

Modifier and TypeField and Description
private String
Inherited from org.springframework.beans.factory.support.AbstractBeanDefinition:
AUTOWIRE_AUTODETECTAUTOWIRE_BY_NAMEAUTOWIRE_BY_TYPEAUTOWIRE_CONSTRUCTORAUTOWIRE_NODEPENDENCY_CHECK_ALLDEPENDENCY_CHECK_NONEDEPENDENCY_CHECK_OBJECTSDEPENDENCY_CHECK_SIMPLEINFER_METHODORDER_ATTRIBUTEPREFERRED_CONSTRUCTORS_ATTRIBUTESCOPE_DEFAULT

Constructor Summary

AccessConstructor and Description
public
ChildBeanDefinition(String
the name of the parent bean
parentName
)

Create a new ChildBeanDefinition for the given parent, to be configured through its bean properties and configuration methods.

public
ChildBeanDefinition(String
the name of the parent bean
parentName
,
MutablePropertyValues
the additional property values of the child
pvs
)

Create a new ChildBeanDefinition for the given parent.

public
ChildBeanDefinition(String
the name of the parent bean
parentName
,
ConstructorArgumentValues
the constructor argument values to apply
cargs
,
MutablePropertyValues
the additional property values of the child
pvs
)

Create a new ChildBeanDefinition for the given parent.

public
ChildBeanDefinition(String
the name of the parent bean
parentName
,
Class<?>
the class of the bean to instantiate
beanClass
,
ConstructorArgumentValues
the constructor argument values to apply
cargs
,
MutablePropertyValues
the property values to apply
pvs
)

Create a new ChildBeanDefinition for the given parent, providing constructor arguments and property values.

public
ChildBeanDefinition(String
the name of the parent bean
parentName
,
String
the name of the class to instantiate
beanClassName
,
ConstructorArgumentValues
the constructor argument values to apply
cargs
,
MutablePropertyValues
the property values to apply
pvs
)

Create a new ChildBeanDefinition for the given parent, providing constructor arguments and property values.

public
ChildBeanDefinition(ChildBeanDefinition
the original bean definition to copy from
original
)

Create a new ChildBeanDefinition as deep copy of the given bean definition.

Method Summary

Modifier and TypeMethod and Description
public AbstractBeanDefinition
public boolean
equals(Object
the reference object with which to compare.
other
)

Overrides org.springframework.beans.factory.support.AbstractBeanDefinition.equals.

Indicates whether some other object is "equal to" this one.
public String
getParentName()

Implements org.springframework.beans.factory.config.BeanDefinition.getParentName.

Return the name of the parent definition of this bean definition, if any.
public int
hashCode()

Overrides org.springframework.beans.factory.support.AbstractBeanDefinition.hashCode.

Returns a hash code value for the object.
public void
setParentName(String parentName)

Implements org.springframework.beans.factory.config.BeanDefinition.setParentName.

Set the name of the parent definition of this bean definition, if any.
public String
toString()

Overrides org.springframework.beans.factory.support.AbstractBeanDefinition.toString.

Returns a string representation of the object.
public void
Inherited from org.springframework.beans.factory.support.AbstractBeanDefinition:
addQualifierapplyDefaultsclonecopyQualifiersFromgetAutowireModegetBeanClassgetBeanClassNamegetConstructorArgumentValuesgetDependencyCheckgetDependsOngetDescriptiongetDestroyMethodNamegetDestroyMethodNamesgetFactoryBeanNamegetFactoryMethodNamegetInitMethodNamegetInitMethodNamesgetInstanceSuppliergetLazyInitgetMethodOverridesgetOriginatingBeanDefinitiongetPropertyValuesgetQualifiergetQualifiersgetResolvableTypegetResolvedAutowireModegetResourcegetResourceDescriptiongetRolegetScopehasBeanClasshasConstructorArgumentValueshasMethodOverrideshasPropertyValueshasQualifierisAbstractisAutowireCandidateisEnforceDestroyMethodisEnforceInitMethodisLazyInitisLenientConstructorResolutionisNonPublicAccessAllowedisPrimaryisPrototypeisSingletonisSyntheticoverrideFromprepareMethodOverrideprepareMethodOverridesresolveBeanClasssetAbstractsetAutowireCandidatesetAutowireModesetBeanClasssetBeanClassNamesetConstructorArgumentValuessetDependencyChecksetDependsOnsetDescriptionsetDestroyMethodNamesetDestroyMethodNamessetEnforceDestroyMethodsetEnforceInitMethodsetFactoryBeanNamesetFactoryMethodNamesetInitMethodNamesetInitMethodNamessetInstanceSuppliersetLazyInitsetLenientConstructorResolutionsetMethodOverridessetNonPublicAccessAllowedsetOriginatingBeanDefinitionsetPrimarysetPropertyValuessetResourcesetResourceDescriptionsetRolesetScopesetSynthetic

Field Detail

parentNameback to summary
private String parentName
Annotations
@Nullable

Constructor Detail

ChildBeanDefinitionback to summary
public ChildBeanDefinition(String parentName)

Create a new ChildBeanDefinition for the given parent, to be configured through its bean properties and configuration methods.

Parameters
parentName:String

the name of the parent bean

See Also
setBeanClass, setScope, setConstructorArgumentValues, setPropertyValues
ChildBeanDefinitionback to summary
public ChildBeanDefinition(String parentName, MutablePropertyValues pvs)

Create a new ChildBeanDefinition for the given parent.

Parameters
parentName:String

the name of the parent bean

pvs:MutablePropertyValues

the additional property values of the child

ChildBeanDefinitionback to summary
public ChildBeanDefinition(String parentName, ConstructorArgumentValues cargs, MutablePropertyValues pvs)

Create a new ChildBeanDefinition for the given parent.

Parameters
parentName:String

the name of the parent bean

cargs:ConstructorArgumentValues

the constructor argument values to apply

pvs:MutablePropertyValues

the additional property values of the child

ChildBeanDefinitionback to summary
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:String

the name of the parent bean

beanClass:Class<?>

the class of the bean to instantiate

cargs:ConstructorArgumentValues

the constructor argument values to apply

pvs:MutablePropertyValues

the property values to apply

ChildBeanDefinitionback to summary
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:String

the name of the parent bean

beanClassName:String

the name of the class to instantiate

cargs:ConstructorArgumentValues

the constructor argument values to apply

pvs:MutablePropertyValues

the property values to apply

ChildBeanDefinitionback to summary
public ChildBeanDefinition(ChildBeanDefinition original)

Create a new ChildBeanDefinition as deep copy of the given bean definition.

Parameters
original:ChildBeanDefinition

the original bean definition to copy from

Method Detail

cloneBeanDefinitionback to summary
public AbstractBeanDefinition cloneBeanDefinition()

Implements abstract org.springframework.beans.factory.support.AbstractBeanDefinition.cloneBeanDefinition.

Doc from org.springframework.beans.factory.support.AbstractBeanDefinition.cloneBeanDefinition.

Clone this bean definition. To be implemented by concrete subclasses.

Returns:AbstractBeanDefinition

the cloned bean definition object

Annotations
@Override
equalsback to summary
public boolean equals(Object other)

Overrides org.springframework.beans.factory.support.AbstractBeanDefinition.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
other:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getParentNameback to summary
public String getParentName()

Implements org.springframework.beans.factory.config.BeanDefinition.getParentName.

Doc from org.springframework.beans.factory.config.BeanDefinition.getParentName.

Return the name of the parent definition of this bean definition, if any.

Annotations
@Override
@Nullable
hashCodeback to summary
public int hashCode()

Overrides org.springframework.beans.factory.support.AbstractBeanDefinition.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

Annotations
@Override
setParentNameback to summary
public void setParentName(String parentName)

Implements org.springframework.beans.factory.config.BeanDefinition.setParentName.

Doc from org.springframework.beans.factory.config.BeanDefinition.setParentName.

Set the name of the parent definition of this bean definition, if any.

Annotations
@Override
toStringback to summary
public String toString()

Overrides org.springframework.beans.factory.support.AbstractBeanDefinition.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
validateback to summary
public void validate() throws BeanDefinitionValidationException

Overrides org.springframework.beans.factory.support.AbstractBeanDefinition.validate.

Doc from org.springframework.beans.factory.support.AbstractBeanDefinition.validate.

Validate this bean definition.

Annotations
@Override
Exceptions
BeanDefinitionValidationException:
in case of validation failure