ws-axis-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r373418 - in /webservices/axis2/trunk/java/modules: adb/src/org/apache/axis2/databinding/ adb/src/org/apache/axis2/databinding/utils/ adb/test/org/apache/axis2/databinding/ doom/src/org/apache/axis2/soap/impl/dom/factory/ doom/src/org/apach...
Date Mon, 30 Jan 2006 03:07:01 GMT
Author: dims
Date: Sun Jan 29 19:06:52 2006
New Revision: 373418

URL: http://svn.apache.org/viewcvs?rev=373418&view=rev
Log:
- Getting rid of ugly hack(s) in ADBSOAPModelBuilder
- Added a getSoapVersionURI for SOAPFactory, so that given a soap factory, we can at least
get to know which version of soap it is for.
- change access for 2 methods in StAXSOAPModelBuilder so that the can be overridden
- Extend ADBSOAPModelBuilder from StAXSOAPModelBuilder instead of StAXOMBuilder
- ADBSOAPModelBuilder used a few inner ADBbeans for Envelope/Header/Body and relies on ADBPullParser
to generate the necessary StaX events.
- Added a test with getXMLStreamReaderWithoutCaching in ADBSOAPModelBuilderTest



Modified:
    webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/ADBSOAPModelBuilder.java
    webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/ADBPullParser.java
    webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/ADBSOAPModelBuilderTest.java
    webservices/axis2/trunk/java/modules/doom/src/org/apache/axis2/soap/impl/dom/factory/DOMSOAPFactory.java
    webservices/axis2/trunk/java/modules/doom/src/org/apache/axis2/soap/impl/dom/soap11/SOAP11Factory.java
    webservices/axis2/trunk/java/modules/doom/src/org/apache/axis2/soap/impl/dom/soap12/SOAP12Factory.java
    webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/soap/SOAPFactory.java
    webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/builder/StAXSOAPModelBuilder.java
    webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/factory/SOAPLinkedListImplFactory.java
    webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/soap11/SOAP11Factory.java
    webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/soap12/SOAP12Factory.java

Modified: webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/ADBSOAPModelBuilder.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/ADBSOAPModelBuilder.java?rev=373418&r1=373417&r2=373418&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/ADBSOAPModelBuilder.java
(original)
+++ webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/ADBSOAPModelBuilder.java
Sun Jan 29 19:06:52 2006
@@ -1,61 +1,87 @@
 package org.apache.axis2.databinding;
 
-import org.apache.axis2.om.OMException;
-import org.apache.axis2.om.impl.OMNodeEx;
-import org.apache.axis2.om.impl.llom.builder.StAXOMBuilder;
-import org.apache.axis2.soap.SOAPBody;
+import org.apache.axis2.soap.SOAPConstants;
 import org.apache.axis2.soap.SOAPEnvelope;
 import org.apache.axis2.soap.SOAPFactory;
+import org.apache.axis2.soap.impl.llom.builder.StAXSOAPModelBuilder;
 
-import javax.xml.stream.XMLStreamException;
+import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamReader;
 
 /**
  * Builds a SOAPEnvelope around an ADB pull parser
  */
-public class ADBSOAPModelBuilder extends StAXOMBuilder {
-    private SOAPBody body;
-    private SOAPEnvelope envelope;
-    
+public class ADBSOAPModelBuilder extends StAXSOAPModelBuilder {
     public ADBSOAPModelBuilder(XMLStreamReader parser, SOAPFactory factory) {
-        super(factory, parser);
+        super(new Envelope(parser).getPullParser(new QName(factory.getSoapVersionURI(), SOAPConstants.SOAPENVELOPE_LOCAL_NAME,
SOAPConstants.SOAP_DEFAULT_NAMESPACE_PREFIX)),
+                factory,
+                factory.getSoapVersionURI());
+    }
 
-        document = factory.createSOAPMessage(this);
-        envelope = factory.getDefaultEnvelope();
-        document.addChild(envelope);
-        body = envelope.getBody();
-
-        envelope.setBuilder(this);
-        envelope.getHeader().setBuilder(this);
-        body.setBuilder(this);
-        lastNode = body;
-
-        ((OMNodeEx)envelope).setComplete(false);
-        ((OMNodeEx)body).setComplete(false);
-        
-    }
-
-    long count = -1;
-    public int next() throws OMException {
-        count++;
-        if(count == 0)
-            return 0;
-        
-        int ret = super.next();
-        try {
-            // Peek to see if the parser has any more and set the done flag.
-            if(!parser.hasNext()) {
-                done = true;
-                ((OMNodeEx)body).setComplete(true);
-                ((OMNodeEx)envelope).setComplete(true);
-            }
-        } catch (XMLStreamException e) {
-            throw new OMException(e);
+    public SOAPEnvelope getEnvelope() {
+        return getSOAPEnvelope();
+    }
+
+    public static class Envelope
+            implements org.apache.axis2.databinding.ADBBean {
+        Body body;
+
+        Envelope(XMLStreamReader parser) {
+            body = new Body(parser);
         }
-        return ret;
+
+        public javax.xml.stream.XMLStreamReader getPullParser(javax.xml.namespace.QName qName)
{
+            java.util.ArrayList elementList = new java.util.ArrayList();
+            elementList.add(new QName(qName.getNamespaceURI(), "Header", SOAPConstants.BODY_NAMESPACE_PREFIX));
+            elementList.add(new Header());
+            elementList.add(new QName(qName.getNamespaceURI(), "Body", SOAPConstants.BODY_NAMESPACE_PREFIX));
+            elementList.add(body);
+            return org.apache.axis2.databinding.utils.ADBPullParser.createPullParser(qName,
elementList.toArray(), null);
+        }
+    }
+    
+    protected void parseHeaders() {
+        //Do nothing        
+    }
+    
+    protected void identifySOAPVersion(String soapVersionURIFromTransport) {
+        //Do nothing
     }
 
-    public SOAPEnvelope getEnvelope() {
-        return envelope;
+    public static class Body
+            implements org.apache.axis2.databinding.ADBBean {
+        Child child;
+
+        Body(XMLStreamReader parser) {
+            child = new Child(parser);
+        }
+
+        public javax.xml.stream.XMLStreamReader getPullParser(javax.xml.namespace.QName qName)
{
+            java.util.ArrayList elementList = new java.util.ArrayList();
+            elementList.add(qName);
+            elementList.add(child);
+            return org.apache.axis2.databinding.utils.ADBPullParser.createPullParser(qName,
elementList.toArray(), null);
+        }
+    }
+
+    public static class Header
+            implements org.apache.axis2.databinding.ADBBean {
+        public javax.xml.stream.XMLStreamReader getPullParser(javax.xml.namespace.QName qName)
{
+            java.util.ArrayList elementList = new java.util.ArrayList();
+            return org.apache.axis2.databinding.utils.ADBPullParser.createPullParser(qName,
elementList.toArray(), null);
+        }
+    }
+
+    public static class Child
+            implements org.apache.axis2.databinding.ADBBean {
+        XMLStreamReader parser;
+
+        Child(XMLStreamReader parser) {
+            this.parser = parser;
+        }
+
+        public javax.xml.stream.XMLStreamReader getPullParser(javax.xml.namespace.QName qName)
{
+            return parser;
+        }
     }
 }

Modified: webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/ADBPullParser.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/ADBPullParser.java?rev=373418&r1=373417&r2=373418&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/ADBPullParser.java
(original)
+++ webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/ADBPullParser.java
Sun Jan 29 19:06:52 2006
@@ -643,7 +643,7 @@
         try {
             return next();
         } catch (XMLStreamException e) {
-            throw new RuntimeException("FIXME");
+            throw new RuntimeException(e);
         }
     }
 

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=373418&r1=373417&r2=373418&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
Sun Jan 29 19:06:52 2006
@@ -16,20 +16,10 @@
 
 package org.apache.axis2.databinding;
 
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.util.ArrayList;
-
-import javax.xml.namespace.QName;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.stream.XMLStreamReader;
-
 import org.apache.axis2.databinding.utils.ADBPullParser;
-import org.apache.axis2.om.DOOMAbstractFactory;
 import org.apache.axis2.om.OMAbstractFactory;
 import org.apache.axis2.om.OMElement;
+import org.apache.axis2.om.DOOMAbstractFactory;
 import org.apache.axis2.soap.SOAP11Constants;
 import org.apache.axis2.soap.SOAPEnvelope;
 import org.apache.axis2.soap.impl.llom.builder.StAXSOAPModelBuilder;
@@ -37,6 +27,15 @@
 import org.w3c.dom.Document;
 import org.xml.sax.SAXException;
 
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.stream.XMLStreamReader;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+
 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>";
@@ -61,7 +60,7 @@
         assertXMLEqual(actualDom, expectedDOM);
     }
     
-    public void testConvertToDOOM() {
+    public void testConvertToDOOM() throws Exception {
         
         CreateAccountRequest request = new CreateAccountRequest();
         ClientInfo clientInfo = new ClientInfo();
@@ -78,11 +77,33 @@
         env.build();
         
         StAXSOAPModelBuilder builder2 = new StAXSOAPModelBuilder(env.getXMLStreamReader(),
DOOMAbstractFactory.getSOAP11Factory(), SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
-        
         SOAPEnvelope envelope = builder2.getSOAPEnvelope();
         envelope.build();
+        
+        envelope.serialize(System.out);
     }
     
+    public void testConvertToDOOM2() throws Exception {
+        
+        CreateAccountRequest request = new CreateAccountRequest();
+        ClientInfo clientInfo = new ClientInfo();
+        clientInfo.setName("bob");
+        clientInfo.setSsn("123456789");
+        request.setClientInfo(clientInfo);
+        request.setPassword("passwd");
+        
+        ADBSOAPModelBuilder builder = new ADBSOAPModelBuilder(request
+                .getPullParser(CreateAccountRequest.MY_QNAME),
+                OMAbstractFactory.getSOAP11Factory());
+        
+        SOAPEnvelope env = builder.getEnvelope();
+        
+        StAXSOAPModelBuilder builder2 = new StAXSOAPModelBuilder(env.getXMLStreamReaderWithoutCaching(),
DOOMAbstractFactory.getSOAP11Factory(), SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+        SOAPEnvelope envelope = builder2.getSOAPEnvelope();
+        envelope.build();
+        
+        envelope.serialize(System.out);
+    }
 
     public class DummyADBBean implements ADBBean {
         ArrayList propertyList = new ArrayList();
@@ -115,5 +136,4 @@
         DocumentBuilder db = dbf.newDocumentBuilder();
         return db.parse(new ByteArrayInputStream(xml.getBytes()));
     }
-    
 }

Modified: webservices/axis2/trunk/java/modules/doom/src/org/apache/axis2/soap/impl/dom/factory/DOMSOAPFactory.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/doom/src/org/apache/axis2/soap/impl/dom/factory/DOMSOAPFactory.java?rev=373418&r1=373417&r2=373418&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/doom/src/org/apache/axis2/soap/impl/dom/factory/DOMSOAPFactory.java
(original)
+++ webservices/axis2/trunk/java/modules/doom/src/org/apache/axis2/soap/impl/dom/factory/DOMSOAPFactory.java
Sun Jan 29 19:06:52 2006
@@ -45,12 +45,16 @@
 	public DOMSOAPFactory(DocumentImpl doc) {
 		super(doc);
 	}
-	
-	public SOAPMessage createSOAPMessage(OMXMLParserWrapper builder) {
-		SOAPMessageImpl messageImpl = new SOAPMessageImpl(builder);
-		this.document = messageImpl;
-		return messageImpl;
-	}
+
+    public String getSoapVersionURI() {
+        throw new UnsupportedOperationException();
+    }
+
+    public SOAPMessage createSOAPMessage(OMXMLParserWrapper builder) {
+        SOAPMessageImpl messageImpl = new SOAPMessageImpl(builder);
+        this.document = messageImpl;
+        return messageImpl;
+    }
 
 	public SOAPMessage createSOAPMessage(SOAPEnvelope envelope, OMXMLParserWrapper parserWrapper)
{
 		SOAPMessageImpl messageImpl = new SOAPMessageImpl(envelope, parserWrapper);

Modified: webservices/axis2/trunk/java/modules/doom/src/org/apache/axis2/soap/impl/dom/soap11/SOAP11Factory.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/doom/src/org/apache/axis2/soap/impl/dom/soap11/SOAP11Factory.java?rev=373418&r1=373417&r2=373418&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/doom/src/org/apache/axis2/soap/impl/dom/soap11/SOAP11Factory.java
(original)
+++ webservices/axis2/trunk/java/modules/doom/src/org/apache/axis2/soap/impl/dom/soap11/SOAP11Factory.java
Sun Jan 29 19:06:52 2006
@@ -48,7 +48,11 @@
 	public SOAP11Factory(DocumentImpl doc) {
 		super(doc);
 	}
-	
+
+    public String getSoapVersionURI() {
+        return SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI;
+    }
+
     public SOAPEnvelope createSOAPEnvelope() {
         return new SOAPEnvelopeImpl(
                 new NamespaceImpl(

Modified: webservices/axis2/trunk/java/modules/doom/src/org/apache/axis2/soap/impl/dom/soap12/SOAP12Factory.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/doom/src/org/apache/axis2/soap/impl/dom/soap12/SOAP12Factory.java?rev=373418&r1=373417&r2=373418&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/doom/src/org/apache/axis2/soap/impl/dom/soap12/SOAP12Factory.java
(original)
+++ webservices/axis2/trunk/java/modules/doom/src/org/apache/axis2/soap/impl/dom/soap12/SOAP12Factory.java
Sun Jan 29 19:06:52 2006
@@ -46,6 +46,10 @@
 		super(doc);
 	}
 	
+    public String getSoapVersionURI() {
+        return SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI;
+    }
+
     public SOAPEnvelope createSOAPEnvelope() {
         return new SOAPEnvelopeImpl(
                 new NamespaceImpl(

Modified: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/soap/SOAPFactory.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/soap/SOAPFactory.java?rev=373418&r1=373417&r2=373418&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/soap/SOAPFactory.java (original)
+++ webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/soap/SOAPFactory.java Sun
Jan 29 19:06:52 2006
@@ -22,6 +22,9 @@
 
 
 public interface SOAPFactory extends OMFactory {
+    
+    public String getSoapVersionURI();
+    
     /**
      * Eran Chinthaka (chinthaka@apache.org)
      */

Modified: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/builder/StAXSOAPModelBuilder.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/builder/StAXSOAPModelBuilder.java?rev=373418&r1=373417&r2=373418&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/builder/StAXSOAPModelBuilder.java
(original)
+++ webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/builder/StAXSOAPModelBuilder.java
Sun Jan 29 19:06:52 2006
@@ -134,7 +134,7 @@
         parseHeaders();
     }
 
-    private void identifySOAPVersion(String soapVersionURIFromTransport) {
+    protected void identifySOAPVersion(String soapVersionURIFromTransport) {
 
         SOAPEnvelope soapEnvelope = getSOAPEnvelope();
         if (soapEnvelope == null) {
@@ -164,7 +164,7 @@
         }
     }
 
-    private void parseHeaders() {
+    protected void parseHeaders() {
         // by the time execution comes here the nullity of SOAPEnvelope has been cheched
in the
         // identifySOAPVersion() method. So not checking getSOAPEnvelope() == null here
         SOAPHeader soapHeader = getSOAPEnvelope().getHeader();

Modified: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/factory/SOAPLinkedListImplFactory.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/factory/SOAPLinkedListImplFactory.java?rev=373418&r1=373417&r2=373418&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/factory/SOAPLinkedListImplFactory.java
(original)
+++ webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/factory/SOAPLinkedListImplFactory.java
Sun Jan 29 19:06:52 2006
@@ -39,10 +39,15 @@
 import org.apache.axis2.soap.impl.llom.SOAPMessageImpl;
 
 public class SOAPLinkedListImplFactory extends OMLinkedListImplFactory implements SOAPFactory
{
+    public String getSoapVersionURI() {
+        throw new UnsupportedOperationException();
+    }
+
     public SOAPMessage createSOAPMessage(OMXMLParserWrapper builder) {
         return new SOAPMessageImpl(builder);
     }
 
+    
     public SOAPMessage createSOAPMessage(SOAPEnvelope envelope, OMXMLParserWrapper parserWrapper)
{
         return new SOAPMessageImpl(envelope, parserWrapper);
     }

Modified: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/soap11/SOAP11Factory.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/soap11/SOAP11Factory.java?rev=373418&r1=373417&r2=373418&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/soap11/SOAP11Factory.java
(original)
+++ webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/soap11/SOAP11Factory.java
Sun Jan 29 19:06:52 2006
@@ -42,6 +42,10 @@
      * Eran Chinthaka (chinthaka@apache.org)
      */
 
+    public String getSoapVersionURI() {
+        return SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI;
+    }
+
     public SOAPEnvelope createSOAPEnvelope() {
         return new SOAPEnvelopeImpl(
                 new OMNamespaceImpl(

Modified: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/soap12/SOAP12Factory.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/soap12/SOAP12Factory.java?rev=373418&r1=373417&r2=373418&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/soap12/SOAP12Factory.java
(original)
+++ webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/soap12/SOAP12Factory.java
Sun Jan 29 19:06:52 2006
@@ -42,6 +42,10 @@
      * Eran Chinthaka (chinthaka@apache.org)
      */
 
+    public String getSoapVersionURI() {
+        return SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI;
+    }
+
     public SOAPEnvelope createSOAPEnvelope() {
         return new SOAPEnvelopeImpl(
                 new OMNamespaceImpl(



Mime
View raw message