commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgo...@apache.org
Subject svn commit: r766570 - in /commons/proper/configuration/trunk/src/java/org/apache/commons/configuration: DefaultConfigurationBuilder.java resolver/CatalogResolver.java
Date Mon, 20 Apr 2009 04:44:16 GMT
Author: rgoers
Date: Mon Apr 20 04:44:15 2009
New Revision: 766570

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

Modified:
    commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DefaultConfigurationBuilder.java
    commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/resolver/CatalogResolver.java

Modified: commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DefaultConfigurationBuilder.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DefaultConfigurationBuilder.java?rev=766570&r1=766569&r2=766570&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DefaultConfigurationBuilder.java
(original)
+++ commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/DefaultConfigurationBuilder.java
Mon Apr 20 04:44:15 2009
@@ -746,7 +746,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/trunk/src/java/org/apache/commons/configuration/resolver/CatalogResolver.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/resolver/CatalogResolver.java?rev=766570&r1=766569&r2=766570&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/resolver/CatalogResolver.java
(original)
+++ commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/resolver/CatalogResolver.java
Mon Apr 20 04:44:15 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.configuration.FileSystem;
 
 import java.net.URL;
 import java.io.InputStream;
@@ -50,12 +51,18 @@
     /**
      * 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 +91,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,28 +159,15 @@
 
             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)
             {
+                e.printStackTrace();
                 log.debug("Failed to create InputSource for " + resolved + " ("
                                 + e.toString() + ")");
                 return null;



Mime
View raw message