axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dee...@apache.org
Subject svn commit: r789129 - in /webservices/axis2/trunk/java/modules/adb: src/org/apache/axis2/databinding/utils/BeanUtil.java src/org/apache/axis2/rpc/receivers/RPCUtil.java test/org/apache/axis2/databinding/utils/BeanUtilTest.java
Date Sun, 28 Jun 2009 17:18:20 GMT
Author: deepal
Date: Sun Jun 28 17:18:20 2009
New Revision: 789129

URL: http://svn.apache.org/viewvc?rev=789129&view=rev
Log:
applying path in AXIS2-2782,
I think now we need some test cases. Let's get it done it soon as you have mentioned in the
JIRA.

https://issues.apache.org/jira/browse/AXIS2-2782

Modified:
    webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java
    webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/rpc/receivers/RPCUtil.java
    webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/utils/BeanUtilTest.java

Modified: webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java?rev=789129&r1=789128&r2=789129&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java
(original)
+++ webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java
Sun Jun 28 17:18:20 2009
@@ -41,9 +41,7 @@
 import java.beans.IntrospectionException;
 import java.beans.Introspector;
 import java.beans.PropertyDescriptor;
-import java.lang.reflect.Array;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
+import java.lang.reflect.*;
 import java.util.*;
 
 
@@ -484,12 +482,13 @@
     public static Object [] deserialize(OMElement response,
                                         Object [] javaTypes,
                                         ObjectSupplier objectSupplier) throws AxisFault {
-        return BeanUtil.deserialize(response, javaTypes, objectSupplier, null);
+        return BeanUtil.deserialize(response, javaTypes, objectSupplier, null, null);
     }
     public static Object [] deserialize(OMElement response,
                                         Object [] javaTypes,
                                         ObjectSupplier objectSupplier,
-                                        String[] parameterNames) throws AxisFault {
+                                        String[] parameterNames,
+                                        Method method) throws AxisFault {
         /*
          * Take the number of parameters in the method and , only take that much of child
elements
          * from the OMElement , other are ignore , as an example
@@ -529,6 +528,11 @@
         // has to  get and add to the list
         Class classType;
         String currentLocalName;
+        Type[] genericParameterTypes = null;
+        if (method !=null) {
+            genericParameterTypes = method.getGenericParameterTypes();
+        }
+        Type genericType = null ;
         while (parts.hasNext() && count < length) {
             Object objValue = parts.next();
             OMElement omElement;
@@ -557,13 +561,16 @@
 
             currentLocalName = omElement.getLocalName();
             classType = (Class)javaTypes[count];
+            if(genericParameterTypes !=null){
+                genericType = genericParameterTypes[count];
+            }
             omElement = ProcessElement(classType, omElement, helper, parts,
-                    currentLocalName, retObjs, count, objectSupplier);
+                    currentLocalName, retObjs, count, objectSupplier, genericType);
             while (omElement != null) {
                 count ++;
                 omElement = ProcessElement((Class)javaTypes[count], omElement,
                         helper, parts, omElement.getLocalName(), retObjs, count,
-                        objectSupplier);
+                        objectSupplier, genericType);
             }
             count ++;
         }
@@ -585,7 +592,8 @@
                                             String currentLocalName,
                                             Object[] retObjs,
                                             int count,
-                                            ObjectSupplier objectSupplier) throws AxisFault
{
+                                            ObjectSupplier objectSupplier,
+                                            Type genericType) throws AxisFault {
         Object objValue;
         if (classType.isArray()) {
             boolean done = true;
@@ -593,12 +601,12 @@
             Class arrayClassType = classType.getComponentType();
             if ("byte".equals(arrayClassType.getName())) {
                 retObjs[count] =
-                        processObject(omElement, arrayClassType, helper, true, objectSupplier);
+                        processObject(omElement, arrayClassType, helper, true, objectSupplier,
genericType);
                 return null;
             } else {
                 valueList.add(processObject(omElement, arrayClassType, helper, true,
-                        objectSupplier));
-            }
+                        objectSupplier, genericType));
+            }                                                                           
          
             while (parts.hasNext()) {
                 objValue = parts.next();
                 if (objValue instanceof OMElement) {
@@ -611,7 +619,7 @@
                     break;
                 }
                 Object o = processObject(omElement, arrayClassType,
-                        helper, true, objectSupplier);
+                        helper, true, objectSupplier, genericType);
                 valueList.add(o);
             }
             if(valueList.get(0)==null){
@@ -625,16 +633,38 @@
             }
         } else {
             //handling refs
-            retObjs[count] = processObject(omElement, classType, helper, false, objectSupplier);
+            retObjs[count] = processObject(omElement, classType, helper, false, objectSupplier,
genericType);
         }
         return null;
     }
 
+      private static List ProcessGenericsElement(Class classType, OMElement omElement,
+                                                  MultirefHelper helper, Iterator parts,
+                                                  ObjectSupplier objectSupplier,
+                                                  Type genericType) throws AxisFault {
+              Object objValue;
+          ArrayList valueList = new ArrayList();
+          while (parts.hasNext()) {
+              objValue = parts.next();
+              if (objValue instanceof OMElement) {
+                  omElement = (OMElement)objValue;
+              } else {
+                  continue;
+              }
+              Object o = processObject(omElement, classType,
+                      helper, true, objectSupplier, genericType);
+              valueList.add(o);
+          }
+          return valueList;
+      }
+
+
     public static Object processObject(OMElement omElement,
                                        Class classType,
                                        MultirefHelper helper,
                                        boolean isArrayType,
-                                       ObjectSupplier objectSupplier) throws AxisFault {
+                                       ObjectSupplier objectSupplier,
+                                       Type generictype) throws AxisFault {
         boolean hasRef = false;
         OMAttribute omatribute = MultirefHelper.processRefAtt(omElement);
         String ref = null;
@@ -673,6 +703,13 @@
                         return SimpleTypeMapper.getSimpleTypeObject(classType, omElement);
                     }
                 } else if (SimpleTypeMapper.isCollection(classType)) {
+                    if(generictype !=null && (generictype instanceof ParameterizedType)){
+                        ParameterizedType aType = (ParameterizedType) generictype;
+                        Type[] parameterArgTypes = aType.getActualTypeArguments();
+                        Type parameter = parameterArgTypes[0];
+                        Iterator parts = omElement.getChildElements();
+                        return ProcessGenericsElement((Class) parameter,omElement,helper,
parts,objectSupplier,generictype);
+                    }
                     return SimpleTypeMapper.getArrayList(omElement);
                 } else if (SimpleTypeMapper.isDataHandler(classType)) {
                     return SimpleTypeMapper.getDataHandler(omElement);

Modified: webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/rpc/receivers/RPCUtil.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/rpc/receivers/RPCUtil.java?rev=789129&r1=789128&r2=789129&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/rpc/receivers/RPCUtil.java
(original)
+++ webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/rpc/receivers/RPCUtil.java
Sun Jun 28 17:18:20 2009
@@ -45,6 +45,7 @@
 import java.lang.reflect.Array;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import java.lang.reflect.Type;
 import java.util.Collection;
 import java.util.Iterator;
 
@@ -150,7 +151,7 @@
                                           Method method, ObjectSupplier objectSupplier, String[]
parameterNames)
             throws AxisFault {
         Class[] parameters = method.getParameterTypes();
-        return BeanUtil.deserialize(methodElement, parameters, objectSupplier, parameterNames);
+        return BeanUtil.deserialize(methodElement, parameters, objectSupplier, parameterNames,
method);
     }
 
     public static Object[] processRequest(OMElement methodElement,

Modified: webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/utils/BeanUtilTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/utils/BeanUtilTest.java?rev=789129&r1=789128&r2=789129&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/utils/BeanUtilTest.java
(original)
+++ webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/utils/BeanUtilTest.java
Sun Jun 28 17:18:20 2009
@@ -63,7 +63,7 @@
     public void testProcessObjectAsSimpleType() throws Exception {
         omElement.setText("World");
         
-        Object result = BeanUtil.processObject(omElement, String.class, new MultirefHelper(omElement),
false, objectSupplier);
+        Object result = BeanUtil.processObject(omElement, String.class, new MultirefHelper(omElement),
false, objectSupplier, null);
         assertTrue(result instanceof String);
         assertEquals("World", result);
     }
@@ -71,7 +71,7 @@
     public void testProcessObjectAsOmElement() throws Exception {
         omElement.setText("World");
         
-        Object result = BeanUtil.processObject(omElement, OMElement.class, new MultirefHelper(omElement),
false, objectSupplier);
+        Object result = BeanUtil.processObject(omElement, OMElement.class, new MultirefHelper(omElement),
false, objectSupplier, null);
         assertTrue(result instanceof OMElement);
         assertEquals(omElement, result);
     }
@@ -80,14 +80,14 @@
         OMAttribute nilAttribute = omFactory.createOMAttribute("nil", xsiNamespace, "true");
         omElement.addAttribute(nilAttribute);
         
-        Object result = BeanUtil.processObject(omElement, String.class, new MultirefHelper(omElement),
false, objectSupplier);
+        Object result = BeanUtil.processObject(omElement, String.class, new MultirefHelper(omElement),
false, objectSupplier, null);
         assertNull(result);
     }
 
     public void testProcessObjectAsByteArray() throws Exception {
         omElement.setText("Word");
         
-        Object result = BeanUtil.processObject(omElement, byte.class, new MultirefHelper(omElement),
true, objectSupplier);
+        Object result = BeanUtil.processObject(omElement, byte.class, new MultirefHelper(omElement),
true, objectSupplier, null);
         assertTrue(result instanceof byte[]);
         assertEquals(3, ((byte[]) result).length);
     }
@@ -96,7 +96,7 @@
         OMElement child = omFactory.createOMElement(new QName("child"), omElement);
         child.setText("World");
         
-        Object result = BeanUtil.processObject(omElement, List.class, new MultirefHelper(omElement),
false, objectSupplier);
+        Object result = BeanUtil.processObject(omElement, List.class, new MultirefHelper(omElement),
false, objectSupplier, null);
         assertTrue(result instanceof List);
         assertEquals(1, ((List) result).size());
     }
@@ -104,7 +104,7 @@
     public void testProcessObjectAsDataHandler() throws Exception {
         omElement.setText("Word");
         
-        Object result = BeanUtil.processObject(omElement, DataHandler.class, new MultirefHelper(omElement),
false, objectSupplier);
+        Object result = BeanUtil.processObject(omElement, DataHandler.class, new MultirefHelper(omElement),
false, objectSupplier, null);
         assertTrue(result instanceof DataHandler);
     }
 
@@ -112,7 +112,7 @@
         OMElement child = omFactory.createOMElement(new QName("child"), omElement);
         child.setText("World");
         
-        Object result = BeanUtil.processObject(omElement, ComplexType.class, new MultirefHelper(omElement),
false, objectSupplier);
+        Object result = BeanUtil.processObject(omElement, ComplexType.class, new MultirefHelper(omElement),
false, objectSupplier, null);
         assertTrue(result instanceof ComplexType);
         assertEquals("World", ((ComplexType) result).getChild());
     }
@@ -123,7 +123,7 @@
         omElement.setText("World");
         omElement.addAttribute(createTypeAttribute("xs:string"));
         
-        Object result = BeanUtil.processObject(omElement, Object.class, new MultirefHelper(omElement),
false, objectSupplier);
+        Object result = BeanUtil.processObject(omElement, Object.class, new MultirefHelper(omElement),
false, objectSupplier, null);
         assertTrue(result instanceof OMText);
         assertEquals("World", ((OMText) result).getText());
     }



Mime
View raw message