You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by ff...@apache.org on 2009/08/06 05:02:05 UTC

svn commit: r801503 - /servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/ContextFinder.java

Author: ffang
Date: Thu Aug  6 03:02:05 2009
New Revision: 801503

URL: http://svn.apache.org/viewvc?rev=801503&view=rev
Log:
[SMX4-331]contextFinder do not invoke createContext(String, ClassLoader) method

Modified:
    servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/ContextFinder.java

Modified: servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/ContextFinder.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/ContextFinder.java?rev=801503&r1=801502&r2=801503&view=diff
==============================================================================
--- servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/ContextFinder.java (original)
+++ servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/ContextFinder.java Thu Aug  6 03:02:05 2009
@@ -32,12 +32,13 @@
 
     public static JAXBContext find(String contextPath, ClassLoader classLoader, Map properties) throws JAXBException {
         String className = null;
+        // Patch for bug https://issues.apache.org/activemq/browse/SMX4-329
         if (contextPath == null || contextPath.length() == 0) {
-            throw new JAXBException("Invalid contextPath");
-        }
+            throw new JAXBException("Invalid contextPath (empty or null)");
+  	    }
         String[] packages = contextPath.split(":");
         if (packages == null || packages.length == 0) {
-            throw new JAXBException("Invalid contextPath");
+            throw new JAXBException("Invalid contextPath (no packages)");
         }
         for (String pkg : packages) {
             String url = pkg.replace('.', '/') + "/jaxb.properties";
@@ -61,6 +62,13 @@
             Method m = spi.getMethod("createContext", new Class[] { String.class, ClassLoader.class, Map.class });
             return (JAXBContext) m.invoke(null, new Object[] { contextPath, classLoader, properties });
         } catch (Throwable t) {
+            // Ignored
+        }
+        // Fallback for JAXB 1.0 compatibility (at least JAXB TCK tests are using that feature)
+        try {
+            Method m = spi.getMethod("createContext", new Class[] { String.class, ClassLoader.class, });
+            return (JAXBContext) m.invoke(null, new Object[] { contextPath, classLoader });
+        } catch (Throwable t) {
             throw new JAXBException("Unable to create context", t);
         }
     }
@@ -170,3 +178,4 @@
 
 
 }
+