org.springframework.beans.factory.support
Class BeanDefinitionBuilder

java.lang.Object
  extended by org.springframework.beans.factory.support.BeanDefinitionBuilder

public class BeanDefinitionBuilder
extends java.lang.Object

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

Method Summary
 BeanDefinitionBuilder addConstructorArg(java.lang.Object value)
          Deprecated. since Spring 2.5, in favor of addConstructorArgValue(java.lang.Object)
 BeanDefinitionBuilder addConstructorArgReference(java.lang.String beanName)
          Add a reference to a named bean as a constructor arg.
 BeanDefinitionBuilder addConstructorArgValue(java.lang.Object value)
          Add an indexed constructor arg value.
 BeanDefinitionBuilder addDependsOn(java.lang.String beanName)
          Append the specified bean name to the list of beans that this definition depends on.
 BeanDefinitionBuilder addPropertyReference(java.lang.String name, java.lang.String beanName)
          Add a reference to the specified bean name under the property specified.
 BeanDefinitionBuilder addPropertyValue(java.lang.String name, java.lang.Object value)
          Add the supplied property value under the given name.
static BeanDefinitionBuilder childBeanDefinition(java.lang.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(java.lang.Class beanClass)
          Create a new BeanDefinitionBuilder used to construct a GenericBeanDefinition.
static BeanDefinitionBuilder genericBeanDefinition(java.lang.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(java.lang.Class beanClass)
          Create a new BeanDefinitionBuilder used to construct a RootBeanDefinition.
static BeanDefinitionBuilder rootBeanDefinition(java.lang.Class beanClass, java.lang.String factoryMethodName)
          Create a new BeanDefinitionBuilder used to construct a RootBeanDefinition.
static BeanDefinitionBuilder rootBeanDefinition(java.lang.String beanClassName)
          Create a new BeanDefinitionBuilder used to construct a RootBeanDefinition.
static BeanDefinitionBuilder rootBeanDefinition(java.lang.String beanClassName, java.lang.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 depency check mode for this definition.
 BeanDefinitionBuilder setDestroyMethodName(java.lang.String methodName)
          Set the destroy method for this definition.
 BeanDefinitionBuilder setFactoryBean(java.lang.String factoryBean, java.lang.String factoryMethod)
          Deprecated. since Spring 2.5, in favor of preparing this on the raw BeanDefinition object
 BeanDefinitionBuilder setFactoryMethod(java.lang.String factoryMethod)
          Set the name of the factory method to use for this definition.
 BeanDefinitionBuilder setInitMethodName(java.lang.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(java.lang.String parentName)
          Set the name of the parent definition of this bean definition.
 BeanDefinitionBuilder setResourceDescription(java.lang.String resourceDescription)
          Deprecated. since Spring 2.5, in favor of preparing this on the raw BeanDefinition object
 BeanDefinitionBuilder setRole(int role)
          Set the role of this definition.
 BeanDefinitionBuilder setScope(java.lang.String scope)
          Set the scope of this definition.
 BeanDefinitionBuilder setSingleton(boolean singleton)
          Deprecated. since Spring 2.5, in favor of setScope(java.lang.String)
 BeanDefinitionBuilder setSource(java.lang.Object source)
          Deprecated. since Spring 2.5, in favor of preparing this on the raw BeanDefinition object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

genericBeanDefinition

public static BeanDefinitionBuilder genericBeanDefinition()
Create a new BeanDefinitionBuilder used to construct a GenericBeanDefinition.


genericBeanDefinition

public static BeanDefinitionBuilder genericBeanDefinition(java.lang.Class beanClass)
Create a new BeanDefinitionBuilder used to construct a GenericBeanDefinition.

Parameters:
beanClass - the Class of the bean that the definition is being created for

genericBeanDefinition

public static BeanDefinitionBuilder genericBeanDefinition(java.lang.String beanClassName)
Create a new BeanDefinitionBuilder used to construct a GenericBeanDefinition.

Parameters:
beanClassName - the class name for the bean that the definition is being created for

rootBeanDefinition

public static BeanDefinitionBuilder rootBeanDefinition(java.lang.Class beanClass)
Create a new BeanDefinitionBuilder used to construct a RootBeanDefinition.

Parameters:
beanClass - the Class of the bean that the definition is being created for

rootBeanDefinition

public static BeanDefinitionBuilder rootBeanDefinition(java.lang.Class beanClass,
                                                       java.lang.String factoryMethodName)
Create a new BeanDefinitionBuilder used to construct a RootBeanDefinition.

Parameters:
beanClass - the Class of the bean that the definition is being created for
factoryMethodName - the name of the method to use to construct the bean instance

rootBeanDefinition

public static BeanDefinitionBuilder rootBeanDefinition(java.lang.String beanClassName)
Create a new BeanDefinitionBuilder used to construct a RootBeanDefinition.

Parameters:
beanClassName - the class name for the bean that the definition is being created for

rootBeanDefinition

public static BeanDefinitionBuilder rootBeanDefinition(java.lang.String beanClassName,
                                                       java.lang.String factoryMethodName)
Create a new BeanDefinitionBuilder used to construct a RootBeanDefinition.

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

childBeanDefinition

public static BeanDefinitionBuilder childBeanDefinition(java.lang.String parentName)
Create a new BeanDefinitionBuilder used to construct a ChildBeanDefinition.

Parameters:
parentName - the name of the parent bean

getRawBeanDefinition

public AbstractBeanDefinition getRawBeanDefinition()
Return the current BeanDefinition object in its raw (unvalidated) form.

See Also:
getBeanDefinition()

getBeanDefinition

public AbstractBeanDefinition getBeanDefinition()
Validate and return the created BeanDefinition object.


setParentName

public BeanDefinitionBuilder setParentName(java.lang.String parentName)
Set the name of the parent definition of this bean definition.


setFactoryMethod

public BeanDefinitionBuilder setFactoryMethod(java.lang.String factoryMethod)
Set the name of the factory method to use for this definition.


setFactoryBean

@Deprecated
public BeanDefinitionBuilder setFactoryBean(java.lang.String factoryBean,
                                                       java.lang.String factoryMethod)
Deprecated. since Spring 2.5, in favor of preparing this on the raw BeanDefinition object

Set the name of the factory bean to use for this definition.


addConstructorArg

@Deprecated
public BeanDefinitionBuilder addConstructorArg(java.lang.Object value)
Deprecated. since Spring 2.5, in favor of addConstructorArgValue(java.lang.Object)

Add an indexed constructor arg value. The current index is tracked internally and all additions are at the present point.


addConstructorArgValue

public BeanDefinitionBuilder addConstructorArgValue(java.lang.Object value)
Add an indexed constructor arg value. The current index is tracked internally and all additions are at the present point.


addConstructorArgReference

public BeanDefinitionBuilder addConstructorArgReference(java.lang.String beanName)
Add a reference to a named bean as a constructor arg.

See Also:
addConstructorArgValue(Object)

addPropertyValue

public BeanDefinitionBuilder addPropertyValue(java.lang.String name,
                                              java.lang.Object value)
Add the supplied property value under the given name.


addPropertyReference

public BeanDefinitionBuilder addPropertyReference(java.lang.String name,
                                                  java.lang.String beanName)
Add 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

setInitMethodName

public BeanDefinitionBuilder setInitMethodName(java.lang.String methodName)
Set the init method for this definition.


setDestroyMethodName

public BeanDefinitionBuilder setDestroyMethodName(java.lang.String methodName)
Set the destroy method for this definition.


setScope

public BeanDefinitionBuilder setScope(java.lang.String scope)
Set the scope of this definition.

See Also:
BeanDefinition.SCOPE_SINGLETON, BeanDefinition.SCOPE_PROTOTYPE

setSingleton

@Deprecated
public BeanDefinitionBuilder setSingleton(boolean singleton)
Deprecated. since Spring 2.5, in favor of setScope(java.lang.String)

Set whether or not this definition describes a singleton bean, as alternative to setScope(java.lang.String).


setAbstract

public BeanDefinitionBuilder setAbstract(boolean flag)
Set whether or not this definition is abstract.


setLazyInit

public BeanDefinitionBuilder setLazyInit(boolean lazy)
Set whether beans for this definition should be lazily initialized or not.


setAutowireMode

public BeanDefinitionBuilder setAutowireMode(int autowireMode)
Set the autowire mode for this definition.


setDependencyCheck

public BeanDefinitionBuilder setDependencyCheck(int dependencyCheck)
Set the depency check mode for this definition.


addDependsOn

public BeanDefinitionBuilder addDependsOn(java.lang.String beanName)
Append the specified bean name to the list of beans that this definition depends on.


setRole

public BeanDefinitionBuilder setRole(int role)
Set the role of this definition.


setSource

@Deprecated
public BeanDefinitionBuilder setSource(java.lang.Object source)
Deprecated. since Spring 2.5, in favor of preparing this on the raw BeanDefinition object

Set the source of this definition.


setResourceDescription

@Deprecated
public BeanDefinitionBuilder setResourceDescription(java.lang.String resourceDescription)
Deprecated. since Spring 2.5, in favor of preparing this on the raw BeanDefinition object

Set the description associated with this definition.