cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r810143 - in /cxf/trunk: common/common/src/main/java/org/apache/cxf/common/util/ rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/ rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ systests/uncategorized/src/test/java/org/apache/cx...
Date Tue, 01 Sep 2009 17:53:19 GMT
Author: dkulp
Date: Tue Sep  1 17:53:18 2009
New Revision: 810143

URL: http://svn.apache.org/viewvc?rev=810143&view=rev
Log:
[CXF-2411] Fix some issues with parameratized types and JAXB

Modified:
    cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/ASMHelper.java
    cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/WrapperClassGenerator.java
    cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/jaxws/ClientServerMiscTest.java
    cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/jaxws/DocLitWrappedCodeFirstService.java
    cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/jaxws/DocLitWrappedCodeFirstServiceImpl.java

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/ASMHelper.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/ASMHelper.java?rev=810143&r1=810142&r2=810143&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/ASMHelper.java (original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/ASMHelper.java Tue Sep
 1 17:53:18 2009
@@ -24,6 +24,7 @@
 import java.lang.reflect.Method;
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
@@ -99,6 +100,14 @@
         } else if (type instanceof GenericArrayType) {
             GenericArrayType at = (GenericArrayType)type;
             return "[" + getClassCode(at.getGenericComponentType());
+        } else if (type instanceof TypeVariable) {
+            TypeVariable tv = (TypeVariable)type;
+            Type[] bounds = tv.getBounds();
+            if (bounds != null && bounds.length == 1) {
+                return getClassCode(bounds[0]);
+            } else {
+                throw new IllegalArgumentException("Unable to determine type for: " + tv);
+            }
         } else if (type instanceof ParameterizedType) {
             ParameterizedType pt = (ParameterizedType)type;
             StringBuilder a = new StringBuilder(getClassCode(pt.getRawType()));

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=810143&r1=810142&r2=810143&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 Sep  1 17:53:18 2009
@@ -27,6 +27,7 @@
 import java.lang.reflect.Modifier;
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
 import java.util.Collection;
 import java.util.Set;
 
@@ -181,8 +182,24 @@
                 addType(t2);
             }
         } else if (cls instanceof GenericArrayType) {
+            Class ct;
             GenericArrayType gt = (GenericArrayType)cls;
-            Class ct = (Class) gt.getGenericComponentType();
+            Type componentType = gt.getGenericComponentType();
+            if (componentType instanceof Class) {
+                ct = (Class)componentType;
+            } else {
+                TypeVariable tv = (TypeVariable)componentType;
+                Type[] bounds = tv.getBounds();
+                if (bounds != null && bounds.length == 1) {
+                    if (bounds[0] instanceof Class) {
+                        ct = (Class)bounds[0];
+                    } else {
+                        throw new IllegalArgumentException("Unable to determine type for:
" + tv);
+                    }
+                } else {
+                    throw new IllegalArgumentException("Unable to determine type for: " +
tv);
+                }
+            }
             ct = Array.newInstance(ct, 0).getClass();
 
             addClass(ct);

Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/WrapperClassGenerator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/WrapperClassGenerator.java?rev=810143&r1=810142&r2=810143&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/WrapperClassGenerator.java
(original)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/WrapperClassGenerator.java
Tue Sep  1 17:53:18 2009
@@ -277,21 +277,25 @@
         String classCode = getClassCode(clz);
         String fieldDescriptor = null;
         
-        if (genericType instanceof ParameterizedType
-            && (Collection.class.isAssignableFrom(clz) || clz.isArray())) {
-            ParameterizedType ptype = (ParameterizedType)genericType;
+        if (genericType instanceof ParameterizedType) {
+            if (Collection.class.isAssignableFrom(clz) || clz.isArray()) {
+                ParameterizedType ptype = (ParameterizedType)genericType;
 
-            Type[] types = ptype.getActualTypeArguments();
-            // TODO: more complex Parameterized type
-            if (types.length > 0) {
-                if (types[0] instanceof Class) {
-                    fieldDescriptor = getClassCode(genericType);
-                } else if (types[0] instanceof GenericArrayType) {
-                    fieldDescriptor = getClassCode(genericType);
-                } else if (types[0] instanceof ParameterizedType) {
-                    classCode = getClassCode(((ParameterizedType)types[0]).getRawType());
-                    fieldDescriptor = getClassCode(genericType);
+                Type[] types = ptype.getActualTypeArguments();
+                // TODO: more complex Parameterized type
+                if (types.length > 0) {
+                    if (types[0] instanceof Class) {
+                        fieldDescriptor = getClassCode(genericType);
+                    } else if (types[0] instanceof GenericArrayType) {
+                        fieldDescriptor = getClassCode(genericType);
+                    } else if (types[0] instanceof ParameterizedType) {
+                        classCode = getClassCode(((ParameterizedType)types[0]).getRawType());
+                        fieldDescriptor = getClassCode(genericType);
+                    }
                 }
+            } else {
+                classCode = getClassCode(((ParameterizedType)genericType).getRawType());
+                fieldDescriptor = getClassCode(genericType);
             }
         }
         String fieldName = JavaUtils.isJavaKeyword(name) ? JavaUtils.makeNonJavaKeyword(name)
: name;

Modified: cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/jaxws/ClientServerMiscTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/jaxws/ClientServerMiscTest.java?rev=810143&r1=810142&r2=810143&view=diff
==============================================================================
--- cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/jaxws/ClientServerMiscTest.java
(original)
+++ cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/jaxws/ClientServerMiscTest.java
Tue Sep  1 17:53:18 2009
@@ -59,6 +59,8 @@
 import org.apache.cxf.ordered_param_holder.ComplexStruct;
 import org.apache.cxf.ordered_param_holder.OrderedParamHolder;
 import org.apache.cxf.ordered_param_holder.OrderedParamHolder_Service;
+import org.apache.cxf.systest.jaxws.DocLitWrappedCodeFirstService.CXF2411Result;
+import org.apache.cxf.systest.jaxws.DocLitWrappedCodeFirstService.CXF2411SubClass;
 import org.apache.cxf.systest.jaxws.DocLitWrappedCodeFirstService.Foo;
 import org.apache.cxf.tests.inherit.Inherit;
 import org.apache.cxf.tests.inherit.InheritService;
@@ -350,7 +352,7 @@
     private void setASM(boolean b) throws Exception {
         Field f = ASMHelper.class.getDeclaredField("oldASM");
         f.setAccessible(true);
-        f.set(null, b);
+        f.set(null, !b);
     }
     
     @Test
@@ -413,6 +415,11 @@
         assertEquals("Hello", echoMsg);
     }
     private void runDocLitTest(DocLitWrappedCodeFirstService port) throws Exception {
+        CXF2411Result<CXF2411SubClass> o = port.doCXF2411();
+        assertNotNull(o);
+        assertNotNull(o.getContent());
+        Object[] ar = o.getContent(); 
+        assertTrue(ar[0] instanceof CXF2411SubClass);
         Foo foo = new Foo();
         foo.setName("blah");
         assertEquals("blah", port.modifyFoo(foo).getName());

Modified: cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/jaxws/DocLitWrappedCodeFirstService.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/jaxws/DocLitWrappedCodeFirstService.java?rev=810143&r1=810142&r2=810143&view=diff
==============================================================================
--- cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/jaxws/DocLitWrappedCodeFirstService.java
(original)
+++ cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/jaxws/DocLitWrappedCodeFirstService.java
Tue Sep  1 17:53:18 2009
@@ -214,4 +214,22 @@
             return dbReves;
         }
     }
+    
+    CXF2411Result<CXF2411SubClass> doCXF2411();
+    
+    public class CXF2411Result<T extends CXF2411Base> {
+        private T[] content;
+        public T[] getContent() {
+            return content;
+        }
+        public void setContent(T[] content) {
+            this.content = content;
+        }
+    }
+
+    public class CXF2411Base {
+    }
+
+    public class CXF2411SubClass extends CXF2411Base {
+    }
 }

Modified: cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/jaxws/DocLitWrappedCodeFirstServiceImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/jaxws/DocLitWrappedCodeFirstServiceImpl.java?rev=810143&r1=810142&r2=810143&view=diff
==============================================================================
--- cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/jaxws/DocLitWrappedCodeFirstServiceImpl.java
(original)
+++ cxf/trunk/systests/uncategorized/src/test/java/org/apache/cxf/systest/jaxws/DocLitWrappedCodeFirstServiceImpl.java
Tue Sep  1 17:53:18 2009
@@ -228,5 +228,13 @@
         }
         return f;
     }
+
+    public CXF2411Result<CXF2411SubClass> doCXF2411() {
+        CXF2411Result<CXF2411SubClass> ret = new CXF2411Result<CXF2411SubClass>();
+        CXF2411SubClass content[] = new CXF2411SubClass[1];
+        content[0] = new CXF2411SubClass();
+        ret.setContent(content);
+        return ret;
+    }
     
 }



Mime
View raw message