You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2007/10/19 17:27:21 UTC

svn commit: r586501 - /incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java

Author: dkulp
Date: Fri Oct 19 08:27:20 2007
New Revision: 586501

URL: http://svn.apache.org/viewvc?rev=586501&view=rev
Log:
CXF-1121 - patch from Adrian Nistor applied.   Thanks!

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

Modified: incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java?rev=586501&r1=586500&r2=586501&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java (original)
+++ incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java Fri Oct 19 08:27:20 2007
@@ -23,12 +23,15 @@
 import java.lang.reflect.Field;
 import java.lang.reflect.GenericArrayType;
 import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.Set;
 
+import javax.xml.bind.annotation.XmlTransient;
+
 import org.apache.cxf.common.util.PackageUtils;
 import org.apache.cxf.service.ServiceModelVisitor;
 import org.apache.cxf.service.model.MessagePartInfo;
@@ -172,28 +175,33 @@
         }
     }
 
-    
-    private void walkReferences(Class<?> cls) {
-        if (cls.getName().startsWith("java.")
-            || cls.getName().startsWith("javax.")) {
-            return;
-        }
-        //walk the public fields/methods to try and find all the classes.  JAXB will only load the 
-        //EXACT classes in the fields/methods if they are in a different package.   Thus,
-        //subclasses won't be found and the xsi:type stuff won't work at all.
+    private void walkReferences(Class<?> cls) { 
+        if (cls.getName().startsWith("java.") 
+            || cls.getName().startsWith("javax.")) { 
+            return; 
+        } 
+        //walk the public fields/methods to try and find all the classes. JAXB will only load the 
+        //EXACT classes in the fields/methods if they are in a different package. Thus, 
+        //subclasses won't be found and the xsi:type stuff won't work at all. 
         //We'll grab the public field/method types and then add the ObjectFactory stuff 
-        //as well as look for jaxb.index files in those packages.
-        
-        Field fields[] = cls.getFields();
-        for (Field f : fields) {
-            addType(f.getGenericType());
-        }
-        Method methods[] = cls.getMethods();
-        for (Method m : methods) {
-            addType(m.getGenericReturnType());
-            for (Type t : m.getGenericParameterTypes()) {
-                addType(t);
-            }
-        }
-    }
+        //as well as look for jaxb.index files in those packages. 
+
+        Field fields[] = cls.getFields(); 
+        for (Field f : fields) { 
+            if (f.getAnnotation(XmlTransient.class) == null
+                && !Modifier.isStatic(f.getModifiers())) { 
+                addType(f.getGenericType()); 
+            } 
+        } 
+        Method methods[] = cls.getMethods(); 
+        for (Method m : methods) { 
+            if (m.getAnnotation(XmlTransient.class) == null
+                && !Modifier.isStatic(m.getModifiers())) { 
+                addType(m.getGenericReturnType()); 
+                for (Type t : m.getGenericParameterTypes()) { 
+                    addType(t); 
+                } 
+            } 
+        } 
+    } 
 }