Class BeanDefinitionBuilder
java.lang.Object
org.springframework.beans.factory.support.BeanDefinitionBuilder
Programmatic means of constructing
 
BeanDefinitions
 using the builder pattern. Intended primarily for use when implementing Spring 2.0
 NamespaceHandlers.- Since:
- 2.0
- Author:
- Rod Johnson, Rob Harrop, Juergen Hoeller, Yanming Zhou
- 
Method SummaryModifier and TypeMethodDescriptionaddAutowiredProperty(String name) Add an autowired marker for the specified property on the specified bean.addConstructorArgReference(String beanName) Add a reference to a named bean as a constructor arg.addConstructorArgValue(Object value) Add an indexed constructor arg value.addDependsOn(String beanName) Append the specified bean name to the list of beans that this definition depends on.addPropertyReference(String name, String beanName) Add a reference to the specified bean name under the property specified.addPropertyValue(String name, Object value) Add the supplied property value under the given property name.applyCustomizers(BeanDefinitionCustomizer... customizers) Apply the given customizers to the underlying bean definition.static BeanDefinitionBuilderchildBeanDefinition(String parentName) Create a newBeanDefinitionBuilderused to construct aChildBeanDefinition.static BeanDefinitionBuilderCreate a newBeanDefinitionBuilderused to construct aGenericBeanDefinition.static BeanDefinitionBuildergenericBeanDefinition(Class<?> beanClass) Create a newBeanDefinitionBuilderused to construct aGenericBeanDefinition.static <T> BeanDefinitionBuildergenericBeanDefinition(Class<T> beanClass, Supplier<T> instanceSupplier) Create a newBeanDefinitionBuilderused to construct aGenericBeanDefinition.static BeanDefinitionBuildergenericBeanDefinition(String beanClassName) Create a newBeanDefinitionBuilderused to construct aGenericBeanDefinition.Validate and return the created BeanDefinition object.Return the current BeanDefinition object in its raw (unvalidated) form.static BeanDefinitionBuilderrootBeanDefinition(Class<?> beanClass) Create a newBeanDefinitionBuilderused to construct aRootBeanDefinition.static BeanDefinitionBuilderrootBeanDefinition(Class<?> beanClass, String factoryMethodName) Create a newBeanDefinitionBuilderused to construct aRootBeanDefinition.static <T> BeanDefinitionBuilderrootBeanDefinition(Class<T> beanClass, Supplier<T> instanceSupplier) Create a newBeanDefinitionBuilderused to construct aRootBeanDefinition.static BeanDefinitionBuilderrootBeanDefinition(String beanClassName) Create a newBeanDefinitionBuilderused to construct aRootBeanDefinition.static BeanDefinitionBuilderrootBeanDefinition(String beanClassName, String factoryMethodName) Create a newBeanDefinitionBuilderused to construct aRootBeanDefinition.static <T> BeanDefinitionBuilderrootBeanDefinition(ResolvableType beanType, Supplier<T> instanceSupplier) Create a newBeanDefinitionBuilderused to construct aRootBeanDefinition.setAbstract(boolean flag) Set whether this definition is abstract.setAutowireMode(int autowireMode) Set the autowire mode for this definition.setDependencyCheck(int dependencyCheck) Set the dependency check mode for this definition.setDestroyMethodName(String methodName) Set the destroy method for this definition.setFactoryMethod(String factoryMethod) Set the name of a static factory method to use for this definition, to be called on this bean's class.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.setFallback(boolean fallback) Set whether this bean is a fallback autowire candidate.setInitMethodName(String methodName) Set the init method for this definition.setLazyInit(boolean lazy) Set whether beans for this definition should be lazily initialized or not.setParentName(String parentName) Set the name of the parent definition of this bean definition.setPrimary(boolean primary) Set whether this bean is a primary autowire candidate.setRole(int role) Set the role of this definition.Set the scope of this definition.setSynthetic(boolean synthetic) Set whether this bean is 'synthetic', that is, not defined by the application itself.
- 
Method Details- 
genericBeanDefinitionCreate a newBeanDefinitionBuilderused to construct aGenericBeanDefinition.
- 
genericBeanDefinitionCreate a newBeanDefinitionBuilderused to construct aGenericBeanDefinition.- Parameters:
- beanClassName- the class name for the bean that the definition is being created for
 
- 
genericBeanDefinitionCreate a newBeanDefinitionBuilderused to construct aGenericBeanDefinition.- Parameters:
- beanClass- the- Classof the bean that the definition is being created for
 
- 
genericBeanDefinitionpublic static <T> BeanDefinitionBuilder genericBeanDefinition(Class<T> beanClass, Supplier<T> instanceSupplier) Create a newBeanDefinitionBuilderused to construct aGenericBeanDefinition.- Parameters:
- beanClass- the- Classof the bean that the definition is being created for
- instanceSupplier- a callback for creating an instance of the bean
- Since:
- 5.0
 
- 
rootBeanDefinitionCreate a newBeanDefinitionBuilderused to construct aRootBeanDefinition.- Parameters:
- beanClassName- the class name for the bean that the definition is being created for
 
- 
rootBeanDefinitionpublic static BeanDefinitionBuilder rootBeanDefinition(String beanClassName, @Nullable String factoryMethodName) Create a newBeanDefinitionBuilderused to construct aRootBeanDefinition.- Parameters:
- beanClassName- the class name for the bean that the definition is being created for
- factoryMethodName- the name of the method to use to construct the bean instance
 
- 
rootBeanDefinitionCreate a newBeanDefinitionBuilderused to construct aRootBeanDefinition.- Parameters:
- beanClass- the- Classof the bean that the definition is being created for
 
- 
rootBeanDefinitionpublic static BeanDefinitionBuilder rootBeanDefinition(Class<?> beanClass, @Nullable String factoryMethodName) Create a newBeanDefinitionBuilderused to construct aRootBeanDefinition.- Parameters:
- beanClass- the- Classof the bean that the definition is being created for
- factoryMethodName- the name of the method to use to construct the bean instance
 
- 
rootBeanDefinitionpublic static <T> BeanDefinitionBuilder rootBeanDefinition(ResolvableType beanType, Supplier<T> instanceSupplier) Create a newBeanDefinitionBuilderused to construct aRootBeanDefinition.- Parameters:
- beanType- the- typeof the bean that the definition is being created for
- instanceSupplier- a callback for creating an instance of the bean
- Since:
- 5.3.9
 
- 
rootBeanDefinitionpublic static <T> BeanDefinitionBuilder rootBeanDefinition(Class<T> beanClass, Supplier<T> instanceSupplier) Create a newBeanDefinitionBuilderused to construct aRootBeanDefinition.- Parameters:
- beanClass- the- Classof the bean that the definition is being created for
- instanceSupplier- a callback for creating an instance of the bean
- Since:
- 5.3.9
- See Also:
 
- 
childBeanDefinitionCreate a newBeanDefinitionBuilderused to construct aChildBeanDefinition.- Parameters:
- parentName- the name of the parent bean
 
- 
getRawBeanDefinitionReturn the current BeanDefinition object in its raw (unvalidated) form.- See Also:
 
- 
getBeanDefinitionValidate and return the created BeanDefinition object.
- 
setParentNameSet the name of the parent definition of this bean definition.
- 
setFactoryMethodSet the name of a static factory method to use for this definition, to be called on this bean's class.
- 
setFactoryMethodOnBeanSet 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.- Parameters:
- factoryMethod- the name of the factory method
- factoryBean- the name of the bean to call the specified factory method on
- Since:
- 4.3.6
 
- 
addConstructorArgValueAdd an indexed constructor arg value. The current index is tracked internally and all additions are at the present point.
- 
addConstructorArgReferenceAdd a reference to a named bean as a constructor arg.- See Also:
 
- 
addPropertyValueAdd the supplied property value under the given property name.
- 
addPropertyReferenceAdd a reference to the specified bean name under the property specified.- Parameters:
- name- the name of the property to add the reference to
- beanName- the name of the bean being referenced
 
- 
addAutowiredPropertyAdd an autowired marker for the specified property on the specified bean.- Parameters:
- name- the name of the property to mark as autowired
- Since:
- 5.2
- See Also:
 
- 
setInitMethodNameSet the init method for this definition.
- 
setDestroyMethodNameSet the destroy method for this definition.
- 
setScopeSet the scope of this definition.
- 
setAbstractSet whether this definition is abstract.
- 
setLazyInitSet whether beans for this definition should be lazily initialized or not.
- 
setAutowireModeSet the autowire mode for this definition.
- 
setDependencyCheckSet the dependency check mode for this definition.
- 
addDependsOnAppend the specified bean name to the list of beans that this definition depends on.
- 
setPrimarySet whether this bean is a primary autowire candidate.- Since:
- 5.1.11
 
- 
setFallbackSet whether this bean is a fallback autowire candidate.- Since:
- 6.2
 
- 
setRoleSet the role of this definition.
- 
setSyntheticSet whether this bean is 'synthetic', that is, not defined by the application itself.- Since:
- 5.3.9
 
- 
applyCustomizersApply the given customizers to the underlying bean definition.- Since:
- 5.0
 
 
-