| Method from org.springframework.beans.factory.support.AbstractBeanDefinition Detail: |
public void addQualifier(AutowireCandidateQualifier qualifier) {
this.qualifiers.put(qualifier.getTypeName(), qualifier);
}
Register a qualifier to be used for autowire candidate resolution,
keyed by the qualifier's type name. |
public void applyDefaults(BeanDefinitionDefaults defaults) {
setLazyInit(defaults.isLazyInit());
setDependencyCheck(defaults.getDependencyCheck());
setAutowireMode(defaults.getAutowireMode());
setInitMethodName(defaults.getInitMethodName());
setEnforceInitMethod(false);
setDestroyMethodName(defaults.getDestroyMethodName());
setEnforceDestroyMethod(false);
}
Apply the provided default values to this bean. |
public Object clone() {
return cloneBeanDefinition();
}
|
abstract public AbstractBeanDefinition cloneBeanDefinition()
Clone this bean definition.
To be implemented by concrete subclasses. |
protected void copyQualifiersFrom(AbstractBeanDefinition source) {
Assert.notNull(source, "Source must not be null");
this.qualifiers.putAll(source.qualifiers);
}
Copy the qualifiers from the supplied AbstractBeanDefinition to this bean definition. |
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (!(other instanceof AbstractBeanDefinition)) {
return false;
}
AbstractBeanDefinition that = (AbstractBeanDefinition) other;
if (!ObjectUtils.nullSafeEquals(getBeanClassName(), that.getBeanClassName())) return false;
if (!ObjectUtils.nullSafeEquals(this.scope, that.scope)) return false;
if (this.abstractFlag != that.abstractFlag) return false;
if (this.lazyInit != that.lazyInit) return false;
if (this.autowireMode != that.autowireMode) return false;
if (this.dependencyCheck != that.dependencyCheck) return false;
if (!Arrays.equals(this.dependsOn, that.dependsOn)) return false;
if (this.autowireCandidate != that.autowireCandidate) return false;
if (!ObjectUtils.nullSafeEquals(this.qualifiers, that.qualifiers)) return false;
if (this.primary != that.primary) return false;
if (!ObjectUtils.nullSafeEquals(this.constructorArgumentValues, that.constructorArgumentValues)) return false;
if (!ObjectUtils.nullSafeEquals(this.propertyValues, that.propertyValues)) return false;
if (!ObjectUtils.nullSafeEquals(this.methodOverrides, that.methodOverrides)) return false;
if (!ObjectUtils.nullSafeEquals(this.factoryBeanName, that.factoryBeanName)) return false;
if (!ObjectUtils.nullSafeEquals(this.factoryMethodName, that.factoryMethodName)) return false;
if (!ObjectUtils.nullSafeEquals(this.initMethodName, that.initMethodName)) return false;
if (this.enforceInitMethod != that.enforceInitMethod) return false;
if (!ObjectUtils.nullSafeEquals(this.destroyMethodName, that.destroyMethodName)) return false;
if (this.enforceDestroyMethod != that.enforceDestroyMethod) return false;
if (this.synthetic != that.synthetic) return false;
if (!ObjectUtils.nullSafeEquals(this.resource, that.resource)) return false;
if (this.role != that.role) return false;
return super.equals(other);
}
|
public int getAutowireMode() {
return this.autowireMode;
}
Return the autowire mode as specified in the bean definition. |
public Class getBeanClass() throws IllegalStateException {
if (this.beanClass == null) {
throw new IllegalStateException("No bean class specified on bean definition");
}
if (!(this.beanClass instanceof Class)) {
throw new IllegalStateException(
"Bean class name [" + this.beanClass + "] has not been resolved into an actual Class");
}
return (Class) this.beanClass;
}
Return the class of the wrapped bean, if already resolved. |
public String getBeanClassName() {
if (this.beanClass instanceof Class) {
return ((Class) this.beanClass).getName();
}
else {
return (String) this.beanClass;
}
}
|
public ConstructorArgumentValues getConstructorArgumentValues() {
return this.constructorArgumentValues;
}
Return constructor argument values for this bean (never null). |
public int getDependencyCheck() {
return this.dependencyCheck;
}
Return the dependency check code. |
public String[] getDependsOn() {
return this.dependsOn;
}
Return the bean names that this bean depends on. |
public String getDescription() {
return this.description;
}
|
public String getDestroyMethodName() {
return this.destroyMethodName;
}
Return the name of the destroy method. |
public String getFactoryBeanName() {
return this.factoryBeanName;
}
|
public String getFactoryMethodName() {
return this.factoryMethodName;
}
|
public String getInitMethodName() {
return this.initMethodName;
}
Return the name of the initializer method. |
public MethodOverrides getMethodOverrides() {
return this.methodOverrides;
}
Return information about methods to be overridden by the IoC
container. This will be empty if there are no method overrides.
Never returns null. |
public BeanDefinition getOriginatingBeanDefinition() {
return (this.resource instanceof BeanDefinitionResource ?
((BeanDefinitionResource) this.resource).getBeanDefinition() : null);
}
|
public MutablePropertyValues getPropertyValues() {
return this.propertyValues;
}
Return property values for this bean (never null). |
public AutowireCandidateQualifier getQualifier(String typeName) {
return (AutowireCandidateQualifier) this.qualifiers.get(typeName);
}
Return the qualifier mapped to the provided type name. |
public Set getQualifiers() {
return new LinkedHashSet(this.qualifiers.values());
}
Return all registered qualifiers. |
public int getResolvedAutowireMode() {
if (this.autowireMode == AUTOWIRE_AUTODETECT) {
// Work out whether to apply setter autowiring or constructor autowiring.
// If it has a no-arg constructor it's deemed to be setter autowiring,
// otherwise we'll try constructor autowiring.
Constructor[] constructors = getBeanClass().getConstructors();
for (int i = 0; i < constructors.length; i++) {
if (constructors[i].getParameterTypes().length == 0) {
return AUTOWIRE_BY_TYPE;
}
}
return AUTOWIRE_CONSTRUCTOR;
}
else {
return this.autowireMode;
}
}
Return the resolved autowire code,
(resolving AUTOWIRE_AUTODETECT to AUTOWIRE_CONSTRUCTOR or AUTOWIRE_BY_TYPE). |
public Resource getResource() {
return this.resource;
}
Return the resource that this bean definition came from. |
public String getResourceDescription() {
return (this.resource != null ? this.resource.getDescription() : null);
}
|
public int getRole() {
return this.role;
}
Return the role hint for this BeanDefinition. |
public String getScope() {
return this.scope;
}
Return the name of the target scope for the bean. |
public boolean hasBeanClass() {
return (this.beanClass instanceof Class);
}
Return whether this definition specifies a bean class. |
public boolean hasConstructorArgumentValues() {
return !this.constructorArgumentValues.isEmpty();
}
Return if there are constructor argument values defined for this bean. |
public boolean hasQualifier(String typeName) {
return this.qualifiers.keySet().contains(typeName);
}
Return whether this bean has the specified qualifier. |
public int hashCode() {
int hashCode = ObjectUtils.nullSafeHashCode(getBeanClassName());
hashCode = 29 * hashCode + ObjectUtils.nullSafeHashCode(this.scope);
hashCode = 29 * hashCode + ObjectUtils.nullSafeHashCode(this.constructorArgumentValues);
hashCode = 29 * hashCode + ObjectUtils.nullSafeHashCode(this.propertyValues);
hashCode = 29 * hashCode + ObjectUtils.nullSafeHashCode(this.factoryBeanName);
hashCode = 29 * hashCode + ObjectUtils.nullSafeHashCode(this.factoryMethodName);
hashCode = 29 * hashCode + super.hashCode();
return hashCode;
}
|
public boolean isAbstract() {
return this.abstractFlag;
}
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. |
public boolean isAutowireCandidate() {
return this.autowireCandidate;
}
Return whether this bean is a candidate for getting autowired into some other bean. |
public boolean isEnforceDestroyMethod() {
return this.enforceDestroyMethod;
}
Indicate whether the configured destroy method is the default. |
public boolean isEnforceInitMethod() {
return this.enforceInitMethod;
}
Indicate whether the configured init method is the default. |
public boolean isLazyInit() {
return this.lazyInit;
}
Return whether this bean should be lazily initialized, i.e. not
eagerly instantiated on startup. Only applicable to a singleton bean. |
public boolean isPrimary() {
return this.primary;
}
Return whether this bean is a primary autowire candidate.
If this value is true for exactly one bean among multiple
matching candidates, it will serve as a tie-breaker. |
public boolean isPrototype() {
return this.prototype;
}
Return whether this a Prototype, with an independent instance
returned for each call. |
public boolean isSingleton() {
return this.singleton;
}
Return whether this a Singleton, with a single shared instance
returned from all calls. |
public boolean isSynthetic() {
return this.synthetic;
}
Return whether this bean definition is 'synthetic', that is,
not defined by the application itself. |
public void overrideFrom(AbstractBeanDefinition other) {
overrideFrom((BeanDefinition) other);
} Deprecated! since - Spring 2.5, in favor of #overrideFrom(BeanDefinition)
Override settings in this bean definition (assumably a copied parent
from a parent-child inheritance relationship) from the given bean
definition (assumably the child). |
public void overrideFrom(BeanDefinition other) {
if (other.getBeanClassName() != null) {
setBeanClassName(other.getBeanClassName());
}
if (other.getFactoryBeanName() != null) {
setFactoryBeanName(other.getFactoryBeanName());
}
if (other.getFactoryMethodName() != null) {
setFactoryMethodName(other.getFactoryMethodName());
}
setScope(other.getScope());
setAbstract(other.isAbstract());
setLazyInit(other.isLazyInit());
getConstructorArgumentValues().addArgumentValues(other.getConstructorArgumentValues());
getPropertyValues().addPropertyValues(other.getPropertyValues());
setSource(other.getSource());
setRole(other.getRole());
copyAttributesFrom(other);
if (other instanceof AbstractBeanDefinition) {
AbstractBeanDefinition otherAbd = (AbstractBeanDefinition) other;
if (otherAbd.hasBeanClass()) {
setBeanClass(otherAbd.getBeanClass());
}
setAutowireCandidate(otherAbd.isAutowireCandidate());
setAutowireMode(otherAbd.getAutowireMode());
copyQualifiersFrom(otherAbd);
setPrimary(otherAbd.isPrimary());
setDependencyCheck(otherAbd.getDependencyCheck());
setDependsOn(otherAbd.getDependsOn());
if (otherAbd.getInitMethodName() != null) {
setInitMethodName(otherAbd.getInitMethodName());
setEnforceInitMethod(otherAbd.isEnforceInitMethod());
}
if (otherAbd.getDestroyMethodName() != null) {
setDestroyMethodName(otherAbd.getDestroyMethodName());
setEnforceDestroyMethod(otherAbd.isEnforceDestroyMethod());
}
getMethodOverrides().addOverrides(otherAbd.getMethodOverrides());
setSynthetic(otherAbd.isSynthetic());
setResource(otherAbd.getResource());
}
else {
setResourceDescription(other.getResourceDescription());
}
}
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, scope,
lazyInit, autowireMode, dependencyCheck,
and dependsOn from the given bean definition.
- Will add
constructorArgumentValues, propertyValues,
methodOverrides from the given bean definition to existing ones.
- Will override
factoryBeanName, factoryMethodName,
initMethodName, and destroyMethodName if specified
in the given bean definition.
|
protected void prepareMethodOverride(MethodOverride mo) throws BeanDefinitionValidationException {
int count = ClassUtils.getMethodCountForName(getBeanClass(), mo.getMethodName());
if (count == 0) {
throw new BeanDefinitionValidationException(
"Invalid method override: no method with name '" + mo.getMethodName() +
"' on class [" + getBeanClassName() + "]");
}
else if (count == 1) {
// Mark override as not overloaded, to avoid the overhead of arg type checking.
mo.setOverloaded(false);
}
}
Validate and prepare the given method override.
Checks for existence of a method with the specified name,
marking it as not overloaded if none found. |
public void prepareMethodOverrides() throws BeanDefinitionValidationException {
// Check that lookup methods exists.
MethodOverrides methodOverrides = getMethodOverrides();
if (!methodOverrides.isEmpty()) {
for (Iterator it = methodOverrides.getOverrides().iterator(); it.hasNext(); ) {
MethodOverride mo = (MethodOverride) it.next();
prepareMethodOverride(mo);
}
}
}
Validate and prepare the method overrides defined for this bean.
Checks for existence of a method with the specified name. |
public Class resolveBeanClass(ClassLoader classLoader) throws ClassNotFoundException {
String className = getBeanClassName();
if (className == null) {
return null;
}
Class resolvedClass = ClassUtils.forName(className, classLoader);
this.beanClass = resolvedClass;
return resolvedClass;
}
Determine the class of the wrapped bean, resolving it from a
specified class name if necessary. Will also reload a specified
Class from its name when called with the bean class already resolved. |
public void setAbstract(boolean abstractFlag) {
this.abstractFlag = 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. |
public void setAutowireCandidate(boolean autowireCandidate) {
this.autowireCandidate = autowireCandidate;
}
Set whether this bean is a candidate for getting autowired into some other bean. |
public void setAutowireMode(int autowireMode) {
this.autowireMode = 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. |
public void setBeanClass(Class beanClass) {
this.beanClass = beanClass;
}
Specify the class for this bean. |
public void setBeanClassName(String beanClassName) {
this.beanClass = beanClassName;
}
|
public void setConstructorArgumentValues(ConstructorArgumentValues constructorArgumentValues) {
this.constructorArgumentValues =
(constructorArgumentValues != null ? constructorArgumentValues : new ConstructorArgumentValues());
}
Specify constructor argument values for this bean. |
public void setDependencyCheck(int dependencyCheck) {
this.dependencyCheck = dependencyCheck;
}
Set the dependency check code. |
public void setDependsOn(String[] dependsOn) {
this.dependsOn = 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. |
public void setDescription(String description) {
this.description = description;
}
Set a human-readable description of this bean definition. |
public void setDestroyMethodName(String destroyMethodName) {
this.destroyMethodName = destroyMethodName;
}
Set the name of the destroy method. The default is null
in which case there is no destroy method. |
public void setEnforceDestroyMethod(boolean enforceDestroyMethod) {
this.enforceDestroyMethod = enforceDestroyMethod;
}
Specify whether or not the configured destroy method is the default.
Default value is false. |
public void setEnforceInitMethod(boolean enforceInitMethod) {
this.enforceInitMethod = enforceInitMethod;
}
Specify whether or not the configured init method is the default.
Default value is false. |
public void setFactoryBeanName(String factoryBeanName) {
this.factoryBeanName = factoryBeanName;
}
|
public void setFactoryMethodName(String factoryMethodName) {
this.factoryMethodName = factoryMethodName;
}
|
public void setInitMethodName(String initMethodName) {
this.initMethodName = initMethodName;
}
Set the name of the initializer method. The default is null
in which case there is no initializer method. |
public void setLazyInit(boolean lazyInit) {
this.lazyInit = 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. |
public void setMethodOverrides(MethodOverrides methodOverrides) {
this.methodOverrides = (methodOverrides != null ? methodOverrides : new MethodOverrides());
}
Specify method overrides for the bean, if any. |
public void setOriginatingBeanDefinition(BeanDefinition originatingBd) {
this.resource = new BeanDefinitionResource(originatingBd);
}
Set the originating (e.g. decorated) BeanDefinition, if any. |
public void setPrimary(boolean primary) {
this.primary = primary;
}
Set whether this bean is a primary autowire candidate.
If this value is true for exactly one bean among multiple
matching candidates, it will serve as a tie-breaker. |
public void setPropertyValues(MutablePropertyValues propertyValues) {
this.propertyValues = (propertyValues != null ? propertyValues : new MutablePropertyValues());
}
Specify property values for this bean, if any. |
public void setResource(Resource resource) {
this.resource = resource;
}
Set the resource that this bean definition came from
(for the purpose of showing context in case of errors). |
public void setResourceDescription(String resourceDescription) {
this.resource = new DescriptiveResource(resourceDescription);
}
Set a description of the resource that this bean definition
came from (for the purpose of showing context in case of errors). |
public void setRole(int role) {
this.role = role;
}
Set the role hint for this BeanDefinition. |
public void setScope(String scope) {
Assert.notNull(scope, "Scope must not be null");
this.scope = scope;
this.singleton = SCOPE_SINGLETON.equals(scope);
this.prototype = SCOPE_PROTOTYPE.equals(scope);
}
Set the name of the target scope for the bean.
Default is "singleton"; the out-of-the-box alternative is "prototype".
Extended bean factories might support further scopes. |
public void setSingleton(boolean singleton) {
this.scope = (singleton ? SCOPE_SINGLETON : SCOPE_PROTOTYPE);
this.singleton = singleton;
this.prototype = !singleton;
} Deprecated! since - Spring 2.5, in favor of #setScope
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".
Note that as of Spring 2.0, this flag is just an alternative way to
specify scope="singleton" or scope="prototype". |
public void setSynthetic(boolean synthetic) {
this.synthetic = 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>). |
public String toString() {
StringBuffer sb = new StringBuffer("class [");
sb.append(getBeanClassName()).append("]");
sb.append("; scope=").append(this.scope);
sb.append("; abstract=").append(this.abstractFlag);
sb.append("; lazyInit=").append(this.lazyInit);
sb.append("; autowireMode=").append(this.autowireMode);
sb.append("; dependencyCheck=").append(this.dependencyCheck);
sb.append("; autowireCandidate=").append(this.autowireCandidate);
sb.append("; primary=").append(this.primary);
sb.append("; factoryBeanName=").append(this.factoryBeanName);
sb.append("; factoryMethodName=").append(this.factoryMethodName);
sb.append("; initMethodName=").append(this.initMethodName);
sb.append("; destroyMethodName=").append(this.destroyMethodName);
if (this.resource != null) {
sb.append("; defined in ").append(this.resource.getDescription());
}
return sb.toString();
}
|
public void validate() throws BeanDefinitionValidationException {
if (!getMethodOverrides().isEmpty() && getFactoryMethodName() != null) {
throw new BeanDefinitionValidationException(
"Cannot combine static factory method with method overrides: " +
"the static factory method must create the instance");
}
if (hasBeanClass()) {
prepareMethodOverrides();
}
}
Validate this bean definition. |