axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dee...@apache.org
Subject svn commit: r330016 - in /webservices/axis2/trunk/java/modules: codegen/src/org/apache/axis2/rpc/receivers/ codegen/src/org/apache/axis2/util/ integration/test/org/apache/axis2/rpc/
Date Tue, 01 Nov 2005 10:27:24 GMT
Author: deepal
Date: Tue Nov  1 02:27:08 2005
New Revision: 330016

URL: http://svn.apache.org/viewcvs?rev=330016&view=rev
Log:
Improved RPCMessageReceiver to handle arrays properly .

Added:
    webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/Company.java
Modified:
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/rpc/receivers/SimpleTypeMapper.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/util/BeanSerializerUtil.java
    webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCCallTest.java
    webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCServiceClass.java

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/rpc/receivers/SimpleTypeMapper.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/rpc/receivers/SimpleTypeMapper.java?rev=330016&r1=330015&r2=330016&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/rpc/receivers/SimpleTypeMapper.java
(original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/rpc/receivers/SimpleTypeMapper.java
Tue Nov  1 02:27:08 2005
@@ -19,6 +19,7 @@
 
 import org.apache.axis2.om.OMElement;
 
+import javax.xml.namespace.QName;
 import java.text.SimpleDateFormat;
 import java.util.*;
 
@@ -94,7 +95,17 @@
         }
     }
 
-     public static ArrayList getArrayList(OMElement element){
+    public static ArrayList getArrayList(OMElement element, String localName){
+        Iterator childitr = element.getChildrenWithName(new QName(localName));
+        ArrayList list = new ArrayList();
+        while (childitr.hasNext()) {
+            Object o = childitr.next();
+            list.add(o);
+        }
+        return list;
+    }
+
+    public static ArrayList getArrayList(OMElement element){
         Iterator childitr = element.getChildren();
         ArrayList list = new ArrayList();
         while (childitr.hasNext()) {

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/util/BeanSerializerUtil.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/util/BeanSerializerUtil.java?rev=330016&r1=330015&r2=330016&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/util/BeanSerializerUtil.java
(original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/util/BeanSerializerUtil.java
Tue Nov  1 02:27:08 2005
@@ -62,6 +62,10 @@
                     Object value =  propDesc.getReadMethod().invoke(beanObject,null);
                     objetc.add(propDesc.getName());
                     objetc.add(value.toString());
+                } else if(SimpleTypeMapper.isArrayList(ptype)){
+                    objetc.add(new QName(propDesc.getName()));
+                    Object value =  propDesc.getReadMethod().invoke(beanObject,null);
+                    objetc.add(((ArrayList) value).toArray());
                 } else {
                     objetc.add(new QName(propDesc.getName()));
                     Object value =  propDesc.getReadMethod().invoke(beanObject,null);
@@ -108,10 +112,19 @@
                     Class parameters = prty.getPropertyType();
                     if (prty.equals("class"))
                         continue;
-                    Object partObj = SimpleTypeMapper.getSimpleTypeObject(parameters, parts);
-                    if (partObj == null) {
+
+                    Object partObj;
+                    if(SimpleTypeMapper.isSimpleType(parameters)){
+                        partObj = SimpleTypeMapper.getSimpleTypeObject(parameters, parts);
+                    } else if(SimpleTypeMapper.isArrayList(parameters)){
+                        partObj = SimpleTypeMapper.getArrayList((OMElement)parts.getParent(),prty.getName());
+                    } else {
                         partObj = deserialize(parameters, parts);
                     }
+//                    Object partObj = SimpleTypeMapper.getSimpleTypeObject(parameters, parts);
+//                    if (partObj == null) {
+//                        partObj = deserialize(parameters, parts);
+//                    }
                     Object [] parms = new Object[]{partObj};
                     prty.getWriteMethod().invoke(beanObj,parms);
                 }
@@ -233,6 +246,9 @@
 //have to check the instnceof
         MultirefHelper helper = new MultirefHelper((OMElement)response.getParent());
         boolean hasRef = false;
+        //to support array . if the paramter type is array , then all the omelemnts with
that paramtre name
+        // has to  get and add to the list
+        Class classType = null;
         while (parts.hasNext() && count < length) {
             Object objValue = parts.next();
             OMElement omElement;
@@ -241,8 +257,7 @@
             }   else {
                 continue;
             }
-
-            Class classType = (Class)javaTypes[count];
+            classType = (Class)javaTypes[count];
 //handling refs
             OMAttribute omatribute = MultirefHelper.processRefAtt(omElement);
             String ref=null;

Added: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/Company.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/Company.java?rev=330016&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/Company.java
(added)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/Company.java
Tue Nov  1 02:27:08 2005
@@ -0,0 +1,43 @@
+package org.apache.axis2.rpc;
+
+import java.util.ArrayList;
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+* @author : Deepal Jayasinghe (deepal@apache.org)
+*
+*/
+
+public class Company {
+
+    private ArrayList persons;
+    private String name;
+
+    public ArrayList getPersons() {
+        return persons;
+    }
+
+    public void setPersons(ArrayList persons) {
+        this.persons = persons;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+}

Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCCallTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCCallTest.java?rev=330016&r1=330015&r2=330016&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCCallTest.java
(original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCCallTest.java
Tue Nov  1 02:27:08 2005
@@ -20,6 +20,7 @@
 import junit.framework.TestCase;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.Constants;
+import org.apache.axis2.databinding.utils.ADBPullParser;
 import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.context.ServiceContext;
@@ -48,10 +49,7 @@
 import javax.xml.stream.XMLStreamReader;
 import java.io.ByteArrayInputStream;
 import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.TimeZone;
+import java.util.*;
 
 public class RPCCallTest extends TestCase {
 
@@ -280,6 +278,55 @@
         args.add("1");
         OMElement response = call.invokeBlocking(operationName, args.toArray());
         assertEquals(Byte.parseByte(response.getFirstElement().getText()), 1);
+        call.close();
+    }
+
+    public void testCompany() throws AxisFault {
+        configureSystem("echoCompany");
+        RPCCall call =
+                new RPCCall("target/test-resources/intregrationRepo");
+
+        call.setTo(targetEPR);
+        call.setTransportInfo(Constants.TRANSPORT_HTTP,
+                Constants.TRANSPORT_HTTP,
+                false);
+
+        Company com = new Company();
+        com.setName("MyCompany");
+
+        ArrayList ps = new ArrayList();
+
+        Person p1 = new Person();
+        p1.setAge(10);
+        p1.setName("P1");
+        ps.add(p1);
+
+        Person p2 = new Person();
+        p2.setAge(15);
+        p2.setName("P2");
+        ps.add(p2);
+
+        Person p3 = new Person();
+        p3.setAge(20);
+        p3.setName("P3");
+        ps.add(p3);
+
+        com.setPersons(ps);
+
+//        List list = new ArrayList();
+//        list.add(new QName(com.getName()));
+//        list.add(com);
+//        list.add(new QName("Persons"));
+//        list.add(ps.toArray());
+//
+//        XMLStreamReader pullParser = ADBPullParser.createPullParser(new QName("UdaEka"),
list.toArray(), null);
+//        OMElement documentElement = new StAXOMBuilder(pullParser).getDocumentElement();
+//        System.out.println("documentElement = " + documentElement);
+
+
+        ArrayList args = new ArrayList();
+        args.add(com);
+        OMElement response = call.invokeBlocking(operationName, args.toArray());
         call.close();
     }
 

Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCServiceClass.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCServiceClass.java?rev=330016&r1=330015&r2=330016&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCServiceClass.java
(original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/rpc/RPCServiceClass.java
Tue Nov  1 02:27:08 2005
@@ -145,6 +145,19 @@
 
     public Employee echoEmployee(Employee em){
         System.out.println("vale: " + em.toString());
-       return em;
+        return em;
+    }
+
+
+    public Company echoCompany(Company com) throws AxisFault {
+        ArrayList pss = com.getPersons();
+        ArrayList tems= new ArrayList();
+        for (int i = 0; i < pss.size(); i++) {
+            OMElement omElement = (OMElement) pss.get(i);
+            Person  p =(Person)BeanSerializerUtil.deserialize(Person.class,omElement);
+            tems.add(p);
+        }
+        com.setPersons(tems);
+        return com;
     }
 }



Mime
View raw message