Further compensations for STS; binary compat fixes
Defensively catch NoSuchMethodError when calling BDPD.getEnvironment() and supply a DefaultEnvironment if not available. Replace the single-arg constructor for BDPD and deprecate, preserving binary compat particularly for Spring Integration who instantiates this class directly, which is unusual. git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@3982 50f2f4bb-b051-0410-bef5-90022cba6387
This commit is contained in:
parent
3fbe9d5a55
commit
1a751de04f
|
|
@ -27,6 +27,7 @@ import java.util.Set;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.w3c.dom.NamedNodeMap;
|
import org.w3c.dom.NamedNodeMap;
|
||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
|
|
@ -58,6 +59,7 @@ import org.springframework.beans.factory.support.ManagedProperties;
|
||||||
import org.springframework.beans.factory.support.ManagedSet;
|
import org.springframework.beans.factory.support.ManagedSet;
|
||||||
import org.springframework.beans.factory.support.MethodOverrides;
|
import org.springframework.beans.factory.support.MethodOverrides;
|
||||||
import org.springframework.beans.factory.support.ReplaceOverride;
|
import org.springframework.beans.factory.support.ReplaceOverride;
|
||||||
|
import org.springframework.core.env.DefaultEnvironment;
|
||||||
import org.springframework.core.env.Environment;
|
import org.springframework.core.env.Environment;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.util.ClassUtils;
|
import org.springframework.util.ClassUtils;
|
||||||
|
|
@ -265,6 +267,17 @@ public class BeanDefinitionParserDelegate {
|
||||||
this.environment = environment;
|
this.environment = environment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new BeanDefinitionParserDelegate associated with the
|
||||||
|
* supplied {@link XmlReaderContext} and a new {@link DefaultEnvironment}.
|
||||||
|
* @deprecated since Spring 3.1 in favor of
|
||||||
|
* {@link #BeanDefinitionParserDelegate(XmlReaderContext, Environment)}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public BeanDefinitionParserDelegate(XmlReaderContext readerContext) {
|
||||||
|
this(readerContext, new DefaultEnvironment());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the {@link XmlReaderContext} associated with this helper instance.
|
* Get the {@link XmlReaderContext} associated with this helper instance.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ import org.springframework.beans.factory.parsing.ProblemReporter;
|
||||||
import org.springframework.beans.factory.parsing.ReaderContext;
|
import org.springframework.beans.factory.parsing.ReaderContext;
|
||||||
import org.springframework.beans.factory.xml.BeanDefinitionParser;
|
import org.springframework.beans.factory.xml.BeanDefinitionParser;
|
||||||
import org.springframework.beans.factory.xml.ParserContext;
|
import org.springframework.beans.factory.xml.ParserContext;
|
||||||
|
import org.springframework.core.env.DefaultEnvironment;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -54,11 +55,19 @@ public abstract class AbstractSpecificationBeanDefinitionParser implements BeanD
|
||||||
specContext.setRegistry(parserContext.getRegistry());
|
specContext.setRegistry(parserContext.getRegistry());
|
||||||
specContext.setRegistrar(new ComponentRegistrarAdapter(parserContext));
|
specContext.setRegistrar(new ComponentRegistrarAdapter(parserContext));
|
||||||
specContext.setResourceLoader(parserContext.getReaderContext().getResourceLoader());
|
specContext.setResourceLoader(parserContext.getReaderContext().getResourceLoader());
|
||||||
specContext.setEnvironment(parserContext.getDelegate().getEnvironment());
|
try {
|
||||||
|
// again, STS constraints around the addition of the new getEnvironment()
|
||||||
|
// method in 3.1.0 (it's not present in STS current spring version, 3.0.5)
|
||||||
|
// TODO 3.1 GA: remove this block prior to 3.1 GA
|
||||||
|
specContext.setEnvironment(parserContext.getDelegate().getEnvironment());
|
||||||
|
} catch (NoSuchMethodError ex) {
|
||||||
|
specContext.setEnvironment(new DefaultEnvironment());
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
// access the reader context's problem reporter reflectively in order to
|
// access the reader context's problem reporter reflectively in order to
|
||||||
// compensate for tooling (STS) constraints around introduction of changes
|
// compensate for tooling (STS) constraints around introduction of changes
|
||||||
// to parser context / reader context classes.
|
// to parser context / reader context classes.
|
||||||
|
// TODO 3.1 GA: remove this block prior to 3.1 GA
|
||||||
Field field = ReaderContext.class.getDeclaredField("problemReporter");
|
Field field = ReaderContext.class.getDeclaredField("problemReporter");
|
||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
ProblemReporter problemReporter = (ProblemReporter)field.get(parserContext.getReaderContext());
|
ProblemReporter problemReporter = (ProblemReporter)field.get(parserContext.getReaderContext());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue