svn commit: r1850144 - in /xmlbeans/trunk: ./ src/common/org/apache/xmlbeans/impl/common/ src/saaj_api/org/apache/xmlbeans/impl/soap/ src/store/org/apache/xmlbeans/impl/store/ src/typeimpl/org/apache/xmlbeans/impl/schema/ src/xmlcomp/org/apache/xmlbean...

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1850144 - in /xmlbeans/trunk: ./ src/common/org/apache/xmlbeans/impl/common/ src/saaj_api/org/apache/xmlbeans/impl/soap/ src/store/org/apache/xmlbeans/impl/store/ src/typeimpl/org/apache/xmlbeans/impl/schema/ src/xmlcomp/org/apache/xmlbean...

fanningpj
Author: fanningpj
Date: Wed Jan  2 02:42:42 2019
New Revision: 1850144

URL: http://svn.apache.org/viewvc?rev=1850144&view=rev
Log:
XMLBEANS-526 try to make resource loading more robust

Added:
    xmlbeans/trunk/src/common/org/apache/xmlbeans/impl/common/DefaultClassLoaderResourceLoader.java   (with props)
Modified:
    xmlbeans/trunk/build.xml
    xmlbeans/trunk/src/saaj_api/org/apache/xmlbeans/impl/soap/FactoryFinder.java
    xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Path.java
    xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Query.java
    xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java
    xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/CommandLine.java
    xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlBeans.java

Modified: xmlbeans/trunk/build.xml
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/build.xml?rev=1850144&r1=1850143&r2=1850144&view=diff
==============================================================================
--- xmlbeans/trunk/build.xml (original)
+++ xmlbeans/trunk/build.xml Wed Jan  2 02:42:42 2019
@@ -19,7 +19,7 @@
     <property name="javac.source" value="1.6"/>
     <property name="javac.target" value="1.6"/>
 
-    <property name="version.base" value="3.0.2"/>
+    <property name="version.base" value="3.0.3"/>
     <property name="version.rc" value=""/>
 
     <!-- manifest entries -->

Added: xmlbeans/trunk/src/common/org/apache/xmlbeans/impl/common/DefaultClassLoaderResourceLoader.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/common/org/apache/xmlbeans/impl/common/DefaultClassLoaderResourceLoader.java?rev=1850144&view=auto
==============================================================================
--- xmlbeans/trunk/src/common/org/apache/xmlbeans/impl/common/DefaultClassLoaderResourceLoader.java (added)
+++ xmlbeans/trunk/src/common/org/apache/xmlbeans/impl/common/DefaultClassLoaderResourceLoader.java Wed Jan  2 02:42:42 2019
@@ -0,0 +1,43 @@
+/*   Copyright 2019 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.xmlbeans.impl.common;
+
+import java.io.InputStream;
+
+import org.apache.xmlbeans.ResourceLoader;
+
+public class DefaultClassLoaderResourceLoader implements ResourceLoader
+{
+    public InputStream getResourceAsStream(String resourceName) {
+        InputStream in = null;
+        try {
+            in = getResourceAsStream(Thread.currentThread().getContextClassLoader(), resourceName);
+        } catch (SecurityException securityexception) {}
+        if (in == null) {
+            in = getResourceAsStream(DefaultClassLoaderResourceLoader.class.getClassLoader(), resourceName);
+        }
+        if (in == null) {
+            in = DefaultClassLoaderResourceLoader.class.getResourceAsStream(resourceName);
+        }
+        return in;
+    }
+
+    public void close() {}
+
+    private InputStream getResourceAsStream(ClassLoader loader, String resourceName) {
+        return loader == null ? null : loader.getResourceAsStream(resourceName);
+    }
+}

Propchange: xmlbeans/trunk/src/common/org/apache/xmlbeans/impl/common/DefaultClassLoaderResourceLoader.java
------------------------------------------------------------------------------
    svn:executable = *

Modified: xmlbeans/trunk/src/saaj_api/org/apache/xmlbeans/impl/soap/FactoryFinder.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/saaj_api/org/apache/xmlbeans/impl/soap/FactoryFinder.java?rev=1850144&r1=1850143&r2=1850144&view=diff
==============================================================================
--- xmlbeans/trunk/src/saaj_api/org/apache/xmlbeans/impl/soap/FactoryFinder.java (original)
+++ xmlbeans/trunk/src/saaj_api/org/apache/xmlbeans/impl/soap/FactoryFinder.java Wed Jan  2 02:42:42 2019
@@ -149,6 +149,9 @@ class FactoryFinder {
         if (inputstream == null) {
             inputstream = FactoryFinder.class.getResourceAsStream(factoryResource);
         }
+        if (inputstream == null && FactoryFinder.class.getClassLoader() != null) {
+            inputstream = FactoryFinder.class.getClassLoader().getResourceAsStream(factoryResource);
+        }
         return inputstream;
     }
 }

Modified: xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Path.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Path.java?rev=1850144&r1=1850143&r2=1850144&view=diff
==============================================================================
--- xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Path.java (original)
+++ xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Path.java Wed Jan  2 02:42:42 2019
@@ -24,6 +24,7 @@ import java.lang.ref.WeakReference;
 import java.math.BigDecimal;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
 
+import org.apache.xmlbeans.impl.common.DefaultClassLoaderResourceLoader;
 import org.apache.xmlbeans.impl.common.XPath;
 import org.apache.xmlbeans.impl.common.XPath.XPathCompileException;
 import org.apache.xmlbeans.impl.common.XPath.ExecutionContext;
@@ -68,7 +69,7 @@ public abstract class Path
     static
     {
         String id = "META-INF/services/org.apache.xmlbeans.impl.store.PathDelegate.SelectPathInterface";
-        InputStream in = Path.class.getResourceAsStream(id);
+        InputStream in = new DefaultClassLoaderResourceLoader().getResourceAsStream(id);
         try
         {
             BufferedReader br = new BufferedReader(new InputStreamReader(in));

Modified: xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Query.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Query.java?rev=1850144&r1=1850143&r2=1850144&view=diff
==============================================================================
--- xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Query.java (original)
+++ xmlbeans/trunk/src/store/org/apache/xmlbeans/impl/store/Query.java Wed Jan  2 02:42:42 2019
@@ -16,6 +16,7 @@
 package org.apache.xmlbeans.impl.store;
 
 import org.apache.xmlbeans.*;
+import org.apache.xmlbeans.impl.common.DefaultClassLoaderResourceLoader;
 import org.apache.xmlbeans.impl.common.XPath;
 import org.w3c.dom.*;
 
@@ -53,7 +54,7 @@ public abstract class Query
     static
     {
         String id = "META-INF/services/org.apache.xmlbeans.impl.store.QueryDelegate.QueryInterface";
-        InputStream in = Query.class.getResourceAsStream(id);
+        InputStream in = new DefaultClassLoaderResourceLoader().getResourceAsStream(id);
         try
         {
             BufferedReader br = new BufferedReader(new InputStreamReader(in));

Modified: xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java?rev=1850144&r1=1850143&r2=1850144&view=diff
==============================================================================
--- xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java (original)
+++ xmlbeans/trunk/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java Wed Jan  2 02:42:42 2019
@@ -417,8 +417,14 @@ public class SchemaTypeSystemImpl extend
         try
         {
             is = SchemaTypeSystemImpl.class.getResourceAsStream(HOLDER_TEMPLATE_CLASSFILE);
-            if (is == null)
+            if (is == null) {
+                ClassLoaderResourceLoader clLoader = new ClassLoaderResourceLoader(SchemaTypeSystemImpl.class.getClassLoader());
+                is = clLoader.getResourceAsStream(HOLDER_TEMPLATE_CLASSFILE);
+                clLoader.close();
+            }
+            if (is == null) {
                 throw new SchemaTypeLoaderException("couldn't find resource: " + HOLDER_TEMPLATE_CLASSFILE, _name, null, SchemaTypeLoaderException.IO_EXCEPTION);
+            }
             in = new DataInputStream(is);
 
             os = _filer.createBinaryFile(indexClassName.replace('.', '/') + ".class");

Modified: xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/CommandLine.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/CommandLine.java?rev=1850144&r1=1850143&r2=1850144&view=diff
==============================================================================
--- xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/CommandLine.java (original)
+++ xmlbeans/trunk/src/xmlcomp/org/apache/xmlbeans/impl/tool/CommandLine.java Wed Jan  2 02:42:42 2019
@@ -16,6 +16,7 @@
 package org.apache.xmlbeans.impl.tool;
 
 import org.apache.xmlbeans.XmlBeans;
+import org.apache.xmlbeans.impl.common.DefaultClassLoaderResourceLoader;
 import org.apache.xmlbeans.impl.common.IOUtil;
 
 import java.io.File;
@@ -76,7 +77,7 @@ public class CommandLine
     {
         try
         {
-            IOUtil.copyCompletely(CommandLine.class.getResourceAsStream("LICENSE.txt"), System.out);
+            IOUtil.copyCompletely(new DefaultClassLoaderResourceLoader().getResourceAsStream("LICENSE.txt"), System.out);
         }
         catch (Exception e)
         {

Modified: xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlBeans.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlBeans.java?rev=1850144&r1=1850143&r2=1850144&view=diff
==============================================================================
--- xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlBeans.java (original)
+++ xmlbeans/trunk/src/xmlpublic/org/apache/xmlbeans/XmlBeans.java Wed Jan  2 02:42:42 2019
@@ -35,7 +35,7 @@ import org.w3c.dom.Node;
 public final class XmlBeans
 {
     private static String XMLBEANS_TITLE = "org.apache.xmlbeans";
-    private static String XMLBEANS_VERSION = "3.0.2";
+    private static String XMLBEANS_VERSION = "3.0.3";
     private static String XMLBEANS_VENDOR = "Apache Software Foundation";
 
     static



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]