GenericBeanDefinitions from XML declarations.
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. This is particularly applicable for
programmatic definitions derived from factory methods (e.g. @Bean methods)
and instance suppliers (e.g. lambda expressions) which come with extra type metadata
(see setTargetType(ResolvableType)/setResolvedFactoryMethod(Method)).
Note
The preferred choice for bean definitions derived from declarative sources
(e.g. XML definitions) is the flexible GenericBeanDefinition variant.
GenericBeanDefinition comes with the advantage that it allows for dynamically
defining parent dependencies, not 'hard-coding' the role as a root bean definition,
even supporting parent relationship changes in the bean post-processor phase.
GenericBeanDefinition, ChildBeanDefinition
| Modifier and Type | Field and Description |
|---|---|
| pack-priv boolean | |
| pack-priv volatile Boolean | beforeInstantiationResolved
Package-visible field that indicates a before-instantiation post-processor having kicked in. |
| pack-priv final Object | constructorArgumentLock
Common lock for the four constructor fields below. |
| pack-priv boolean | constructorArgumentsResolved
Package-visible field that marks the constructor arguments as resolved. |
| private BeanDefinitionHolder | |
| private Set | |
| private Set | |
| private Set | |
| pack-priv volatile ResolvableType | factoryMethodReturnType
Package-visible field for caching the return type of a generically typed factory method. |
| pack-priv volatile Method | factoryMethodToIntrospect
Package-visible field for caching a unique factory method candidate for introspection. |
| pack-priv volatile Boolean | isFactoryBean
Package-visible field for caching if the bean is a factory bean. |
| pack-priv boolean | |
| pack-priv boolean | postProcessed
Package-visible field that indicates MergedBeanDefinitionPostProcessor having been applied. |
| pack-priv final Object | postProcessingLock
Common lock for the two post-processing fields below. |
| pack-priv Object[] | preparedConstructorArguments
Package-visible field for caching partly prepared constructor arguments. |
| private AnnotatedElement | |
| pack-priv Object[] | resolvedConstructorArguments
Package-visible field for caching fully resolved constructor arguments. |
| pack-priv Executable | resolvedConstructorOrFactoryMethod
Package-visible field for caching the resolved constructor or factory method. |
| pack-priv volatile String | resolvedDestroyMethodName
Package-visible field for caching a resolved destroy method name (also for inferred). |
| pack-priv volatile Class | resolvedTargetType
Package-visible field for caching the determined Class of a given bean definition. |
| pack-priv volatile boolean | stale
Determines if the definition needs to be re-merged. |
| pack-priv volatile ResolvableType |
| Access | Constructor and Description |
|---|---|
| public | RootBeanDefinition()
Create a new RootBeanDefinition, to be configured through its bean properties and configuration methods. |
| public | RootBeanDefinition(Class<?>
the class of the bean to instantiate beanClass)Create a new RootBeanDefinition for a singleton. |
| public | RootBeanDefinition(ResolvableType
the type of bean to instantiate beanType)
Deprecated
since 6.0.11. as of 6.0.11, in favor of an extra
setTargetType(ResolvableType) call
Create a new RootBeanDefinition for a singleton. |
| public <T> | RootBeanDefinition(Class<T>
the class of the bean to instantiate beanClass, Supplier<T> the supplier to construct a bean instance,
as an alternative to a declaratively specified factory method instanceSupplier)Create a new RootBeanDefinition for a singleton bean, constructing each instance through calling the given supplier (possibly a lambda or method reference). |
| public <T> | RootBeanDefinition(Class<T>
the class of the bean to instantiate beanClass, String the name of the corresponding scope scope, Supplier<T> the supplier to construct a bean instance,
as an alternative to a declaratively specified factory method instanceSupplier)Create a new RootBeanDefinition for a scoped bean, constructing each instance through calling the given supplier (possibly a lambda or method reference). |
| public | RootBeanDefinition(Class<?>
the class of the bean to instantiate beanClass, int by name or type, using the constants in this interface autowireMode, boolean whether to perform a dependency check for objects
(not applicable to autowiring a constructor, thus ignored there) dependencyCheck)Create a new RootBeanDefinition for a singleton, using the given autowire mode. |
| public | RootBeanDefinition(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 RootBeanDefinition for a singleton, providing constructor arguments and property values. |
| public | RootBeanDefinition(String
the name of the class to instantiate beanClassName)Create a new RootBeanDefinition for a singleton, providing constructor arguments and property values. |
| public | RootBeanDefinition(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 RootBeanDefinition for a singleton, providing constructor arguments and property values. |
| public | RootBeanDefinition(RootBeanDefinition
the original bean definition to copy from original)Create a new RootBeanDefinition as deep copy of the given bean definition. |
| pack-priv | RootBeanDefinition(BeanDefinition
the original bean definition to copy from original)Create a new RootBeanDefinition as deep copy of the given bean definition. |
| Modifier and Type | Method and Description |
|---|---|
| public RootBeanDefinition | cloneBeanDefinition()
Implements abstract org. Clone this bean definition. |
| public boolean | equals(Object
the reference object with which to compare. other)Overrides org. Indicates whether some other object is "equal to" this one. |
| public BeanDefinitionHolder | getDecoratedDefinition()
Return the target definition that is being decorated by this bean definition, if any. |
| public Set | getExternallyManagedConfigMembers()
Get all externally managed configuration methods and fields (as an immutable Set). |
| public Set | getExternallyManagedDestroyMethods()
Get all externally managed destruction methods (as an immutable Set). |
| public Set | getExternallyManagedInitMethods()
Get all externally managed initialization methods (as an immutable Set). |
| public String | getParentName()
Implements org. Return the name of the parent definition of this bean definition, if any. |
| public Constructor | Returns: one or more preferred constructors, ornull if none
(in which case the regular no-arg default constructor will be called)Determine preferred constructors to use for default construction, if any. |
| public AnnotatedElement | |
| public ResolvableType | getResolvableType()
Overrides org. Implements org. Return a |
| public Method | Returns: the factory method, ornull if not found or not resolved yetReturn the resolved factory method as a Java Method object, if available. |
| public Class | getTargetType()
Return the target type of this bean definition, if known (either specified in advance or resolved on first instantiation). |
| pack-priv boolean | hasAnyExternallyManagedDestroyMethod(String destroyMethod)
Determine if the given method name indicates an externally managed destruction method, regardless of method visibility. |
| pack-priv boolean | hasAnyExternallyManagedInitMethod(String initMethod)
Determine if the given method name indicates an externally managed initialization method, regardless of method visibility. |
| private static boolean | |
| public boolean | isExternallyManagedConfigMember(Member configMember)
Determine if the given method or field is an externally managed configuration member. |
| public boolean | isExternallyManagedDestroyMethod(String destroyMethod)
Determine if the given method name indicates an externally managed destruction method. |
| public boolean | isExternallyManagedInitMethod(String initMethod)
Determine if the given method name indicates an externally managed initialization method. |
| public boolean | |
| public void | markAsPostProcessed()
Mark this bean definition as post-processed,
i.e. processed by |
| public void | registerExternallyManagedConfigMember(Member configMember)
Register an externally managed configuration method or field. |
| public void | registerExternallyManagedDestroyMethod(String destroyMethod)
Register an externally managed configuration destruction method —
for example, a method annotated with JSR-250's
|
| public void | registerExternallyManagedInitMethod(String initMethod)
Register an externally managed configuration initialization method —
for example, a method annotated with JSR-250's |
| public void | |
| public void | setDecoratedDefinition(BeanDefinitionHolder decoratedDefinition)
Register a target definition that is being decorated by this bean definition. |
| public void | setInstanceSupplier(Supplier<?> supplier)
Overrides org. Specify a callback for creating an instance of the bean, as an alternative to a declaratively specified factory method. |
| public void | setNonUniqueFactoryMethodName(String name)
Specify a factory method name that refers to an overloaded method. |
| public void | setParentName(String parentName)
Implements org. Set the name of the parent definition of this bean definition, if any. |
| public void | setQualifiedElement(AnnotatedElement qualifiedElement)
Specify the |
| public void | setResolvedFactoryMethod(Method
the resolved factory method, or method)null to reset itSet a resolved Java Method for the factory method on this bean definition. |
| public void | setTargetType(ResolvableType targetType)
Specify a generics-containing target type of this bean definition, if known in advance. |
| public void | setTargetType(Class<?> targetType)
Specify the target type of this bean definition, if known in advance. |
| public void | setUniqueFactoryMethodName(String name)
Specify a factory method name that refers to a non-overloaded method. |
| public String | toString()
Overrides org. Returns a string representation of the object. |
| allowCaching | back to summary |
|---|---|
| pack-priv boolean allowCaching | |
| beforeInstantiationResolved | back to summary |
|---|---|
| pack-priv volatile Boolean beforeInstantiationResolved Package-visible field that indicates a before-instantiation post-processor having kicked in. | |
| constructorArgumentLock | back to summary |
|---|---|
| pack-priv final Object constructorArgumentLock Common lock for the four constructor fields below. | |
| constructorArgumentsResolved | back to summary |
|---|---|
| pack-priv boolean constructorArgumentsResolved Package-visible field that marks the constructor arguments as resolved. | |
| decoratedDefinition | back to summary |
|---|---|
| private BeanDefinitionHolder decoratedDefinition
| |
| externallyManagedConfigMembers | back to summary |
|---|---|
| private Set<Member> externallyManagedConfigMembers
| |
| externallyManagedDestroyMethods | back to summary |
|---|---|
| private Set<String> externallyManagedDestroyMethods
| |
| externallyManagedInitMethods | back to summary |
|---|---|
| private Set<String> externallyManagedInitMethods
| |
| factoryMethodReturnType | back to summary |
|---|---|
| pack-priv volatile ResolvableType factoryMethodReturnType Package-visible field for caching the return type of a generically typed factory method. | |
| factoryMethodToIntrospect | back to summary |
|---|---|
| pack-priv volatile Method factoryMethodToIntrospect Package-visible field for caching a unique factory method candidate for introspection. | |
| isFactoryBean | back to summary |
|---|---|
| pack-priv volatile Boolean isFactoryBean Package-visible field for caching if the bean is a factory bean. | |
| isFactoryMethodUnique | back to summary |
|---|---|
| pack-priv boolean isFactoryMethodUnique | |
| postProcessed | back to summary |
|---|---|
| pack-priv boolean postProcessed Package-visible field that indicates MergedBeanDefinitionPostProcessor having been applied. | |
| postProcessingLock | back to summary |
|---|---|
| pack-priv final Object postProcessingLock Common lock for the two post-processing fields below. | |
| preparedConstructorArguments | back to summary |
|---|---|
| pack-priv Object[] preparedConstructorArguments Package-visible field for caching partly prepared constructor arguments. | |
| qualifiedElement | back to summary |
|---|---|
| private AnnotatedElement qualifiedElement
| |
| resolvedConstructorArguments | back to summary |
|---|---|
| pack-priv Object[] resolvedConstructorArguments Package-visible field for caching fully resolved constructor arguments. | |
| resolvedConstructorOrFactoryMethod | back to summary |
|---|---|
| pack-priv Executable resolvedConstructorOrFactoryMethod Package-visible field for caching the resolved constructor or factory method. | |
| resolvedDestroyMethodName | back to summary |
|---|---|
| pack-priv volatile String resolvedDestroyMethodName Package-visible field for caching a resolved destroy method name (also for inferred). | |
| resolvedTargetType | back to summary |
|---|---|
| pack-priv volatile Class<?> resolvedTargetType Package-visible field for caching the determined Class of a given bean definition. | |
| stale | back to summary |
|---|---|
| pack-priv volatile boolean stale Determines if the definition needs to be re-merged. | |
| targetType | back to summary |
|---|---|
| pack-priv volatile ResolvableType targetType
| |
| RootBeanDefinition | back to summary |
|---|---|
| public RootBeanDefinition() Create a new RootBeanDefinition, to be configured through its bean properties and configuration methods. | |
| RootBeanDefinition | back to summary |
|---|---|
| public RootBeanDefinition(Class<?> beanClass) Create a new RootBeanDefinition for a singleton.
| |
| RootBeanDefinition | back to summary |
|---|---|
| public RootBeanDefinition(ResolvableType beanType)
Create a new RootBeanDefinition for a singleton.
| |
| RootBeanDefinition | back to summary |
|---|---|
| public <T> 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 | back to summary |
|---|---|
| public <T> 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 | back to summary |
|---|---|
| public RootBeanDefinition(Class<?> beanClass, int autowireMode, boolean dependencyCheck) Create a new RootBeanDefinition for a singleton, using the given autowire mode.
| |
| RootBeanDefinition | back to summary |
|---|---|
| public RootBeanDefinition(Class<?> beanClass, ConstructorArgumentValues cargs, MutablePropertyValues pvs) Create a new RootBeanDefinition for a singleton, providing constructor arguments and property values.
| |
| RootBeanDefinition | back to summary |
|---|---|
| public RootBeanDefinition(String beanClassName) Create a new RootBeanDefinition for a singleton, providing constructor arguments and property values. Takes a bean class name to avoid eager loading of the bean class.
| |
| RootBeanDefinition | back to summary |
|---|---|
| public RootBeanDefinition(String beanClassName, ConstructorArgumentValues cargs, MutablePropertyValues pvs) Create a new RootBeanDefinition for a singleton, providing constructor arguments and property values. Takes a bean class name to avoid eager loading of the bean class.
| |
| RootBeanDefinition | back to summary |
|---|---|
| public RootBeanDefinition(RootBeanDefinition original) Create a new RootBeanDefinition as deep copy of the given bean definition.
| |
| RootBeanDefinition | back to summary |
|---|---|
| pack-priv RootBeanDefinition(BeanDefinition original) Create a new RootBeanDefinition as deep copy of the given bean definition.
| |
| cloneBeanDefinition | back to summary |
|---|---|
| public RootBeanDefinition cloneBeanDefinition() Implements abstract org. Doc from org. Clone this bean definition. To be implemented by concrete subclasses.
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object other) Overrides org. Doc from java. Indicates whether some other object is "equal to" this one.
The
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. | |
| getDecoratedDefinition | back to summary |
|---|---|
| public BeanDefinitionHolder getDecoratedDefinition() Return the target definition that is being decorated by this bean definition, if any.
| |
| getExternallyManagedConfigMembers | back to summary |
|---|---|
| public Set Get all externally managed configuration methods and fields (as an immutable Set).
| |
| getExternallyManagedDestroyMethods | back to summary |
|---|---|
| public Set Get all externally managed destruction methods (as an immutable Set). See
| |
| getExternallyManagedInitMethods | back to summary |
|---|---|
| public Set Get all externally managed initialization methods (as an immutable Set). See
| |
| getParentName | back to summary |
|---|---|
| public String getParentName() Implements org. Doc from org. Return the name of the parent definition of this bean definition, if any.
| |
| getPreferredConstructors | back to summary |
|---|---|
| public Constructor Determine preferred constructors to use for default construction, if any. Constructor arguments will be autowired if necessary. As of 6.1, the default implementation of this method takes the
| |
| getQualifiedElement | back to summary |
|---|---|
| public AnnotatedElement getQualifiedElement() Return the
| |
| getResolvableType | back to summary |
|---|---|
| public ResolvableType getResolvableType() Overrides org. Implements org. Return a
| |
| getResolvedFactoryMethod | back to summary |
|---|---|
| public Method getResolvedFactoryMethod() Return the resolved factory method as a Java Method object, if available. | |
| getTargetType | back to summary |
|---|---|
| public Class Return the target type of this bean definition, if known (either specified in advance or resolved on first instantiation).
| |
| hasAnyExternallyManagedDestroyMethod | back to summary |
|---|---|
| pack-priv boolean hasAnyExternallyManagedDestroyMethod(String destroyMethod) Determine if the given method name indicates an externally managed destruction method, regardless of method visibility. In contrast to
| |
| hasAnyExternallyManagedInitMethod | back to summary |
|---|---|
| pack-priv boolean hasAnyExternallyManagedInitMethod(String initMethod) Determine if the given method name indicates an externally managed initialization method, regardless of method visibility. In contrast to
| |
| hasAnyExternallyManagedMethod | back to summary |
|---|---|
| private static boolean hasAnyExternallyManagedMethod(Set<String> candidates, String methodName) | |
| isExternallyManagedConfigMember | back to summary |
|---|---|
| public boolean isExternallyManagedConfigMember(Member configMember) Determine if the given method or field is an externally managed configuration member. | |
| isExternallyManagedDestroyMethod | back to summary |
|---|---|
| public boolean isExternallyManagedDestroyMethod(String destroyMethod) Determine if the given method name indicates an externally managed destruction method. See | |
| isExternallyManagedInitMethod | back to summary |
|---|---|
| public boolean isExternallyManagedInitMethod(String initMethod) Determine if the given method name indicates an externally managed initialization method. See | |
| isFactoryMethod | back to summary |
|---|---|
| public boolean isFactoryMethod(Method candidate) Check whether the given candidate qualifies as a factory method. | |
| markAsPostProcessed | back to summary |
|---|---|
| public void markAsPostProcessed() Mark this bean definition as post-processed,
i.e. processed by
| |
| registerExternallyManagedConfigMember | back to summary |
|---|---|
| public void registerExternallyManagedConfigMember(Member configMember) Register an externally managed configuration method or field. | |
| registerExternallyManagedDestroyMethod | back to summary |
|---|---|
| public void registerExternallyManagedDestroyMethod(String destroyMethod) Register an externally managed configuration destruction method —
for example, a method annotated with JSR-250's
The supplied | |
| registerExternallyManagedInitMethod | back to summary |
|---|---|
| public void registerExternallyManagedInitMethod(String initMethod) Register an externally managed configuration initialization method —
for example, a method annotated with JSR-250's The supplied | |
| resolveDestroyMethodIfNecessary | back to summary |
|---|---|
| public void resolveDestroyMethodIfNecessary() Resolve the inferred destroy method if necessary.
| |
| setDecoratedDefinition | back to summary |
|---|---|
| public void setDecoratedDefinition(BeanDefinitionHolder decoratedDefinition) Register a target definition that is being decorated by this bean definition. | |
| setInstanceSupplier | back to summary |
|---|---|
| public void setInstanceSupplier(Supplier<?> supplier) Overrides org. Doc from org. Specify a callback for creating an instance of the bean, as an alternative to a declaratively specified factory method. If such a callback is set, it will override any other constructor or factory method metadata. However, bean property population and potential annotation-driven injection will still apply as usual.
| |
| setNonUniqueFactoryMethodName | back to summary |
|---|---|
| public void setNonUniqueFactoryMethodName(String name) Specify a factory method name that refers to an overloaded method.
| |
| setParentName | back to summary |
|---|---|
| public void setParentName(String parentName) Implements org. Doc from org. Set the name of the parent definition of this bean definition, if any.
| |
| setQualifiedElement | back to summary |
|---|---|
| public void setQualifiedElement(AnnotatedElement qualifiedElement) Specify the
| |
| setResolvedFactoryMethod | back to summary |
|---|---|
| public void setResolvedFactoryMethod(Method method) Set a resolved Java Method for the factory method on this bean definition.
| |
| setTargetType | back to summary |
|---|---|
| public void setTargetType(ResolvableType targetType) Specify a generics-containing target type of this bean definition, if known in advance.
| |
| setTargetType | back to summary |
|---|---|
| public void setTargetType(Class<?> targetType) Specify the target type of this bean definition, if known in advance.
| |
| setUniqueFactoryMethodName | back to summary |
|---|---|
| public void setUniqueFactoryMethodName(String name) Specify a factory method name that refers to a non-overloaded method. | |
| toString | back to summary |
|---|---|
| public String toString() Overrides org. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non- | |