org.springframework.beans.factory.support
Class RootBeanDefinition

java.lang.Object
  extended byorg.springframework.beans.factory.support.AbstractBeanDefinition
      extended byorg.springframework.beans.factory.support.RootBeanDefinition
All Implemented Interfaces:
BeanDefinition

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.

Version:
$Id: RootBeanDefinition.java,v 1.18 2004/03/19 17:45:36 jhoeller Exp $
Author:
Rod Johnson, Juergen Hoeller
See Also:
AutowireCapableBeanFactory

Field Summary
static int AUTOWIRE_AUTODETECT
           
static int AUTOWIRE_BY_NAME
           
static int AUTOWIRE_BY_TYPE
           
static int AUTOWIRE_CONSTRUCTOR
           
static int AUTOWIRE_NO
           
static int DEPENDENCY_CHECK_ALL
           
static int DEPENDENCY_CHECK_NONE
           
static int DEPENDENCY_CHECK_OBJECTS
           
static int DEPENDENCY_CHECK_SIMPLE
           
 
Constructor Summary
RootBeanDefinition(java.lang.Class beanClass, ConstructorArgumentValues cargs, MutablePropertyValues pvs)
          Create a new RootBeanDefinition for a singleton, providing constructor arguments and property values.
RootBeanDefinition(java.lang.Class beanClass, int autowireMode)
          Create a new RootBeanDefinition for a singleton, using the given autowire mode.
RootBeanDefinition(java.lang.Class beanClass, int autowireMode, boolean dependencyCheck)
          Create a new RootBeanDefinition for a singleton, using the given autowire mode.
RootBeanDefinition(java.lang.Class beanClass, MutablePropertyValues pvs)
          Create a new RootBeanDefinition for a singleton, providing property values.
RootBeanDefinition(java.lang.Class beanClass, MutablePropertyValues pvs, boolean singleton)
          Create a new RootBeanDefinition with the given singleton status, providing property values.
RootBeanDefinition(RootBeanDefinition other)
          Deep copy constructor.
RootBeanDefinition(java.lang.String beanClassName, ConstructorArgumentValues cargs, MutablePropertyValues pvs)
          Create a new RootBeanDefinition for a singleton, providing constructor arguments and property values.
 
Method Summary
 int getAutowireMode()
          Return the autowire mode as specified in the bean definition.
 java.lang.Class getBeanClass()
          Returns the class of the wrapped bean.
 java.lang.String getBeanClassName()
          Returns the class name of the wrapped bean.
 ConstructorArgumentValues getConstructorArgumentValues()
          This implementations returns null: Just RootBeanDefinitions have concrete support for constructor argument values.
 int getDependencyCheck()
          Return the dependency check code.
 java.lang.String[] getDependsOn()
          Return the bean names that this bean depends on.
 java.lang.String getDestroyMethodName()
          Return the name of the destroy method.
 java.lang.String getInitMethodName()
          Return the name of the initializer method.
 int getResolvedAutowireMode()
          Return the resolved autowire code, (resolving AUTOWIRE_AUTODETECT to AUTOWIRE_CONSTRUCTOR or AUTOWIRE_BY_TYPE).
 boolean hasConstructorArgumentValues()
          Return if there are constructor argument values for this bean.
 void setAutowireMode(int autowireMode)
          Set the autowire code.
 void setDependencyCheck(int dependencyCheck)
          Set the dependency check code.
 void setDependsOn(java.lang.String[] dependsOn)
          Set the names of the beans that this bean depends on being initialized.
 void setDestroyMethodName(java.lang.String destroyMethodName)
          Set the name of the destroy method.
 void setInitMethodName(java.lang.String initMethodName)
          Set the name of the initializer method.
 java.lang.String toString()
           
 void validate()
          Validate this bean definition.
 
Methods inherited from class org.springframework.beans.factory.support.AbstractBeanDefinition
getPropertyValues, getResourceDescription, isLazyInit, isSingleton, setLazyInit, setResourceDescription, setSingleton
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

AUTOWIRE_NO

public static final int AUTOWIRE_NO
See Also:
Constant Field Values

AUTOWIRE_BY_NAME

public static final int AUTOWIRE_BY_NAME
See Also:
Constant Field Values

AUTOWIRE_BY_TYPE

public static final int AUTOWIRE_BY_TYPE
See Also:
Constant Field Values

AUTOWIRE_CONSTRUCTOR

public static final int AUTOWIRE_CONSTRUCTOR
See Also:
Constant Field Values

AUTOWIRE_AUTODETECT

public static final int AUTOWIRE_AUTODETECT
See Also:
Constant Field Values

DEPENDENCY_CHECK_NONE

public static final int DEPENDENCY_CHECK_NONE
See Also:
Constant Field Values

DEPENDENCY_CHECK_OBJECTS

public static final int DEPENDENCY_CHECK_OBJECTS
See Also:
Constant Field Values

DEPENDENCY_CHECK_SIMPLE

public static final int DEPENDENCY_CHECK_SIMPLE
See Also:
Constant Field Values

DEPENDENCY_CHECK_ALL

public static final int DEPENDENCY_CHECK_ALL
See Also:
Constant Field Values
Constructor Detail

RootBeanDefinition

public RootBeanDefinition(java.lang.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(java.lang.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(java.lang.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(java.lang.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(java.lang.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(java.lang.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

getConstructorArgumentValues

public ConstructorArgumentValues getConstructorArgumentValues()
Description copied from class: AbstractBeanDefinition
This implementations returns null: Just RootBeanDefinitions have concrete support for constructor argument values.

Specified by:
getConstructorArgumentValues in interface BeanDefinition
Overrides:
getConstructorArgumentValues in class AbstractBeanDefinition

hasConstructorArgumentValues

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


getBeanClass

public final java.lang.Class getBeanClass()
                                   throws java.lang.IllegalStateException
Returns the class of the wrapped bean.

Throws:
java.lang.IllegalStateException - if the bean definition does not carry a resolved bean class

getBeanClassName

public final java.lang.String getBeanClassName()
Returns the class name of the wrapped 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

getAutowireMode

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


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

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

getDependencyCheck

public int getDependencyCheck()
Return the dependency check code.


setDependsOn

public void setDependsOn(java.lang.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.


getDependsOn

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


setInitMethodName

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


getInitMethodName

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


setDestroyMethodName

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


getDestroyMethodName

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


validate

public void validate()
              throws BeanDefinitionValidationException
Description copied from class: AbstractBeanDefinition
Validate this bean definition.

Overrides:
validate in class AbstractBeanDefinition
Throws:
BeanDefinitionValidationException - in case of validation failure

toString

public java.lang.String toString()


Copyright (C) 2003-2004 The Spring Framework Project.