axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dee...@apache.org
Subject svn commit: r398106 - in /webservices/axis2/trunk/java/modules: adb/src/org/apache/axis2/databinding/utils/BeanUtil.java integration/test/org/apache/axis2/rpc/RPCCallTest.java integration/test/org/apache/axis2/rpc/RPCServiceClass.java
Date Sat, 29 Apr 2006 08:34:49 GMT
Author: deepal
Date: Sat Apr 29 01:34:48 2006
New Revision: 398106

URL: http://svn.apache.org/viewcvs?rev=398106&view=rev
Log:
-improve RPCMessageReciever to handle mutiple arrays

Modified:
    webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.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/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java?rev=398106&r1=398105&r2=398106&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
Sat Apr 29 01:34:48 2006
@@ -23,23 +23,14 @@
 import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.impl.builder.StAXOMBuilder;
 import org.apache.axiom.om.impl.llom.factory.OMXMLBuilderFactory;
-import org.apache.axiom.om.impl.serialize.StreamingOMSerializer;
 import org.apache.axis2.AxisFault;
-import org.apache.axis2.util.StreamWrapper;
 import org.apache.axis2.databinding.typemapping.SimpleTypeMapper;
 import org.apache.axis2.databinding.utils.reader.ADBXMLStreamReaderImpl;
-import org.codehaus.jam.JClass;
-import org.codehaus.jam.JProperty;
-import org.codehaus.jam.JamClassIterator;
-import org.codehaus.jam.JamService;
-import org.codehaus.jam.JamServiceFactory;
-import org.codehaus.jam.JamServiceParams;
+import org.apache.axis2.util.StreamWrapper;
+import org.codehaus.jam.*;
 
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamReader;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamWriter;
-import javax.xml.stream.XMLOutputFactory;
 import java.beans.BeanInfo;
 import java.beans.IntrospectionException;
 import java.beans.Introspector;
@@ -49,7 +40,6 @@
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Locale;
-import java.io.ByteArrayOutputStream;
 
 
 public class BeanUtil {
@@ -366,28 +356,10 @@
             }
             currentLocalName = omElement.getLocalName();
             classType = (Class) javaTypes[count];
-            if (classType.isArray()) {
-                ArrayList valueList = new ArrayList();
-                Class arrayClassType = classType.getComponentType();
-                valueList.add(processObject(omElement, arrayClassType, helper));
-                while (parts.hasNext()) {
-                    objValue = parts.next();
-                    if (objValue instanceof OMElement) {
-                        omElement = (OMElement) objValue;
-                    } else {
-                        continue;
-                    }
-                    if (!currentLocalName.equals(omElement.getLocalName())) {
-                        break;
-                    }
-                    valueList.add(processObject(omElement, arrayClassType,
-                            helper));
-                }
-                retObjs[count] = ConverterUtil.convertToArray(arrayClassType,
-                        valueList);
-            } else {
-                //handling refs
-                retObjs[count] = processObject(omElement, classType, helper);
+            omElement = ProcessElement(classType, omElement, helper, parts, currentLocalName,
retObjs, count);
+            while (omElement != null) {
+                count ++;
+                omElement = ProcessElement((Class) javaTypes[count], omElement, helper, parts,
omElement.getLocalName(), retObjs, count);
             }
             count ++;
         }
@@ -396,6 +368,42 @@
         return retObjs;
     }
 
+    private static OMElement ProcessElement(Class classType, OMElement omElement,
+                                            MultirefHelper helper, Iterator parts,
+                                            String currentLocalName,
+                                            Object[] retObjs, int count) throws AxisFault
{
+        Object objValue;
+        if (classType.isArray()) {
+            boolean done = true;
+            ArrayList valueList = new ArrayList();
+            Class arrayClassType = classType.getComponentType();
+            valueList.add(processObject(omElement, arrayClassType, helper));
+            while (parts.hasNext()) {
+                objValue = parts.next();
+                if (objValue instanceof OMElement) {
+                    omElement = (OMElement) objValue;
+                } else {
+                    continue;
+                }
+                if (!currentLocalName.equals(omElement.getLocalName())) {
+                    done = false;
+                    break;
+                }
+                valueList.add(processObject(omElement, arrayClassType,
+                        helper));
+            }
+            retObjs[count] = ConverterUtil.convertToArray(arrayClassType,
+                    valueList);
+            if (!done) {
+                return omElement;
+            }
+        } else {
+            //handling refs
+            retObjs[count] = processObject(omElement, classType, helper);
+        }
+        return null;
+    }
+
     public static Object processObject(OMElement omElement,
                                        Class classType,
                                        MultirefHelper helper) throws AxisFault {
@@ -533,20 +541,20 @@
     }
 
     /**
-        * JAM convert first name of an attribute into UpperCase as an example
-        * if there is a instance variable called foo in a bean , then Jam give that as Foo
-        * so this method is to correct that error
-        *
-        * @param wrongName
-        * @return the right name, using english as the locale for case conversion
-        */
-       private static String getCorrectName(String wrongName) {
-           if (wrongName.length() > 1) {
-               return wrongName.substring(0, 1).toLowerCase(Locale.ENGLISH)
-                       + wrongName.substring(1, wrongName.length());
-           } else {
-               return wrongName.substring(0, 1).toLowerCase(Locale.ENGLISH);
-           }
-       }
+     * JAM convert first name of an attribute into UpperCase as an example
+     * if there is a instance variable called foo in a bean , then Jam give that as Foo
+     * so this method is to correct that error
+     *
+     * @param wrongName
+     * @return the right name, using english as the locale for case conversion
+     */
+    private static String getCorrectName(String wrongName) {
+        if (wrongName.length() > 1) {
+            return wrongName.substring(0, 1).toLowerCase(Locale.ENGLISH)
+                    + wrongName.substring(1, wrongName.length());
+        } else {
+            return wrongName.substring(0, 1).toLowerCase(Locale.ENGLISH);
+        }
+    }
 
 }

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=398106&r1=398105&r2=398106&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
Sat Apr 29 01:34:48 2006
@@ -92,6 +92,13 @@
 
 
     protected void setUp() throws Exception {
+        String className = "org.apache.axis2.rpc.RPCServiceClass";
+        service = new AxisService(serviceName.getLocalPart());
+        service.setClassLoader(Thread.currentThread().getContextClassLoader());
+        service.addParameter(new Parameter(AbstractMessageReceiver.SERVICE_CLASS,
+                className));
+        UtilServer.start();
+        UtilServer.deployService(service);
     }
 
     protected void tearDown() throws Exception {
@@ -137,17 +144,11 @@
                 new EndpointReference("http://127.0.0.1:"
                         + (UtilServer.TESTING_PORT)
                         + "/axis2/services/EchoXMLService/" + opName);
-        String className = "org.apache.axis2.rpc.RPCServiceClass";
         operationName = new QName("http://org.apache.axis2/xsd", opName, "req");
-        AxisService service = new AxisService(serviceName.getLocalPart());
-        service.setClassLoader(Thread.currentThread().getContextClassLoader());
-        service.addParameter(new Parameter(AbstractMessageReceiver.SERVICE_CLASS,
-                className));
         AxisOperation axisOp = new InOutAxisOperation(operationName);
         axisOp.setMessageReceiver(new RPCMessageReceiver());
         axisOp.setStyle(WSDLConstants.STYLE_RPC);
         service.addOperation(axisOp);
-        UtilServer.deployService(service);
     }
 
     public void testEchoBean() throws AxisFault {
@@ -603,6 +604,36 @@
                 ret.toArray());
         assertNotNull(objs);
         assertEquals(Boolean.TRUE, Boolean.valueOf(objs[0].toString()));
+    }
+
+    public void testmultiArrays() throws AxisFault {
+        configureSystem("multiArrays");
+
+        Options options = new Options();
+        options.setTo(targetEPR);
+        options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
+
+        ConfigurationContext configContext =
+                ConfigurationContextFactory.createConfigurationContextFromFileSystem(null,
null);
+        RPCServiceClient sender = new RPCServiceClient(configContext, null);
+        sender.setOptions(options);
+
+        ArrayList args = new ArrayList();
+        String [] values = new String[]{"abc", "cde", "efg"};
+        args.add(values);
+
+        String [] values2 = new String[]{"abc", "cde", "efg"};
+        args.add(values2);
+        String [] values3 = new String[]{"abc", "cde", "efg"};
+        args.add(values3);
+        args.add("10");
+
+        ArrayList ret = new ArrayList();
+        ret.add(Integer.class);
+        Object [] objs = sender.invokeBlocking(operationName, args.toArray(),
+                ret.toArray());
+        assertNotNull(objs);
+        assertEquals(19, Integer.parseInt(objs[0].toString()));
     }
 
     public void testmulReturn() throws AxisFault {

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=398106&r1=398105&r2=398106&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
Sat Apr 29 01:34:48 2006
@@ -188,4 +188,8 @@
     public Mail echoMail(Mail mail) {
         return mail;
     }
+
+    public int multiArrays(String [] a, String b [],String d [], int c) {
+        return a.length + b.length  + d.length+ c;
+    }
 }



Mime
View raw message