cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1053868 - /cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
Date Thu, 30 Dec 2010 12:22:34 GMT
Author: sergeyb
Date: Thu Dec 30 12:22:34 2010
New Revision: 1053868

URL: http://svn.apache.org/viewvc?rev=1053868&view=rev
Log:
[JAX-RS] Minor update to AbstractJAXBProvider to simplify the checks and minimise the noise
to do with the creation of package contexts

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java?rev=1053868&r1=1053867&r2=1053868&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
Thu Dec 30 12:22:34 2010
@@ -385,7 +385,7 @@ public abstract class AbstractJAXBProvid
             JAXBContext context = packageContexts.get(packageName);
             if (context == null) {
                 try {
-                    if (type.getClassLoader() != null) { 
+                    if (type.getClassLoader() != null && objectFactoryOrIndexAvailable(type))
{ 
                         context = JAXBContext.newInstance(packageName, type.getClassLoader(),
cProperties);
                         packageContexts.put(packageName, context);
                     }
@@ -406,24 +406,19 @@ public abstract class AbstractJAXBProvid
         }
         return type.getAnnotation(XmlRootElement.class) != null
             || JAXBElement.class.isAssignableFrom(type)
-            || objectFactoryForClass(type)
+            || objectFactoryOrIndexAvailable(type)
             || (type != genericType && objectFactoryForType(genericType))
-            || getAdapter(type, anns) != null
-            || type.getResource("jaxb.index") != null;
+            || getAdapter(type, anns) != null;
     
     }
     
-    protected boolean objectFactoryForClass(Class<?> type) {
-        try {
-            return type.getClassLoader().loadClass(PackageUtils.getPackageName(type) 
-                                        + ".ObjectFactory") != null;
-        } catch (Exception ex) {
-            return false;
-        }
+    protected boolean objectFactoryOrIndexAvailable(Class<?> type) {
+        return type.getResource("ObjectFactory.class") != null
+               || type.getResource("jaxb.index") != null; 
     }
     
     private boolean objectFactoryForType(Type genericType) {
-        return objectFactoryForClass(InjectionUtils.getActualType(genericType));
+        return objectFactoryOrIndexAvailable(InjectionUtils.getActualType(genericType));
     }
     
     protected Unmarshaller createUnmarshaller(Class<?> cls, Type genericType) 



Mime
View raw message