类 ChildBeanDefinition
- java.lang.Object
- org.springframework.core.AttributeAccessorSupport
- org.springframework.beans.BeanMetadataAttributeAccessor
- org.springframework.beans.factory.support.AbstractBeanDefinition
- org.springframework.beans.factory.support.ChildBeanDefinition
public class ChildBeanDefinition extends AbstractBeanDefinition
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 theGenericBeanDefinition.setParentName(java.lang.String)
method. This effectively supersedes the ChildBeanDefinition class for most use cases.- 作者:
- Rod Johnson, Juergen Hoeller
- 另请参阅:
GenericBeanDefinition
,RootBeanDefinition
, 序列化表格
字段概要
从类继承的字段 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, SCOPE_DEFAULT
从接口继承的字段 org.springframework.beans.factory.config.BeanDefinition
ROLE_APPLICATION, ROLE_INFRASTRUCTURE, ROLE_SUPPORT, SCOPE_PROTOTYPE, SCOPE_SINGLETON
构造器概要
构造器 构造器 说明 ChildBeanDefinition(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.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 AbstractBeanDefinition
cloneBeanDefinition()
Clone this bean definition.boolean
equals(Object other)
String
getParentName()
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.String
toString()
void
validate()
Validate this bean definition.从类继承的方法 org.springframework.beans.factory.support.AbstractBeanDefinition
addQualifier, applyDefaults, clone, copyQualifiersFrom, getAutowireMode, getBeanClass, getBeanClassName, getConstructorArgumentValues, getDependencyCheck, getDependsOn, getDescription, getDestroyMethodName, getFactoryBeanName, getFactoryMethodName, getInitMethodName, getInstanceSupplier, getLazyInit, getMethodOverrides, getOriginatingBeanDefinition, getPropertyValues, getQualifier, getQualifiers, getResolvableType, 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
从类继承的方法 org.springframework.beans.BeanMetadataAttributeAccessor
addMetadataAttribute, getAttribute, getMetadataAttribute, getSource, removeAttribute, setAttribute, setSource
从类继承的方法 org.springframework.core.AttributeAccessorSupport
attributeNames, copyAttributesFrom, hasAttribute
从接口继承的方法 org.springframework.core.AttributeAccessor
attributeNames, getAttribute, hasAttribute, removeAttribute, setAttribute
从接口继承的方法 org.springframework.beans.BeanMetadataElement
getSource
构造器详细资料
ChildBeanDefinition
public ChildBeanDefinition(String parentName)
Create a new ChildBeanDefinition for the given parent, to be configured through its bean properties and configuration methods.- 参数:
parentName
- the name of the parent bean- 另请参阅:
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
public ChildBeanDefinition(String parentName, MutablePropertyValues pvs)
Create a new ChildBeanDefinition for the given parent.- 参数:
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.- 参数:
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.- 参数:
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.- 参数:
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
public ChildBeanDefinition(ChildBeanDefinition original)
Create a new ChildBeanDefinition as deep copy of the given bean definition.- 参数:
original
- the original bean definition to copy from
方法详细资料
setParentName
public void setParentName(@Nullable String parentName)
从接口复制的说明:BeanDefinition
Set the name of the parent definition of this bean definition, if any.
getParentName
@Nullable public String getParentName()
从接口复制的说明:BeanDefinition
Return the name of the parent definition of this bean definition, if any.
validate
public void validate() throws BeanDefinitionValidationException
从类复制的说明:AbstractBeanDefinition
Validate this bean definition.- 覆盖:
validate
在类中AbstractBeanDefinition
- 抛出:
BeanDefinitionValidationException
- in case of validation failure
cloneBeanDefinition
public AbstractBeanDefinition cloneBeanDefinition()
从类复制的说明:AbstractBeanDefinition
Clone this bean definition. To be implemented by concrete subclasses.- 指定者:
cloneBeanDefinition
在类中AbstractBeanDefinition
- 返回:
- the cloned bean definition object
equals
public boolean equals(@Nullable Object other)
- 覆盖:
equals
在类中AbstractBeanDefinition
hashCode
public int hashCode()
- 覆盖:
hashCode
在类中AbstractBeanDefinition
toString
public String toString()
- 覆盖:
toString
在类中AbstractBeanDefinition