tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From antel...@apache.org
Subject svn commit: r1171125 - /tuscany/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/WrapperBeanGenerator.java
Date Thu, 15 Sep 2011 15:10:35 GMT
Author: antelder
Date: Thu Sep 15 15:10:35 2011
New Revision: 1171125

URL: http://svn.apache.org/viewvc?rev=1171125&view=rev
Log:
Update the WrapperBeanGenerator to create the correct classes for async methods

Modified:
    tuscany/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/WrapperBeanGenerator.java

Modified: tuscany/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/WrapperBeanGenerator.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/WrapperBeanGenerator.java?rev=1171125&r1=1171124&r2=1171125&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/WrapperBeanGenerator.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/WrapperBeanGenerator.java
Thu Sep 15 15:10:35 2011
@@ -21,6 +21,7 @@ package org.apache.tuscany.sca.interface
 
 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;
@@ -29,6 +30,7 @@ import javax.jws.WebParam;
 import javax.jws.WebResult;
 
 import org.apache.tuscany.sca.interfacedef.java.impl.JavaInterfaceUtil;
+import org.oasisopen.sca.ResponseDispatch;
 
 public class WrapperBeanGenerator extends BaseBeanGenerator {
 
@@ -71,7 +73,15 @@ public class WrapperBeanGenerator extend
                 Type[] genericParamTypes = m.getGenericParameterTypes();
                 Annotation[][] paramAnnotations = m.getParameterAnnotations();
                 List<BeanProperty> properties = new ArrayList<BeanProperty>();
-                for (int i = 0; i < paramTypes.length; i++) {
+
+                boolean asyncMethod = m.getName().endsWith("Async") && paramTypes.length
> 0 && ResponseDispatch.class.equals(paramTypes[paramTypes.length-1]);
+                int length = paramTypes.length;
+                if (asyncMethod) {
+                    length -= 1;
+                }
+                
+                for (int i = 0; i < length; i++) {
+                    
                     String propNS = "";
                     String propName = "arg" + i;
 
@@ -87,6 +97,7 @@ public class WrapperBeanGenerator extend
                         }
                         propNS = webParam.targetNamespace();
                     }
+                    
                     if (mode.equals(WebParam.Mode.IN) || mode.equals(WebParam.Mode.INOUT))
{
                         java.lang.reflect.Type genericParamType = getHolderValueType(genericParamTypes[i]);
                         Class<?> paramType = CodeGenerationHelper.getErasure(genericParamType);
@@ -133,7 +144,14 @@ public class WrapperBeanGenerator extend
                 Annotation[][] paramAnns = m.getParameterAnnotations();
                 Class<?>[] paramTypes = m.getParameterTypes();
                 java.lang.reflect.Type[] genericParamTypes = m.getGenericParameterTypes();
-                for (int i = 0; i < paramTypes.length; i++) {
+
+                boolean asyncMethod = m.getName().endsWith("Async") && paramTypes.length
> 0 && ResponseDispatch.class.equals(paramTypes[paramTypes.length-1]);
+                int length = paramTypes.length;
+                if (asyncMethod) {
+                    length -= 1;
+                }
+                
+                for (int i = 0; i < length; i++) {
                     WebParam webParam = findAnnotation(paramAnns[i], WebParam.class);
                     if (webParam != null) {
                         if (webParam.header() || webParam.mode() == WebParam.Mode.IN) {
@@ -166,6 +184,9 @@ public class WrapperBeanGenerator extend
 
                 WebResult webResult = m.getAnnotation(WebResult.class);
                 Class<?> returnType = m.getReturnType();
+                if (asyncMethod) {
+                    returnType = (Class<?>)((ParameterizedType)genericParamTypes[genericParamTypes.length-1]).getActualTypeArguments()[0];
+                }
                 if (!((webResult != null && webResult.header()) || returnType ==
Void.TYPE)) {
                     String propName = "return";
                     String propNS = "";
@@ -181,7 +202,7 @@ public class WrapperBeanGenerator extend
 
                     List<Annotation> jaxb = findJAXBAnnotations(m.getAnnotations());
 
-                    Type genericReturnType = m.getGenericReturnType();
+                    Type genericReturnType = asyncMethod? returnType : m.getGenericReturnType();
                     BeanProperty prop = new BeanProperty(propNS, propName, returnType, genericReturnType,
true);
                     prop.getJaxbAnnotaions().addAll(jaxb);
                     properties.add(prop);



Mime
View raw message