axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dee...@apache.org
Subject svn commit: r383857 - in /webservices/axis2/trunk/java/modules: adb/src/org/apache/axis2/databinding/utils/ core/src/org/apache/axis2/engine/ integration/test/org/apache/axis2/rpc/
Date Tue, 07 Mar 2006 12:03:09 GMT
Author: deepal
Date: Tue Mar  7 04:03:06 2006
New Revision: 383857

URL: http://svn.apache.org/viewcvs?rev=383857&view=rev
Log:
-small fixing in BeanUtil
- there are few code duplication I will fix that soon

Modified:
    webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AxisEngine.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=383857&r1=383856&r2=383857&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
Tue Mar  7 04:03:06 2006
@@ -26,12 +26,7 @@
 import org.apache.ws.commons.om.OMFactory;
 import org.apache.ws.commons.om.impl.llom.builder.StAXOMBuilder;
 import org.apache.ws.commons.om.impl.llom.factory.OMXMLBuilderFactory;
-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.codehaus.jam.*;
 
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamReader;
@@ -323,6 +318,7 @@
         //to support array . if the parameter type is array , then all the omelemnts with
that paramtre name
         // has to  get and add to the list
         Class classType;
+        String currentLocalName = "";
         while (parts.hasNext() && count < length) {
             Object objValue = parts.next();
             OMElement omElement;
@@ -331,45 +327,136 @@
             } else {
                 continue;
             }
+            currentLocalName = omElement.getLocalName();
             classType = (Class) javaTypes[count];
-            //handling refs
-            OMAttribute omatribute = MultirefHelper.processRefAtt(omElement);
-            String ref = null;
-            if (omatribute != null) {
-                hasRef = true;
-                ref = MultirefHelper.getAttvalue(omatribute);
-            }
+            if (classType.isArray()) {
+                ArrayList valueList = new ArrayList();
+                Class arrayClassType = classType.getComponentType();
+
+                OMAttribute omatribute = MultirefHelper.processRefAtt(omElement);
+                String ref = null;
+                if (omatribute != null) {
+                    hasRef = true;
+                    ref = MultirefHelper.getAttvalue(omatribute);
+                }
 
-            if (OMElement.class.isAssignableFrom(classType)) {
-                if (hasRef) {
-                    OMElement elemnt = helper.getOMElement(ref);
-                    if (elemnt == null) {
-                        retObjs[count] = helper.processOMElementRef(ref);
+                if (OMElement.class.isAssignableFrom(arrayClassType)) {
+                    if (hasRef) {
+                        OMElement elemnt = helper.getOMElement(ref);
+                        if (elemnt == null) {
+                            valueList.add(helper.processOMElementRef(ref));
+                        } else {
+                            valueList.add(omElement);
+                        }
+                    } else
+                        valueList.add(omElement);
+                } else {
+                    if (hasRef) {
+                        if (helper.getObject(ref) != null) {
+                            valueList.add(helper.getObject(ref));
+                        } else {
+                            valueList.add(helper.processRef(classType, ref));
+                        }
                     } else {
-                        retObjs[count] = omElement;
+                        if (SimpleTypeMapper.isSimpleType(arrayClassType)) {
+                            valueList.add(SimpleTypeMapper.getSimpleTypeObject(arrayClassType,
omElement));
+                        } else if (SimpleTypeMapper.isArrayList(arrayClassType)) {
+                            valueList.add(SimpleTypeMapper.getArrayList(omElement));
+                        } else {
+                            valueList.add(BeanUtil.deserialize(arrayClassType, omElement));
+                        }
                     }
-                } else
-                    retObjs[count] = omElement;
-            } else {
-                if (hasRef) {
-                    if (helper.getObject(ref) != null) {
-                        retObjs[count] = helper.getObject(ref);
+                }
+
+                while (parts.hasNext()) {
+                    objValue = parts.next();
+                    if (objValue instanceof OMElement) {
+                        omElement = (OMElement) objValue;
+                    } else {
+                        continue;
+                    }
+
+                    if (!currentLocalName.equals(omElement.getLocalName())) {
+                        break;
+                    }
+                    omatribute = MultirefHelper.processRefAtt(omElement);
+                    ref = null;
+                    if (omatribute != null) {
+                        hasRef = true;
+                        ref = MultirefHelper.getAttvalue(omatribute);
+                    }
+
+                    if (OMElement.class.isAssignableFrom(arrayClassType)) {
+                        if (hasRef) {
+                            OMElement elemnt = helper.getOMElement(ref);
+                            if (elemnt == null) {
+                                valueList.add(helper.processOMElementRef(ref));
+                            } else {
+                                valueList.add(omElement);
+                            }
+                        } else
+                            valueList.add(omElement);
                     } else {
-                        retObjs[count] = helper.processRef(classType, ref);
+                        if (hasRef) {
+                            if (helper.getObject(ref) != null) {
+                                valueList.add(helper.getObject(ref));
+                            } else {
+                                valueList.add(helper.processRef(classType, ref));
+                            }
+                        } else {
+                            if (SimpleTypeMapper.isSimpleType(arrayClassType)) {
+                                valueList.add(SimpleTypeMapper.getSimpleTypeObject(arrayClassType,
omElement));
+                            } else if (SimpleTypeMapper.isArrayList(arrayClassType)) {
+                                valueList.add(SimpleTypeMapper.getArrayList(omElement));
+                            } else {
+                                valueList.add(BeanUtil.deserialize(arrayClassType, omElement));
+                            }
+                        }
                     }
+
+                }
+                retObjs[count] = ConverterUtil.convertToArray(arrayClassType, valueList);
+            } else {
+                //handling refs
+                OMAttribute omatribute = MultirefHelper.processRefAtt(omElement);
+                String ref = null;
+                if (omatribute != null) {
+                    hasRef = true;
+                    ref = MultirefHelper.getAttvalue(omatribute);
+                }
+
+                if (OMElement.class.isAssignableFrom(classType)) {
+                    if (hasRef) {
+                        OMElement elemnt = helper.getOMElement(ref);
+                        if (elemnt == null) {
+                            retObjs[count] = helper.processOMElementRef(ref);
+                        } else {
+                            retObjs[count] = omElement;
+                        }
+                    } else
+                        retObjs[count] = omElement;
                 } else {
-                    if (SimpleTypeMapper.isSimpleType(classType)) {
-                        retObjs[count] = SimpleTypeMapper.getSimpleTypeObject(classType,
omElement);
-                    } else if (SimpleTypeMapper.isArrayList(classType)) {
-                        retObjs[count] = SimpleTypeMapper.getArrayList(omElement);
+                    if (hasRef) {
+                        if (helper.getObject(ref) != null) {
+                            retObjs[count] = helper.getObject(ref);
+                        } else {
+                            retObjs[count] = helper.processRef(classType, ref);
+                        }
                     } else {
-                        retObjs[count] = BeanUtil.deserialize(classType, omElement);
+                        if (SimpleTypeMapper.isSimpleType(classType)) {
+                            retObjs[count] = SimpleTypeMapper.getSimpleTypeObject(classType,
omElement);
+                        } else if (SimpleTypeMapper.isArrayList(classType)) {
+                            retObjs[count] = SimpleTypeMapper.getArrayList(omElement);
+                        } else {
+                            retObjs[count] = BeanUtil.deserialize(classType, omElement);
+                        }
                     }
                 }
             }
             hasRef = false;
             count ++;
         }
+
         helper.clean();
         return retObjs;
     }

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AxisEngine.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AxisEngine.java?rev=383857&r1=383856&r2=383857&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AxisEngine.java
(original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AxisEngine.java
Tue Mar  7 04:03:06 2006
@@ -454,7 +454,7 @@
      * @throws AxisFault
      */
     public void receiveFault(MessageContext msgContext) throws AxisFault {
-        log.info( Messages.getMessage("receivederrormessage",
+        log.info(Messages.getMessage("receivederrormessage",
                 msgContext.getMessageID()));
         ConfigurationContext confContext = msgContext.getConfigurationContext();
         ArrayList preCalculatedPhases =
@@ -569,7 +569,8 @@
         private MessageContext msgctx;
         private TransportSender sender;
 
-        public TranportNonBlockingInvocationWorker(MessageContext msgctx, TransportSender
sender) {
+        public TranportNonBlockingInvocationWorker(MessageContext msgctx,
+                                                   TransportSender sender) {
             this.msgctx = msgctx;
             this.sender = sender;
         }

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=383857&r1=383856&r2=383857&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 Mar  7 04:03:06 2006
@@ -101,7 +101,7 @@
         options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
 
         ConfigurationContext configContext =
-                ConfigurationContextFactory.createConfigurationContextFromFileSystem(clientHome,null);
+                ConfigurationContextFactory.createConfigurationContextFromFileSystem(clientHome,
null);
         RPCServiceClient sender = new RPCServiceClient(configContext, null);
         sender.setOptions(options);
         options.setTo(targetEPR);
@@ -153,7 +153,7 @@
         options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
 
         ConfigurationContext configContext =
-                ConfigurationContextFactory.createConfigurationContextFromFileSystem("target/test-resources/integrationRepo",null);
+                ConfigurationContextFactory.createConfigurationContextFromFileSystem("target/test-resources/integrationRepo",
null);
         RPCServiceClient sender = new RPCServiceClient(configContext, null);
         sender.setOptions(options);
 
@@ -186,7 +186,7 @@
         options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
 
         ConfigurationContext configContext =
-                ConfigurationContextFactory.createConfigurationContextFromFileSystem("target/test-resources/integrationRepo",null);
+                ConfigurationContextFactory.createConfigurationContextFromFileSystem("target/test-resources/integrationRepo",
null);
         RPCServiceClient sender = new RPCServiceClient(configContext, null);
         sender.setOptions(options);
 
@@ -204,7 +204,7 @@
         options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
 
         ConfigurationContext configContext =
-                ConfigurationContextFactory.createConfigurationContextFromFileSystem("target/test-resources/integrationRepo",null);
+                ConfigurationContextFactory.createConfigurationContextFromFileSystem("target/test-resources/integrationRepo",
null);
         RPCServiceClient sender = new RPCServiceClient(configContext, null);
         sender.setOptions(options);
 
@@ -218,7 +218,7 @@
     public void testAdd() throws AxisFault {
         configureSystem("add");
         ConfigurationContext configContext =
-                ConfigurationContextFactory.createConfigurationContextFromFileSystem("target/test-resources/integrationRepo",null);
+                ConfigurationContextFactory.createConfigurationContextFromFileSystem("target/test-resources/integrationRepo",
null);
         RPCServiceClient sender = new RPCServiceClient(configContext, null);
 
         Options options = new Options();
@@ -241,7 +241,7 @@
         options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
 
         ConfigurationContext configContext =
-                ConfigurationContextFactory.createConfigurationContextFromFileSystem("target/test-resources/integrationRepo",null);
+                ConfigurationContextFactory.createConfigurationContextFromFileSystem("target/test-resources/integrationRepo",
null);
         RPCServiceClient sender = new RPCServiceClient(configContext, null);
         sender.setOptions(options);
 
@@ -261,7 +261,7 @@
         options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
 
         ConfigurationContext configContext =
-                ConfigurationContextFactory.createConfigurationContextFromFileSystem("target/test-resources/integrationRepo",null);
+                ConfigurationContextFactory.createConfigurationContextFromFileSystem("target/test-resources/integrationRepo",
null);
         RPCServiceClient sender = new RPCServiceClient(configContext, null);
         sender.setOptions(options);
 
@@ -281,7 +281,7 @@
         options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
 
         ConfigurationContext configContext =
-                ConfigurationContextFactory.createConfigurationContextFromFileSystem("target/test-resources/integrationRepo",null);
+                ConfigurationContextFactory.createConfigurationContextFromFileSystem("target/test-resources/integrationRepo",
null);
         RPCServiceClient sender = new RPCServiceClient(configContext, null);
         sender.setOptions(options);
 
@@ -299,7 +299,7 @@
         options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
 
         ConfigurationContext configContext =
-                ConfigurationContextFactory.createConfigurationContextFromFileSystem("target/test-resources/integrationRepo",null);
+                ConfigurationContextFactory.createConfigurationContextFromFileSystem("target/test-resources/integrationRepo",
null);
         RPCServiceClient sender = new RPCServiceClient(configContext, null);
         sender.setOptions(options);
 
@@ -337,7 +337,7 @@
         options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
 
         ConfigurationContext configContext =
-                ConfigurationContextFactory.createConfigurationContextFromFileSystem("target/test-resources/integrationRepo",null);
+                ConfigurationContextFactory.createConfigurationContextFromFileSystem("target/test-resources/integrationRepo",
null);
         RPCServiceClient sender = new RPCServiceClient(configContext, null);
         sender.setOptions(options);
 
@@ -356,7 +356,7 @@
         options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
 
         ConfigurationContext configContext =
-                ConfigurationContextFactory.createConfigurationContextFromFileSystem("target/test-resources/integrationRepo",null);
+                ConfigurationContextFactory.createConfigurationContextFromFileSystem("target/test-resources/integrationRepo",
null);
         RPCServiceClient sender = new RPCServiceClient(configContext, null);
         sender.setOptions(options);
 
@@ -377,7 +377,7 @@
         options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
 
         ConfigurationContext configContext =
-                ConfigurationContextFactory.createConfigurationContextFromFileSystem("target/test-resources/integrationRepo",null);
+                ConfigurationContextFactory.createConfigurationContextFromFileSystem("target/test-resources/integrationRepo",
null);
         RPCServiceClient sender = new RPCServiceClient(configContext, null);
         sender.setOptions(options);
 
@@ -410,7 +410,7 @@
         options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
 
         ConfigurationContext configContext =
-                ConfigurationContextFactory.createConfigurationContextFromFileSystem("target/test-resources/integrationRepo",null);
+                ConfigurationContextFactory.createConfigurationContextFromFileSystem("target/test-resources/integrationRepo",
null);
         RPCServiceClient sender = new RPCServiceClient(configContext, null);
         sender.setOptions(options);
 
@@ -432,7 +432,7 @@
         options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
 
         ConfigurationContext configContext =
-                ConfigurationContextFactory.createConfigurationContextFromFileSystem("target/test-resources/integrationRepo",null);
+                ConfigurationContextFactory.createConfigurationContextFromFileSystem("target/test-resources/integrationRepo",
null);
         RPCServiceClient sender = new RPCServiceClient(configContext, null);
         sender.setOptions(options);
 
@@ -449,6 +449,43 @@
 //        assertEquals(Byte.parseByte(response.getFirstElement().getText()),1);
     }
 
+    public void testStringArray() throws AxisFault {
+        configureSystem("handleStringArray");
+
+        Options options = new Options();
+        options.setTo(targetEPR);
+        options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
+
+        ConfigurationContext configContext =
+                ConfigurationContextFactory.createConfigurationContextFromFileSystem("target/test-resources/integrationRepo",
null);
+        RPCServiceClient sender = new RPCServiceClient(configContext, null);
+        sender.setOptions(options);
+
+        String str = "<req:handleStringArray xmlns:req=\"http://org.apache.axis2/xsd\">\n"
+
+                "    <item0>abc</item0>\n" +
+                "    <item0>def</item0>\n" +
+                "    <item0>ghi</item0>\n" +
+                "    <item0>klm</item0>\n" +
+                "</req:handleStringArray>";
+        StAXOMBuilder staxOMBuilder;
+        try {
+            XMLStreamReader xmlReader = XMLInputFactory.newInstance().createXMLStreamReader(new
+                    ByteArrayInputStream(str.getBytes()));
+            OMFactory fac = OMAbstractFactory.getOMFactory();
+
+            staxOMBuilder = new
+                    StAXOMBuilder(fac, xmlReader);
+        } catch (XMLStreamException e) {
+            throw new AxisFault(e);
+        } catch (FactoryConfigurationError factoryConfigurationError) {
+            throw new AxisFault(factoryConfigurationError);
+        }
+        ;
+
+        OMElement result = sender.sendReceive(staxOMBuilder.getDocumentElement());
+        assertEquals(result.getFirstElement().getText(), "true");
+    }
+
     public void testmulReturn() throws AxisFault {
         configureSystem("mulReturn");
 
@@ -457,7 +494,7 @@
         options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
 
         ConfigurationContext configContext =
-                ConfigurationContextFactory.createConfigurationContextFromFileSystem("target/test-resources/integrationRepo",null);
+                ConfigurationContextFactory.createConfigurationContextFromFileSystem("target/test-resources/integrationRepo",
null);
         RPCServiceClient sender = new RPCServiceClient(configContext, null);
         sender.setOptions(options);
 
@@ -478,7 +515,7 @@
         options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
 
         ConfigurationContext configContext =
-                ConfigurationContextFactory.createConfigurationContextFromFileSystem("target/test-resources/integrationRepo",null);
+                ConfigurationContextFactory.createConfigurationContextFromFileSystem("target/test-resources/integrationRepo",
null);
         RPCServiceClient sender = new RPCServiceClient(configContext, null);
         sender.setOptions(options);
 

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=383857&r1=383856&r2=383857&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 Mar  7 04:03:06 2006
@@ -131,11 +131,11 @@
         return bean2 != null && bean != null;
     }
 
-    public String handleArrayList(ArrayList list, int b){
-        String str="";
+    public String handleArrayList(ArrayList list, int b) {
+        String str = "";
         for (int i = 0; i < list.size(); i++) {
             Object obj = list.get(i);
-            if(obj instanceof OMElement){
+            if (obj instanceof OMElement) {
                 OMElement omElement = (OMElement) obj;
                 str = str + omElement.getText();
             }
@@ -143,25 +143,29 @@
         return str + b;
     }
 
-    public Employee echoEmployee(Employee em){
+    public Employee echoEmployee(Employee em) {
         return em;
     }
 
 
     public Company echoCompany(Company com) throws AxisFault {
         ArrayList pss = com.getPersons();
-        ArrayList tems= new ArrayList();
+        ArrayList tems = new ArrayList();
         for (int i = 0; i < pss.size(); i++) {
             OMElement omElement = (OMElement) pss.get(i);
-            Person  p =(Person) BeanUtil.deserialize(Person.class,omElement);
+            Person p = (Person) BeanUtil.deserialize(Person.class, omElement);
             tems.add(p);
         }
         com.setPersons(tems);
         return com;
     }
 
-    public void handlAnyThing(String value1, int abc, Date date){
+    public void handlAnyThing(String value1, int abc, Date date) {
 
+    }
+
+    public boolean handleStringArray(String [] value) {
+        return value.length > 0;
     }
 
 }



Mime
View raw message