Return-Path: Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: (qmail 39013 invoked from network); 19 Jun 2009 17:20:20 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 19 Jun 2009 17:20:20 -0000 Received: (qmail 16476 invoked by uid 500); 19 Jun 2009 17:20:31 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 16380 invoked by uid 500); 19 Jun 2009 17:20:30 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 16371 invoked by uid 99); 19 Jun 2009 17:20:30 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 19 Jun 2009 17:20:30 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 19 Jun 2009 17:20:28 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 4916C23888C2; Fri, 19 Jun 2009 17:20:08 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: 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... Date: Fri, 19 Jun 2009 17:20:08 -0000 To: commits@cxf.apache.org From: dkulp@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090619172008.4916C23888C2@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 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 buildFields(final Method method, final MessageInfo message) { List fields = new ArrayList(); 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 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 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 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 getReturn()") != -1); + } + }