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 2009/06/19 19:20:08 UTC

svn commit: r786589 - in /cxf/branches/2.2.x-fixes: ./ tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/ tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/withannotation/doc/ tools/javato/ws/src/test/java/o...

Author: dkulp
Date: Fri Jun 19 17:20:07 2009
New Revision: 786589

URL: http://svn.apache.org/viewvc?rev=786589&view=rev
Log:
Merged revisions 786395 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r786395 | asoldano | 2009-06-19 03:07:05 -0400 (Fri, 19 Jun 2009) | 2 lines
  
  [CXF-2300] Adding generic support to response wrapper
........

Added:
    cxf/branches/2.2.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/withannotation/doc/EchoGenericNoWrapperBean.java
      - copied unchanged from r786395, cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/withannotation/doc/EchoGenericNoWrapperBean.java
Modified:
    cxf/branches/2.2.x-fixes/   (props changed)
    cxf/branches/2.2.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/RequestWrapper.java
    cxf/branches/2.2.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/ResponseWrapper.java
    cxf/branches/2.2.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/Wrapper.java
    cxf/branches/2.2.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/WrapperBeanGeneratorTest.java

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Jun 19 17:20:07 2009
@@ -1 +1 @@
-/cxf/trunk:782728-782730,783097,783294,783396,784059,784181-784184,784893,784895,785279-785282,785468,785621,785624,785651,785734,785866,786142,786271-786272,786514
+/cxf/trunk:782728-782730,783097,783294,783396,784059,784181-784184,784893,784895,785279-785282,785468,785621,785624,785651,785734,785866,786142,786271-786272,786395,786514

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Fri Jun 19 17:20:07 2009
@@ -1 +1 @@
-/cxf/trunk:1-782619,782728-782730,783097,783294,783396,784059,784181-784184,784893-785866,785932,786142,786271-786272,786514
+/cxf/trunk:1-782619,782728-782730,783097,783294,783396,784059,784181-784184,784893-785866,785932,786142,786271-786272,786395,786514

Modified: cxf/branches/2.2.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/RequestWrapper.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/RequestWrapper.java?rev=786589&r1=786588&r2=786589&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/RequestWrapper.java (original)
+++ cxf/branches/2.2.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/RequestWrapper.java Fri Jun 19 17:20:07 2009
@@ -20,14 +20,12 @@
 package org.apache.cxf.tools.java2wsdl.processor.internal.jaxws;
 
 import java.lang.annotation.Annotation;
-import java.lang.reflect.GenericArrayType;
 import java.lang.reflect.Method;
-import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
 import java.util.ArrayList;
 import java.util.List;
+
 import javax.jws.WebParam;
-import javax.xml.ws.Holder;
 
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.service.model.MessageInfo;
@@ -61,39 +59,7 @@
     @Override
     protected List<JavaField> buildFields() {
         return buildFields(getMethod(), getOperationInfo().getUnwrappedOperation().getInput());
-    }
-
-    private String getTypeString(Type t) {
-        String type = "Object";
-        if (t instanceof Class) {
-            Class clz = (Class) t;
-            if (clz.isArray()) {
-                if (isBuiltInTypes(clz.getComponentType())) {
-                    type = clz.getComponentType().getSimpleName() + "[]";
-                } else {
-                    type = clz.getComponentType().getName() + "[]";
-                }
-            } else {
-                type = clz.getName();
-            }
-        } else if (t instanceof ParameterizedType) {
-            ParameterizedType pt = (ParameterizedType) t;
-            Class c = (Class)pt.getRawType();
-            if (Holder.class.isAssignableFrom(c)
-                && pt.getActualTypeArguments().length == 1
-                && pt.getActualTypeArguments()[0] instanceof Class) {
-                type = getTypeString(pt.getActualTypeArguments()[0]);
-            } else {
-                type = t.toString();
-            }
-        } else if (t instanceof GenericArrayType) {
-            GenericArrayType gat = (GenericArrayType)t;
-            type = gat.toString();
-        }
-        type = type.replace('$', '.');
-        return type;
-    }
-    
+    }    
     
     protected List<JavaField> buildFields(final Method method, final MessageInfo message) {
         List<JavaField> fields = new ArrayList<JavaField>();

Modified: cxf/branches/2.2.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/ResponseWrapper.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/ResponseWrapper.java?rev=786589&r1=786588&r2=786589&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/ResponseWrapper.java (original)
+++ cxf/branches/2.2.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/ResponseWrapper.java Fri Jun 19 17:20:07 2009
@@ -21,7 +21,6 @@
 
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
-import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
 import java.util.ArrayList;
 import java.util.List;
@@ -79,16 +78,7 @@
 
         if (!returnType.isAssignableFrom(void.class)) {
             hasReturnType = true;
-            String type;
-            if (returnType.isArray()) {
-                if (isBuiltInTypes(returnType.getComponentType())) {
-                    type = returnType.getComponentType().getSimpleName() + "[]";
-                } else {
-                    type = returnType.getComponentType().getName() + "[]";
-                }
-            } else {
-                type = returnType.getName();
-            }
+            String type = getTypeString(method.getGenericReturnType());
             List<Annotation> jaxbAnns = WrapperUtil.getJaxbAnnotations(method);
             field.setType(type);
             field.setJaxbAnnotations(jaxbAnns.toArray(new Annotation[jaxbAnns.size()]));
@@ -102,27 +92,9 @@
             int idx = hasReturnType ? mpi.getIndex() - 1 : mpi.getIndex();
             if (idx >= 0) {
                 String name = mpi.getName().getLocalPart();
-                String type = "Object";
 
                 Type t = paramClasses[idx];
-                if (t instanceof Class) {
-                    Class clz = (Class) t;
-                    if (clz.isArray()) {
-                        if (isBuiltInTypes(clz.getComponentType())) {
-                            type = clz.getComponentType().getSimpleName() + "[]";
-                        } else {
-                            type = clz.getComponentType().getName() + "[]";
-                        }
-                    } else {
-                        type = clz.getName();
-                    }
-                } else if (t instanceof ParameterizedType) {
-                    ParameterizedType pt = (ParameterizedType) t;
-                    if (pt.getActualTypeArguments().length > 0
-                        && pt.getActualTypeArguments()[0] instanceof Class) {
-                        type = ((Class)pt.getActualTypeArguments()[0]).getName();
-                    }
-                }
+                String type = getTypeString(t);
 
                 JavaField jf = new JavaField(name, type, "");
                 List<Annotation> jaxbAnns = WrapperUtil.getJaxbAnnotations(method, idx - 1);
@@ -134,7 +106,7 @@
 
         return fields;
     }
-
+    
     @Override
     public WrapperBeanClass getWrapperBeanClass(final Method method) {
         javax.xml.ws.ResponseWrapper resWrapper = method.getAnnotation(javax.xml.ws.ResponseWrapper.class);
@@ -157,7 +129,4 @@
         return jClass;
     }
 
-
-
-
 }

Modified: cxf/branches/2.2.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/Wrapper.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/Wrapper.java?rev=786589&r1=786588&r2=786589&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/Wrapper.java (original)
+++ cxf/branches/2.2.x-fixes/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/Wrapper.java Fri Jun 19 17:20:07 2009
@@ -19,12 +19,17 @@
 
 package org.apache.cxf.tools.java2wsdl.processor.internal.jaxws;
 
+import java.lang.reflect.GenericArrayType;
 import java.lang.reflect.Method;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.logging.Level;
 import java.util.logging.Logger;
+
 import javax.xml.namespace.QName;
+import javax.xml.ws.Holder;
 
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.common.logging.LogUtils;
@@ -190,4 +195,36 @@
     public OperationInfo getOperationInfo() {
         return this.operationInfo;
     }
+    
+    protected String getTypeString(Type t) {
+        String type = "Object";
+        if (t instanceof Class) {
+            Class clz = (Class) t;
+            if (clz.isArray()) {
+                if (isBuiltInTypes(clz.getComponentType())) {
+                    type = clz.getComponentType().getSimpleName() + "[]";
+                } else {
+                    type = clz.getComponentType().getName() + "[]";
+                }
+            } else {
+                type = clz.getName();
+            }
+        } else if (t instanceof ParameterizedType) {
+            ParameterizedType pt = (ParameterizedType) t;
+            Class c = (Class)pt.getRawType();
+            if (Holder.class.isAssignableFrom(c)
+                && pt.getActualTypeArguments().length == 1
+                && pt.getActualTypeArguments()[0] instanceof Class) {
+                type = getTypeString(pt.getActualTypeArguments()[0]);
+            } else {
+                type = t.toString();
+            }
+        } else if (t instanceof GenericArrayType) {
+            GenericArrayType gat = (GenericArrayType)t;
+            type = gat.toString();
+        }
+        type = type.replace('$', '.');
+        return type;
+    }
+
 }

Modified: cxf/branches/2.2.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/WrapperBeanGeneratorTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/WrapperBeanGeneratorTest.java?rev=786589&r1=786588&r2=786589&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/WrapperBeanGeneratorTest.java (original)
+++ cxf/branches/2.2.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/WrapperBeanGeneratorTest.java Fri Jun 19 17:20:07 2009
@@ -135,4 +135,26 @@
         assertNotNull(field.getAnnotation(XmlList.class));
     }
     
+    @Test
+    public void testGenGeneric() throws Exception {
+        String testingClass = "org.apache.cxf.tools.fortest.withannotation.doc.EchoGenericNoWrapperBean";
+        env.put(ToolConstants.CFG_CLASSNAME, testingClass);
+        
+        WrapperBeanGenerator generator = new WrapperBeanGenerator();
+        generator.setServiceModel(getServiceInfo());
+        
+        generator.generate(output);
+
+        String pkgBase = "org/apache/cxf";
+        File requestWrapperClass = new File(output, pkgBase + "/EchoGeneric.java");
+        assertTrue(requestWrapperClass.exists());
+        String contents = IOUtils.toString(new FileInputStream(requestWrapperClass));
+        assertTrue(contents.indexOf("public java.util.List<java.lang.String> get") != -1);
+        
+        File responseWrapperClass = new File(output, pkgBase + "/EchoGenericResponse.java");
+        assertTrue(responseWrapperClass.exists());
+        contents = IOUtils.toString(new FileInputStream(responseWrapperClass));
+        assertTrue(contents.indexOf("public java.util.List<java.lang.String> getReturn()") != -1);
+    }
+    
 }