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.
This commit is contained in:
parent
9cc125531b
commit
b7d7fa7b7e
|
|
@ -27,6 +27,7 @@ import java.util.Set;
|
|||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
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.MethodOverrides;
|
||||
import org.springframework.beans.factory.support.ReplaceOverride;
|
||||
import org.springframework.core.env.DefaultEnvironment;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
|
@ -265,6 +267,17 @@ public class BeanDefinitionParserDelegate {
|
|||
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.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import org.springframework.beans.factory.parsing.ProblemReporter;
|
|||
import org.springframework.beans.factory.parsing.ReaderContext;
|
||||
import org.springframework.beans.factory.xml.BeanDefinitionParser;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.core.env.DefaultEnvironment;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
|
|
@ -54,11 +55,19 @@ public abstract class AbstractSpecificationBeanDefinitionParser implements BeanD
|
|||
specContext.setRegistry(parserContext.getRegistry());
|
||||
specContext.setRegistrar(new ComponentRegistrarAdapter(parserContext));
|
||||
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 {
|
||||
// access the reader context's problem reporter reflectively in order to
|
||||
// compensate for tooling (STS) constraints around introduction of changes
|
||||
// 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.setAccessible(true);
|
||||
ProblemReporter problemReporter = (ProblemReporter)field.get(parserContext.getReaderContext());
|
||||
|
|
|
|||
Loading…
Reference in New Issue