You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by ve...@apache.org on 2016/02/25 09:03:11 UTC

svn commit: r1732254 - in /webservices/axiom/trunk: aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/mixin/ aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/mixin/ implementations/axiom-dom/src/main/java/org/apache/axiom/soap/impl/d...

Author: veithen
Date: Thu Feb 25 08:03:10 2016
New Revision: 1732254

URL: http://svn.apache.org/viewvc?rev=1732254&view=rev
Log:
Remove the special serialization logic from SOAPMessage and SOAPEnvelope implementations.

Modified:
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/mixin/AxiomContainerSupport.aj
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/mixin/AxiomDocumentSupport.aj
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/mixin/AxiomSOAPMessageSupport.aj
    webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPEnvelopeImpl.java
    webservices/axiom/trunk/implementations/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPEnvelopeImpl.java
    webservices/axiom/trunk/src/site/markdown/release-notes/1.3.0.md
    webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/message/TestSerialize.java

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/mixin/AxiomContainerSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/mixin/AxiomContainerSupport.aj?rev=1732254&r1=1732253&r2=1732254&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/mixin/AxiomContainerSupport.aj (original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/mixin/AxiomContainerSupport.aj Thu Feb 25 08:03:10 2016
@@ -377,31 +377,37 @@ public aspect AxiomContainerSupport {
             // events from the underlying XMLStreamReader.
             if (!isComplete() && coreGetBuilder() != null) {
                 Builder builder = coreGetBuilder();
-                StAXHelper helper = new StAXHelper(builder.disableCaching(), handler);
-                int depth = 0;
-                loop: while (true) {
-                    switch (helper.lookahead()) {
-                        case XMLStreamReader.START_ELEMENT:
-                            depth++;
-                            break;
-                        case XMLStreamReader.END_ELEMENT:
-                            if (depth == 0) {
+                XMLStreamReader reader = builder.disableCaching();
+                // The reader is null in the very special case where this is an OMDocument and
+                // the current event is END_DOCUMENT (which means that auto-close is triggered
+                // and the parser is released, resulting in a null value).
+                if (reader != null) {
+                    StAXHelper helper = new StAXHelper(reader, handler);
+                    int depth = 0;
+                    loop: while (true) {
+                        switch (helper.lookahead()) {
+                            case XMLStreamReader.START_ELEMENT:
+                                depth++;
+                                break;
+                            case XMLStreamReader.END_ELEMENT:
+                                if (depth == 0) {
+                                    break loop;
+                                } else {
+                                    depth--;
+                                }
+                                break;
+                            case XMLStreamReader.END_DOCUMENT:
+                                if (depth != 0) {
+                                    // If we get here, then we have seen a START_ELEMENT event without
+                                    // a matching END_ELEMENT
+                                    throw new IllegalStateException();
+                                }
                                 break loop;
-                            } else {
-                                depth--;
-                            }
-                            break;
-                        case XMLStreamReader.END_DOCUMENT:
-                            if (depth != 0) {
-                                // If we get here, then we have seen a START_ELEMENT event without
-                                // a matching END_ELEMENT
-                                throw new IllegalStateException();
-                            }
-                            break loop;
+                        }
+                        // Note that we don't copy the final END_ELEMENT/END_DOCUMENT event for
+                        // the container. This is the responsibility of the caller.
+                        helper.next();
                     }
-                    // Note that we don't copy the final END_ELEMENT/END_DOCUMENT event for
-                    // the container. This is the responsibility of the caller.
-                    helper.next();
                 }
                 builder.reenableCaching(this);
             }

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/mixin/AxiomDocumentSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/mixin/AxiomDocumentSupport.aj?rev=1732254&r1=1732253&r2=1732254&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/mixin/AxiomDocumentSupport.aj (original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/mixin/AxiomDocumentSupport.aj Thu Feb 25 08:03:10 2016
@@ -57,12 +57,6 @@ public aspect AxiomDocumentSupport {
     }
 
     public final void AxiomDocument.internalSerialize(XmlHandler handler, OMOutputFormat format, boolean cache) throws StreamException {
-        internalSerialize(handler, format, cache, !format.isIgnoreXMLDeclaration());
-    }
-
-    // Overridden in AxiomSOAPMessageSupport
-    public void AxiomDocument.internalSerialize(XmlHandler handler, OMOutputFormat format,
-            boolean cache, boolean includeXMLDeclaration) throws StreamException {
         handler.startDocument(coreGetInputEncoding(), coreGetXmlVersion(), coreGetXmlEncoding(), coreIsStandalone());
         serializeChildren(handler, format, cache);
         handler.endDocument();

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/mixin/AxiomSOAPMessageSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/mixin/AxiomSOAPMessageSupport.aj?rev=1732254&r1=1732253&r2=1732254&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/mixin/AxiomSOAPMessageSupport.aj (original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/mixin/AxiomSOAPMessageSupport.aj Thu Feb 25 08:03:10 2016
@@ -20,11 +20,7 @@ package org.apache.axiom.soap.impl.mixin
 
 import org.apache.axiom.core.ClonePolicy;
 import org.apache.axiom.core.CoreNode;
-import org.apache.axiom.core.stream.StreamException;
-import org.apache.axiom.core.stream.XmlHandler;
 import org.apache.axiom.om.OMFactory;
-import org.apache.axiom.om.OMOutputFormat;
-import org.apache.axiom.om.impl.intf.AxiomElement;
 import org.apache.axiom.soap.SOAPEnvelope;
 import org.apache.axiom.soap.SOAPFactory;
 import org.apache.axiom.soap.impl.intf.AxiomSOAPMessage;
@@ -52,12 +48,6 @@ public aspect AxiomSOAPMessageSupport {
         return factory;
     }
     
-    // TODO: this violates OO design principles and should disappear in a future Axiom version
-    public final void AxiomSOAPMessage.internalSerialize(XmlHandler handler, OMOutputFormat format,
-            boolean cache, boolean includeXMLDeclaration) throws StreamException {
-        ((AxiomElement)getOMDocumentElement()).internalSerialize(handler, format, cache);
-    }
-
     public final SOAPEnvelope AxiomSOAPMessage.getSOAPEnvelope() {
         return (SOAPEnvelope)getOMDocumentElement();
     }

Modified: webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPEnvelopeImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPEnvelopeImpl.java?rev=1732254&r1=1732253&r2=1732254&view=diff
==============================================================================
--- webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPEnvelopeImpl.java (original)
+++ webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPEnvelopeImpl.java Thu Feb 25 08:03:10 2016
@@ -19,13 +19,10 @@
 
 package org.apache.axiom.soap.impl.dom;
 
-import org.apache.axiom.core.stream.StreamException;
-import org.apache.axiom.core.stream.XmlHandler;
 import org.apache.axiom.om.OMConstants;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMException;
 import org.apache.axiom.om.OMNode;
-import org.apache.axiom.om.OMOutputFormat;
 import org.apache.axiom.soap.SOAP11Version;
 import org.apache.axiom.soap.SOAPBody;
 import org.apache.axiom.soap.SOAPConstants;
@@ -127,22 +124,4 @@ public abstract class SOAPEnvelopeImpl e
     public void checkParent(OMElement parent) throws SOAPProcessingException {
         // here do nothing as SOAPEnvelope doesn't have a parent !!!
     }
-
-    public void internalSerialize(XmlHandler handler, OMOutputFormat format, boolean cache)
-            throws StreamException {
-
-        if (!format.isIgnoreXMLDeclaration()) {
-            String charSetEncoding = format.getCharSetEncoding();
-            String xmlVersion = format.getXmlVersion();
-            handler.startDocument(
-                    null,
-                    xmlVersion == null ? OMConstants.DEFAULT_XML_VERSION
-                            : xmlVersion,
-                    charSetEncoding == null ? OMConstants.DEFAULT_CHAR_SET_ENCODING
-                            : charSetEncoding,
-                    true);
-        }
-        super.internalSerialize(handler, format, cache);
-        handler.endDocument();
-    }
 }

Modified: webservices/axiom/trunk/implementations/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPEnvelopeImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/implementations/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPEnvelopeImpl.java?rev=1732254&r1=1732253&r2=1732254&view=diff
==============================================================================
--- webservices/axiom/trunk/implementations/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPEnvelopeImpl.java (original)
+++ webservices/axiom/trunk/implementations/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPEnvelopeImpl.java Thu Feb 25 08:03:10 2016
@@ -19,27 +19,19 @@
 
 package org.apache.axiom.soap.impl.llom;
 
-import org.apache.axiom.core.Builder;
-import org.apache.axiom.core.stream.StreamException;
-import org.apache.axiom.core.stream.XmlHandler;
 import org.apache.axiom.om.OMConstants;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMException;
 import org.apache.axiom.om.OMNode;
-import org.apache.axiom.om.OMOutputFormat;
 import org.apache.axiom.soap.SOAPBody;
 import org.apache.axiom.soap.SOAPConstants;
 import org.apache.axiom.soap.SOAPHeader;
 import org.apache.axiom.soap.SOAPProcessingException;
 import org.apache.axiom.soap.impl.intf.AxiomSOAPEnvelope;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 
 /** Class SOAPEnvelopeImpl */
 public abstract class SOAPEnvelopeImpl extends SOAPElement
         implements AxiomSOAPEnvelope, OMConstants {
-    private static final Log log = LogFactory.getLog(SOAPEnvelopeImpl.class);
-
     /**
      * Add a SOAPHeader or SOAPBody object
      * @param child an OMNode to add - must be either a SOAPHeader or a SOAPBody
@@ -117,39 +109,4 @@ public abstract class SOAPEnvelopeImpl e
     public void checkParent(OMElement parent) throws SOAPProcessingException {
         // here do nothing as SOAPEnvelope doesn't have a parent !!!
     }
-
-    public void internalSerialize(XmlHandler handler, OMOutputFormat format, boolean cache)
-            throws StreamException {
-        if (!format.isIgnoreXMLDeclaration()) {
-            String charSetEncoding = format.getCharSetEncoding();
-            String xmlVersion = format.getXmlVersion();
-            handler.startDocument(
-                    null,
-                    xmlVersion == null ? OMConstants.DEFAULT_XML_VERSION : xmlVersion,
-                    charSetEncoding == null ? OMConstants.DEFAULT_CHAR_SET_ENCODING
-                            : charSetEncoding,
-                    true);
-        }
-        super.internalSerialize(handler, format, cache);
-        handler.endDocument();
-        if (!cache) {
-            // let's try to close the builder/parser here since we are now done with the
-            // non-caching code block serializing the top-level SOAPEnvelope element
-            Builder builder = coreGetBuilder();
-            if (builder != null) {
-                try {
-                    if (log.isDebugEnabled()) {
-                        log.debug("closing builder: " + builder);
-                    }
-                    builder.close();
-                } catch (Exception e) {
-                    if (log.isDebugEnabled()) {
-                        log.error("Could not close builder or parser due to: ", e);
-                    }
-                }
-            } else {
-                log.debug("Could not close builder or parser due to: builder is null");
-            }
-        }
-    }
 }

Modified: webservices/axiom/trunk/src/site/markdown/release-notes/1.3.0.md
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/src/site/markdown/release-notes/1.3.0.md?rev=1732254&r1=1732253&r2=1732254&view=diff
==============================================================================
--- webservices/axiom/trunk/src/site/markdown/release-notes/1.3.0.md (original)
+++ webservices/axiom/trunk/src/site/markdown/release-notes/1.3.0.md Thu Feb 25 08:03:10 2016
@@ -121,3 +121,16 @@ Changes in this release
     `SOAPFaultNode` interface because they conflict with methods defined by
     DOM's `Node` interface. Note that these methods were already deprecated in
     Axiom 1.2.x, with alternative methods being available.
+
+*   In Axiom 1.2.x the `SOAPMessage` and `SOAPEnvelope` implementations had
+    special serialization logic, causing the serialization of a `SOAPEnvelope`
+    to emit an XML declaration by default and the serialization of a
+    `SOAPMessage` to skip all content in the prolog and epilog. This behavior
+    was completely undocumented and violates basic object oriented design
+    principles: although `SOAPMessage` is an `OMDocument` and `SOAPEnvelope` is
+    an `OMElement`, they didn't behave in the same way as `OMDocument` and
+    `OMElement` when it comes to serialization. This in turn led to an awkward
+    design. This special serialization logic has been removed in Axiom 1.3 and
+    `SOAPMessage` and `SOAPEnvelope` now have the same behavior as any other
+    `OMDocument` and `OMElement`. The main implication is that the serialization
+    of a `SOAPEnvelope` no longer generates an XML declaration.

Modified: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/message/TestSerialize.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/message/TestSerialize.java?rev=1732254&r1=1732253&r2=1732254&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/message/TestSerialize.java (original)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/message/TestSerialize.java Thu Feb 25 08:03:10 2016
@@ -52,7 +52,6 @@ public class TestSerialize extends Axiom
         assertAbout(xml())
                 .that(serializationStrategy.serialize(soapMessage).getInputSource())
                 .ignoringRedundantNamespaceDeclarations()
-                .ignoringPrologAndEpilog()  // TODO: why???
                 .hasSameContentAs(message.getInputStream());
         soapMessage.close(false);
     }