ws-axis-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aj...@apache.org
Subject svn commit: r391258 [2/2] - in /webservices/axis2/trunk/java/modules: adb/src/org/apache/axis2/databinding/ adb/src/org/apache/axis2/databinding/utils/ adb/src/org/apache/axis2/databinding/utils/reader/ adb/test/org/apache/axis2/databinding/ adb/test/o...
Date Tue, 04 Apr 2006 09:19:18 GMT
Added: webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/reader/WrappingXMLStreamReader.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/reader/WrappingXMLStreamReader.java?rev=391258&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/reader/WrappingXMLStreamReader.java (added)
+++ webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/reader/WrappingXMLStreamReader.java Tue Apr  4 02:19:13 2006
@@ -0,0 +1,252 @@
+package org.apache.axis2.databinding.utils.reader;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.Location;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.namespace.QName;
+import javax.xml.namespace.NamespaceContext;
+/*
+ * 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.
+ */
+
+public class WrappingXMLStreamReader implements ADBXMLStreamReader{
+
+    private XMLStreamReader reader;
+    private int depth = 0;
+    private boolean initState = true;
+
+    public WrappingXMLStreamReader(XMLStreamReader reader) {
+        this.reader = reader;
+    }
+
+    public boolean isDone() {
+        /////////////////////////////////
+//        try {
+//            System.out.println("1 -----------" + this.reader.hasNext());
+//            System.out.println("2  -----------" +(depth==0 && !initState));
+//        } catch (XMLStreamException e) {
+//            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+//        }
+//        ////////////////////////////////
+//        try {
+//            boolean b = hasNext();
+//            System.out.println("######" + b + "#####");
+//            System.out.println("----------" + (depth==0 && !initState && !b) + " -------");
+//            return (depth==0 && !initState && !b);
+//        } catch (XMLStreamException e) {
+//            throw new RuntimeException(e);
+//        }
+        try {
+            return !hasNext();
+        } catch (XMLStreamException e) {
+             throw new RuntimeException(e);
+        }
+    }
+
+    public Object getProperty(String string) throws IllegalArgumentException {
+        return reader.getProperty(string);
+    }
+
+    public int next() throws XMLStreamException {
+        int event = reader.next();
+        initState = false;
+        if (event==START_ELEMENT || event==START_DOCUMENT){
+            depth++;
+        }else if (event==END_ELEMENT || event==END_DOCUMENT){
+            depth = depth!=0?depth--:depth;
+        }
+        return event;
+    }
+
+    public void require(int i, String string, String string1) throws XMLStreamException {
+        //nothing to do
+    }
+
+    public String getElementText() throws XMLStreamException {
+       return reader.getElementText();
+    }
+
+    public int nextTag() throws XMLStreamException {
+        return reader.nextTag();
+    }
+
+    public boolean hasNext() throws XMLStreamException {
+        return reader.hasNext();
+    }
+
+    public void close() throws XMLStreamException {
+         reader.close();
+    }
+
+    public String getNamespaceURI(String string) {
+        return reader.getNamespaceURI(string);
+    }
+
+    public boolean isStartElement() {
+         return reader.isStartElement();
+    }
+
+    public boolean isEndElement() {
+        return reader.isEndElement();
+    }
+
+    public boolean isCharacters() {
+       return reader.isCharacters();
+    }
+
+    public boolean isWhiteSpace() {
+        return reader.isWhiteSpace();
+    }
+
+    public String getAttributeValue(String string, String string1) {
+        return reader.getAttributeValue(string,string1);
+    }
+
+    public int getAttributeCount() {
+        return reader.getAttributeCount();
+    }
+
+    public QName getAttributeName(int i) {
+        return reader.getAttributeName(i);
+    }
+
+    public String getAttributeNamespace(int i) {
+       return reader.getAttributeNamespace(i);
+    }
+
+    public String getAttributeLocalName(int i) {
+        return reader.getAttributeLocalName(i);
+    }
+
+    public String getAttributePrefix(int i) {
+       return reader.getAttributeLocalName(i);
+    }
+
+    public String getAttributeType(int i) {
+        return reader.getAttributeType(i);
+    }
+
+    public String getAttributeValue(int i) {
+        return reader.getAttributeValue(i);
+    }
+
+    public boolean isAttributeSpecified(int i) {
+        return reader.isAttributeSpecified(i);
+    }
+
+    public int getNamespaceCount() {
+        return reader.getNamespaceCount();
+    }
+
+    public String getNamespacePrefix(int i) {
+          return reader.getNamespacePrefix(i);
+    }
+
+    public String getNamespaceURI(int i) {
+          return reader.getNamespaceURI(i);
+    }
+
+    public NamespaceContext getNamespaceContext() {
+        return reader.getNamespaceContext();
+    }
+
+    public int getEventType() {
+       return reader.getEventType();
+    }
+
+    public String getText() {
+        return reader.getText();
+    }
+
+    public char[] getTextCharacters() {
+       return reader.getTextCharacters();
+    }
+
+    public int getTextCharacters(int i, char[] chars, int i1, int i2) throws XMLStreamException {
+        return reader.getTextCharacters(i,chars,i1,i2);
+    }
+
+    public int getTextStart() {
+        return reader.getTextStart();
+    }
+
+    public int getTextLength() {
+        return reader.getTextLength();
+    }
+
+    public String getEncoding() {
+        return reader.getEncoding();
+    }
+
+    public boolean hasText() {
+        return reader.hasText();
+    }
+
+    public Location getLocation() {
+        return reader.getLocation();
+    }
+
+    public QName getName() {
+         return reader.getName();
+    }
+
+    public String getLocalName() {
+        return reader.getLocalName();
+    }
+
+    public boolean hasName() {
+         return reader.hasName();
+    }
+
+    public String getNamespaceURI() {
+         return reader.getNamespaceURI();
+    }
+
+    public String getPrefix() {
+         return reader.getPrefix();
+    }
+
+    public String getVersion() {
+        return reader.getVersion();
+    }
+
+    public boolean isStandalone() {
+        return reader.isStandalone();
+    }
+
+    public boolean standaloneSet() {
+       return reader.standaloneSet();
+    }
+
+    public String getCharacterEncodingScheme() {
+        return reader.getCharacterEncodingScheme();
+    }
+
+    public String getPITarget() {
+         return reader.getPITarget();
+    }
+
+    public String getPIData() {
+        return reader.getPIData();
+    }
+
+    public void addNamespaceContext(NamespaceContext nsContext) {
+        //nothing to do here
+    }
+
+    public void init() {
+        //Nothing to do here
+    }
+}

Modified: webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/ADBSOAPModelBuilderTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/ADBSOAPModelBuilderTest.java?rev=391258&r1=391257&r2=391258&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/ADBSOAPModelBuilderTest.java (original)
+++ webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/ADBSOAPModelBuilderTest.java Tue Apr  4 02:19:13 2006
@@ -22,8 +22,9 @@
 import org.apache.axiom.soap.SOAP11Constants;
 import org.apache.axiom.soap.SOAPEnvelope;
 import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
-import org.apache.axis2.databinding.utils.ADBPullParser;
 import org.apache.axis2.databinding.utils.PrintEvents;
+import org.apache.axis2.databinding.utils.reader.ADBXMLStreamReaderImpl;
+import org.apache.axis2.util.StreamWrapper;
 import org.custommonkey.xmlunit.XMLTestCase;
 import org.w3c.dom.Document;
 import org.xml.sax.SAXException;
@@ -42,7 +43,21 @@
 
 public class ADBSOAPModelBuilderTest extends XMLTestCase {
     public void testSimpleArrayList() throws Exception {
-        String expectedXML = "<?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"><soapenv:Header /><soapenv:Body><Person xmlns=\"\"><Name xmlns=\"\">FooOne</Name><DependentOne xmlns=\"\"><Name xmlns=\"\">FooTwo</Name><Age xmlns=\"\">25</Age><Sex xmlns=\"\">Male</Sex></DependentOne><DependentTwo xmlns=\"\"><Name xmlns=\"\">FooTwo</Name><Age xmlns=\"\">25</Age><Sex xmlns=\"\">Male</Sex></DependentTwo><Organization xmlns=\"\">Apache</Organization></Person></soapenv:Body></soapenv:Envelope>";
+        String expectedXML = "<?xml version='1.0' encoding='utf-8'?>" +
+                "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
+                "<soapenv:Header />" +
+                "<soapenv:Body>" +
+                "<Person xmlns=\"\">" +
+                "<Name xmlns=\"\">FooOne</Name>" +
+                "<DependentOne xmlns=\"\"><Name xmlns=\"\">FooTwo</Name>" +
+                "<Age xmlns=\"\">25</Age>" +
+                "<Sex xmlns=\"\">Male</Sex></DependentOne>" +
+                "<DependentTwo xmlns=\"\">" +
+                "<Name xmlns=\"\">FooTwo</Name>" +
+                "<Age xmlns=\"\">25</Age>" +
+                "<Sex xmlns=\"\">Male</Sex></DependentTwo>" +
+                "<Organization xmlns=\"\">Apache</Organization>" +
+                "</Person></soapenv:Body></soapenv:Envelope>";
         ArrayList propertyList = new ArrayList();
         propertyList.add("Name");
         propertyList.add("FooOne");
@@ -54,8 +69,9 @@
         propertyList.add("Apache");
         QName projectQName = new QName("Person");
 
-        XMLStreamReader pullParser = ADBPullParser.createPullParser(projectQName, propertyList.toArray(), null);
-        ADBSOAPModelBuilder builder = new ADBSOAPModelBuilder(pullParser, OMAbstractFactory.getSOAP11Factory());
+        XMLStreamReader pullParser =new ADBXMLStreamReaderImpl(projectQName, propertyList.toArray(), null);
+        ADBSOAPModelBuilder builder = new ADBSOAPModelBuilder(
+                pullParser, OMAbstractFactory.getSOAP11Factory());
 
         OMElement root = builder.getDocumentElement();
         assertTrue("Root element can not be null", root != null);
@@ -161,7 +177,7 @@
         }
 
         public XMLStreamReader getPullParser(QName adbBeanQName) {
-            return ADBPullParser.createPullParser(adbBeanQName, propertyList.toArray(), null);
+            return new ADBXMLStreamReaderImpl(adbBeanQName, propertyList.toArray(), null);
         }
     }
 

Modified: webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/ClientInfo.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/ClientInfo.java?rev=391258&r1=391257&r2=391258&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/ClientInfo.java (original)
+++ webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/ClientInfo.java Tue Apr  4 02:19:13 2006
@@ -100,7 +100,8 @@
         elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localSsn));
 
 
-        return org.apache.axis2.databinding.utils.ADBPullParser.createPullParser(qName, elementList.toArray(), attribList.toArray());
+        return new org.apache.axis2.databinding.utils.reader.ADBXMLStreamReaderImpl
+                (qName, elementList.toArray(), attribList.toArray());
 
 
     }

Modified: webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/CreateAccountRequest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/CreateAccountRequest.java?rev=391258&r1=391257&r2=391258&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/CreateAccountRequest.java (original)
+++ webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/CreateAccountRequest.java Tue Apr  4 02:19:13 2006
@@ -85,8 +85,8 @@
         elementList.add(org.apache.axis2.databinding.utils.ConverterUtil
                 .convertToString(localPassword));
 
-        return org.apache.axis2.databinding.utils.ADBPullParser
-                .createPullParser(qName, elementList.toArray(), attribList
+        return new org.apache.axis2.databinding.utils.reader.ADBXMLStreamReaderImpl
+                (qName, elementList.toArray(), attribList
                         .toArray());
 
     }

Added: webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/utils/reader/ADBXMLStreamReaderTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/utils/reader/ADBXMLStreamReaderTest.java?rev=391258&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/utils/reader/ADBXMLStreamReaderTest.java (added)
+++ webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/utils/reader/ADBXMLStreamReaderTest.java Tue Apr  4 02:19:13 2006
@@ -0,0 +1,713 @@
+package org.apache.axis2.databinding.utils.reader;
+
+import org.custommonkey.xmlunit.XMLTestCase;
+import org.apache.axis2.util.StreamWrapper;
+import org.apache.axis2.databinding.utils.Constants;
+import org.apache.axis2.databinding.ADBBean;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.impl.serialize.StreamingOMSerializer;
+import org.xml.sax.SAXException;
+import org.w3c.dom.Document;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.DocumentBuilder;
+import java.util.ArrayList;
+import java.util.List;
+import java.io.IOException;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+/*
+ * 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.
+ */
+
+public class ADBXMLStreamReaderTest extends XMLTestCase {
+
+    private DocumentBuilder db;
+
+    protected void setUp() throws Exception {
+        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+        dbf.setNamespaceAware(true);
+        db = dbf.newDocumentBuilder();
+    }
+
+    /**
+     * complex array scenario
+     */
+    public void testComplexObjectArrayScenario() {
+        try {
+            String expectedXML = "<ns1:TestComplexStringArrayScenario xmlns:ns1=\"http://testComplexStringArrayScenario.org\">" +
+                    "<Foo>Some Text</Foo>" +
+                    "<Dependent>" +
+                    "<Name>FooTwo</Name>" +
+                    "<Age>25</Age>" +
+                    "<Sex>Male</Sex>" +
+                    "</Dependent>" +
+                    "<AdditionalDependent>" +
+                    "<Name>FooTwo</Name>" +
+                    "<Age>25</Age>" +
+                    "<Sex>Male</Sex>" +
+                    "</AdditionalDependent>" +
+                    "<AdditionalDependent>" +
+                    "<Name>FooTwo</Name>" +
+                    "<Age>25</Age>" +
+                    "<Sex>Male</Sex>" +
+                    "</AdditionalDependent>" +
+                    "<AdditionalDependent>" +
+                    "<Name>FooTwo</Name>" +
+                    "<Age>25</Age>" +
+                    "<Sex>Male</Sex>" +
+                    "</AdditionalDependent>" +
+                    "<AdditionalDependent>" +
+                    "<Name>FooTwo</Name>" +
+                    "<Age>25</Age>" +
+                    "<Sex>Male</Sex>" +
+                    "</AdditionalDependent>" +
+                    "<Bar>Some More Text</Bar><" +
+                    "/ns1:TestComplexStringArrayScenario>";
+
+            ArrayList propertyList = new ArrayList();
+            propertyList.add("Foo");
+            propertyList.add("Some Text");
+            propertyList.add(new QName("Dependent"));
+            DummyADBBean dummyBean = new DummyADBBean();
+            propertyList.add(dummyBean);
+
+            ADBBean[] adbBeans = new ADBBean[4];
+            for (int i = 0; i < 4; i++) {
+                adbBeans[i] = new DummyADBBean();
+            }
+            for (int i = 0; i < adbBeans.length; i++) {
+                propertyList.add(new QName("AdditionalDependent"));
+                propertyList.add(adbBeans[i]);
+
+            }
+
+            propertyList.add("Bar");
+            propertyList.add("Some More Text");
+
+            XMLStreamReader pullParser = new ADBXMLStreamReaderImpl(new QName("http://testComplexStringArrayScenario.org", "TestComplexStringArrayScenario", "ns1"), propertyList.toArray(), null);
+            String actualXML = getStringXML(pullParser);
+
+
+            assertXMLEqual(newDocument(expectedXML), newDocument(actualXML));
+        } catch (ParserConfigurationException e) {
+            fail("Error has occurred " + e);
+        } catch (SAXException e) {
+            fail("Error has occurred " + e);
+        } catch (IOException e) {
+            fail("Error has occurred " + e);
+        } catch (Exception e) {
+            fail("Error has occurred " + e);
+        }
+    }
+
+
+    /**
+     * Empty array
+     */
+    public void testComplexObjectArrayScenarioEmptyArray() {
+        try {
+            String expectedXML = "<ns1:TestComplexStringArrayScenario xmlns:ns1=\"http://testComplexStringArrayScenario.org\">" +
+                    "<Foo>Some Text</Foo>" +
+                    "<Dependent>" +
+                    "<Name>FooTwo</Name>" +
+                    "<Age>25</Age>" +
+                    "<Sex>Male</Sex>" +
+                    "</Dependent>" +
+                    "<Bar>Some More Text</Bar><" +
+                    "/ns1:TestComplexStringArrayScenario>";
+
+            ArrayList propertyList = new ArrayList();
+            propertyList.add("Foo");
+            propertyList.add("Some Text");
+            propertyList.add(new QName("Dependent"));
+            DummyADBBean dummyBean = new DummyADBBean();
+            propertyList.add(dummyBean);
+
+            String[] array = new String[]{};
+            propertyList.add(new QName("AdditionalDependent"));
+            propertyList.add(array);
+
+            propertyList.add("Bar");
+            propertyList.add("Some More Text");
+
+            XMLStreamReader pullParser = new ADBXMLStreamReaderImpl(
+                    new QName("http://testComplexStringArrayScenario.org",
+                            "TestComplexStringArrayScenario", "ns1"),
+                    propertyList.toArray(),
+                    null);
+            String actualXML = getStringXML(pullParser);
+            assertXMLEqual(newDocument(expectedXML), newDocument(actualXML));
+
+        } catch (ParserConfigurationException e) {
+            fail("Error has occurred " + e);
+        } catch (SAXException e) {
+            fail("Error has occurred " + e);
+        } catch (IOException e) {
+            fail("Error has occurred " + e);
+        } catch (Exception e) {
+            fail("Error has occurred " + e);
+        }
+    }
+    /**
+     * test a complex array list
+     */
+    public void testComplexArrayList() {
+        try {
+
+            String exptectedXML = "<Person><Name>FooOne</Name><Organization>Apache</Organization>" +
+                    "<Dependent><Name>FooTwo</Name><Age>25</Age><Sex>Male</Sex><Depemdent>" +
+                    "<Name>FooTwo</Name><Age>25</Age><Sex>Male</Sex><Depemdent><Name>FooTwo</Name>" +
+                    "<Age>25</Age><Sex>Male</Sex></Depemdent></Depemdent></Dependent>" +
+                    "<test:Dependent xmlns:test=\"http://whatever.com\"><Name>FooTwo</Name><Age>25</Age>" +
+                    "<Sex>Male</Sex><Depemdent><Name>FooTwo</Name><Age>25</Age><Sex>Male</Sex>" +
+                    "</Depemdent></test:Dependent></Person>";
+
+
+            ArrayList propertyList = new ArrayList();
+            propertyList.add("Name");
+            propertyList.add("FooOne");
+
+            propertyList.add("Organization");
+            propertyList.add("Apache");
+
+            propertyList.add(new QName("Dependent"));
+            DummyADBBean dummyBean = new DummyADBBean();
+            DummyADBBean nextdummyBean = dummyBean.addAnotherBean();
+            nextdummyBean.addAnotherBean();
+            propertyList.add(dummyBean);
+
+            propertyList.add(new QName("http://whatever.com", "Dependent", "test"));
+            dummyBean = new DummyADBBean();
+            dummyBean.addAnotherBean();
+            propertyList.add(dummyBean);
+
+            QName projectQName = new QName("Person");
+            XMLStreamReader pullParser = new ADBXMLStreamReaderImpl(projectQName, propertyList.toArray(), null);
+
+            Document actualDom = newDocument(getStringXML(pullParser));
+            Document expectedDocument = newDocument(exptectedXML);
+            assertXMLEqual(actualDom, expectedDocument);
+        } catch (ParserConfigurationException e) {
+            fail("Exception in parsing documents " + e);
+        } catch (SAXException e) {
+            fail("Exception in parsing documents " + e);
+        } catch (IOException e) {
+            fail("Exception in parsing documents " + e);
+        } catch (XMLStreamException e) {
+            fail("Exception in parsing documents " + e);
+        }
+
+    }
+
+    public static class DummyADBBean implements ADBBean {
+        ArrayList propertyList = new ArrayList();
+
+        public DummyADBBean() {
+            propertyList.add("Name");
+            propertyList.add("FooTwo");
+            propertyList.add("Age");
+            propertyList.add("25");
+            propertyList.add("Sex");
+            propertyList.add("Male");
+        }
+
+        public DummyADBBean addAnotherBean() {
+            propertyList.add(new QName("Depemdent"));
+            DummyADBBean dummyBean = new DummyADBBean();
+            propertyList.add(dummyBean);
+            return dummyBean;
+        }
+
+        public XMLStreamReader getPullParser(QName adbBeanQName) {
+            return new ADBXMLStreamReaderImpl(adbBeanQName, propertyList.toArray(), null);
+        }
+    }
+
+    public void testWithOMElements() throws XMLStreamException {
+
+        String expectedXML = "<OMElementTest><axis2:FirstOMElement xmlns:axis2=\"http://ws.apache.org/namespaces/axis2\">" +
+                "<axis2:SecondOMElement></axis2:SecondOMElement></axis2:FirstOMElement><Foo>Some Text</Foo>" +
+                "<Dependent><Name>FooTwo</Name><Age>25</Age><Sex>Male</Sex></Dependent>" +
+                "<axis2:SecondOMElement xmlns:axis2=\"http://ws.apache.org/namespaces/axis2\">" +
+                "</axis2:SecondOMElement></OMElementTest>";
+
+        OMFactory factory = OMAbstractFactory.getOMFactory();
+        OMNamespace axis2Namespace = factory.createOMNamespace(org.apache.axis2.Constants.AXIS2_NAMESPACE_URI, org.apache.axis2.Constants.AXIS2_NAMESPACE_PREFIX);
+        OMElement firstElement = factory.createOMElement("FirstOMElement", axis2Namespace);
+        OMElement secondElement = factory.createOMElement("SecondOMElement", axis2Namespace, firstElement);
+
+        ArrayList propertyList = new ArrayList();
+
+        // add an OMElement
+        propertyList.add(firstElement.getQName());
+        propertyList.add(firstElement);
+
+        // add some more stuff
+        propertyList.add("Foo");
+        propertyList.add("Some Text");
+        propertyList.add(new QName("Dependent"));
+        DummyADBBean dummyBean = new DummyADBBean();
+        propertyList.add(dummyBean);
+
+//         lets add one more element
+        propertyList.add(secondElement.getQName());
+        propertyList.add(secondElement);
+
+
+        XMLStreamReader pullParser = new ADBXMLStreamReaderImpl(new QName("OMElementTest"), propertyList.toArray(), null);
+        String stringXML = getStringXML(pullParser);
+        try {
+            Document actualDom = newDocument(stringXML);
+            Document expectedDocument = newDocument(expectedXML);
+            assertXMLEqual(actualDom, expectedDocument);
+        } catch (ParserConfigurationException e) {
+            fail("Exception in parsing documents " + e);
+        } catch (SAXException e) {
+            fail("Exception in parsing documents " + e);
+        } catch (IOException e) {
+            fail("Exception in parsing documents " + e);
+        }
+
+    }
+    /**
+     * Test a completely null element
+     */
+    public void testNullableAttribute() {
+        try {
+
+            /*
+            This is what I expect :
+
+            */
+            String exptectedXML = "<Person xmlns=\"\"><Name xmlns=\"\">FooOne</Name><DependentOne xmlns=\"\" " +
+                    "xsi:nil=\"true\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"/>" +
+                    "</Person>";
+
+            ArrayList propertyList = new ArrayList();
+            propertyList.add("Name");
+            propertyList.add("FooOne");
+            propertyList.add(new QName("DependentOne"));
+            propertyList.add(null);
+
+            QName projectQName = new QName("Person");
+            XMLStreamReader pullParser = new ADBXMLStreamReaderImpl(projectQName, propertyList.toArray(), null);
+
+            Document actualDom = newDocument(getStringXML(pullParser));
+            Document expectedDocument = newDocument(exptectedXML);
+            assertXMLEqual(actualDom, expectedDocument);
+        } catch (ParserConfigurationException e) {
+            fail("Exception in parsing documents " + e);
+        } catch (SAXException e) {
+            fail("Exception in parsing documents " + e);
+        } catch (IOException e) {
+            fail("Exception in parsing documents " + e);
+        }  catch (XMLStreamException e) {
+            fail("Exception in parsing documents " + e);
+        }
+
+    }
+
+    /**
+     * Test a simple array
+     */
+    public void testComplexStringArrayScenario() {
+        try {
+            String expectedXML = "<ns1:TestComplexStringArrayScenario xmlns:ns1=\"http://testComplexStringArrayScenario.org\">" +
+                    "<StringInfo>Some Text 0</StringInfo>" +
+                    "<StringInfo>Some Text 1</StringInfo>" +
+                    "<StringInfo>Some Text 2</StringInfo>" +
+                    "<StringInfo>Some Text 3</StringInfo>" +
+                    "</ns1:TestComplexStringArrayScenario>";
+
+            ArrayList propertyList = new ArrayList();
+
+            String[] stringArray = new String[4];
+            for (int i = 0; i < 4; i++) {
+                stringArray[i] = "Some Text " + i;
+            }
+            propertyList.add("StringInfo");
+            propertyList.add(stringArray);
+
+            XMLStreamReader pullParser = new ADBXMLStreamReaderImpl(
+                    new QName("http://testComplexStringArrayScenario.org",
+                            "TestComplexStringArrayScenario", "ns1"),
+                    propertyList.toArray(), null);
+            String actualXML = getStringXML(pullParser);
+
+
+            assertXMLEqual(newDocument(expectedXML), newDocument(actualXML));
+        } catch (ParserConfigurationException e) {
+            fail("Error has occurred " + e);
+        } catch (SAXException e) {
+            fail("Error has occurred " + e);
+        } catch (IOException e) {
+            fail("Error has occurred " + e);
+        }catch (XMLStreamException e) {
+            fail("Error has occurred " + e);
+        }
+
+
+    }
+
+    /**
+     * test the mixed content
+     */
+    public void testComplexStringArrayScenarioWithMixedContent() {
+        try {
+            String expectedXML = "<ns1:TestComplexStringArrayScenario xmlns:ns1=\"http://testComplexStringArrayScenario.org\">" +
+                    "<Foo>Some Text</Foo>" +
+                    "<Dependent>" +
+                    "<Name>FooTwo</Name>" +
+                    "<Age>25</Age>" +
+                    "<Sex>Male</Sex>" +
+                    "</Dependent>" +
+                    "<StringInfo>Some Text 0</StringInfo>" +
+                    "<StringInfo>Some Text 1</StringInfo>" +
+                    "<StringInfo>Some Text 2</StringInfo>" +
+                    "<StringInfo>Some Text 3</StringInfo>" +
+                    "<Bar>Some More Text</Bar>" +
+                    "</ns1:TestComplexStringArrayScenario>";
+
+            ArrayList propertyList = new ArrayList();
+            propertyList.add("Foo");
+            propertyList.add("Some Text");
+            propertyList.add(new QName("Dependent"));
+            DummyADBBean dummyBean = new DummyADBBean();
+            propertyList.add(dummyBean);
+
+            String[] stringArray = new String[4];
+            for (int i = 0; i < 4; i++) {
+                stringArray[i] = "Some Text " + i;
+            }
+            propertyList.add("StringInfo");
+            propertyList.add(stringArray);
+
+            propertyList.add("Bar");
+            propertyList.add("Some More Text");
+
+            XMLStreamReader pullParser = new ADBXMLStreamReaderImpl(
+                    new QName("http://testComplexStringArrayScenario.org",
+                            "TestComplexStringArrayScenario", "ns1"),
+                    propertyList.toArray(),
+                    null);
+            String actualXML = getStringXML(pullParser);
+
+
+            assertXMLEqual(newDocument(expectedXML), newDocument(actualXML));
+        } catch (ParserConfigurationException e) {
+            fail("Error has occurred " + e);
+        } catch (SAXException e) {
+            fail("Error has occurred " + e);
+        } catch (IOException e) {
+            fail("Error has occurred " + e);
+        }catch (Exception e) {
+            fail("Error has occurred " + e);
+        }
+
+
+    }
+    /**
+     * Test a simple array with one element nil
+     */
+    public void testComplexStringArrayScenarioWithNull() {
+        try {
+            String expectedXML = "<ns1:TestComplexStringArrayScenario " +
+                    "xmlns:ns1=\"http://testComplexStringArrayScenario.org\" " +
+                    ">" +
+                    "<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>" +
+                    "</ns1:TestComplexStringArrayScenario>";
+
+            ArrayList propertyList = new ArrayList();
+
+            String[] stringArray = new String[4];
+            for (int i = 0; i < 4; i++) {
+                if (i!=1) stringArray[i] = "Some Text " + i;
+            }
+            stringArray[1]  = null;
+
+            propertyList.add("StringInfo");
+            propertyList.add(stringArray);
+
+            XMLStreamReader pullParser = new ADBXMLStreamReaderImpl(
+                    new QName("http://testComplexStringArrayScenario.org",
+                            "TestComplexStringArrayScenario", "ns1"),
+                    propertyList.toArray(), null);
+            String actualXML = getStringXML(pullParser);
+
+
+            assertXMLEqual(newDocument(expectedXML), newDocument(actualXML));
+        } catch (ParserConfigurationException e) {
+            fail("Error has occurred " + e);
+        } catch (SAXException e) {
+            fail("Error has occurred " + e);
+        } catch (IOException e) {
+            fail("Error has occurred " + e);
+        }catch (XMLStreamException e) {
+            fail("Error has occurred " + e);
+        }
+
+
+    }
+
+    /**
+     * Test multiple unqulified attributes
+     * @throws XMLStreamException
+     */
+    public void testAttributes() throws XMLStreamException {
+
+        String expectedXML = "<emp:Employee xmlns:emp=\"http://ec.org/software\" Attr2=\"Value 2\" " +
+                "Attr3=\"Value 3\" Attr1=\"Value 1\" Attr5=\"Value 5\" Attr4=\"Value 4\"></emp:Employee>";
+
+        OMFactory factory = OMAbstractFactory.getOMFactory();
+        QName elementQName = new QName("http://ec.org/software", "Employee", "emp");
+        OMAttribute[] attribute = new OMAttribute[5];
+
+        for (int i = 0; i < 5; i++) {
+            attribute[i] = factory.createOMAttribute("Attr" + (i + 1), null, "Value " + (i + 1));
+        }
+
+        List omAttribList = new ArrayList();
+        for (int i = 0; i < attribute.length; i++) {
+            omAttribList.add(Constants.OM_ATTRIBUTE_KEY);
+            omAttribList.add(attribute[i]);
+        }
+
+
+        String stringXML = getStringXML(new ADBXMLStreamReaderImpl(elementQName,
+                null,
+                omAttribList.toArray()));
+        try {
+            Document actualDom = newDocument(stringXML);
+            Document expectedDocument = newDocument(expectedXML);
+            assertXMLEqual(actualDom, expectedDocument);
+        } catch (ParserConfigurationException e) {
+            fail("Exception in parsing documents " + e);
+        } catch (SAXException e) {
+            fail("Exception in parsing documents " + e);
+        } catch (IOException e) {
+            fail("Exception in parsing documents " + e);
+        }
+
+
+    }
+
+    /**
+     * A text only element
+     */
+    public void testElementText() {
+
+        String expectedXML = "<ns1:testElementText xmlns:ns1=\"http://testElementText.org\">" +
+                "This is some Text for the element</ns1:testElementText>";
+        try {
+            ArrayList properties = new ArrayList();
+            properties.add(ADBXMLStreamReader.ELEMENT_TEXT);
+            properties.add("This is some Text for the element");
+
+            XMLStreamReader pullParser = new ADBXMLStreamReaderImpl(
+                    new QName("http://testElementText.org", "testElementText", "ns1"), properties.toArray(), null);
+
+            String actualXML = getStringXML(pullParser);
+
+            assertXMLEqual(newDocument(expectedXML), newDocument(actualXML));
+        } catch (ParserConfigurationException e) {
+            fail("Error has occurred " + e);
+        } catch (SAXException e) {
+            fail("Error has occurred " + e);
+        } catch (IOException e) {
+            fail("Error has occurred " + e);
+        } catch (Exception e) {
+            fail("Error has occurred " + e);
+        }
+    }
+
+/// todo Fails due to a bug in WSTX writer
+//    /**
+//     * Test multiple qualified attributes
+//     * @throws XMLStreamException
+//     */
+//    public void testAttributesWithNamespaces() throws XMLStreamException {
+//
+//        String expectedXML = "<emp:Employee xmlns:emp=\"http://ec.org/software\" " +
+//                "xmlns:attrNS=\"mailto:whoever@whatever.com\" attrNS:Attr2=\"Value 2\" " +
+//                "attrNS:Attr3=\"Value 3\" attrNS:Attr1=\"Value 1\"\n" +
+//                "              attrNS:Attr5=\"Value 5\" attrNS:Attr4=\"Value 4\"></emp:Employee>";
+//
+//        OMFactory factory = OMAbstractFactory.getOMFactory();
+//        QName elementQName = new QName("http://ec.org/software", "Employee", "emp");
+//        OMNamespace attrNS = factory.createOMNamespace("mailto:whoever@whatever.com", "attrNS");
+//
+//        // add some attributes with namespaces
+//        OMAttribute[] attribute = new OMAttribute[5];
+//        for (int i = 0; i < 5; i++) {
+//            attribute[i] = factory.createOMAttribute("Attr" + (i + 1), attrNS, "Value " + (i + 1));
+//        }
+//
+//        List omAttribList = new ArrayList();
+//        for (int i = 0; i < attribute.length; i++) {
+//            omAttribList.add(Constants.OM_ATTRIBUTE_KEY);
+//            omAttribList.add(attribute[i]);
+//        }
+//        String stringXML = getStringXML(new ADBXMLStreamReaderImpl(elementQName,
+//                null,
+//                omAttribList.toArray()));
+//        try {
+//            Document actualDom = newDocument(stringXML);
+//            Document expectedDocument = newDocument(expectedXML);
+//            assertXMLEqual(actualDom, expectedDocument);
+//        } catch (ParserConfigurationException e) {
+//            fail("Exception in parsing documents " + e);
+//        } catch (SAXException e) {
+//            fail("Exception in parsing documents " + e);
+//        } catch (IOException e) {
+//            fail("Exception in parsing documents " + e);
+//        }
+//    }
+    /**
+     * test for qualified attributes
+     */
+    public void testUnQualifiedAttributes() {
+
+        String expectedXML = "<ns1:testElementText xmlns:ns1=\"http://testElementText.org\" MyUnQualifiedAttribute=\"MyAttributeValue\">" +
+                "<ns2:QualifiedElement xmlns:ns2=\"http://testQElementText.org\">" +
+                "This is some Text for the element</ns2:QualifiedElement></ns1:testElementText>";
+        try {
+            ArrayList properties = new ArrayList();
+            properties.add(new QName("http://testQElementText.org", "QualifiedElement", "ns2"));
+            properties.add("This is some Text for the element");
+
+            String[] attributes = new String[2];
+            attributes[0] = "MyUnQualifiedAttribute";
+            attributes[1] = "MyAttributeValue";
+
+
+            XMLStreamReader pullParser =new ADBXMLStreamReaderImpl(
+                    new QName("http://testElementText.org", "testElementText", "ns1"),
+                    properties.toArray(),
+                    attributes);
+
+            String actualXML = getStringXML(pullParser);
+
+            assertXMLEqual(newDocument(expectedXML), newDocument(actualXML));
+        } catch (ParserConfigurationException e) {
+            fail("Error has occurred " + e);
+        } catch (SAXException e) {
+            fail("Error has occurred " + e);
+        } catch (IOException e) {
+            fail("Error has occurred " + e);
+        }catch (Exception e) {
+            fail("Error has occurred " + e);
+        }
+    }
+    /**
+     * test the qualified elements
+     * A qulified element has been associated with a namespace
+     */
+    public void testQualifiedElement() {
+
+        String expectedXML = "<ns1:testElementText xmlns:ns1=\"http://testElementText.org\">" +
+                "<ns2:QualifiedElement xmlns:ns2=\"http://testQElementText.org\">" +
+                "This is some Text for the element</ns2:QualifiedElement></ns1:testElementText>";
+        try {
+            ArrayList properties = new ArrayList();
+            properties.add(new QName("http://testQElementText.org", "QualifiedElement", "ns2"));
+            properties.add("This is some Text for the element");
+
+            XMLStreamReader pullParser = new ADBXMLStreamReaderImpl(
+                    new QName("http://testElementText.org", "testElementText", "ns1"),
+                    properties.toArray(),
+                    null);
+
+            String actualXML = getStringXML(pullParser);
+            assertXMLEqual(newDocument(expectedXML), newDocument(actualXML));
+        } catch (ParserConfigurationException e) {
+            fail("Error has occurred " + e);
+        } catch (SAXException e) {
+            fail("Error has occurred " + e);
+        } catch (IOException e) {
+            fail("Error has occurred " + e);
+        } catch (Exception e) {
+            fail("Error has occurred " + e);
+        }
+    }
+
+    /**
+     * Util method to convert the pullstream to a string
+     * @param reader
+     * @return
+     */
+    private String getStringXML(XMLStreamReader reader) throws XMLStreamException{
+        //the returned pullparser starts at an Element rather than the start
+        //document event. This is somewhat disturbing but since an ADBBean
+        //denotes an XMLFragment, it is justifiable to keep the current event
+        //at the Start-element rather than the start document
+        //What it boils down to is that we need to wrap the reader in a
+        //stream wrapper to get a fake start-document event
+
+        StreamingOMSerializer ser = new StreamingOMSerializer();
+        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+        XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(byteArrayOutputStream);
+        ser.serialize(
+                new StreamWrapper(reader),
+                writer);
+        writer.flush();
+        return byteArrayOutputStream.toString();
+    }
+
+//     /**
+//     * Util method to convert the pullstream to a string
+//     * @param reader
+//     * @return
+//     */
+//    private String getStringXML(XMLStreamReader reader) {
+//        //the returned pullparser starts at an Element rather than the start
+//        //document event. This is somewhat disturbing but since an ADBBean
+//        //denotes an XMLFragment, it is justifiable to keep the current event
+//        //at the Start-element rather than the start document
+//        //What it boils down to is that we need to wrap the reader in a
+//        //stream wrapper to get a fake start-document event
+//        StAXOMBuilder stAXOMBuilder = new StAXOMBuilder(
+//                new StreamWrapper(reader));
+//        //stAXOMBuilder.setDoDebug(true);
+//        OMElement omelement = stAXOMBuilder.getDocumentElement();
+//        return omelement.toString();
+//    }
+    /**
+     * Creates a DOM document from the string
+     * @param xml
+     * @return
+     * @throws ParserConfigurationException
+     * @throws SAXException
+     * @throws IOException
+     */
+    public Document newDocument(String xml)
+            throws ParserConfigurationException, SAXException, IOException {
+        return db.parse(new ByteArrayInputStream(xml.getBytes()));
+    }
+}

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/rpc/receivers/RPCMessageReceiver.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/rpc/receivers/RPCMessageReceiver.java?rev=391258&r1=391257&r2=391258&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/rpc/receivers/RPCMessageReceiver.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/rpc/receivers/RPCMessageReceiver.java Tue Apr  4 02:19:13 2006
@@ -29,6 +29,7 @@
 import org.apache.axiom.soap.SOAPEnvelope;
 import org.apache.axiom.soap.SOAPFactory;
 import org.apache.axis2.AxisFault;
+import org.apache.axis2.util.StreamWrapper;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.databinding.typemapping.SimpleTypeMapper;
 import org.apache.axis2.databinding.utils.BeanUtil;
@@ -161,7 +162,7 @@
                         new QName(RETURN_WRAPPER));
                 StAXOMBuilder stAXOMBuilder =
                         OMXMLBuilderFactory.createStAXOMBuilder(
-                                OMAbstractFactory.getOMFactory(), xr);
+                                OMAbstractFactory.getOMFactory(), new StreamWrapper(xr));
                 OMElement documentElement = stAXOMBuilder.getDocumentElement();
                 if (documentElement != null) {
                     bodyContent.addChild(documentElement);

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl?rev=391258&r1=391257&r2=391258&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl Tue Apr  4 02:19:13 2006
@@ -285,17 +285,19 @@
                      <xsl:variable name="namespace"><xsl:value-of select="@nsuri"/></xsl:variable>
                     <xsl:choose>
                         <xsl:when test="@anyAtt">
-                            attribList.add(null);
+                            attribList.add(org.apache.axis2.databinding.utils.Constants.OM_ATTRIBUTE_KEY);
                             attribList.add(<xsl:value-of select="$varName"/>);
                         </xsl:when>
                         <xsl:otherwise>
-                            attribList.add(new javax.xml.namespace.QName("<xsl:value-of select="$namespace"/>","<xsl:value-of select="$propertyName"/>"));
-                            attribList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(<xsl:value-of select="$varName"/>));
+                            attribList.add(
+                            new javax.xml.namespace.QName("<xsl:value-of select="$namespace"/>","<xsl:value-of select="$propertyName"/>"));
+                            attribList.add(
+                            org.apache.axis2.databinding.utils.ConverterUtil.convertToString(<xsl:value-of select="$varName"/>));
                         </xsl:otherwise>
                     </xsl:choose>
                 </xsl:for-each>
 
-                return org.apache.axis2.databinding.utils.ADBPullParser.createPullParser(qName, elementList.toArray(), attribList.toArray());
+                return new org.apache.axis2.databinding.utils.reader.ADBXMLStreamReaderImpl(qName, elementList.toArray(), attribList.toArray());
             <!-- end of when for type & anon -->
             </xsl:when>
             <!-- Not a type and not anon. So it better be only one inclusion-->
@@ -313,7 +315,7 @@
                         <xsl:choose>
                             <xsl:when test="$nillable">
                                 if (<xsl:value-of select="$varName"/>==null){
-                                   return new org.apache.axis2.databinding.utils.NullablePullParser(MY_QNAME);
+                                   return new org.apache.axis2.databinding.utils.reader.NullXMLStreamReader(MY_QNAME);
                                 }else{
                                    return <xsl:value-of select="$varName"/>.getPullParser(MY_QNAME);
                                 }
@@ -325,19 +327,19 @@
                         <xsl:choose>
                             <xsl:when test="$nillable and not($primitive)">
                                 if (<xsl:value-of select="$varName"/>==null){
-                                      return new org.apache.axis2.databinding.utils.NullablePullParser(MY_QNAME);
+                                      return new org.apache.axis2.databinding.utils.reader.NullXMLStreamReader(MY_QNAME);
                                 }else{
-                                   return org.apache.axis2.databinding.utils.ADBPullParser.createPullParser(MY_QNAME,
+                                   return new org.apache.axis2.databinding.utils.reader.ADBXMLStreamReaderImpl(MY_QNAME,
                                        new Object[]{
-                                       org.apache.axis2.databinding.utils.ADBPullParser.ELEMENT_TEXT,
+                                      org.apache.axis2.databinding.utils.reader.ADBXMLStreamReader.ELEMENT_TEXT,
                                        org.apache.axis2.databinding.utils.ConverterUtil.convertToString(<xsl:value-of select="$varName"/>)
                                        },
                                        new Object[]{});
                                 }
                             </xsl:when>
-                            <xsl:otherwise> return org.apache.axis2.databinding.utils.ADBPullParser.createPullParser(MY_QNAME,
+                            <xsl:otherwise> return new org.apache.axis2.databinding.utils.reader.ADBXMLStreamReaderImpl(MY_QNAME,
                             new Object[]{
-                            org.apache.axis2.databinding.utils.ADBPullParser.ELEMENT_TEXT,
+                            org.apache.axis2.databinding.utils.reader.ADBXMLStreamReader.ELEMENT_TEXT,
                             org.apache.axis2.databinding.utils.ConverterUtil.convertToString(<xsl:value-of select="$varName"/>)
                             },
                             new Object[]{});</xsl:otherwise>

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/DatabindingTemplate.xsl
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/DatabindingTemplate.xsl?rev=391258&r1=391257&r2=391258&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/DatabindingTemplate.xsl (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/DatabindingTemplate.xsl Tue Apr  4 02:19:13 2006
@@ -19,8 +19,7 @@
                 private  org.apache.axiom.om.OMElement  toOM(<xsl:value-of select="@type"/> param, boolean optimzieContent){
                 org.apache.axiom.om.impl.builder.StAXOMBuilder builder = new org.apache.axiom.om.impl.builder.StAXOMBuilder
                 (org.apache.axiom.om.OMAbstractFactory.getOMFactory(),new org.apache.axis2.util.StreamWrapper(param.newXMLStreamReader())) ;
-
-                org.apache.axiom.om.OMElement documentElement = builder.getDocumentElement();
+                 org.apache.axiom.om.OMElement documentElement = builder.getDocumentElement();
 
 		<xsl:if test="$base64">
 		if (optimzieContent) {
@@ -182,8 +181,10 @@
                 <xsl:if test="@type!=''">
                     private  org.apache.axiom.om.OMElement  toOM(<xsl:value-of select="@type"/> param, boolean optimizeContent){
                         if (param instanceof org.apache.axis2.databinding.ADBBean){
-                            org.apache.axiom.om.impl.builder.StAXOMBuilder builder = new org.apache.axiom.om.impl.builder.StAXOMBuilder
-                            (org.apache.axiom.om.OMAbstractFactory.getOMFactory(), param.getPullParser(<xsl:value-of select="@type"/>.MY_QNAME));
+                            org.apache.axiom.om.impl.builder.StAXOMBuilder builder
+                                       = new org.apache.axiom.om.impl.builder.StAXOMBuilder
+                            (org.apache.axiom.om.OMAbstractFactory.getOMFactory(),
+                               new org.apache.axis2.util.StreamWrapper(param.getPullParser(<xsl:value-of select="@type"/>.MY_QNAME)));
                             org.apache.axiom.om.OMElement documentElement = builder.getDocumentElement();
                             ((org.apache.axiom.om.impl.OMNodeEx) documentElement).setParent(null); // remove the parent link
                             return documentElement;

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/StreamWrapper.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/StreamWrapper.java?rev=391258&r1=391257&r2=391258&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/StreamWrapper.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/StreamWrapper.java Tue Apr  4 02:19:13 2006
@@ -27,10 +27,13 @@
     private static final int STATE_SWITCHED = 0;
     private static final int STATE_INIT = 1;
     private static final int STATE_SWITCH_AT_NEXT = 2;
+    private static final int STATE_COMPLETE_AT_NEXT = 3;
+    private static final int STATE_COMPLETED = 4;
     private XMLStreamReader realReader = null;
     private int state = STATE_INIT;
     private int prevState = state;
 
+
     public StreamWrapper(XMLStreamReader realReader) {
         if (realReader == null) {
             throw new UnsupportedOperationException("Reader cannot be null");
@@ -49,26 +52,42 @@
 
     public int next() throws XMLStreamException {
         prevState = state;
+        int returnEvent = -1;
 
-        if (state == STATE_SWITCHED) {
-            return realReader.next();
-        } else if (state == STATE_INIT) {
-            if (realReader.getEventType() == START_DOCUMENT) {
+        switch (state) {
+            case STATE_INIT:
+                if (realReader.getEventType() == START_DOCUMENT) {
+                    state = STATE_SWITCHED;
+                    returnEvent = realReader.getEventType();
+                } else {
+                    state = STATE_SWITCH_AT_NEXT;
+                    returnEvent = START_DOCUMENT;
+                }
+                break;
+            case STATE_SWITCHED:
+                returnEvent = realReader.next();
+                if (returnEvent == END_DOCUMENT) {
+                    state = STATE_COMPLETED;
+                } else if (!realReader.hasNext()) {
+                    state = STATE_COMPLETE_AT_NEXT;
+                }
+                break;
+            case STATE_SWITCH_AT_NEXT:
                 state = STATE_SWITCHED;
-
-                return realReader.getEventType();
-            } else {
-                state = STATE_SWITCH_AT_NEXT;
-
-                return START_DOCUMENT;
-            }
-        } else if (state == STATE_SWITCH_AT_NEXT) {
-            state = STATE_SWITCHED;
-
-            return realReader.getEventType();
-        } else {
-            throw new UnsupportedOperationException();
+                returnEvent = realReader.getEventType();
+                break;
+            case STATE_COMPLETE_AT_NEXT:
+                state = STATE_COMPLETED;
+                returnEvent = END_DOCUMENT;
+                break;
+            case STATE_COMPLETED:
+                //oops - no way we can go beyond this
+                throw new XMLStreamException("end reached!");
+            default:
+                throw new UnsupportedOperationException();
         }
+
+        return returnEvent;
     }
 
     public int nextTag() throws XMLStreamException {
@@ -350,7 +369,11 @@
     }
 
     public boolean hasNext() throws XMLStreamException {
-        if (prevState != STATE_INIT) {
+        if (state == STATE_COMPLETE_AT_NEXT) {
+            return true;
+        } else if (state == STATE_COMPLETED) {
+            return false;
+        } else if (prevState != STATE_INIT) {
             return realReader.hasNext();
         } else {
             return true;

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=391258&r1=391257&r2=391258&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 Apr  4 02:19:13 2006
@@ -129,7 +129,7 @@
     private void configureSystem(String opName) throws AxisFault {
         targetEPR =
                 new EndpointReference("http://127.0.0.1:"
-                        + (UtilServer.TESTING_PORT)
+                        +5000 //+ (UtilServer.TESTING_PORT)
                         + "/axis2/services/EchoXMLService/" + opName);
         String className = "org.apache.axis2.rpc.RPCServiceClass";
         operationName = new QName("http://org.apache.axis2/xsd", opName, "req");

Modified: webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/trust/types/RequestSecurityTokenResponseType.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/trust/types/RequestSecurityTokenResponseType.java?rev=391258&r1=391257&r2=391258&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/trust/types/RequestSecurityTokenResponseType.java (original)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/trust/types/RequestSecurityTokenResponseType.java Tue Apr  4 02:19:13 2006
@@ -225,8 +225,8 @@
         attribList.add(org.apache.axis2.databinding.utils.ConverterUtil
                 .convertToString(localContext));
 
-        return org.apache.axis2.databinding.utils.ADBPullParser
-                .createPullParser(qName, elementList.toArray(), attribList
+        return new org.apache.axis2.databinding.utils.reader.ADBXMLStreamReaderImpl
+                (qName, elementList.toArray(), attribList
                         .toArray());
 
     }

Modified: webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/trust/types/RequestSecurityTokenType.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/trust/types/RequestSecurityTokenType.java?rev=391258&r1=391257&r2=391258&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/trust/types/RequestSecurityTokenType.java (original)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/trust/types/RequestSecurityTokenType.java Tue Apr  4 02:19:13 2006
@@ -223,8 +223,8 @@
         attribList.add(org.apache.axis2.databinding.utils.ConverterUtil
                 .convertToString(localContext));
 
-        return org.apache.axis2.databinding.utils.ADBPullParser
-                .createPullParser(qName, elementList.toArray(), attribList
+        return new org.apache.axis2.databinding.utils.reader.
+                ADBXMLStreamReaderImpl(qName, elementList.toArray(), attribList
                         .toArray());
 
     }

Modified: webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/trust/types/RequestedSecurityTokenType.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/trust/types/RequestedSecurityTokenType.java?rev=391258&r1=391257&r2=391258&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/trust/types/RequestedSecurityTokenType.java (original)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/trust/types/RequestedSecurityTokenType.java Tue Apr  4 02:19:13 2006
@@ -62,8 +62,8 @@
         }
         elementList.add(localExtraElement);
 
-        return org.apache.axis2.databinding.utils.ADBPullParser
-                .createPullParser(qName, elementList.toArray(), attribList
+        return new org.apache.axis2.databinding.utils.reader.ADBXMLStreamReaderImpl
+                (qName, elementList.toArray(), attribList
                         .toArray());
 
     }



Mime
View raw message