ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1747975 - in /webservices/axiom/trunk: aspects/core-aspects/src/main/java/org/apache/axiom/core/impl/ aspects/core-aspects/src/main/java/org/apache/axiom/core/impl/builder/ aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/ a...
Date Sun, 12 Jun 2016 10:33:11 GMT
Author: veithen
Date: Sun Jun 12 10:33:11 2016
New Revision: 1747975

URL: http://svn.apache.org/viewvc?rev=1747975&view=rev
Log:
Support getting an XOP encoded XMLStreamReader directly from an OMContainer.

Added:
    webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/XOPEncoded.java
      - copied, changed from r1745667, webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/util/stax/xop/XOPEncodedStream.java
Modified:
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/impl/TreeWalkerImpl.java
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/impl/builder/BuilderHandler.java
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/NullXmlHandler.java
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/XmlHandler.java
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/XmlHandlerWrapper.java
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/sax/ContentHandlerXmlHandler.java
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/serializer/Serializer.java
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/stax/pull/StAXPivot.java
    webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/xop/AbstractXOPEncodingFilterHandler.java
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/SAXResultContentHandler.java
    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/stream/stax/push/XMLStreamWriterHandler.java
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/stream/xop/XOPEncodingFilterHandler.java
    webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/OMContainer.java
    webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/JAXBCustomBuilder.java
    webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap12/mtom/TestGetXMLStreamReaderMTOMEncoded.java

Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/impl/TreeWalkerImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/impl/TreeWalkerImpl.java?rev=1747975&r1=1747974&r2=1747975&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/impl/TreeWalkerImpl.java
(original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/impl/TreeWalkerImpl.java
Sun Jun 12 10:33:11 2016
@@ -100,6 +100,9 @@ public final class TreeWalkerImpl implem
     
     @Override
     public boolean proceed() throws StreamException {
+        if (incremental && !handler.drain()) {
+            return false;
+        }
         try {
             // Determine the next node (i.e. the node for which the next event is generated)
and
             // update the state

Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/impl/builder/BuilderHandler.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/impl/builder/BuilderHandler.java?rev=1747975&r1=1747974&r2=1747975&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/impl/builder/BuilderHandler.java
(original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/impl/builder/BuilderHandler.java
Sun Jun 12 10:33:11 2016
@@ -217,4 +217,9 @@ final class BuilderHandler implements Xm
         context = null;
         done = true;
     }
+
+    @Override
+    public boolean drain() throws StreamException {
+        return true;
+    }
 }

Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/NullXmlHandler.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/NullXmlHandler.java?rev=1747975&r1=1747974&r2=1747975&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/NullXmlHandler.java
(original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/NullXmlHandler.java
Sun Jun 12 10:33:11 2016
@@ -95,4 +95,9 @@ public final class NullXmlHandler implem
     @Override
     public void completed() throws StreamException {
     }
+
+    @Override
+    public boolean drain() throws StreamException {
+        return true;
+    }
 }

Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/XmlHandler.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/XmlHandler.java?rev=1747975&r1=1747974&r2=1747975&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/XmlHandler.java
(original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/XmlHandler.java
Sun Jun 12 10:33:11 2016
@@ -141,4 +141,14 @@ public interface XmlHandler {
      *             if an error occurs when processing the event
      */
     void completed() throws StreamException;
+    
+    /**
+     * Drain the pipeline by pushing pending events to the next handler in the chain.
+     * 
+     * @return {@code true} if the pipeline was already drained and no new events were pushed,
+     *         {@code false} if at least one event was pushed and this method should be called
again
+     *         to continue draining the pipeline
+     * @throws StreamException
+     */
+    boolean drain() throws StreamException;
 }

Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/XmlHandlerWrapper.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/XmlHandlerWrapper.java?rev=1747975&r1=1747974&r2=1747975&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/XmlHandlerWrapper.java
(original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/XmlHandlerWrapper.java
Sun Jun 12 10:33:11 2016
@@ -118,4 +118,9 @@ public class XmlHandlerWrapper implement
     public void completed() throws StreamException {
         parent.completed();
     }
+
+    @Override
+    public boolean drain() throws StreamException {
+        return parent.drain();
+    }
 }

Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/sax/ContentHandlerXmlHandler.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/sax/ContentHandlerXmlHandler.java?rev=1747975&r1=1747974&r2=1747975&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/sax/ContentHandlerXmlHandler.java
(original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/sax/ContentHandlerXmlHandler.java
Sun Jun 12 10:33:11 2016
@@ -285,4 +285,9 @@ public class ContentHandlerXmlHandler im
             throw new StreamException(ex);
         }
     }
+
+    @Override
+    public boolean drain() throws StreamException {
+        return true;
+    }
 }

Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/serializer/Serializer.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/serializer/Serializer.java?rev=1747975&r1=1747974&r2=1747975&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/serializer/Serializer.java
(original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/serializer/Serializer.java
Sun Jun 12 10:33:11 2016
@@ -1098,4 +1098,9 @@ public final class Serializer extends Se
     public void completed() throws StreamException {
         flushBuffer();
     }
+
+    @Override
+    public boolean drain() throws StreamException {
+        return true;
+    }
 }

Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/stax/pull/StAXPivot.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/stax/pull/StAXPivot.java?rev=1747975&r1=1747974&r2=1747975&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/stax/pull/StAXPivot.java
(original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/stax/pull/StAXPivot.java
Sun Jun 12 10:33:11 2016
@@ -441,6 +441,11 @@ public final class StAXPivot implements
     }
 
     @Override
+    public boolean drain() throws StreamException {
+        return true;
+    }
+
+    @Override
     public Object getProperty(String name) throws IllegalArgumentException {
         if (extensions != null) {
             Object extension = extensions.get(name);

Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/xop/AbstractXOPEncodingFilterHandler.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/xop/AbstractXOPEncodingFilterHandler.java?rev=1747975&r1=1747974&r2=1747975&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/xop/AbstractXOPEncodingFilterHandler.java
(original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/xop/AbstractXOPEncodingFilterHandler.java
Sun Jun 12 10:33:11 2016
@@ -24,6 +24,7 @@ import org.apache.axiom.core.stream.XmlH
 
 public abstract class AbstractXOPEncodingFilterHandler extends XmlHandlerWrapper {
     private final CompletionListener completionListener;
+    private boolean inXOPInclude;
 
     public AbstractXOPEncodingFilterHandler(XmlHandler parent, CompletionListener completionListener)
{
         super(parent);
@@ -66,6 +67,29 @@ public abstract class AbstractXOPEncodin
         return "cid:" + contentID.replaceAll("%", "%25");
     }
 
+    private boolean flushIfNecessary() throws StreamException {
+        if (inXOPInclude) {
+            super.endElement();
+            inXOPInclude = false;
+            return false;
+        } else {
+            return true;
+        }
+    }
+
+    @Override
+    public void startElement(String namespaceURI, String localName, String prefix)
+            throws StreamException {
+        flushIfNecessary();
+        super.startElement(namespaceURI, localName, prefix);
+    }
+
+    @Override
+    public void endElement() throws StreamException {
+        flushIfNecessary();
+        super.endElement();
+    }
+
     @Override
     public void processCharacterData(Object data, boolean ignorable) throws StreamException
{
         if (!ignorable) {
@@ -75,7 +99,7 @@ public abstract class AbstractXOPEncodin
                 super.processNamespaceDeclaration(XOPConstants.DEFAULT_PREFIX, XOPConstants.NAMESPACE_URI);
                 super.processAttribute("", XOPConstants.HREF, "", getURLForContentID(contentID),
"CDATA", true);
                 super.attributesCompleted();
-                super.endElement();
+                inXOPInclude = true;
                 return;
             }
         }
@@ -85,6 +109,17 @@ public abstract class AbstractXOPEncodin
     @Override
     public void completed() throws StreamException {
         super.completed();
-        completionListener.completed(this);
+        if (completionListener != null) {
+            completionListener.completed(this);
+        }
+    }
+
+    @Override
+    public boolean drain() throws StreamException {
+        if (super.drain()) {
+            return flushIfNecessary();
+        } else {
+            return false;
+        }
     }
 }

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/SAXResultContentHandler.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/SAXResultContentHandler.java?rev=1747975&r1=1747974&r2=1747975&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/SAXResultContentHandler.java
(original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/SAXResultContentHandler.java
Sun Jun 12 10:33:11 2016
@@ -159,4 +159,9 @@ public final class SAXResultContentHandl
             throw new UnsupportedOperationException();
         }
     }
+
+    @Override
+    public boolean drain() throws StreamException {
+        return true;
+    }
 }

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=1747975&r1=1747974&r2=1747975&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
Sun Jun 12 10:33:11 2016
@@ -58,6 +58,7 @@ import org.apache.axiom.om.OMNode;
 import org.apache.axiom.om.OMOutputFormat;
 import org.apache.axiom.om.OMXMLParserWrapper;
 import org.apache.axiom.om.OMXMLStreamReaderConfiguration;
+import org.apache.axiom.om.XOPEncoded;
 import org.apache.axiom.om.impl.OMMultipartWriter;
 import org.apache.axiom.om.impl.common.AxiomExceptionTranslator;
 import org.apache.axiom.om.impl.common.AxiomSemantics;
@@ -77,6 +78,7 @@ import org.apache.axiom.om.impl.stream.x
 import org.apache.axiom.om.impl.stream.xop.XOPEncodingFilterHandler;
 import org.apache.axiom.util.io.IOUtils;
 import org.apache.axiom.util.stax.xop.ContentIDGenerator;
+import org.apache.axiom.util.stax.xop.OptimizationPolicy;
 import org.xml.sax.InputSource;
 
 public aspect AxiomContainerSupport {
@@ -141,6 +143,17 @@ public aspect AxiomContainerSupport {
         return pivot;
     }
     
+    public final XOPEncoded<XMLStreamReader> AxiomContainer.getXOPEncodedStreamReader(boolean
cache) {
+        StAXPivot pivot = new StAXPivot(AxiomXMLStreamReaderExtensionFactory.INSTANCE);
+        XOPEncodingFilterHandler encoder = new XOPEncodingFilterHandler(pivot, ContentIDGenerator.DEFAULT,
OptimizationPolicy.ALL, null);
+        try {
+            pivot.setReader(coreGetReader(encoder, cache, true));
+        } catch (StreamException ex) {
+            throw new OMException(ex);
+        }
+        return new XOPEncoded<XMLStreamReader>(pivot, encoder);
+    }
+    
     public final AxiomChildNode AxiomContainer.prepareNewChild(OMNode omNode) {
         AxiomChildNode child;
         // Careful here: if the child was created by another Axiom implementation, it doesn't

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/stream/stax/push/XMLStreamWriterHandler.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/stream/stax/push/XMLStreamWriterHandler.java?rev=1747975&r1=1747974&r2=1747975&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/stream/stax/push/XMLStreamWriterHandler.java
(original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/stream/stax/push/XMLStreamWriterHandler.java
Sun Jun 12 10:33:11 2016
@@ -215,4 +215,9 @@ public class XMLStreamWriterHandler impl
     public void completed() throws StreamException {
         // TODO: the original StAX serialization code newer called writeEndDocument; this
is probably a mistake
     }
+
+    @Override
+    public boolean drain() throws StreamException {
+        return true;
+    }
 }

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/stream/xop/XOPEncodingFilterHandler.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/stream/xop/XOPEncodingFilterHandler.java?rev=1747975&r1=1747974&r2=1747975&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/stream/xop/XOPEncodingFilterHandler.java
(original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/stream/xop/XOPEncodingFilterHandler.java
Sun Jun 12 10:33:11 2016
@@ -32,12 +32,13 @@ import org.apache.axiom.core.stream.XmlH
 import org.apache.axiom.core.stream.xop.AbstractXOPEncodingFilterHandler;
 import org.apache.axiom.core.stream.xop.CompletionListener;
 import org.apache.axiom.ext.stax.datahandler.DataHandlerProvider;
+import org.apache.axiom.mime.MimePartProvider;
 import org.apache.axiom.om.impl.intf.TextContent;
 import org.apache.axiom.util.stax.xop.ContentIDGenerator;
 import org.apache.axiom.util.stax.xop.OptimizationPolicy;
 import org.apache.axiom.util.stax.xop.XOPUtils;
 
-public final class XOPEncodingFilterHandler extends AbstractXOPEncodingFilterHandler implements
XOPHandler {
+public final class XOPEncodingFilterHandler extends AbstractXOPEncodingFilterHandler implements
XOPHandler, MimePartProvider {
     private final Map<String,Object> dataHandlerObjects = new LinkedHashMap<String,Object>();
     private final ContentIDGenerator contentIDGenerator;
     private final OptimizationPolicy optimizationPolicy;
@@ -78,6 +79,7 @@ public final class XOPEncodingFilterHand
         return Collections.unmodifiableSet(dataHandlerObjects.keySet());
     }
 
+    @Override
     public DataHandler getDataHandler(String contentID) throws IOException {
         Object dataHandlerObject = dataHandlerObjects.get(contentID);
         if (dataHandlerObject == null) {
@@ -90,6 +92,19 @@ public final class XOPEncodingFilterHand
         }
     }
 
+    @Override
+    public boolean isLoaded(String contentID) {
+        Object dataHandlerObject = dataHandlerObjects.get(contentID);
+        if (dataHandlerObject == null) {
+            throw new IllegalArgumentException("No DataHandler object found for content ID
'" +
+                    contentID + "'");
+        } else if (dataHandlerObject instanceof DataHandler) {
+            return true;
+        } else {
+            return ((DataHandlerProvider)dataHandlerObject).isLoaded();
+        }
+    }
+
     @Override
     protected String processCharacterData(Object data) throws StreamException {
         if (data instanceof TextContent) {

Modified: webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/OMContainer.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/OMContainer.java?rev=1747975&r1=1747974&r2=1747975&view=diff
==============================================================================
--- webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/OMContainer.java (original)
+++ webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/OMContainer.java Sun
Jun 12 10:33:11 2016
@@ -404,4 +404,13 @@ public interface OMContainer extends OMS
      * @see OMXMLBuilderFactory#createOMBuilder(OMFactory, SAXSource, boolean)
      */
     SAXResult getSAXResult();
+    
+    /**
+     * Get an XOP encoded pull parser representation of this information item.
+     * 
+     * @param cache
+     *            indicates if caching should be enabled
+     * @return an XOP encoded representation of this information item
+     */
+    XOPEncoded<XMLStreamReader> getXOPEncodedStreamReader(boolean cache);
 }

Copied: webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/XOPEncoded.java
(from r1745667, webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/util/stax/xop/XOPEncodedStream.java)
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/XOPEncoded.java?p2=webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/XOPEncoded.java&p1=webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/util/stax/xop/XOPEncodedStream.java&r1=1745667&r2=1747975&rev=1747975&view=diff
==============================================================================
--- webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/util/stax/xop/XOPEncodedStream.java
(original)
+++ webservices/axiom/trunk/axiom-api/src/main/java/org/apache/axiom/om/XOPEncoded.java Sun
Jun 12 10:33:11 2016
@@ -16,42 +16,39 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-
-package org.apache.axiom.util.stax.xop;
-
-import javax.xml.stream.XMLStreamReader;
+package org.apache.axiom.om;
 
 import org.apache.axiom.mime.MimePartProvider;
 
 /**
- * Represents an XOP encoded stream. Since an XOP message is a MIME package with
+ * Represent XOP encoded data. Since an XOP message is a MIME package with
  * a root part in XML and a set of additional (binary) parts referenced from
- * the main part, this class encapsulates an {@link XMLStreamReader}
+ * the main part, this class encapsulates an API dependent object
  * representing the main part and a {@link MimePartProvider} giving access to
  * the attachments. Instances of this class can be obtained from
- * {@link XOPUtils#getXOPEncodedStream(XMLStreamReader)}.
+ * {@link OMContainer#getXOPEncodedStreamReader(boolean)}.
  */
-public class XOPEncodedStream {
-    private final XMLStreamReader reader;
+public final class XOPEncoded<T> {
+    private final T rootPart;
     private final MimePartProvider mimePartProvider;
     
-    XOPEncodedStream(XMLStreamReader reader, MimePartProvider mimePartProvider) {
-        this.reader = reader;
+    public XOPEncoded(T rootPart, MimePartProvider mimePartProvider) {
+        this.rootPart = rootPart;
         this.mimePartProvider = mimePartProvider;
     }
 
     /**
-     * Get the stream reader for the main part of the XOP message.
+     * Get the root part of the XOP message.
      * 
-     * @return the stream reader for the main part
+     * @return the root part
      */
-    public XMLStreamReader getReader() {
-        return reader;
+    public T getRootPart() {
+        return rootPart;
     }
 
     /**
      * Get the provider object for the additional MIME parts referenced by the
-     * main part.
+     * root part.
      * 
      * @return the MIME part provider
      */

Modified: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/JAXBCustomBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/JAXBCustomBuilder.java?rev=1747975&r1=1747974&r2=1747975&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/JAXBCustomBuilder.java
(original)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/builder/JAXBCustomBuilder.java
Sun Jun 12 10:33:11 2016
@@ -29,10 +29,9 @@ import javax.xml.stream.XMLStreamWriter;
 import org.apache.axiom.om.OMDataSource;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMException;
+import org.apache.axiom.om.XOPEncoded;
 import org.apache.axiom.om.ds.AbstractPushOMDataSource;
 import org.apache.axiom.om.ds.custombuilder.CustomBuilder;
-import org.apache.axiom.util.stax.xop.XOPEncodedStream;
-import org.apache.axiom.util.stax.xop.XOPUtils;
 
 public class JAXBCustomBuilder implements CustomBuilder {
     private final JAXBContext jaxbContext;
@@ -46,18 +45,17 @@ public class JAXBCustomBuilder implement
     @Override
     public OMDataSource create(OMElement element) throws OMException {
         try {
-            XMLStreamReader reader = element.getXMLStreamReaderWithoutCaching();
+            XOPEncoded<XMLStreamReader> xopStream = element.getXOPEncodedStreamReader(false);
+            XMLStreamReader reader = xopStream.getRootPart();
             reader.next();
             final String namespaceURI = reader.getNamespaceURI();
             final String localName = reader.getLocalName();
-            XOPEncodedStream xopStream = XOPUtils.getXOPEncodedStream(reader);
-            XMLStreamReader encodedReader = xopStream.getReader();
             Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
             AttachmentUnmarshallerImpl attachmentUnmarshaller = new AttachmentUnmarshallerImpl(xopStream.getMimePartProvider());
             unmarshaller.setAttachmentUnmarshaller(attachmentUnmarshaller);
             // For the purpose of the test we just store the JAXB object and return
             // a dummy OMDataSource.
-            jaxbObject = unmarshaller.unmarshal(encodedReader);
+            jaxbObject = unmarshaller.unmarshal(reader);
             reader.close();
             attachmentsAccessed = attachmentUnmarshaller.isAccessed();
             return new AbstractPushOMDataSource() {

Modified: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap12/mtom/TestGetXMLStreamReaderMTOMEncoded.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap12/mtom/TestGetXMLStreamReaderMTOMEncoded.java?rev=1747975&r1=1747974&r2=1747975&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap12/mtom/TestGetXMLStreamReaderMTOMEncoded.java
(original)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap12/mtom/TestGetXMLStreamReaderMTOMEncoded.java
Sun Jun 12 10:33:11 2016
@@ -28,9 +28,9 @@ import org.apache.axiom.attachments.Atta
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMMetaFactory;
 import org.apache.axiom.om.OMXMLBuilderFactory;
+import org.apache.axiom.om.XOPEncoded;
 import org.apache.axiom.ts.AxiomTestCase;
 import org.apache.axiom.ts.soap.MTOMSample;
-import org.apache.axiom.util.stax.xop.XOPEncodedStream;
 import org.apache.axiom.util.stax.xop.XOPUtils;
 
 public class TestGetXMLStreamReaderMTOMEncoded extends AxiomTestCase {
@@ -52,8 +52,8 @@ public class TestGetXMLStreamReaderMTOME
         
         // Use tree as input to XMLStreamReader
         // Issue XOP:Include events for optimized MTOM text nodes
-        XOPEncodedStream xopEncodedStream = XOPUtils.getXOPEncodedStream(root.getXMLStreamReader(cache));
-        XMLStreamReader xmlStreamReader = xopEncodedStream.getReader();
+        XOPEncoded<XMLStreamReader> xopEncodedStream = root.getXOPEncodedStreamReader(cache);
+        XMLStreamReader xmlStreamReader = xopEncodedStream.getRootPart();
         
         DataHandler dh = null;
         while(xmlStreamReader.hasNext() && dh == null) {



Mime
View raw message