public class RootBeanDefinition extends AbstractBeanDefinition
GenericBeanDefinitions.
A root bean definition is essentially the 'unified' bean definition view at runtime.
Root bean definitions may also be used for registering individual bean definitions
in the configuration phase. However, since Spring 2.5, the preferred way to register
bean definitions programmatically is the GenericBeanDefinition class.
GenericBeanDefinition has the advantage that it allows to dynamically define
parent dependencies, not 'hard-coding' the role as a root bean definition.
GenericBeanDefinition,
ChildBeanDefinition,
Serialized FormAUTOWIRE_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_DEFAULTROLE_APPLICATION, ROLE_INFRASTRUCTURE, ROLE_SUPPORT, SCOPE_PROTOTYPE, SCOPE_SINGLETON| Constructor and Description |
|---|
RootBeanDefinition()
Create a new RootBeanDefinition, to be configured through its bean
properties and configuration methods.
|
RootBeanDefinition(Class<?> beanClass)
Create a new RootBeanDefinition for a singleton.
|
RootBeanDefinition(Class<?> beanClass,
ConstructorArgumentValues cargs,
MutablePropertyValues pvs)
Create a new RootBeanDefinition for a singleton,
providing constructor arguments and property values.
|
RootBeanDefinition(Class<?> beanClass,
int autowireMode,
boolean dependencyCheck)
Create a new RootBeanDefinition for a singleton,
using the given autowire mode.
|
RootBeanDefinition(Class<T> beanClass,
String scope,
Supplier<T> instanceSupplier)
Create a new RootBeanDefinition for a scoped bean, constructing each instance
through calling the given supplier (possibly a lambda or method reference).
|
RootBeanDefinition(Class<T> beanClass,
Supplier<T> instanceSupplier)
Create a new RootBeanDefinition for a singleton bean, constructing each instance
through calling the given supplier (possibly a lambda or method reference).
|
RootBeanDefinition(RootBeanDefinition original)
Create a new RootBeanDefinition as deep copy of the given
bean definition.
|
RootBeanDefinition(String beanClassName)
Create a new RootBeanDefinition for a singleton,
providing constructor arguments and property values.
|
RootBeanDefinition(String beanClassName,
ConstructorArgumentValues cargs,
MutablePropertyValues pvs)
Create a new RootBeanDefinition for a singleton,
providing constructor arguments and property values.
|
| Modifier and Type | Method and Description |
|---|---|
RootBeanDefinition |
cloneBeanDefinition()
Clone this bean definition.
|
boolean |
equals(Object other) |
BeanDefinitionHolder |
getDecoratedDefinition()
Return the target definition that is being decorated by this bean definition, if any.
|
Set<Member> |
getExternallyManagedConfigMembers()
Get all externally managed configuration methods and fields (as an immutable Set).
|
Set<String> |
getExternallyManagedDestroyMethods()
Get all externally managed destruction methods (as an immutable Set).
|
Set<String> |
getExternallyManagedInitMethods()
Return all externally managed initialization methods (as an immutable Set).
|
String |
getParentName()
Return the name of the parent definition of this bean definition, if any.
|
Constructor<?>[] |
getPreferredConstructors()
Determine preferred constructors to use for default construction, if any.
|
AnnotatedElement |
getQualifiedElement()
Return the
AnnotatedElement defining qualifiers, if any. |
org.springframework.core.ResolvableType |
getResolvableType()
Return a
ResolvableType for this bean definition,
either from runtime-cached type information or from configuration-time
setTargetType(ResolvableType) or AbstractBeanDefinition.setBeanClass(Class),
also considering resolved factory method definitions. |
Method |
getResolvedFactoryMethod()
Return the resolved factory method as a Java Method object, if available.
|
Class<?> |
getTargetType()
Return the target type of this bean definition, if known
(either specified in advance or resolved on first instantiation).
|
boolean |
isExternallyManagedConfigMember(Member configMember)
Determine if the given method or field is an externally managed configuration member.
|
boolean |
isExternallyManagedDestroyMethod(String destroyMethod)
Determine if the given method name indicates an externally managed
destruction method.
|
boolean |
isExternallyManagedInitMethod(String initMethod)
Determine if the given method name indicates an externally managed
initialization method.
|
boolean |
isFactoryMethod(Method candidate)
Check whether the given candidate qualifies as a factory method.
|
void |
registerExternallyManagedConfigMember(Member configMember)
Register an externally managed configuration method or field.
|
void |
registerExternallyManagedDestroyMethod(String destroyMethod)
Register an externally managed configuration destruction method —
for example, a method annotated with JSR-250's
PreDestroy annotation. |
void |
registerExternallyManagedInitMethod(String initMethod)
Register an externally managed configuration initialization method —
for example, a method annotated with JSR-250's
PostConstruct annotation. |
void |
setDecoratedDefinition(BeanDefinitionHolder decoratedDefinition)
Register a target definition that is being decorated by this bean definition.
|
void |
setNonUniqueFactoryMethodName(String name)
Specify a factory method name that refers to an overloaded method.
|
void |
setParentName(String parentName)
Set the name of the parent definition of this bean definition, if any.
|
void |
setQualifiedElement(AnnotatedElement qualifiedElement)
Specify the
AnnotatedElement defining qualifiers,
to be used instead of the target class or factory method. |
void |
setResolvedFactoryMethod(Method method)
Set a resolved Java Method for the factory method on this bean definition.
|
void |
setTargetType(Class<?> targetType)
Specify the target type of this bean definition, if known in advance.
|
void |
setTargetType(org.springframework.core.ResolvableType targetType)
Specify a generics-containing target type of this bean definition, if known in advance.
|
void |
setUniqueFactoryMethodName(String name)
Specify a factory method name that refers to a non-overloaded method.
|
String |
toString() |
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, hashCode, 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, validateaddMetadataAttribute, getAttribute, getMetadataAttribute, getSource, removeAttribute, setAttribute, setSourceattributeNames, computeAttribute, copyAttributesFrom, hasAttributefinalize, getClass, notify, notifyAll, wait, wait, waitattributeNames, computeAttribute, getAttribute, hasAttribute, removeAttribute, setAttributegetSourcepublic RootBeanDefinition()
AbstractBeanDefinition.setBeanClass(java.lang.Class<?>),
AbstractBeanDefinition.setScope(java.lang.String),
AbstractBeanDefinition.setConstructorArgumentValues(org.springframework.beans.factory.config.ConstructorArgumentValues),
AbstractBeanDefinition.setPropertyValues(org.springframework.beans.MutablePropertyValues)public RootBeanDefinition(@Nullable
Class<?> beanClass)
beanClass - the class of the bean to instantiateAbstractBeanDefinition.setBeanClass(java.lang.Class<?>)public RootBeanDefinition(@Nullable
Class<T> beanClass,
@Nullable
Supplier<T> instanceSupplier)
beanClass - the class of the bean to instantiateinstanceSupplier - the supplier to construct a bean instance,
as an alternative to a declaratively specified factory methodAbstractBeanDefinition.setInstanceSupplier(java.util.function.Supplier<?>)public RootBeanDefinition(@Nullable
Class<T> beanClass,
String scope,
@Nullable
Supplier<T> instanceSupplier)
beanClass - the class of the bean to instantiatescope - the name of the corresponding scopeinstanceSupplier - the supplier to construct a bean instance,
as an alternative to a declaratively specified factory methodAbstractBeanDefinition.setInstanceSupplier(java.util.function.Supplier<?>)public RootBeanDefinition(@Nullable
Class<?> beanClass,
int autowireMode,
boolean dependencyCheck)
beanClass - the class of the bean to instantiateautowireMode - by name or type, using the constants in this interfacedependencyCheck - whether to perform a dependency check for objects
(not applicable to autowiring a constructor, thus ignored there)public RootBeanDefinition(@Nullable
Class<?> beanClass,
@Nullable
ConstructorArgumentValues cargs,
@Nullable
MutablePropertyValues pvs)
beanClass - the class of the bean to instantiatecargs - the constructor argument values to applypvs - the property values to applypublic RootBeanDefinition(String beanClassName)
Takes a bean class name to avoid eager loading of the bean class.
beanClassName - the name of the class to instantiatepublic RootBeanDefinition(String beanClassName, ConstructorArgumentValues cargs, MutablePropertyValues pvs)
Takes a bean class name to avoid eager loading of the bean class.
beanClassName - the name of the class to instantiatecargs - the constructor argument values to applypvs - the property values to applypublic RootBeanDefinition(RootBeanDefinition original)
original - the original bean definition to copy frompublic String getParentName()
BeanDefinitionpublic void setParentName(@Nullable
String parentName)
BeanDefinitionpublic void setDecoratedDefinition(@Nullable
BeanDefinitionHolder decoratedDefinition)
@Nullable public BeanDefinitionHolder getDecoratedDefinition()
public void setQualifiedElement(@Nullable
AnnotatedElement qualifiedElement)
AnnotatedElement defining qualifiers,
to be used instead of the target class or factory method.setTargetType(ResolvableType),
getResolvedFactoryMethod()@Nullable public AnnotatedElement getQualifiedElement()
AnnotatedElement defining qualifiers, if any.
Otherwise, the factory method and target class will be checked.public void setTargetType(org.springframework.core.ResolvableType targetType)
public void setTargetType(@Nullable
Class<?> targetType)
@Nullable public Class<?> getTargetType()
public org.springframework.core.ResolvableType getResolvableType()
ResolvableType for this bean definition,
either from runtime-cached type information or from configuration-time
setTargetType(ResolvableType) or AbstractBeanDefinition.setBeanClass(Class),
also considering resolved factory method definitions.getResolvableType in interface BeanDefinitiongetResolvableType in class AbstractBeanDefinitionResolvableType.NONE)setTargetType(ResolvableType),
AbstractBeanDefinition.setBeanClass(Class),
setResolvedFactoryMethod(Method)@Nullable public Constructor<?>[] getPreferredConstructors()
null if none
(in which case the regular no-arg default constructor will be called)public void setUniqueFactoryMethodName(String name)
public void setNonUniqueFactoryMethodName(String name)
public boolean isFactoryMethod(Method candidate)
public void setResolvedFactoryMethod(@Nullable
Method method)
method - the resolved factory method, or null to reset it@Nullable public Method getResolvedFactoryMethod()
null if not found or not resolved yetpublic void registerExternallyManagedConfigMember(Member configMember)
public boolean isExternallyManagedConfigMember(Member configMember)
public Set<Member> getExternallyManagedConfigMembers()
public void registerExternallyManagedInitMethod(String initMethod)
PostConstruct annotation.
The supplied initMethod may be the
simple method name for non-private methods or the
qualified method name for private methods. A qualified name is
necessary for private methods in order to disambiguate between
multiple private methods with the same name within a class hierarchy.
public boolean isExternallyManagedInitMethod(String initMethod)
See registerExternallyManagedInitMethod(java.lang.String) for details
regarding the format for the supplied initMethod.
public Set<String> getExternallyManagedInitMethods()
See registerExternallyManagedInitMethod(java.lang.String) for details
regarding the format for the initialization methods in the returned set.
public void registerExternallyManagedDestroyMethod(String destroyMethod)
PreDestroy annotation.
The supplied destroyMethod may be the
simple method name for non-private methods or the
qualified method name for private methods. A qualified name is
necessary for private methods in order to disambiguate between
multiple private methods with the same name within a class hierarchy.
public boolean isExternallyManagedDestroyMethod(String destroyMethod)
See registerExternallyManagedDestroyMethod(java.lang.String) for details
regarding the format for the supplied destroyMethod.
public Set<String> getExternallyManagedDestroyMethods()
See registerExternallyManagedDestroyMethod(java.lang.String) for details
regarding the format for the destruction methods in the returned set.
public RootBeanDefinition cloneBeanDefinition()
AbstractBeanDefinitioncloneBeanDefinition in class AbstractBeanDefinitionpublic boolean equals(@Nullable
Object other)
equals in class AbstractBeanDefinitionpublic String toString()
toString in class AbstractBeanDefinition