From bcc6413ef75b563e93bf815153babe730da64918 Mon Sep 17 00:00:00 2001 From: Costin Leau Date: Mon, 9 Nov 2009 15:59:08 +0000 Subject: [PATCH] SPR-5762 + allow unknown URL protocols to be used with import directive --- .../DefaultBeanDefinitionDocumentReader.java | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/org.springframework.beans/src/main/java/org/springframework/beans/factory/xml/DefaultBeanDefinitionDocumentReader.java b/org.springframework.beans/src/main/java/org/springframework/beans/factory/xml/DefaultBeanDefinitionDocumentReader.java index 8e50e81007..aa5ccc0ec2 100644 --- a/org.springframework.beans/src/main/java/org/springframework/beans/factory/xml/DefaultBeanDefinitionDocumentReader.java +++ b/org.springframework.beans/src/main/java/org/springframework/beans/factory/xml/DefaultBeanDefinitionDocumentReader.java @@ -22,19 +22,18 @@ import java.util.Set; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - import org.springframework.beans.factory.BeanDefinitionStoreException; import org.springframework.beans.factory.config.BeanDefinitionHolder; import org.springframework.beans.factory.parsing.BeanComponentDefinition; import org.springframework.beans.factory.support.BeanDefinitionReaderUtils; import org.springframework.core.io.Resource; -import org.springframework.core.io.support.ResourcePatternUtils; +import org.springframework.util.ResourceUtils; import org.springframework.util.StringUtils; import org.springframework.util.SystemPropertyUtils; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; /** * Default implementation of the {@link BeanDefinitionDocumentReader} interface. @@ -168,7 +167,18 @@ public class DefaultBeanDefinitionDocumentReader implements BeanDefinitionDocume location = SystemPropertyUtils.resolvePlaceholders(location); Set actualResources = new LinkedHashSet(4); - if (ResourcePatternUtils.isUrl(location)) { + + // Discover whether the location is an absolute or relative URI + boolean absoluteLocation = false; + + try { + absoluteLocation = ResourceUtils.toURI(location).isAbsolute(); + } catch (Exception ex) { + // cannot convert to an URI, considering the location relative + } + + // check the + if (absoluteLocation) { try { int importCount = getReaderContext().getReader().loadBeanDefinitions(location, actualResources); if (logger.isDebugEnabled()) {