org.springframework.beans.factory.support
Class RootBeanDefinition

org.springframework.beans.factory.support.AbstractBeanDefinition
  |
  +--org.springframework.beans.factory.support.RootBeanDefinition

public class RootBeanDefinition
extends AbstractBeanDefinition

Root bean definitions have a class plus optionally constructor argument values and property values. This is the most common type of bean definition.

The autowire constants match the ones defined in the AutowireCapableBeanFactory interface, adding AUTOWIRE_NO.

Author:
Rod Johnson, Juergen Hoeller
Version: $Id: RootBeanDefinition.java,v 1.16 2004/02/04 17:23:46 jhoeller Exp $
See Also: AutowireCapableBeanFactory

Field Summary
 final static intAUTOWIRE_AUTODETECT
           
 final static intAUTOWIRE_BY_NAME
           
 final static intAUTOWIRE_BY_TYPE
           
 final static intAUTOWIRE_CONSTRUCTOR
           
 final static intAUTOWIRE_NO
           
 final static intDEPENDENCY_CHECK_ALL
           
 final static intDEPENDENCY_CHECK_NONE
           
 final static intDEPENDENCY_CHECK_OBJECTS
           
 final static intDEPENDENCY_CHECK_SIMPLE
           

Constructor Summary
RootBeanDefinition(Class beanClass, int autowireMode)
          Create a new RootBeanDefinition for a singleton, using the given autowire mode.
RootBeanDefinition(Class beanClass, int autowireMode, boolean dependencyCheck)
          Create a new RootBeanDefinition for a singleton, using the given autowire mode.
RootBeanDefinition(Class beanClass, MutablePropertyValues pvs)
          Create a new RootBeanDefinition for a singleton, providing property values.
RootBeanDefinition(Class beanClass, MutablePropertyValues pvs, boolean singleton)
          Create a new RootBeanDefinition with the given singleton status, providing property values.
RootBeanDefinition(Class beanClass, ConstructorArgumentValues cargs, MutablePropertyValues pvs)
          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.
RootBeanDefinition(RootBeanDefinition other)
          Deep copy constructor.

Method Summary
 intgetAutowireMode()
          Return the autowire mode as specified in the bean definition.
 final ClassgetBeanClass()
          Returns the class of the wrapped bean.
 final StringgetBeanClassName()
          Returns the class name of the wrapped bean.
 ConstructorArgumentValuesgetConstructorArgumentValues()
          Return the constructor argument values for this bean.
 intgetDependencyCheck()
          Return the dependency check code.
 String[]getDependsOn()
          Return the bean names that this bean depends on.
 StringgetDestroyMethodName()
          Return the name of the destroy method.
 StringgetInitMethodName()
          Return the name of the initializer method.
 intgetResolvedAutowireMode()
          Return the resolved autowire code, (resolving AUTOWIRE_AUTODETECT to AUTOWIRE_CONSTRUCTOR or AUTOWIRE_BY_TYPE).
 booleanhasConstructorArgumentValues()
          Return if there are constructor argument values for this bean.
 voidsetAutowireMode(int autowireMode)
          Set the autowire code.
 voidsetDependencyCheck(int dependencyCheck)
          Set the dependency check code.
 voidsetDependsOn(String[] dependsOn)
          Set the names of the beans that this bean depends on being initialized.
 voidsetDestroyMethodName(String destroyMethodName)
          Set the name of the destroy method.
 voidsetInitMethodName(String initMethodName)
          Set the name of the initializer method.
 StringtoString()
           
 voidvalidate()
           

Methods inherited from class org.springframework.beans.factory.support.AbstractBeanDefinition
getPropertyValues, getResourceDescription, isLazyInit, isSingleton, setLazyInit, setResourceDescription, setSingleton

Field Detail

AUTOWIRE_AUTODETECT

public final static int AUTOWIRE_AUTODETECT

AUTOWIRE_BY_NAME

public final static int AUTOWIRE_BY_NAME

AUTOWIRE_BY_TYPE

public final static int AUTOWIRE_BY_TYPE

AUTOWIRE_CONSTRUCTOR

public final static int AUTOWIRE_CONSTRUCTOR

AUTOWIRE_NO

public final static int AUTOWIRE_NO

DEPENDENCY_CHECK_ALL

public final static int DEPENDENCY_CHECK_ALL

DEPENDENCY_CHECK_NONE

public final static int DEPENDENCY_CHECK_NONE

DEPENDENCY_CHECK_OBJECTS

public final static int DEPENDENCY_CHECK_OBJECTS

DEPENDENCY_CHECK_SIMPLE

public final static int DEPENDENCY_CHECK_SIMPLE
Constructor Detail

RootBeanDefinition

public RootBeanDefinition(Class beanClass, int autowireMode)
Create a new RootBeanDefinition for a singleton, using the given autowire mode.
Parameters:
beanClass - the class of the bean to instantiate
autowireMode - by name or type, using the constants in this interface

RootBeanDefinition

public RootBeanDefinition(Class beanClass, int autowireMode, boolean dependencyCheck)
Create a new RootBeanDefinition for a singleton, using the given autowire mode.
Parameters:
beanClass - the class of the bean to instantiate
autowireMode - by name or type, using the constants in this interface
dependencyCheck - whether to perform a dependency check for objects (not applicable to autowiring a constructor, thus ignored there)

RootBeanDefinition

public RootBeanDefinition(Class beanClass, MutablePropertyValues pvs)
Create a new RootBeanDefinition for a singleton, providing property values.
Parameters:
beanClass - the class of the bean to instantiate
pvs - the property values to apply

RootBeanDefinition

public RootBeanDefinition(Class beanClass, MutablePropertyValues pvs, boolean singleton)
Create a new RootBeanDefinition with the given singleton status, providing property values.
Parameters:
beanClass - the class of the bean to instantiate
pvs - the property values to apply
singleton - the singleton status of the bean

RootBeanDefinition

public RootBeanDefinition(Class beanClass, ConstructorArgumentValues cargs, MutablePropertyValues pvs)
Create a new RootBeanDefinition for a singleton, providing constructor arguments and property values.
Parameters:
beanClass - the class of the bean to instantiate
cargs - the constructor argument values to apply
pvs - the property values to apply

RootBeanDefinition

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.
Parameters:
beanClassName - the name of the class to instantiate
cargs - the constructor argument values to apply
pvs - the property values to apply

RootBeanDefinition

public RootBeanDefinition(RootBeanDefinition other)
Deep copy constructor.
Method Detail

getAutowireMode

public int getAutowireMode()
Return the autowire mode as specified in the bean definition.

getBeanClass

public final Class getBeanClass()
throws java.lang.IllegalStateException
Returns the class of the wrapped bean.
Throws:
IllegalStateException - if the bean definition does not carry a resolved bean class

getBeanClassName

public final String getBeanClassName()
Returns the class name of the wrapped bean.

getConstructorArgumentValues

public ConstructorArgumentValues getConstructorArgumentValues()
Return the constructor argument values for this bean.

getDependencyCheck

public int getDependencyCheck()
Return the dependency check code.

getDependsOn

public String[] getDependsOn()
Return the bean names that this bean depends on.

getDestroyMethodName

public String getDestroyMethodName()
Return the name of the destroy method.

getInitMethodName

public String getInitMethodName()
Return the name of the initializer method.

getResolvedAutowireMode

public int getResolvedAutowireMode()
Return the resolved autowire code, (resolving AUTOWIRE_AUTODETECT to AUTOWIRE_CONSTRUCTOR or AUTOWIRE_BY_TYPE).
See Also:
AUTOWIRE_AUTODETECT, AUTOWIRE_CONSTRUCTOR, AUTOWIRE_BY_TYPE

hasConstructorArgumentValues

public boolean hasConstructorArgumentValues()
Return if there are constructor argument values for this bean.

setAutowireMode

public void setAutowireMode(int autowireMode)
Set the autowire code. This determines whether any automagical detection and setting of bean references will happen. Default is AUTOWIRE_NO, which means there's no autowire.
Parameters:
autowireMode - the autowire to set. Must be one of the constants defined in this class.
See Also:
AUTOWIRE_NO, AUTOWIRE_BY_NAME, AUTOWIRE_BY_TYPE, AUTOWIRE_CONSTRUCTOR, AUTOWIRE_AUTODETECT

setDependencyCheck

public void setDependencyCheck(int dependencyCheck)
Set the dependency check code.
Parameters:
dependencyCheck - the code to set. Must be one of the four constants defined in this class.
See Also:
DEPENDENCY_CHECK_NONE, DEPENDENCY_CHECK_OBJECTS, DEPENDENCY_CHECK_SIMPLE, DEPENDENCY_CHECK_ALL

setDependsOn

public void setDependsOn(String[] dependsOn)
Set the names of the beans that this bean depends on being initialized. The bean factory will guarantee that these beans get initialized before.

Note that dependencies are normally expressed through bean properties or constructor arguments. This property should just be necessary for other kinds of dependencies like statics (*ugh*) or database preparation on startup.


setDestroyMethodName

public void setDestroyMethodName(String destroyMethodName)
Set the name of the destroy method. The default is null in which case there is no destroy method.

setInitMethodName

public void setInitMethodName(String initMethodName)
Set the name of the initializer method. The default is null in which case there is no initializer method.

toString

public String toString()

validate

public void validate()
throws BeanDefinitionValidationException

Association Links

to Class org.springframework.beans.factory.config.ConstructorArgumentValues

to Class java.lang.String

to Class java.lang.String

to Class java.lang.String