cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1232498 - /cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java
Date Tue, 17 Jan 2012 17:25:32 GMT
Author: dkulp
Date: Tue Jan 17 17:25:32 2012
New Revision: 1232498

URL: http://svn.apache.org/viewvc?rev=1232498&view=rev
Log:
[CXF-4036] Update JAXBContextInitializer to look for XmlSeeAlso and
TypeAdapters on classes as well.
Patch from david ferbas applied

Modified:
    cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java

Modified: cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java?rev=1232498&r1=1232497&r2=1232498&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java
(original)
+++ cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java
Tue Jan 17 17:25:32 2012
@@ -271,31 +271,38 @@ class JAXBContextInitializer extends Ser
         } else {
             cls = JAXBUtils.getValidClass(cls);
             if (null != cls) {
+                if (classes.contains(cls)) {
+                    return;
+                }
+
+                if (!cls.isInterface()) {
+                    classes.add(cls);
+                }
+
+                XmlSeeAlso xsa = cls.getAnnotation(XmlSeeAlso.class);
+                if (xsa != null) {
+                    for (Class<?> c : xsa.value()) {
+                        addClass(c);
+                    }
+                }
+                XmlJavaTypeAdapter xjta = cls.getAnnotation(XmlJavaTypeAdapter.class);
+                if (xjta != null) {
+                    //has an adapter.   We need to inspect the adapter and then
+                    //return as the adapter will handle the superclass
+                    //and interfaces and such
+                    @SuppressWarnings("rawtypes")
+                    Class<? extends XmlAdapter> c2 = xjta.value();
+                    inspectTypeAdapter(c2);
+                    return;
+                }
+                
                 if (cls.getSuperclass() != null) {
                     //JAXB should do this, but it doesn't always.
                     //in particular, older versions of jaxb don't
                     addClass(cls.getSuperclass());
                 }
-                
-                if (cls.isInterface()) {
-                    //interfaces cannot be added directly, however, they
-                    //may have some interesting annoations we should consider
-                    XmlSeeAlso xsa = cls.getAnnotation(XmlSeeAlso.class);
-                    if (xsa != null) {
-                        for (Class<?> c : xsa.value()) {
-                            addClass(c);
-                        }
-                    }
-                    XmlJavaTypeAdapter xjta = cls.getAnnotation(XmlJavaTypeAdapter.class);
-                    if (xjta != null) {
-                        @SuppressWarnings("rawtypes")
-                        Class<? extends XmlAdapter> c2 = xjta.value();
-                        inspectTypeAdapter(c2);
-                    }
-                } else if (classes.contains(cls)) {
-                    return;
-                } else {
-                    classes.add(cls);
+
+                if (!cls.isInterface()) {
                     walkReferences(cls);
                 }
             }
@@ -410,11 +417,17 @@ class JAXBContextInitializer extends Ser
         if (method.getName().startsWith("is")) {
             beginIndex = 2;
         }
+        Method setter = null;
         try {
-            method.getDeclaringClass().getMethod("set" + method.getName().substring(beginIndex),
-                                                 new Class[] {method.getReturnType()});
+            setter = method.getDeclaringClass()
+                .getMethod("set" + method.getName().substring(beginIndex),
+                           new Class[] {method.getReturnType()});
         } catch (Exception e) {
             //getter, but no setter
+        }
+        if (setter == null 
+            || setter.isAnnotationPresent(XmlTransient.class)
+            || !Modifier.isPublic(setter.getModifiers())) {
             return false;
         }
 



Mime
View raw message