Removed parsing support for the 'singleton' attribute in an XML bean definition
Following the introduction of spring-beans-4.0.xsd and the corresponding removal of the pre-2.0 spring-beans.dtd. Issue: SPR-10437
This commit is contained in:
@@ -136,10 +136,6 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
|
||||
|
||||
private String scope = SCOPE_DEFAULT;
|
||||
|
||||
private boolean singleton = true;
|
||||
|
||||
private boolean prototype = false;
|
||||
|
||||
private boolean abstractFlag = false;
|
||||
|
||||
private boolean lazyInit = false;
|
||||
@@ -409,8 +405,6 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
|
||||
*/
|
||||
public void setScope(String scope) {
|
||||
this.scope = scope;
|
||||
this.singleton = SCOPE_SINGLETON.equals(scope) || SCOPE_DEFAULT.equals(scope);
|
||||
this.prototype = SCOPE_PROTOTYPE.equals(scope);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -420,33 +414,13 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
|
||||
return this.scope;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set if this a <b>Singleton</b>, with a single, shared instance returned
|
||||
* on all calls. In case of "false", the BeanFactory will apply the <b>Prototype</b>
|
||||
* design pattern, with each caller requesting an instance getting an independent
|
||||
* instance. How this is exactly defined will depend on the BeanFactory.
|
||||
* <p>"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".
|
||||
* @deprecated since Spring 2.5, in favor of {@link #setScope}
|
||||
* @see #setScope
|
||||
* @see #SCOPE_SINGLETON
|
||||
* @see #SCOPE_PROTOTYPE
|
||||
*/
|
||||
@Deprecated
|
||||
public void setSingleton(boolean singleton) {
|
||||
this.scope = (singleton ? SCOPE_SINGLETON : SCOPE_PROTOTYPE);
|
||||
this.singleton = singleton;
|
||||
this.prototype = !singleton;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether this a <b>Singleton</b>, with a single shared instance
|
||||
* returned from all calls.
|
||||
* @see #SCOPE_SINGLETON
|
||||
*/
|
||||
public boolean isSingleton() {
|
||||
return this.singleton;
|
||||
return SCOPE_SINGLETON.equals(scope) || SCOPE_DEFAULT.equals(scope);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -455,7 +429,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
|
||||
* @see #SCOPE_PROTOTYPE
|
||||
*/
|
||||
public boolean isPrototype() {
|
||||
return this.prototype;
|
||||
return SCOPE_PROTOTYPE.equals(scope);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -166,28 +166,6 @@ public class BeanDefinitionBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the name of the factory bean to use for this definition.
|
||||
* @deprecated since Spring 2.5, in favor of preparing this on the
|
||||
* {@link #getRawBeanDefinition() raw BeanDefinition object}
|
||||
*/
|
||||
@Deprecated
|
||||
public BeanDefinitionBuilder setFactoryBean(String factoryBean, String factoryMethod) {
|
||||
this.beanDefinition.setFactoryBeanName(factoryBean);
|
||||
this.beanDefinition.setFactoryMethodName(factoryMethod);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an indexed constructor arg value. The current index is tracked internally
|
||||
* and all additions are at the present point.
|
||||
* @deprecated since Spring 2.5, in favor of {@link #addConstructorArgValue}
|
||||
*/
|
||||
@Deprecated
|
||||
public BeanDefinitionBuilder addConstructorArg(Object value) {
|
||||
return addConstructorArgValue(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an indexed constructor arg value. The current index is tracked internally
|
||||
* and all additions are at the present point.
|
||||
@@ -253,17 +231,6 @@ public class BeanDefinitionBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether or not this definition describes a singleton bean,
|
||||
* as alternative to {@link #setScope}.
|
||||
* @deprecated since Spring 2.5, in favor of {@link #setScope}
|
||||
*/
|
||||
@Deprecated
|
||||
public BeanDefinitionBuilder setSingleton(boolean singleton) {
|
||||
this.beanDefinition.setSingleton(singleton);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether or not this definition is abstract.
|
||||
*/
|
||||
@@ -319,26 +286,4 @@ public class BeanDefinitionBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the source of this definition.
|
||||
* @deprecated since Spring 2.5, in favor of preparing this on the
|
||||
* {@link #getRawBeanDefinition() raw BeanDefinition object}
|
||||
*/
|
||||
@Deprecated
|
||||
public BeanDefinitionBuilder setSource(Object source) {
|
||||
this.beanDefinition.setSource(source);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the description associated with this definition.
|
||||
* @deprecated since Spring 2.5, in favor of preparing this on the
|
||||
* {@link #getRawBeanDefinition() raw BeanDefinition object}
|
||||
*/
|
||||
@Deprecated
|
||||
public BeanDefinitionBuilder setResourceDescription(String resourceDescription) {
|
||||
this.beanDefinition.setResourceDescription(resourceDescription);
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -113,33 +113,6 @@ public class RootBeanDefinition extends AbstractBeanDefinition {
|
||||
setBeanClass(beanClass);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new RootBeanDefinition with the given singleton status.
|
||||
* @param beanClass the class of the bean to instantiate
|
||||
* @param singleton the singleton status of the bean
|
||||
* @deprecated since Spring 2.5, in favor of {@link #setScope}
|
||||
*/
|
||||
@Deprecated
|
||||
public RootBeanDefinition(Class beanClass, boolean singleton) {
|
||||
super();
|
||||
setBeanClass(beanClass);
|
||||
setSingleton(singleton);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new RootBeanDefinition for a singleton,
|
||||
* using the given autowire mode.
|
||||
* @param beanClass the class of the bean to instantiate
|
||||
* @param autowireMode by name or type, using the constants in this interface
|
||||
* @deprecated as of Spring 3.0, in favor of {@link #setAutowireMode} usage
|
||||
*/
|
||||
@Deprecated
|
||||
public RootBeanDefinition(Class beanClass, int autowireMode) {
|
||||
super();
|
||||
setBeanClass(beanClass);
|
||||
setAutowireMode(autowireMode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new RootBeanDefinition for a singleton,
|
||||
* using the given autowire mode.
|
||||
@@ -157,34 +130,6 @@ public class RootBeanDefinition extends AbstractBeanDefinition {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new RootBeanDefinition for a singleton,
|
||||
* providing property values.
|
||||
* @param beanClass the class of the bean to instantiate
|
||||
* @param pvs the property values to apply
|
||||
* @deprecated as of Spring 3.0, in favor of {@link #getPropertyValues} usage
|
||||
*/
|
||||
@Deprecated
|
||||
public RootBeanDefinition(Class beanClass, MutablePropertyValues pvs) {
|
||||
super(null, pvs);
|
||||
setBeanClass(beanClass);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new RootBeanDefinition with the given singleton status,
|
||||
* providing property values.
|
||||
* @param beanClass the class of the bean to instantiate
|
||||
* @param pvs the property values to apply
|
||||
* @param singleton the singleton status of the bean
|
||||
* @deprecated since Spring 2.5, in favor of {@link #setScope}
|
||||
*/
|
||||
@Deprecated
|
||||
public RootBeanDefinition(Class beanClass, MutablePropertyValues pvs, boolean singleton) {
|
||||
super(null, pvs);
|
||||
setBeanClass(beanClass);
|
||||
setSingleton(singleton);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new RootBeanDefinition for a singleton,
|
||||
* providing constructor arguments and property values.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -137,8 +137,6 @@ public class BeanDefinitionParserDelegate {
|
||||
|
||||
public static final String SCOPE_ATTRIBUTE = "scope";
|
||||
|
||||
public static final String SINGLETON_ATTRIBUTE = "singleton";
|
||||
|
||||
public static final String LAZY_INIT_ATTRIBUTE = "lazy-init";
|
||||
|
||||
public static final String AUTOWIRE_ATTRIBUTE = "autowire";
|
||||
@@ -598,16 +596,7 @@ public class BeanDefinitionParserDelegate {
|
||||
BeanDefinition containingBean, AbstractBeanDefinition bd) {
|
||||
|
||||
if (ele.hasAttribute(SCOPE_ATTRIBUTE)) {
|
||||
// Spring 2.x "scope" attribute
|
||||
bd.setScope(ele.getAttribute(SCOPE_ATTRIBUTE));
|
||||
if (ele.hasAttribute(SINGLETON_ATTRIBUTE)) {
|
||||
error("Specify either 'scope' or 'singleton', not both", ele);
|
||||
}
|
||||
}
|
||||
else if (ele.hasAttribute(SINGLETON_ATTRIBUTE)) {
|
||||
// Spring 1.x "singleton" attribute
|
||||
bd.setScope(TRUE_VALUE.equals(ele.getAttribute(SINGLETON_ATTRIBUTE)) ?
|
||||
BeanDefinition.SCOPE_SINGLETON : BeanDefinition.SCOPE_PROTOTYPE);
|
||||
}
|
||||
else if (containingBean != null) {
|
||||
// Take default from containing bean in case of an inner bean definition.
|
||||
|
||||
Reference in New Issue
Block a user