Author: rgoers
Date: Mon Apr 20 17:29:39 2009
New Revision: 766764

URL: http://svn.apache.org/viewvc?rev=766764&view=rev
Log:
CatalogResolver should use FileSystem so schemas can be retrieved using the 
same FileSystem as the XML files

Modified:
    
commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/DefaultConfigurationBuilder.java
    
commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/resolver/CatalogResolver.java

Modified: 
commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/DefaultConfigurationBuilder.java
URL: 
http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/DefaultConfigurationBuilder.java?rev=766764&r1=766763&r2=766764&view=diff
==============================================================================
--- 
commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/DefaultConfigurationBuilder.java
 (original)
+++ 
commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/DefaultConfigurationBuilder.java
 Mon Apr 20 17:29:39 2009
@@ -752,7 +752,9 @@
         if (getMaxIndex(KEY_ENTITY_RESOLVER) == 0)
         {
             XMLBeanDeclaration decl = new XMLBeanDeclaration(this, 
KEY_ENTITY_RESOLVER, true);
-            setEntityResolver((EntityResolver) BeanHelper.createBean(decl, 
CatalogResolver.class));
+            EntityResolver resolver = (EntityResolver) 
BeanHelper.createBean(decl, CatalogResolver.class);
+            BeanHelper.setProperty(resolver, "fileSystem", getFileSystem());
+            setEntityResolver(resolver);
         }
     }
 

Modified: 
commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/resolver/CatalogResolver.java
URL: 
http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/resolver/CatalogResolver.java?rev=766764&r1=766763&r2=766764&view=diff
==============================================================================
--- 
commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/resolver/CatalogResolver.java
 (original)
+++ 
commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/resolver/CatalogResolver.java
 Mon Apr 20 17:29:39 2009
@@ -22,6 +22,7 @@
 import org.apache.xml.resolver.CatalogManager;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.impl.NoOpLog;
+import org.apache.commons.configuration2.FileSystem;
 
 import java.net.URL;
 import java.io.InputStream;
@@ -50,12 +51,17 @@
     /**
      * The CatalogResolver
      */
-    private org.apache.xml.resolver.tools.CatalogResolver resolver;
+    protected org.apache.xml.resolver.tools.CatalogResolver resolver;
 
     /**
      * The CatalogManager
      */
-    private CatalogManager manager = new CatalogManager();
+    protected CatalogManager manager = new CatalogManager();
+
+     /**
+     * The FileSystem in use.
+     */
+    protected FileSystem fs = FileSystem.getDefaultFileSystem();
 
     /**
      * Stores the logger.
@@ -84,6 +90,15 @@
     }
 
     /**
+     * Set the FileSystem.
+     * @param fileSystem The FileSystem.
+     */
+    public void setFileSystem(FileSystem fileSystem)
+    {
+        this.fs = fileSystem;
+    }
+
+    /**
      * Enables debug logging of xml-commons Catalog processing.
      * @param debug True if debugging should be enabled, false otherwise.
      */
@@ -143,24 +158,10 @@
 
             try
             {
+                InputStream is = fs.getInputStream(null, resolved);
                 InputSource iSource = new InputSource(resolved);
                 iSource.setPublicId(publicId);
-
-                // Ideally this method would not attempt to open the
-                // InputStream, but there is a bug (in Xerces, at least)
-                // that causes the parser to mistakenly open the wrong
-                // system identifier if the returned InputSource does
-                // not have a byteStream.
-                //
-                // It could be argued that we still shouldn't do this here,
-                // but since the purpose of calling the entityResolver is
-                // almost certainly to open the input stream, it seems to
-                // do little harm.
-                //
-                URL url = new URL(resolved);
-                InputStream iStream = url.openStream();
-                iSource.setByteStream(iStream);
-
+                iSource.setByteStream(is);
                 return iSource;
             }
             catch (Exception e)


Reply via email to