Streamline XML namespace support towards unversioned schemas

This commit also removes support code for outdated options which were only available in older schema versions.

Issue: SPR-13499
This commit is contained in:
Juergen Hoeller
2016-07-05 20:50:00 +02:00
parent 12d373659a
commit bc2c22d51e
217 changed files with 413 additions and 41094 deletions

View File

@@ -125,7 +125,7 @@ public class RootBeanDefinition extends AbstractBeanDefinition {
setBeanClass(beanClass);
setAutowireMode(autowireMode);
if (dependencyCheck && getResolvedAutowireMode() != AUTOWIRE_CONSTRUCTOR) {
setDependencyCheck(RootBeanDefinition.DEPENDENCY_CHECK_OBJECTS);
setDependencyCheck(DEPENDENCY_CHECK_OBJECTS);
}
}

View File

@@ -58,7 +58,6 @@ import org.springframework.beans.factory.support.ManagedProperties;
import org.springframework.beans.factory.support.ManagedSet;
import org.springframework.beans.factory.support.MethodOverrides;
import org.springframework.beans.factory.support.ReplaceOverride;
import org.springframework.core.env.Environment;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.util.CollectionUtils;
@@ -142,8 +141,6 @@ public class BeanDefinitionParserDelegate {
public static final String PRIMARY_ATTRIBUTE = "primary";
public static final String DEPENDENCY_CHECK_ATTRIBUTE = "dependency-check";
public static final String DEPENDS_ON_ATTRIBUTE = "depends-on";
public static final String INIT_METHOD_ATTRIBUTE = "init-method";
@@ -186,8 +183,6 @@ public class BeanDefinitionParserDelegate {
public static final String BEAN_REF_ATTRIBUTE = "bean";
public static final String LOCAL_REF_ATTRIBUTE = "local";
public static final String PARENT_REF_ATTRIBUTE = "parent";
public static final String VALUE_ELEMENT = "value";
@@ -351,10 +346,6 @@ public class BeanDefinitionParserDelegate {
}
defaults.setAutowire(autowire);
// Don't fall back to parentDefaults for dependency-check as it's no longer supported in
// <beans> as of 3.0. Therefore, no nested <beans> would ever need to fall back to it.
defaults.setDependencyCheck(root.getAttribute(DEFAULT_DEPENDENCY_CHECK_ATTRIBUTE));
if (root.hasAttribute(DEFAULT_AUTOWIRE_CANDIDATES_ATTRIBUTE)) {
defaults.setAutowireCandidates(root.getAttribute(DEFAULT_AUTOWIRE_CANDIDATES_ATTRIBUTE));
}
@@ -394,7 +385,6 @@ public class BeanDefinitionParserDelegate {
public BeanDefinitionDefaults getBeanDefinitionDefaults() {
BeanDefinitionDefaults bdd = new BeanDefinitionDefaults();
bdd.setLazyInit("TRUE".equalsIgnoreCase(this.defaults.getLazyInit()));
bdd.setDependencyCheck(this.getDependencyCheck(DEFAULT_VALUE));
bdd.setAutowireMode(this.getAutowireMode(DEFAULT_VALUE));
bdd.setInitMethodName(this.defaults.getInitMethod());
bdd.setDestroyMethodName(this.defaults.getDestroyMethod());
@@ -593,9 +583,6 @@ public class BeanDefinitionParserDelegate {
String autowire = ele.getAttribute(AUTOWIRE_ATTRIBUTE);
bd.setAutowireMode(getAutowireMode(autowire));
String dependencyCheck = ele.getAttribute(DEPENDENCY_CHECK_ATTRIBUTE);
bd.setDependencyCheck(getDependencyCheck(dependencyCheck));
if (ele.hasAttribute(DEPENDS_ON_ATTRIBUTE)) {
String dependsOn = ele.getAttribute(DEPENDS_ON_ATTRIBUTE);
bd.setDependsOn(StringUtils.tokenizeToStringArray(dependsOn, MULTI_VALUE_ATTRIBUTE_DELIMITERS));
@@ -703,25 +690,6 @@ public class BeanDefinitionParserDelegate {
return autowire;
}
public int getDependencyCheck(String attValue) {
String att = attValue;
if (DEFAULT_VALUE.equals(att)) {
att = this.defaults.getDependencyCheck();
}
if (DEPENDENCY_CHECK_ALL_ATTRIBUTE_VALUE.equals(att)) {
return AbstractBeanDefinition.DEPENDENCY_CHECK_ALL;
}
else if (DEPENDENCY_CHECK_OBJECTS_ATTRIBUTE_VALUE.equals(att)) {
return AbstractBeanDefinition.DEPENDENCY_CHECK_OBJECTS;
}
else if (DEPENDENCY_CHECK_SIMPLE_ATTRIBUTE_VALUE.equals(att)) {
return AbstractBeanDefinition.DEPENDENCY_CHECK_SIMPLE;
}
else {
return AbstractBeanDefinition.DEPENDENCY_CHECK_NONE;
}
}
/**
* Parse constructor-arg sub-elements of the given bean element.
*/
@@ -1020,16 +988,12 @@ public class BeanDefinitionParserDelegate {
String refName = ele.getAttribute(BEAN_REF_ATTRIBUTE);
boolean toParent = false;
if (!StringUtils.hasLength(refName)) {
// A reference to the id of another bean in the same XML file.
refName = ele.getAttribute(LOCAL_REF_ATTRIBUTE);
// A reference to the id of another bean in a parent context.
refName = ele.getAttribute(PARENT_REF_ATTRIBUTE);
toParent = true;
if (!StringUtils.hasLength(refName)) {
// A reference to the id of another bean in a parent context.
refName = ele.getAttribute(PARENT_REF_ATTRIBUTE);
toParent = true;
if (!StringUtils.hasLength(refName)) {
error("'bean', 'local' or 'parent' is required for <ref> element", ele);
return null;
}
error("'bean' or 'parent' is required for <ref> element", ele);
return null;
}
}
if (!StringUtils.hasText(refName)) {
@@ -1081,12 +1045,8 @@ public class BeanDefinitionParserDelegate {
// A generic reference to any name of any bean.
String refName = ele.getAttribute(BEAN_REF_ATTRIBUTE);
if (!StringUtils.hasLength(refName)) {
// A reference to the id of another bean in the same XML file.
refName = ele.getAttribute(LOCAL_REF_ATTRIBUTE);
if (!StringUtils.hasLength(refName)) {
error("Either 'bean' or 'local' is required for <idref> element", ele);
return null;
}
error("'bean' is required for <idref> element", ele);
return null;
}
if (!StringUtils.hasText(refName)) {
error("<idref> element contains empty target attribute", ele);
@@ -1469,8 +1429,10 @@ public class BeanDefinitionParserDelegate {
/**
* Get the namespace URI for the supplied node. The default implementation uses {@link Node#getNamespaceURI}.
* Subclasses may override the default implementation to provide a different namespace identification mechanism.
* Get the namespace URI for the supplied node.
* <p>The default implementation uses {@link Node#getNamespaceURI}.
* Subclasses may override the default implementation to provide a
* different namespace identification mechanism.
* @param node the node
*/
public String getNamespaceURI(Node node) {
@@ -1478,8 +1440,10 @@ public class BeanDefinitionParserDelegate {
}
/**
* Ges the local name for the supplied {@link Node}. The default implementation calls {@link Node#getLocalName}.
* Subclasses may override the default implementation to provide a different mechanism for getting the local name.
* Ges the local name for the supplied {@link Node}.
* <p>The default implementation calls {@link Node#getLocalName}.
* Subclasses may override the default implementation to provide a
* different mechanism for getting the local name.
* @param node the {@code Node}
*/
public String getLocalName(Node node) {

View File

@@ -34,8 +34,6 @@ public class DocumentDefaultsDefinition implements DefaultsDefinition {
private String autowire;
private String dependencyCheck;
private String autowireCandidates;
private String initMethod;
@@ -87,20 +85,6 @@ public class DocumentDefaultsDefinition implements DefaultsDefinition {
return this.autowire;
}
/**
* Set the default dependency-check setting for the document that's currently parsed.
*/
public void setDependencyCheck(String dependencyCheck) {
this.dependencyCheck = dependencyCheck;
}
/**
* Return the default dependency-check setting for the document that's currently parsed.
*/
public String getDependencyCheck() {
return this.dependencyCheck;
}
/**
* Set the default autowire-candidate pattern for the document that's currently parsed.
* Also accepts a comma-separated list of patterns.