cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1360444 - in /cxf/trunk/rt/frontend/jaxrs/src: main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
Date Wed, 11 Jul 2012 22:18:03 GMT
Author: sergeyb
Date: Wed Jul 11 22:18:03 2012
New Revision: 1360444

URL: http://svn.apache.org/viewvc?rev=1360444&view=rev
Log:
Updating ResourceUtils to try to convet a given resource to URL first before trying other
options

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java?rev=1360444&r1=1360443&r2=1360444&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
Wed Jul 11 22:18:03 2012
@@ -412,18 +412,22 @@ public final class ResourceUtils {
         if (loc.startsWith(CLASSPATH_PREFIX)) {
             String path = loc.substring(CLASSPATH_PREFIX.length());
             url = ResourceUtils.getClasspathResourceURL(path, ResourceUtils.class, bus);
-            if (url == null) {
-                LOG.warning("No classpath resource " + loc + " is available on classpath");
-                return null;
-            }
         } else {
-            String actualLoc = loc.startsWith("file:") ? loc.substring(5) : loc;
-            File f = new File(actualLoc);
-            if (!f.exists()) {
-                LOG.warning("No file resource " + loc + " is available on local disk");
-                return null;
+            try {
+                url = new URL(loc);
+            } catch (Exception ex) {
+                // it can be either a classpath or file resource without a scheme
+                url = ResourceUtils.getClasspathResourceURL(loc, ResourceUtils.class, bus);
+                if (url == null) {
+                    File file = new File(loc);
+                    if (file.exists()) {
+                        url = file.toURI().toURL();
+                    }
+                }
             }
-            url = f.toURI().toURL();
+        }
+        if (url == null) {
+            LOG.warning("No resource " + loc + " is available");
         }
         return url;
     }

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java?rev=1360444&r1=1360443&r2=1360444&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
Wed Jul 11 22:18:03 2012
@@ -1180,7 +1180,7 @@ public class JAXBElementProviderTest ext
         List<String> locations = new ArrayList<String>();
         String loc = getClass().getClassLoader().getResource("test.xsd").toURI().getPath();
         
-        locations.add(loc);
+        locations.add("file:" + loc);
         provider.setSchemas(locations);
         Schema s = provider.getSchema();
         assertNotNull("schema can not be read from disk", s);
@@ -1213,7 +1213,7 @@ public class JAXBElementProviderTest ext
         JAXBElementProvider<Book2> provider = new JAXBElementProvider<Book2>();
         List<String> locations = new ArrayList<String>();
         String loc = getClass().getClassLoader().getResource("test.xsd").toURI().getPath();
-        locations.add(loc);
+        locations.add("file:" + loc);
         provider.setSchemas(locations);
         Schema s = provider.getSchema();
         assertNotNull("schema can not be read from disk", s);



Mime
View raw message