public final class BeanDefinitionBuilder extends Object
BeanDefinitions
using the builder pattern. Intended primarily for use when implementing Spring 2.0
NamespaceHandlers
.Modifier and Type | Method and Description |
---|---|
BeanDefinitionBuilder |
addAutowiredProperty(String name)
Add an autowired marker for the specified property on the specified bean.
|
BeanDefinitionBuilder |
addConstructorArgReference(String beanName)
Add a reference to a named bean as a constructor arg.
|
BeanDefinitionBuilder |
addConstructorArgValue(Object value)
Add an indexed constructor arg value.
|
BeanDefinitionBuilder |
addDependsOn(String beanName)
Append the specified bean name to the list of beans that this definition
depends on.
|
BeanDefinitionBuilder |
addPropertyReference(String name,
String beanName)
Add a reference to the specified bean name under the property specified.
|
BeanDefinitionBuilder |
addPropertyValue(String name,
Object value)
Add the supplied property value under the given property name.
|
BeanDefinitionBuilder |
applyCustomizers(BeanDefinitionCustomizer... customizers)
Apply the given customizers to the underlying bean definition.
|
static BeanDefinitionBuilder |
childBeanDefinition(String parentName)
Create a new
BeanDefinitionBuilder used to construct a ChildBeanDefinition . |
static BeanDefinitionBuilder |
genericBeanDefinition()
Create a new
BeanDefinitionBuilder used to construct a GenericBeanDefinition . |
static BeanDefinitionBuilder |
genericBeanDefinition(Class<?> beanClass)
Create a new
BeanDefinitionBuilder used to construct a GenericBeanDefinition . |
static <T> BeanDefinitionBuilder |
genericBeanDefinition(Class<T> beanClass,
Supplier<T> instanceSupplier)
Create a new
BeanDefinitionBuilder used to construct a GenericBeanDefinition . |
static BeanDefinitionBuilder |
genericBeanDefinition(String beanClassName)
Create a new
BeanDefinitionBuilder used to construct a GenericBeanDefinition . |
AbstractBeanDefinition |
getBeanDefinition()
Validate and return the created BeanDefinition object.
|
AbstractBeanDefinition |
getRawBeanDefinition()
Return the current BeanDefinition object in its raw (unvalidated) form.
|
static BeanDefinitionBuilder |
rootBeanDefinition(Class<?> beanClass)
Create a new
BeanDefinitionBuilder used to construct a RootBeanDefinition . |
static BeanDefinitionBuilder |
rootBeanDefinition(Class<?> beanClass,
String factoryMethodName)
Create a new
BeanDefinitionBuilder used to construct a RootBeanDefinition . |
static <T> BeanDefinitionBuilder |
rootBeanDefinition(Class<T> beanClass,
Supplier<T> instanceSupplier)
Create a new
BeanDefinitionBuilder used to construct a RootBeanDefinition . |
static <T> BeanDefinitionBuilder |
rootBeanDefinition(ResolvableType beanType,
Supplier<T> instanceSupplier)
Create a new
BeanDefinitionBuilder used to construct a RootBeanDefinition . |
static BeanDefinitionBuilder |
rootBeanDefinition(String beanClassName)
Create a new
BeanDefinitionBuilder used to construct a RootBeanDefinition . |
static BeanDefinitionBuilder |
rootBeanDefinition(String beanClassName,
String factoryMethodName)
Create a new
BeanDefinitionBuilder used to construct a RootBeanDefinition . |
BeanDefinitionBuilder |
setAbstract(boolean flag)
Set whether or not this definition is abstract.
|
BeanDefinitionBuilder |
setAutowireMode(int autowireMode)
Set the autowire mode for this definition.
|
BeanDefinitionBuilder |
setDependencyCheck(int dependencyCheck)
Set the dependency check mode for this definition.
|
BeanDefinitionBuilder |
setDestroyMethodName(String methodName)
Set the destroy method for this definition.
|
BeanDefinitionBuilder |
setFactoryMethod(String factoryMethod)
Set the name of a static factory method to use for this definition,
to be called on this bean's class.
|
BeanDefinitionBuilder |
setFactoryMethodOnBean(String factoryMethod,
String factoryBean)
Set the name of a non-static factory method to use for this definition,
including the bean name of the factory instance to call the method on.
|
BeanDefinitionBuilder |
setInitMethodName(String methodName)
Set the init method for this definition.
|
BeanDefinitionBuilder |
setLazyInit(boolean lazy)
Set whether beans for this definition should be lazily initialized or not.
|
BeanDefinitionBuilder |
setParentName(String parentName)
Set the name of the parent definition of this bean definition.
|
BeanDefinitionBuilder |
setPrimary(boolean primary)
Set whether this bean is a primary autowire candidate.
|
BeanDefinitionBuilder |
setRole(int role)
Set the role of this definition.
|
BeanDefinitionBuilder |
setScope(String scope)
Set the scope of this definition.
|
BeanDefinitionBuilder |
setSynthetic(boolean synthetic)
Set whether this bean is 'synthetic', that is, not defined by
the application itself.
|
public static BeanDefinitionBuilder genericBeanDefinition()
BeanDefinitionBuilder
used to construct a GenericBeanDefinition
.public static BeanDefinitionBuilder genericBeanDefinition(String beanClassName)
BeanDefinitionBuilder
used to construct a GenericBeanDefinition
.beanClassName
- the class name for the bean that the definition is being created forpublic static BeanDefinitionBuilder genericBeanDefinition(Class<?> beanClass)
BeanDefinitionBuilder
used to construct a GenericBeanDefinition
.beanClass
- the Class
of the bean that the definition is being created forpublic static <T> BeanDefinitionBuilder genericBeanDefinition(Class<T> beanClass, Supplier<T> instanceSupplier)
BeanDefinitionBuilder
used to construct a GenericBeanDefinition
.beanClass
- the Class
of the bean that the definition is being created forinstanceSupplier
- a callback for creating an instance of the beanpublic static BeanDefinitionBuilder rootBeanDefinition(String beanClassName)
BeanDefinitionBuilder
used to construct a RootBeanDefinition
.beanClassName
- the class name for the bean that the definition is being created forpublic static BeanDefinitionBuilder rootBeanDefinition(String beanClassName, @Nullable String factoryMethodName)
BeanDefinitionBuilder
used to construct a RootBeanDefinition
.beanClassName
- the class name for the bean that the definition is being created forfactoryMethodName
- the name of the method to use to construct the bean instancepublic static BeanDefinitionBuilder rootBeanDefinition(Class<?> beanClass)
BeanDefinitionBuilder
used to construct a RootBeanDefinition
.beanClass
- the Class
of the bean that the definition is being created forpublic static BeanDefinitionBuilder rootBeanDefinition(Class<?> beanClass, @Nullable String factoryMethodName)
BeanDefinitionBuilder
used to construct a RootBeanDefinition
.beanClass
- the Class
of the bean that the definition is being created forfactoryMethodName
- the name of the method to use to construct the bean instancepublic static <T> BeanDefinitionBuilder rootBeanDefinition(ResolvableType beanType, Supplier<T> instanceSupplier)
BeanDefinitionBuilder
used to construct a RootBeanDefinition
.beanType
- the type
of the bean that the definition is being created forinstanceSupplier
- a callback for creating an instance of the beanpublic static <T> BeanDefinitionBuilder rootBeanDefinition(Class<T> beanClass, Supplier<T> instanceSupplier)
BeanDefinitionBuilder
used to construct a RootBeanDefinition
.beanClass
- the Class
of the bean that the definition is being created forinstanceSupplier
- a callback for creating an instance of the beanrootBeanDefinition(ResolvableType, Supplier)
public static BeanDefinitionBuilder childBeanDefinition(String parentName)
BeanDefinitionBuilder
used to construct a ChildBeanDefinition
.parentName
- the name of the parent beanpublic AbstractBeanDefinition getRawBeanDefinition()
getBeanDefinition()
public AbstractBeanDefinition getBeanDefinition()
public BeanDefinitionBuilder setParentName(String parentName)
public BeanDefinitionBuilder setFactoryMethod(String factoryMethod)
public BeanDefinitionBuilder setFactoryMethodOnBean(String factoryMethod, String factoryBean)
factoryMethod
- the name of the factory methodfactoryBean
- the name of the bean to call the specified factory method onpublic BeanDefinitionBuilder addConstructorArgValue(@Nullable Object value)
public BeanDefinitionBuilder addConstructorArgReference(String beanName)
addConstructorArgValue(Object)
public BeanDefinitionBuilder addPropertyValue(String name, @Nullable Object value)
public BeanDefinitionBuilder addPropertyReference(String name, String beanName)
name
- the name of the property to add the reference tobeanName
- the name of the bean being referencedpublic BeanDefinitionBuilder addAutowiredProperty(String name)
name
- the name of the property to mark as autowiredAutowiredPropertyMarker
public BeanDefinitionBuilder setInitMethodName(@Nullable String methodName)
public BeanDefinitionBuilder setDestroyMethodName(@Nullable String methodName)
public BeanDefinitionBuilder setScope(@Nullable String scope)
public BeanDefinitionBuilder setAbstract(boolean flag)
public BeanDefinitionBuilder setLazyInit(boolean lazy)
public BeanDefinitionBuilder setAutowireMode(int autowireMode)
public BeanDefinitionBuilder setDependencyCheck(int dependencyCheck)
public BeanDefinitionBuilder addDependsOn(String beanName)
public BeanDefinitionBuilder setPrimary(boolean primary)
public BeanDefinitionBuilder setRole(int role)
public BeanDefinitionBuilder setSynthetic(boolean synthetic)
public BeanDefinitionBuilder applyCustomizers(BeanDefinitionCustomizer... customizers)