|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.core.AttributeAccessorSupport org.springframework.beans.BeanMetadataAttributeAccessor org.springframework.beans.factory.support.AbstractBeanDefinition
public abstract class AbstractBeanDefinition
Base class for concrete, full-fledged
BeanDefinition
classes,
factoring out common properties of RootBeanDefinition
and
ChildBeanDefinition
.
The autowire constants match the ones defined in the
AutowireCapableBeanFactory
interface.
RootBeanDefinition
,
ChildBeanDefinition
,
Serialized FormField Summary | |
---|---|
static int |
AUTOWIRE_AUTODETECT
Deprecated. as of Spring 3.0: If you are using mixed autowiring strategies, use annotation-based autowiring for clearer demarcation of autowiring needs. |
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. |
static String |
INFER_METHOD
Constant that indicates the container should attempt to infer the destroy method name for a bean as opposed to explicit
specification of a method name. |
static String |
SCOPE_DEFAULT
Constant for the default scope name: "", equivalent to singleton status but to be overridden from a parent bean definition (if applicable). |
Fields inherited from interface org.springframework.beans.factory.config.BeanDefinition |
---|
ROLE_APPLICATION, ROLE_INFRASTRUCTURE, ROLE_SUPPORT, SCOPE_PROTOTYPE, SCOPE_SINGLETON |
Constructor Summary | |
---|---|
protected |
AbstractBeanDefinition()
Create a new AbstractBeanDefinition with default settings. |
protected |
AbstractBeanDefinition(AbstractBeanDefinition original)
Deprecated. since Spring 2.5, in favor of AbstractBeanDefinition(BeanDefinition) |
protected |
AbstractBeanDefinition(BeanDefinition 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 | |
---|---|
void |
addQualifier(AutowireCandidateQualifier qualifier)
Register a qualifier to be used for autowire candidate resolution, keyed by the qualifier's type name. |
void |
applyDefaults(BeanDefinitionDefaults defaults)
Apply the provided default values to this bean. |
Object |
clone()
Public declaration of Object's clone() method. |
abstract AbstractBeanDefinition |
cloneBeanDefinition()
Clone this bean definition. |
void |
copyQualifiersFrom(AbstractBeanDefinition source)
Copy the qualifiers from the supplied AbstractBeanDefinition to this bean definition. |
boolean |
equals(Object other)
|
int |
getAutowireMode()
Return the autowire mode as specified in the bean definition. |
Class<?> |
getBeanClass()
Return the class of the wrapped bean, if already resolved. |
String |
getBeanClassName()
Return the current bean class name of this bean definition. |
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 |
getDescription()
Return a human-readable description of this bean definition. |
String |
getDestroyMethodName()
Return the name of the destroy method. |
String |
getFactoryBeanName()
Return 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. |
BeanDefinition |
getOriginatingBeanDefinition()
Return the originating BeanDefinition, or null if none. |
MutablePropertyValues |
getPropertyValues()
Return property values for this bean (never null ). |
AutowireCandidateQualifier |
getQualifier(String typeName)
Return the qualifier mapped to the provided type name. |
Set<AutowireCandidateQualifier> |
getQualifiers()
Return all registered qualifiers. |
int |
getResolvedAutowireMode()
Return the resolved autowire code, (resolving AUTOWIRE_AUTODETECT to AUTOWIRE_CONSTRUCTOR or AUTOWIRE_BY_TYPE). |
Resource |
getResource()
Return the resource that this bean definition came from. |
String |
getResourceDescription()
Return a description of the resource that this bean definition came from (for the purpose of showing context in case of errors). |
int |
getRole()
Return the role hint for this BeanDefinition . |
String |
getScope()
Return the name of the target scope for the bean. |
boolean |
hasBeanClass()
Return whether this definition specifies a bean class. |
boolean |
hasConstructorArgumentValues()
Return if there are constructor argument values defined for this bean. |
int |
hashCode()
|
boolean |
hasQualifier(String typeName)
Return whether this bean has the specified qualifier. |
boolean |
isAbstract()
Return whether this bean is "abstract", i.e. |
boolean |
isAutowireCandidate()
Return whether this bean is a candidate for getting autowired into some other bean. |
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. |
boolean |
isLenientConstructorResolution()
Return whether to resolve constructors in lenient mode or in strict mode. |
boolean |
isNonPublicAccessAllowed()
Return whether to allow access to non-public constructors and methods. |
boolean |
isPrimary()
Return whether this bean is a primary autowire candidate. |
boolean |
isPrototype()
Return whether this a Prototype, with an independent instance returned for each call. |
boolean |
isSingleton()
Return whether this a Singleton, with a single shared instance returned from all calls. |
boolean |
isSynthetic()
Return whether this bean definition is 'synthetic', that is, not defined by the application itself. |
void |
overrideFrom(AbstractBeanDefinition other)
Deprecated. since Spring 2.5, in favor of overrideFrom(BeanDefinition) |
void |
overrideFrom(BeanDefinition 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). |
protected void |
prepareMethodOverride(MethodOverride mo)
Validate and prepare the given method override. |
void |
prepareMethodOverrides()
Validate and prepare the method overrides defined for this bean. |
Class |
resolveBeanClass(ClassLoader classLoader)
Determine the class of the wrapped bean, resolving it from a specified class name if necessary. |
void |
setAbstract(boolean abstractFlag)
Set if this bean is "abstract", i.e. |
void |
setAutowireCandidate(boolean autowireCandidate)
Set whether this bean is a candidate for getting autowired into some other bean. |
void |
setAutowireMode(int autowireMode)
Set the autowire mode. |
void |
setBeanClass(Class<?> beanClass)
Specify the class for this bean. |
void |
setBeanClassName(String beanClassName)
Override the bean class name of this bean definition. |
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 |
setDescription(String description)
Set a human-readable description of this bean definition. |
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 |
setLenientConstructorResolution(boolean lenientConstructorResolution)
Specify whether to resolve constructors in lenient mode ( true ,
which is the default) or to switch to strict resolution (throwing an exception
in case of ambigious constructors that all match when converting the arguments,
whereas lenient mode would use the one with the 'closest' type matches). |
void |
setMethodOverrides(MethodOverrides methodOverrides)
Specify method overrides for the bean, if any. |
void |
setNonPublicAccessAllowed(boolean nonPublicAccessAllowed)
Specify whether to allow access to non-public constructors and methods, for the case of externalized metadata pointing to those. |
void |
setOriginatingBeanDefinition(BeanDefinition originatingBd)
Set the originating (e.g. |
void |
setPrimary(boolean primary)
Set whether this bean is a primary autowire candidate. |
void |
setPropertyValues(MutablePropertyValues propertyValues)
Specify property values for this bean, if any. |
void |
setResource(Resource resource)
Set the resource that this bean definition came from (for the purpose of showing context in case of errors). |
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 |
setRole(int role)
Set the role hint for this BeanDefinition . |
void |
setScope(String scope)
Set the name of the target scope for the bean. |
void |
setSingleton(boolean singleton)
Deprecated. since Spring 2.5, in favor of setScope(java.lang.String) |
void |
setSynthetic(boolean synthetic)
Set whether this bean definition is 'synthetic', that is, not defined by the application itself (for example, an infrastructure bean such as a helper for auto-proxying, created through <aop:config> ). |
String |
toString()
|
void |
validate()
Validate this bean definition. |
Methods inherited from class org.springframework.beans.BeanMetadataAttributeAccessor |
---|
addMetadataAttribute, getAttribute, getMetadataAttribute, getSource, removeAttribute, setAttribute, setSource |
Methods inherited from class org.springframework.core.AttributeAccessorSupport |
---|
attributeNames, copyAttributesFrom, hasAttribute |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.springframework.beans.factory.config.BeanDefinition |
---|
getParentName, setParentName |
Methods inherited from interface org.springframework.core.AttributeAccessor |
---|
attributeNames, getAttribute, hasAttribute, removeAttribute, setAttribute |
Methods inherited from interface org.springframework.beans.BeanMetadataElement |
---|
getSource |
Field Detail |
---|
public static final String SCOPE_DEFAULT
public static final int AUTOWIRE_NO
setAutowireMode(int)
,
Constant Field Valuespublic static final int AUTOWIRE_BY_NAME
setAutowireMode(int)
,
Constant Field Valuespublic static final int AUTOWIRE_BY_TYPE
setAutowireMode(int)
,
Constant Field Valuespublic static final int AUTOWIRE_CONSTRUCTOR
setAutowireMode(int)
,
Constant Field Values@Deprecated public static final int AUTOWIRE_AUTODETECT
setAutowireMode(int)
,
Constant Field Valuespublic static final int DEPENDENCY_CHECK_NONE
setDependencyCheck(int)
,
Constant Field Valuespublic static final int DEPENDENCY_CHECK_OBJECTS
setDependencyCheck(int)
,
Constant Field Valuespublic static final int DEPENDENCY_CHECK_SIMPLE
setDependencyCheck(int)
,
BeanUtils.isSimpleProperty(java.lang.Class>)
,
Constant Field Valuespublic static final int DEPENDENCY_CHECK_ALL
setDependencyCheck(int)
,
Constant Field Valuespublic static final String INFER_METHOD
destroy method name
for a bean as opposed to explicit
specification of a method name. The value "(inferred)" is specifically designed to
include characters otherwise illegal in a method name, ensuring no possibility of
collisions with a legitimately named methods having the same name.
Constructor Detail |
---|
protected AbstractBeanDefinition()
protected AbstractBeanDefinition(ConstructorArgumentValues cargs, MutablePropertyValues pvs)
@Deprecated protected AbstractBeanDefinition(AbstractBeanDefinition original)
AbstractBeanDefinition(BeanDefinition)
original
- the original bean definition to copy fromprotected AbstractBeanDefinition(BeanDefinition original)
original
- the original bean definition to copy fromMethod Detail |
---|
@Deprecated public void overrideFrom(AbstractBeanDefinition other)
overrideFrom(BeanDefinition)
public void overrideFrom(BeanDefinition other)
abstract
, scope
,
lazyInit
, autowireMode
, dependencyCheck
,
and dependsOn
from the given bean definition.
constructorArgumentValues
, propertyValues
,
methodOverrides
from the given bean definition to existing ones.
factoryBeanName
, factoryMethodName
,
initMethodName
, and destroyMethodName
if specified
in the given bean definition.
public void applyDefaults(BeanDefinitionDefaults defaults)
defaults
- the defaults to applypublic boolean hasBeanClass()
public void setBeanClass(Class<?> beanClass)
public Class<?> getBeanClass() throws IllegalStateException
null
if none defined
IllegalStateException
- if the bean definition does not define a bean class,
or a specified bean class name has not been resolved into an actual Classpublic void setBeanClassName(String beanClassName)
BeanDefinition
The class name can be modified during bean factory post-processing, typically replacing the original class name with a parsed variant of it.
setBeanClassName
in interface BeanDefinition
public String getBeanClassName()
BeanDefinition
Note that this does not have to be the actual class name used at runtime, in case of a child definition overriding/inheriting the class name from its parent. Hence, do not consider this to be the definitive bean type at runtime but rather only use it for parsing purposes at the individual bean definition level.
getBeanClassName
in interface BeanDefinition
public Class resolveBeanClass(ClassLoader classLoader) throws ClassNotFoundException
classLoader
- the ClassLoader to use for resolving a (potential) class name
ClassNotFoundException
- if the class name could be resolvedpublic void setScope(String scope)
Default is singleton status, although this is only applied once a bean definition becomes active in the containing factory. A bean definition may eventually inherit its scope from a parent bean definitionFor this reason, the default scope name is empty (empty String), with singleton status being assumed until a resolved scope will be set.
setScope
in interface BeanDefinition
BeanDefinition.SCOPE_SINGLETON
,
BeanDefinition.SCOPE_PROTOTYPE
public String getScope()
getScope
in interface BeanDefinition
@Deprecated public void setSingleton(boolean singleton)
setScope(java.lang.String)
"Singletons" are the commoner type, so the default is "true". Note that as of Spring 2.0, this flag is just an alternative way to specify scope="singleton" or scope="prototype".
setScope(java.lang.String)
,
BeanDefinition.SCOPE_SINGLETON
,
BeanDefinition.SCOPE_PROTOTYPE
public boolean isSingleton()
isSingleton
in interface BeanDefinition
BeanDefinition.SCOPE_SINGLETON
public boolean isPrototype()
isPrototype
in interface BeanDefinition
BeanDefinition.SCOPE_PROTOTYPE
public void setAbstract(boolean abstractFlag)
Default is "false". Specify true to tell the bean factory to not try to instantiate that particular bean in any case.
public boolean isAbstract()
isAbstract
in interface BeanDefinition
public void setLazyInit(boolean lazyInit)
If false
, the bean will get instantiated on startup by bean
factories that perform eager initialization of singletons.
setLazyInit
in interface BeanDefinition
public boolean isLazyInit()
isLazyInit
in interface BeanDefinition
public void setAutowireMode(int autowireMode)
autowireMode
- the autowire mode to set.
Must be one of the constants defined in this class.AUTOWIRE_NO
,
AUTOWIRE_BY_NAME
,
AUTOWIRE_BY_TYPE
,
AUTOWIRE_CONSTRUCTOR
,
AUTOWIRE_AUTODETECT
public int getAutowireMode()
public int getResolvedAutowireMode()
AUTOWIRE_AUTODETECT
,
AUTOWIRE_CONSTRUCTOR
,
AUTOWIRE_BY_TYPE
public void setDependencyCheck(int dependencyCheck)
dependencyCheck
- the code to set.
Must be one of the four constants defined in this class.DEPENDENCY_CHECK_NONE
,
DEPENDENCY_CHECK_OBJECTS
,
DEPENDENCY_CHECK_SIMPLE
,
DEPENDENCY_CHECK_ALL
public int getDependencyCheck()
public void setDependsOn(String[] dependsOn)
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.
setDependsOn
in interface BeanDefinition
public String[] getDependsOn()
getDependsOn
in interface BeanDefinition
public void setAutowireCandidate(boolean autowireCandidate)
setAutowireCandidate
in interface BeanDefinition
public boolean isAutowireCandidate()
isAutowireCandidate
in interface BeanDefinition
public void setPrimary(boolean primary)
setPrimary
in interface BeanDefinition
public boolean isPrimary()
isPrimary
in interface BeanDefinition
public void addQualifier(AutowireCandidateQualifier qualifier)
AutowireCandidateQualifier.getTypeName()
public boolean hasQualifier(String typeName)
public AutowireCandidateQualifier getQualifier(String typeName)
public Set<AutowireCandidateQualifier> getQualifiers()
AutowireCandidateQualifier
objects.public void copyQualifiersFrom(AbstractBeanDefinition source)
source
- the AbstractBeanDefinition to copy frompublic void setNonPublicAccessAllowed(boolean nonPublicAccessAllowed)
This applies to constructor resolution, factory method resolution, and also init/destroy methods. Bean property accessors have to be public in any case and are not affected by this setting.
Note that annotation-driven configuration will still access non-public members as far as they have been annotated. This setting applies to externalized metadata in this bean definition only.
public boolean isNonPublicAccessAllowed()
public void setLenientConstructorResolution(boolean lenientConstructorResolution)
true
,
which is the default) or to switch to strict resolution (throwing an exception
in case of ambigious constructors that all match when converting the arguments,
whereas lenient mode would use the one with the 'closest' type matches).
public boolean isLenientConstructorResolution()
public void setConstructorArgumentValues(ConstructorArgumentValues constructorArgumentValues)
public ConstructorArgumentValues getConstructorArgumentValues()
null
).
getConstructorArgumentValues
in interface BeanDefinition
null
)public boolean hasConstructorArgumentValues()
public void setPropertyValues(MutablePropertyValues propertyValues)
public MutablePropertyValues getPropertyValues()
null
).
getPropertyValues
in interface BeanDefinition
null
)public void setMethodOverrides(MethodOverrides methodOverrides)
public MethodOverrides getMethodOverrides()
public void setFactoryBeanName(String factoryBeanName)
BeanDefinition
setFactoryBeanName
in interface BeanDefinition
public String getFactoryBeanName()
BeanDefinition
getFactoryBeanName
in interface BeanDefinition
public void setFactoryMethodName(String factoryMethodName)
BeanDefinition
setFactoryMethodName
in interface BeanDefinition
factoryMethodName
- static factory method name,
or null
if normal constructor creation should be usedBeanDefinition.getBeanClassName()
public String getFactoryMethodName()
BeanDefinition
getFactoryMethodName
in interface BeanDefinition
public void setInitMethodName(String initMethodName)
null
in which case there is no initializer method.
public String getInitMethodName()
public void setEnforceInitMethod(boolean enforceInitMethod)
false
.
setInitMethodName(java.lang.String)
public boolean isEnforceInitMethod()
getInitMethodName()
public void setDestroyMethodName(String destroyMethodName)
null
in which case there is no destroy method.
public String getDestroyMethodName()
public void setEnforceDestroyMethod(boolean enforceDestroyMethod)
false
.
setDestroyMethodName(java.lang.String)
public boolean isEnforceDestroyMethod()
getDestroyMethodName()
public void setSynthetic(boolean synthetic)
<aop:config>
).
public boolean isSynthetic()
public void setRole(int role)
BeanDefinition
.
public int getRole()
BeanDefinition
.
getRole
in interface BeanDefinition
BeanDefinition.ROLE_APPLICATION
,
BeanDefinition.ROLE_INFRASTRUCTURE
,
BeanDefinition.ROLE_SUPPORT
public void setDescription(String description)
public String getDescription()
BeanDefinition
getDescription
in interface BeanDefinition
public void setResource(Resource resource)
public Resource getResource()
public void setResourceDescription(String resourceDescription)
public String getResourceDescription()
BeanDefinition
getResourceDescription
in interface BeanDefinition
public void setOriginatingBeanDefinition(BeanDefinition originatingBd)
public BeanDefinition getOriginatingBeanDefinition()
BeanDefinition
null
if none.
Allows for retrieving the decorated bean definition, if any.
Note that this method returns the immediate originator. Iterate through the originator chain to find the original BeanDefinition as defined by the user.
getOriginatingBeanDefinition
in interface BeanDefinition
public void validate() throws BeanDefinitionValidationException
BeanDefinitionValidationException
- in case of validation failurepublic void prepareMethodOverrides() throws BeanDefinitionValidationException
BeanDefinitionValidationException
- in case of validation failureprotected void prepareMethodOverride(MethodOverride mo) throws BeanDefinitionValidationException
mo
- the MethodOverride object to validate
BeanDefinitionValidationException
- in case of validation failurepublic Object clone()
clone()
method.
Delegates to cloneBeanDefinition()
.
clone
in class Object
Object.clone()
public abstract AbstractBeanDefinition cloneBeanDefinition()
public boolean equals(Object other)
equals
in class AttributeAccessorSupport
public int hashCode()
hashCode
in class AttributeAccessorSupport
public String toString()
toString
in class Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |