You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by am...@apache.org on 2008/09/05 11:05:28 UTC

svn commit: r692388 - in /webservices/axis2/trunk/java/modules/adb: src/org/apache/axis2/databinding/utils/ src/org/apache/axis2/databinding/utils/reader/ test/org/apache/axis2/databinding/utils/reader/

Author: amilas
Date: Fri Sep  5 02:05:26 2008
New Revision: 692388

URL: http://svn.apache.org/viewvc?rev=692388&view=rev
Log:
fixed issue regarding parsing and serializing the multidimentional arrays given
directly under service method

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/databinding/utils/reader/ADBXMLStreamReaderImpl.java
    webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/utils/reader/ADBXMLStreamReaderTest.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=692388&r1=692387&r2=692388&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 Fri Sep  5 02:05:26 2008
@@ -28,6 +28,7 @@
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.databinding.typemapping.SimpleTypeMapper;
 import org.apache.axis2.databinding.utils.reader.ADBXMLStreamReaderImpl;
+import org.apache.axis2.databinding.utils.reader.ArrayObjectWrapper;
 import org.apache.axis2.deployment.util.BeanExcludeInfo;
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.description.java2wsdl.TypeTable;
@@ -95,43 +96,6 @@
         return name;
     }
 
-    /**
-     * this method recursively search for all the supper classes to exclude the exclude bean info
-     * @param beanClass
-     * @param axisService
-     * @return
-     * @throws IntrospectionException
-     */
-    private static List<PropertyDescriptor> getPropertiesToSerialize(Class beanClass,
-                                                              AxisService axisService)
-            throws IntrospectionException {
-        List<PropertyDescriptor> propertiesToSerialize = null;
-        Class supperClass = beanClass.getSuperclass();
-
-        if (!getQualifiedName(supperClass.getPackage()).startsWith("java.")){
-            propertiesToSerialize = getPropertiesToSerialize(supperClass, axisService);
-        } else {
-            propertiesToSerialize = new ArrayList<PropertyDescriptor>();
-        }
-
-        BeanExcludeInfo beanExcludeInfo = null;
-        if (axisService != null && axisService.getExcludeInfo() != null) {
-            beanExcludeInfo = axisService.getExcludeInfo().getBeanExcludeInfoForClass(beanClass.getName());
-        }
-        BeanInfo beanInfo = Introspector.getBeanInfo(beanClass, beanClass.getSuperclass());
-        PropertyDescriptor[] properties = beanInfo.getPropertyDescriptors();
-        PropertyDescriptor property = null;
-        for (int i = 0; i < properties.length; i++) {
-            property = properties[i];
-            if (!property.getName().equals("class")) {
-                if ((beanExcludeInfo == null) || !beanExcludeInfo.isExcludedProperty(property.getName())) {
-                    propertiesToSerialize.add(property);
-                }
-            }
-        }
-        return propertiesToSerialize;
-    }
-
     private static List getPropertyQnameList(Object beanObject,
                                              Class beanClass,
                                              QName beanName,
@@ -368,12 +332,13 @@
                         Object objValue = parts.next();
                         if (objValue instanceof OMElement) {
                             omElement = (OMElement)objValue;
-                            if (!arrayLocalName.equals(omElement.getLocalName())) {
+                            if ((arrayLocalName != null) && !arrayLocalName.equals(omElement.getLocalName())) {
                                 continue;
                             }
+                            // this is a multi dimentional array so always inner element is array
                             Object obj = deserialize(arrayClassType,
                                     omElement,
-                                    objectSupplier, arrayLocalName);
+                                    objectSupplier, "array");
                             
                             	valueList.add(obj);
                         }
@@ -737,39 +702,46 @@
                 objects.add(arg);
                 continue;
             }
-            //todo if the request parameter has name other than argi (0<i<n) , there should be a
-            //way to do that , to solve that problem we need to have RPCRequestParameter
-            //note that The value of request parameter can either be simple type or JavaBean
+
             if (arg instanceof Object[]) {
-                Object array [] = (Object[])arg;
-                for (int j = 0; j < array.length; j++) {
-                    Object o = array[j];
-                    if (o == null) {
-                        objects.add("item" + argCount);
-                        objects.add(o);
-                    } else {
-                        if (SimpleTypeMapper.isSimpleType(o)) {
+                // at the client side the partname is always null. At client side this means user try to
+                // invoke a service with an array argument.
+                if (partName == null) {
+                    Object array [] = (Object[]) arg;
+                    for (int j = 0; j < array.length; j++) {
+                        Object o = array[j];
+                        if (o == null) {
                             objects.add("item" + argCount);
-                            objects.add(SimpleTypeMapper.getStringValue(o));
+                            objects.add(o);
                         } else {
-                            objects.add(new QName("item" + argCount));
-                            if (o instanceof OMElement) {
-                                OMFactory fac = OMAbstractFactory.getOMFactory();
-                                OMElement wrappingElement;
-                                if (partName == null) {
-                                    wrappingElement = fac.createOMElement("item" + argCount, null);
-                                    wrappingElement.addChild((OMElement)o);
+                            if (SimpleTypeMapper.isSimpleType(o)) {
+                                objects.add("item" + argCount);
+                                objects.add(SimpleTypeMapper.getStringValue(o));
+                            } else {
+                                objects.add(new QName("item" + argCount));
+                                if (o instanceof OMElement) {
+                                    OMFactory fac = OMAbstractFactory.getOMFactory();
+                                    OMElement wrappingElement;
+                                    if (partName == null) {
+                                        wrappingElement = fac.createOMElement("item" + argCount, null);
+                                        wrappingElement.addChild((OMElement) o);
+                                    } else {
+                                        wrappingElement = fac.createOMElement(partName, null);
+                                        wrappingElement.addChild((OMElement) o);
+                                    }
+                                    objects.add(wrappingElement);
                                 } else {
-                                    wrappingElement = fac.createOMElement(partName, null);
-                                    wrappingElement.addChild((OMElement)o);
+                                    objects.add(o);
                                 }
-                                objects.add(wrappingElement);
-                            } else {
-                                objects.add(o);
                             }
                         }
                     }
+                } else {
+                    // this happens at the server side. this means it is an multidimentional array.
+                    objects.add(partName);
+                    objects.add(arg);
                 }
+
             } else {
                 if (SimpleTypeMapper.isSimpleType(arg)) {
                     if (partName == null) {

Modified: webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/reader/ADBXMLStreamReaderImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/reader/ADBXMLStreamReaderImpl.java?rev=692388&r1=692387&r2=692388&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/reader/ADBXMLStreamReaderImpl.java (original)
+++ webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/reader/ADBXMLStreamReaderImpl.java Fri Sep  5 02:05:26 2008
@@ -954,7 +954,8 @@
                 List objects = new ArrayList();
 
                 for (int i = 0; i < objectArray.length; i++) {
-                    objects.add(propertyQName);
+                    //for innter Arrary Complex types we use the special local name array
+                    objects.add(new QName(propertyQName.getNamespaceURI(), "array"));
                     objects.add(objectArray[i]);
                 }
 

Modified: webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/utils/reader/ADBXMLStreamReaderTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/utils/reader/ADBXMLStreamReaderTest.java?rev=692388&r1=692387&r2=692388&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/utils/reader/ADBXMLStreamReaderTest.java (original)
+++ webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/utils/reader/ADBXMLStreamReaderTest.java Fri Sep  5 02:05:26 2008
@@ -424,10 +424,10 @@
         try {
             String expectedXML =
                     "<ns1:TestComplexStringArrayScenario xmlns:ns1=\"http://testComplexStringArrayScenario.org\">" +
-                            "<StringInfo><StringInfo>Some Text 0</StringInfo>" +
-                            "<StringInfo>Some Text 1</StringInfo>" +
-                            "<StringInfo>Some Text 2</StringInfo>" +
-                            "<StringInfo>Some Text 3</StringInfo></StringInfo>" +
+                            "<StringInfo><array>Some Text 0</array>" +
+                            "<array>Some Text 1</array>" +
+                            "<array>Some Text 2</array>" +
+                            "<array>Some Text 3</array></StringInfo>" +
                             "</ns1:TestComplexStringArrayScenario>";
 
             ArrayList propertyList = new ArrayList();
@@ -465,10 +465,10 @@
         try {
             String expectedXML =
                     "<ns1:TestComplexStringArrayScenario xmlns:ns1=\"http://testComplexStringArrayScenario.org\">" +
-                            "<StringInfo><StringInfo>Some Text 0</StringInfo>" +
-                            "<StringInfo xsi:nil=\"true\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"/>" +
-                            "<StringInfo>Some Text 2</StringInfo>" +
-                            "<StringInfo>Some Text 3</StringInfo></StringInfo>" +
+                            "<StringInfo><array>Some Text 0</array>" +
+                            "<array xsi:nil=\"true\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"/>" +
+                            "<array>Some Text 2</array>" +
+                            "<array>Some Text 3</array></StringInfo>" +
                             "</ns1:TestComplexStringArrayScenario>";
 
             ArrayList propertyList = new ArrayList();
@@ -515,10 +515,10 @@
                             "<Age>25</Age>" +
                             "<Sex>Male</Sex>" +
                             "</Dependent>" +
-                            "<StringInfo><StringInfo>Some Text 0</StringInfo>" +
-                            "<StringInfo>Some Text 1</StringInfo>" +
-                            "<StringInfo>Some Text 2</StringInfo>" +
-                            "<StringInfo>Some Text 3</StringInfo></StringInfo>" +
+                            "<StringInfo><array>Some Text 0</array>" +
+                            "<array>Some Text 1</array>" +
+                            "<array>Some Text 2</array>" +
+                            "<array>Some Text 3</array></StringInfo>" +
                             "<Bar>Some More Text</Bar>" +
                             "</ns1:TestComplexStringArrayScenario>";
 
@@ -567,11 +567,11 @@
             String expectedXML = "<ns1:TestComplexStringArrayScenario " +
                     "xmlns:ns1=\"http://testComplexStringArrayScenario.org\" " +
                     ">" +
-                    "<StringInfo><StringInfo>Some Text 0</StringInfo>" +
-                    "<StringInfo xsi:nil=\"true\" " +
-                    "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"></StringInfo>" +
-                    "<StringInfo>Some Text 2</StringInfo>" +
-                    "<StringInfo>Some Text 3</StringInfo></StringInfo>" +
+                    "<StringInfo><array>Some Text 0</array>" +
+                    "<array xsi:nil=\"true\" " +
+                    "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"></array>" +
+                    "<array>Some Text 2</array>" +
+                    "<array>Some Text 3</array></StringInfo>" +
                     "</ns1:TestComplexStringArrayScenario>";
 
             ArrayList propertyList = new ArrayList();