Author: veithen
Date: Sun Jun 12 11:58:02 2016
New Revision: 1747983

URL: http://svn.apache.org/viewvc?rev=1747983&view=rev
Log:
Use the new getXOPEncodedStreamReader API.

Modified:
    
axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBCustomBuilder.java
    
axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBDSContext.java
    
axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/JAXBBlockImpl.java
    
axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/message/MessagePersistanceTests.java

Modified: 
axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBCustomBuilder.java
URL: 
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBCustomBuilder.java?rev=1747983&r1=1747982&r2=1747983&view=diff
==============================================================================
--- 
axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBCustomBuilder.java
 (original)
+++ 
axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBCustomBuilder.java
 Sun Jun 12 11:58:02 2016
@@ -31,8 +31,6 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 import javax.xml.bind.JAXBException;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
 
 /**
  * JAXBCustomBuilder creates an OMSourcedElement backed by a JAXBDataSource
@@ -56,22 +54,18 @@ public class JAXBCustomBuilder implement
 
     @Override
     public OMDataSource create(OMElement element) throws OMException {
-        XMLStreamReader reader = element.getXMLStreamReaderWithoutCaching();
         try {
-            reader.next();
             if (log.isDebugEnabled()) {
-                log.debug("create namespace = " + reader.getNamespaceURI());
-                log.debug("  localPart = " + reader.getLocalName());
-                log.debug("  reader = " + reader.getClass());
+                log.debug("create namespace = " + element.getNamespaceURI());
+                log.debug("  localPart = " + element.getLocalName());
             }
         
             // Create an OMSourcedElement backed by an unmarshalled JAXB object
             
-            Object jaxb = jdsContext.unmarshal(reader);
+            Object jaxb = jdsContext.unmarshal(element);
             if (log.isDebugEnabled()) {
                 log.debug("Successfully unmarshalled jaxb object " + jaxb);
             }
-            reader.close();
             
             OMDataSource ds = new JAXBDataSource(jaxb, jdsContext);
             if (log.isDebugEnabled()) {
@@ -82,9 +76,6 @@ public class JAXBCustomBuilder implement
         } catch (JAXBException e) {
             JAXBCustomBuilderMonitor.updateTotalFailedCreates();
             throw new OMException(e);
-        } catch (XMLStreamException e) {
-            JAXBCustomBuilderMonitor.updateTotalFailedCreates();
-            throw new OMException(e);
         }
     }
     

Modified: 
axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBDSContext.java
URL: 
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBDSContext.java?rev=1747983&r1=1747982&r2=1747983&view=diff
==============================================================================
--- 
axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBDSContext.java
 (original)
+++ 
axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBDSContext.java
 Sun Jun 12 11:58:02 2016
@@ -19,11 +19,10 @@
 
 package org.apache.axis2.datasource.jaxb;
 
+import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMException;
+import org.apache.axiom.om.XOPEncoded;
 import org.apache.axiom.om.impl.MTOMXMLStreamWriter;
-import org.apache.axiom.util.stax.XMLStreamReaderUtils;
-import org.apache.axiom.util.stax.xop.XOPEncodedStream;
-import org.apache.axiom.util.stax.xop.XOPUtils;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.java.security.AccessController;
 import org.apache.axis2.jaxws.context.utils.ContextUtils;
@@ -290,24 +289,15 @@ public class JAXBDSContext {
 
     /**
      * Unmarshal the xml into a JAXB object
-     * @param inputReader
+     * @param element
      * @return
      * @throws JAXBException
      */
-    public Object unmarshal(XMLStreamReader inputReader) throws JAXBException {
+    public Object unmarshal(OMElement element) throws JAXBException {
 
-        if (DEBUG_ENABLED) {
-            String clsText = (inputReader !=null) ? 
inputReader.getClass().toString() : "null";
-            log.debug("unmarshal with inputReader=" + clsText);
-        } 
         // See the Javadoc of the CustomBuilder interface for a complete 
explanation of
         // the following two instructions:
-        XOPEncodedStream xopEncodedStream = 
XOPUtils.getXOPEncodedStream(inputReader);
-        XMLStreamReader reader = 
XMLStreamReaderUtils.getOriginalXMLStreamReader(xopEncodedStream.getReader());
-        if (DEBUG_ENABLED) {
-            String clsText = (reader !=null) ? reader.getClass().toString() : 
"null";
-            log.debug("  originalReader=" + clsText);
-        } 
+        XOPEncoded<XMLStreamReader> xopEncodedStream = 
element.getXOPEncodedStreamReader(false);
         
         // There may be a preferred classloader that should be used
         ClassLoader cl = getClassLoader();
@@ -328,6 +318,7 @@ public class JAXBDSContext {
         Object jaxb = null;
 
         // Unmarshal into the business object.
+        XMLStreamReader reader = xopEncodedStream.getRootPart();
         if (getProcessType() == null) {
             jaxb = unmarshalByElement(u, reader);   // preferred and always 
used for
                                                     // style=document

Modified: 
axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/JAXBBlockImpl.java
URL: 
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/JAXBBlockImpl.java?rev=1747983&r1=1747982&r2=1747983&view=diff
==============================================================================
--- 
axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/JAXBBlockImpl.java
 (original)
+++ 
axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/JAXBBlockImpl.java
 Sun Jun 12 11:58:02 2016
@@ -84,24 +84,6 @@ public class JAXBBlockImpl extends Block
         super(omElement, busContext, qName, factory);
     }
 
-    private Object _getBOFromReader(XMLStreamReader reader, JAXBBlockContext 
busContext)
-        throws XMLStreamException, WebServiceException {
-        // Get the JAXBBlockContext. All of the necessry information is 
recorded on it
-        try {
-            busObject = busContext.unmarshal(reader);
-        } catch (JAXBException je) {
-            if (DEBUG_ENABLED) {
-                try {
-                    log.debug("JAXBContext for unmarshal failure:" + 
-                              
busContext.getJAXBContext(busContext.getClassLoader()));
-                } catch (Exception e) {
-                }
-            }
-            throw ExceptionFactory.makeWebServiceException(je);
-        }
-        return busObject;
-    }
-    
     @Override
     protected Object _getBOFromOM(OMElement omElement, JAXBBlockContext 
busContext)
         throws XMLStreamException, WebServiceException {
@@ -128,7 +110,19 @@ public class JAXBBlockImpl extends Block
                 return ((JAXBBlockImpl) ds).getObject();
             }
         }
-        return _getBOFromReader(omElement.getXMLStreamReader(false), 
busContext);
+        
+        try {
+            return busContext.unmarshal(omElement);
+        } catch (JAXBException je) {
+            if (DEBUG_ENABLED) {
+                try {
+                    log.debug("JAXBContext for unmarshal failure:" + 
+                              
busContext.getJAXBContext(busContext.getClassLoader()));
+                } catch (Exception e) {
+                }
+            }
+            throw ExceptionFactory.makeWebServiceException(je);
+        }
     }
 
     /**

Modified: 
axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/message/MessagePersistanceTests.java
URL: 
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/message/MessagePersistanceTests.java?rev=1747983&r1=1747982&r2=1747983&view=diff
==============================================================================
--- 
axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/message/MessagePersistanceTests.java
 (original)
+++ 
axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/message/MessagePersistanceTests.java
 Sun Jun 12 11:58:02 2016
@@ -23,13 +23,13 @@ import junit.framework.TestCase;
 
 import org.apache.axiom.om.OMDataSource;
 import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMNode;
 import org.apache.axiom.om.OMOutputFormat;
 import org.apache.axiom.om.OMSourcedElement;
+import org.apache.axiom.om.OMText;
 import org.apache.axiom.soap.SOAPBody;
 import org.apache.axiom.soap.SOAPCloneOptions;
 import org.apache.axiom.soap.SOAPEnvelope;
-import org.apache.axiom.util.stax.xop.XOPEncodedStream;
-import org.apache.axiom.util.stax.xop.XOPUtils;
 import org.apache.axis2.Constants;
 import org.apache.axis2.Constants.Configuration;
 import org.apache.axis2.datasource.jaxb.JAXBDataSource;
@@ -53,7 +53,6 @@ import javax.imageio.ImageIO;
 import javax.imageio.stream.FileImageInputStream;
 import javax.imageio.stream.ImageInputStream;
 import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamReader;
 
 import java.awt.*;
 import java.io.ByteArrayOutputStream;
@@ -62,6 +61,7 @@ import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
+import java.util.Iterator;
 
 /**
  * These tests simulate the outbound processing 
@@ -515,21 +515,14 @@ public class MessagePersistanceTests ext
         env = restoredMC.getEnvelope();
         env.build();
         
-        // Use tree as input to XMLStreamReader
-        // Issue XOP:Include events for optimized MTOM text nodes
-        XOPEncodedStream stream = 
XOPUtils.getXOPEncodedStream(env.getXMLStreamReader());
-        XMLStreamReader xmlStreamReader = stream.getReader();
-        
         DataHandler dh = null;
-        while(xmlStreamReader.hasNext()) {
-            xmlStreamReader.next();
-            if (xmlStreamReader.isStartElement()) {
-                QName qName =xmlStreamReader.getName();
-                if (XOP_INCLUDE.equals(qName)) {
-                    String hrefValue = xmlStreamReader.getAttributeValue("", 
"href");
-                    if (hrefValue != null) {
-                        dh = 
stream.getMimePartProvider().getDataHandler(XOPUtils.getContentIDFromURL(hrefValue));
-                    }
+        for (Iterator<OMNode> it = env.getDescendants(false); it.hasNext(); ) {
+            OMNode node = it.next();
+            if (node instanceof OMText) {
+                OMText text = (OMText)node;
+                if (text.isBinary()) {
+                    dh = text.getDataHandler();
+                    break;
                 }
             }
         }


Reply via email to