站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > Spring Framework 1.2.9 API 文档英文版

AbstractBeanDefinition (Spring Framework) - Spring Framework 1.2.9 API 文档英文版


org.springframework.beans.factory.support
Class AbstractBeanDefinition

java.lang.Object
  extended by org.springframework.beans.factory.support.AbstractBeanDefinition
All Implemented Interfaces:
BeanDefinition
Direct Known Subclasses:
ChildBeanDefinition, RootBeanDefinition

public abstract class AbstractBeanDefinition
extends Object
implements BeanDefinition

Base class for bean definition objects, factoring out common properties of RootBeanDefinition and ChildBeanDefinition.

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

Author:
Rod Johnson, Juergen Hoeller, Rob Harrop
See Also:
RootBeanDefinition, ChildBeanDefinition

Field Summary
static int AUTOWIRE_AUTODETECT
          Constant that indicates determining an appropriate autowire strategy through introspection of the bean class.
static int AUTOWIRE_BY_NAME
          Constant that indicates autowiring bean properties by name.
static int AUTOWIRE_BY_TYPE
          Constant that indicates autowiring bean properties by type.
static int AUTOWIRE_CONSTRUCTOR
          Constant that indicates autowiring a constructor.
static int AUTOWIRE_NO
          Constant that indicates no autowiring at all.
static int DEPENDENCY_CHECK_ALL
          Constant that indicates dependency checking for all properties (object references as well as "simple" properties).
static int DEPENDENCY_CHECK_NONE
          Constant that indicates no dependency check at all.
static int DEPENDENCY_CHECK_OBJECTS
          Constant that indicates dependency checking for object references.
static int DEPENDENCY_CHECK_SIMPLE
          Constant that indicates dependency checking for "simple" properties.
 
Constructor Summary
protected AbstractBeanDefinition()
          Create a new AbstractBeanDefinition with default settings.
protected AbstractBeanDefinition(AbstractBeanDefinition original)
          Create a new AbstractBeanDefinition as deep copy of the given bean definition.
protected AbstractBeanDefinition(ConstructorArgumentValues cargs, MutablePropertyValues pvs)
          Create a new AbstractBeanDefinition with the given constructor argument values and property values.
 
Method Summary
 int getAutowireMode()
          Return the autowire mode as specified in the bean definition.
 Class getBeanClass()
          Return the class of the wrapped bean.
 String getBeanClassName()
          Return the class name of the wrapped bean.
 ConstructorArgumentValues getConstructorArgumentValues()
          Return constructor argument values for this bean (never null).
 int getDependencyCheck()
          Return the dependency check code.
 String[] getDependsOn()
          Return the bean names that this bean depends on.
 String getDestroyMethodName()
          Return the name of the destroy method.
 String getFactoryBeanName()
          Returns the factory bean name, if any.
 String getFactoryMethodName()
          Return a factory method, if any.
 String getInitMethodName()
          Return the name of the initializer method.
 MethodOverrides getMethodOverrides()
          Return information about methods to be overridden by the IoC container.
 MutablePropertyValues getPropertyValues()
          Return property values for this bean (never null).
 int getResolvedAutowireMode()
          Return the resolved autowire code, (resolving AUTOWIRE_AUTODETECT to AUTOWIRE_CONSTRUCTOR or AUTOWIRE_BY_TYPE).
 String getResourceDescription()
          Return a description of the resource that this bean definition came from.
 boolean hasBeanClass()
          Return whether this definition specifies a bean class.
 boolean hasConstructorArgumentValues()
          Return if there are constructor argument values defined for this bean.
 boolean isAbstract()
          Return whether this bean is "abstract", i.e. not meant to be instantiated itself but rather just serving as parent for concrete child bean definitions.
 boolean isEnforceDestroyMethod()
          Indicate whether the configured destroy method is the default.
 boolean isEnforceInitMethod()
          Indicate whether the configured init method is the default.
 boolean isLazyInit()
          Return whether this bean should be lazily initialized, i.e. not eagerly instantiated on startup.
 boolean isSingleton()
          Return whether this a Singleton, with a single, shared instance returned from all calls.
 void overrideFrom(AbstractBeanDefinition other)
          Override settings in this bean definition (assumably a copied parent from a parent-child inheritance relationship) from the given bean definition (assumably the child).
 void setAbstract(boolean abstractFlag)
          Set if this bean is "abstract", i.e. not meant to be instantiated itself but rather just serving as parent for concrete child bean definitions.
 void setAutowireMode(int autowireMode)
          Set the autowire mode.
 void setBeanClass(Class beanClass)
          Specify the class for this bean.
 void setBeanClassName(String beanClassName)
          Specify the class name for this bean.
 void setConstructorArgumentValues(ConstructorArgumentValues constructorArgumentValues)
          Specify constructor argument values for this bean.
 void setDependencyCheck(int dependencyCheck)
          Set the dependency check code.
 void setDependsOn(String[] dependsOn)
          Set the names of the beans that this bean depends on being initialized.
 void setDestroyMethodName(String destroyMethodName)
          Set the name of the destroy method.
 void setEnforceDestroyMethod(boolean enforceDestroyMethod)
          Specify whether or not the configured destroy method is the default.
 void setEnforceInitMethod(boolean enforceInitMethod)
          Specify whether or not the configured init method is the default.
 void setFactoryBeanName(String factoryBeanName)
          Specify the factory bean to use, if any.
 void setFactoryMethodName(String factoryMethodName)
          Specify a factory method, if any.
 void setInitMethodName(String initMethodName)
          Set the name of the initializer method.
 void setLazyInit(boolean lazyInit)
          Set whether this bean should be lazily initialized.
 void setMethodOverrides(MethodOverrides methodOverrides)
          Specify method overrides for the bean, if any.
 void setPropertyValues(MutablePropertyValues propertyValues)
          Specify property values for this bean, if any.
 void setResourceDescription(String resourceDescription)
          Set a description of the resource that this bean definition came from (for the purpose of showing context in case of errors).
 void setSingleton(boolean singleton)
          Set if this a Singleton, with a single, shared instance returned on all calls.
 String toString()
           
 void validate()
          Validate this bean definition.
protected  void validateMethodOverride(MethodOverride mo)
          Validate the given method override.
 
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
Constant that indicates no autowiring at all.

See Also:
setAutowireMode(int), Constant Field Values

AUTOWIRE_BY_NAME

public static final int AUTOWIRE_BY_NAME
Constant that indicates autowiring bean properties by name.

See Also:
setAutowireMode(int), Constant Field Values

AUTOWIRE_BY_TYPE

public static final int AUTOWIRE_BY_TYPE
Constant that indicates autowiring bean properties by type.

See Also:
setAutowireMode(int), Constant Field Values

AUTOWIRE_CONSTRUCTOR

public static final int AUTOWIRE_CONSTRUCTOR
Constant that indicates autowiring a constructor.

See Also:
setAutowireMode(int), Constant Field Values

AUTOWIRE_AUTODETECT

public static final int AUTOWIRE_AUTODETECT
Constant that indicates determining an appropriate autowire strategy through introspection of the bean class.

See Also:
setAutowireMode(int), Constant Field Values

DEPENDENCY_CHECK_NONE

public static final int DEPENDENCY_CHECK_NONE
Constant that indicates no dependency check at all.

See Also:
setDependencyCheck(int), Constant Field Values

DEPENDENCY_CHECK_OBJECTS

public static final int DEPENDENCY_CHECK_OBJECTS
Constant that indicates dependency checking for object references.

See Also:
setDependencyCheck(int), Constant Field Values

DEPENDENCY_CHECK_SIMPLE

public static final int DEPENDENCY_CHECK_SIMPLE
Constant that indicates dependency checking for "simple" properties.

See Also:
setDependencyCheck(int), BeanUtils.isSimpleProperty(java.lang.Class), Constant Field Values

DEPENDENCY_CHECK_ALL

public static final int DEPENDENCY_CHECK_ALL
Constant that indicates dependency checking for all properties (object references as well as "simple" properties).

See Also:
setDependencyCheck(int), Constant Field Values
Constructor Detail

AbstractBeanDefinition

protected AbstractBeanDefinition()
Create a new AbstractBeanDefinition with default settings.


AbstractBeanDefinition

protected AbstractBeanDefinition(ConstructorArgumentValues cargs,
                                 MutablePropertyValues pvs)
Create a new AbstractBeanDefinition with the given constructor argument values and property values.


AbstractBeanDefinition

protected AbstractBeanDefinition(AbstractBeanDefinition original)
Create a new AbstractBeanDefinition as deep copy of the given bean definition.

Parameters:
original - the original bean definition to copy from
Method Detail

overrideFrom

public void overrideFrom(AbstractBeanDefinition other)
Override settings in this bean definition (assumably a copied parent from a parent-child inheritance relationship) from the given bean definition (assumably the child).

  • Will override beanClass if specified in the given bean definition.
  • Will always take abstract, singleton, lazyInit, autowireMode, dependencyCheck, dependsOn from the given bean definition.
  • Will add constructorArgumentValues, propertyValues, methodOverrides from the given bean definition to existing ones.
  • Will override factoryBeanName, factoryMethodName, initMethodName, destroyMethodName if specified in the given bean definition.


hasBeanClass

public boolean hasBeanClass()
Return whether this definition specifies a bean class.


setBeanClass

public void setBeanClass(Class beanClass)
Specify the class for this bean.


getBeanClass

public Class getBeanClass()
                   throws IllegalStateException
Return the class of the wrapped bean.

Throws:
IllegalStateException - if the bean definition does not define a bean class, or a specified bean class name has not been resolved into an actual Class

setBeanClassName

public void setBeanClassName(String beanClassName)
Specify the class name for this bean.


getBeanClassName

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


setAbstract

public void setAbstract(boolean abstractFlag)
Set if this bean is "abstract", i.e. not meant to be instantiated itself but rather just serving as parent for concrete child bean definitions.

Default is "false". Specify true to tell the bean factory to not try to instantiate that particular bean in any case.


isAbstract

public boolean isAbstract()
Return whether this bean is "abstract", i.e. not meant to be instantiated itself but rather just serving as parent for concrete child bean definitions.

Specified by:
isAbstract in interface BeanDefinition

setSingleton

public void setSingleton(boolean singleton)
Set if this a Singleton, with a single, shared instance returned on all calls. In case of "false", the BeanFactory will apply the Prototype design pattern, with each caller requesting an instance getting an independent instance. How this is exactly defined will depend on the BeanFactory.

"Singletons" are the commoner type, so the default is "true".


isSingleton

public boolean isSingleton()
Return whether this a Singleton, with a single, shared instance returned from all calls.

Specified by:
isSingleton in interface BeanDefinition

setLazyInit

public void setLazyInit(boolean lazyInit)
Set whether this bean should be lazily initialized.

If false, the bean will get instantiated on startup by bean factories that perform eager initialization of singletons.


isLazyInit

public boolean isLazyInit()
Return whether this bean should be lazily initialized, i.e. not eagerly instantiated on startup. Only applicable to a singleton bean.

Specified by:
isLazyInit in interface BeanDefinition

setAutowireMode

public void setAutowireMode(int autowireMode)
Set the autowire mode. 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 mode 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(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 String[] getDependsOn()
Return the bean names that this bean depends on.


setConstructorArgumentValues

public void setConstructorArgumentValues(ConstructorArgumentValues constructorArgumentValues)
Specify constructor argument values for this bean.


getConstructorArgumentValues

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

Specified by:
getConstructorArgumentValues in interface BeanDefinition
Returns:
the ConstructorArgumentValues object, or null

hasConstructorArgumentValues

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


setPropertyValues

public void setPropertyValues(MutablePropertyValues propertyValues)
Specify property values for this bean, if any.


getPropertyValues

public MutablePropertyValues getPropertyValues()
Return property values for this bean (never null).

Specified by:
getPropertyValues in interface BeanDefinition
Returns:
the PropertyValues object, or null

setMethodOverrides

public void setMethodOverrides(MethodOverrides methodOverrides)
Specify method overrides for the bean, if any.


getMethodOverrides

public MethodOverrides getMethodOverrides()
Return information about methods to be overridden by the IoC container. This will be empty if there are no method overrides. Never returns null.


setFactoryBeanName

public void setFactoryBeanName(String factoryBeanName)
Specify the factory bean to use, if any.


getFactoryBeanName

public String getFactoryBeanName()
Returns the factory bean name, if any.


setFactoryMethodName

public void setFactoryMethodName(String factoryMethodName)
Specify a factory method, if any. This method will be invoked with constructor arguments, or with no arguments if none are specified. The static method will be invoked on the specifed factory bean, if any, or on the local bean class else.

Parameters:
factoryMethodName - static factory method name, or null if normal constructor creation should be used
See Also:
getBeanClass()

getFactoryMethodName

public String getFactoryMethodName()
Return a factory method, if any.


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.


getInitMethodName

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


setEnforceInitMethod

public void setEnforceInitMethod(boolean enforceInitMethod)
Specify whether or not the configured init method is the default. Default value is false.

See Also:
setInitMethodName(java.lang.String)

isEnforceInitMethod

public boolean isEnforceInitMethod()
Indicate whether the configured init method is the default.

See Also:
getInitMethodName()

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.


getDestroyMethodName

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


setEnforceDestroyMethod

public void setEnforceDestroyMethod(boolean enforceDestroyMethod)
Specify whether or not the configured destroy method is the default. Default value is false.

See Also:
setDestroyMethodName(java.lang.String)

isEnforceDestroyMethod

public boolean isEnforceDestroyMethod()
Indicate whether the configured destroy method is the default.

See Also:
getDestroyMethodName()

setResourceDescription

public void setResourceDescription(String resourceDescription)
Set a description of the resource that this bean definition came from (for the purpose of showing context in case of errors).


getResourceDescription

public String getResourceDescription()
Return a description of the resource that this bean definition came from.

Specified by:
getResourceDescription in interface BeanDefinition

validate

public void validate()
              throws BeanDefinitionValidationException
Validate this bean definition.

Throws:
BeanDefinitionValidationException - in case of validation failure

validateMethodOverride

protected void validateMethodOverride(MethodOverride mo)
                               throws BeanDefinitionValidationException
Validate the given method override. Checks for existence of a method with the specified name.

Parameters:
mo - the MethodOverride object to validate
Throws:
BeanDefinitionValidationException - in case of validation failure

toString

public String toString()
Overrides:
toString in class Object


Copyright (c) 2002-2007 The Spring Framework Project.