axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sc...@apache.org
Subject svn commit: r655959 - in /webservices/axis2/trunk/java/modules/jaxws: src/org/apache/axis2/datasource/jaxb/ src/org/apache/axis2/jaxws/message/attachments/ src/org/apache/axis2/jaxws/message/databinding/ src/org/apache/axis2/jaxws/message/databinding/i...
Date Tue, 13 May 2008 18:10:55 GMT
Author: scheu
Date: Tue May 13 11:10:55 2008
New Revision: 655959

URL: http://svn.apache.org/viewvc?rev=655959&view=rev
Log:
WSCOMMONS-344
Contributor:Rich Scheuerle
JAXWS Enablement of new OMXMLStreamReader xop:include processing

Modified:
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBAttachmentUnmarshaller.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBDSContext.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/attachments/JAXBAttachmentUnmarshaller.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBBlockContext.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/JAXBBlockImpl.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/MessagePersistanceTests.java

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBAttachmentUnmarshaller.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBAttachmentUnmarshaller.java?rev=655959&r1=655958&r2=655959&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBAttachmentUnmarshaller.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBAttachmentUnmarshaller.java
Tue May 13 11:10:55 2008
@@ -20,6 +20,7 @@
 package org.apache.axis2.datasource.jaxb;
 
 import org.apache.axiom.om.OMException;
+import org.apache.axiom.om.OMXMLStreamReader;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.jaxws.i18n.Messages;
 import org.apache.commons.logging.Log;
@@ -27,6 +28,8 @@
 
 import javax.activation.DataHandler;
 import javax.xml.bind.attachment.AttachmentUnmarshaller;
+import javax.xml.stream.XMLStreamReader;
+
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
@@ -42,8 +45,10 @@
     private static final Log log = LogFactory.getLog(JAXBAttachmentUnmarshaller.class);
 
     private MessageContext msgContext;
+    private XMLStreamReader xmlStreamReader;
 
-    public JAXBAttachmentUnmarshaller(MessageContext msgContext) {
+    public JAXBAttachmentUnmarshaller(MessageContext msgContext, 
+                                      XMLStreamReader xmlStreamReader) {
         this.msgContext = msgContext;
     }
 
@@ -52,6 +57,12 @@
         // Any message that is received might contain MTOM.
         // So always return true.
         boolean value = true;
+        
+        // Have the OM XMLStreamReader (OMStAXWrapper)
+        // sent xop:include events
+        if (xmlStreamReader instanceof OMXMLStreamReader) {
+            ((OMXMLStreamReader) xmlStreamReader).setInlineMTOM(true);
+        }
     
         if (log.isDebugEnabled()){ 
             log.debug("isXOPPackage returns " + value);
@@ -162,6 +173,14 @@
             }
             return dh;
         }
+        if (xmlStreamReader instanceof OMXMLStreamReader) {
+            DataHandler dh = 
+                ((OMXMLStreamReader) xmlStreamReader).getDataHandler(blobcid);
+            if (dh != null) {
+                JAXBAttachmentUnmarshallerMonitor.addBlobCID(blobcid);
+            }
+            return dh;
+        }
         return null;
     }
 }

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBDSContext.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBDSContext.java?rev=655959&r1=655958&r2=655959&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBDSContext.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBDSContext.java
Tue May 13 11:10:55 2008
@@ -226,8 +226,8 @@
      * Create an Attachment unmarshaller for unmarshalling MTOM/SWA Attachments
      * @return AttachmentUnmarshaller
      */
-    protected AttachmentUnmarshaller createAttachmentUnmarshaller() {
-        return new JAXBAttachmentUnmarshaller(getMessageContext());
+    protected AttachmentUnmarshaller createAttachmentUnmarshaller(XMLStreamReader reader)
{
+        return new JAXBAttachmentUnmarshaller(getMessageContext(), reader);
     }
 
     /**
@@ -245,7 +245,7 @@
 
         
         // Create an attachment unmarshaller
-        AttachmentUnmarshaller aum = createAttachmentUnmarshaller();
+        AttachmentUnmarshaller aum = createAttachmentUnmarshaller(reader);
 
         if (aum != null) {
             if (DEBUG_ENABLED) {

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/attachments/JAXBAttachmentUnmarshaller.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/attachments/JAXBAttachmentUnmarshaller.java?rev=655959&r1=655958&r2=655959&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/attachments/JAXBAttachmentUnmarshaller.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/attachments/JAXBAttachmentUnmarshaller.java
Tue May 13 11:10:55 2008
@@ -19,10 +19,12 @@
 
 package org.apache.axis2.jaxws.message.attachments;
 
+import org.apache.axiom.om.OMXMLStreamReader;
 import org.apache.axis2.datasource.jaxb.JAXBAttachmentUnmarshallerMonitor;
 import org.apache.axis2.jaxws.message.Message;
 
 import javax.activation.DataHandler;
+import javax.xml.stream.XMLStreamReader;
 
 /**
  * JAXBAttachmentUnmarshaller
@@ -33,9 +35,10 @@
 public class JAXBAttachmentUnmarshaller extends org.apache.axis2.datasource.jaxb.JAXBAttachmentUnmarshaller
{
 
     private Message message;
+    private XMLStreamReader xmlStreamReader;
 
-    public JAXBAttachmentUnmarshaller(Message message) {
-        super(null);
+    public JAXBAttachmentUnmarshaller(Message message, XMLStreamReader xmlStreamReader) {
+        super(null, xmlStreamReader);
         this.message = message;
     }
 
@@ -48,7 +51,16 @@
                 JAXBAttachmentUnmarshallerMonitor.addBlobCID(cid);
             }
             return dh;
-        } 
+        }
+        
+        if (xmlStreamReader instanceof OMXMLStreamReader) {
+            DataHandler dh = 
+                ((OMXMLStreamReader) xmlStreamReader).getDataHandler(cid);
+            if (dh != null) {
+                JAXBAttachmentUnmarshallerMonitor.addBlobCID(cid);
+            }
+            return dh;
+        }
         return null;
     }
 

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBBlockContext.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBBlockContext.java?rev=655959&r1=655958&r2=655959&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBBlockContext.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBBlockContext.java
Tue May 13 11:10:55 2008
@@ -29,6 +29,7 @@
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.attachment.AttachmentMarshaller;
 import javax.xml.bind.attachment.AttachmentUnmarshaller;
+import javax.xml.stream.XMLStreamReader;
 import javax.xml.stream.XMLStreamWriter;
 import java.util.TreeSet;
 
@@ -93,8 +94,8 @@
     }
     
     @Override
-    protected AttachmentUnmarshaller createAttachmentUnmarshaller() {
-        return new JAXBAttachmentUnmarshaller(getMessage());
+    protected AttachmentUnmarshaller createAttachmentUnmarshaller(XMLStreamReader reader)
{
+        return new JAXBAttachmentUnmarshaller(getMessage(), reader);
     }
 
     public ClassLoader getClassLoader() {

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/JAXBBlockImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/JAXBBlockImpl.java?rev=655959&r1=655958&r2=655959&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/JAXBBlockImpl.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/JAXBBlockImpl.java
Tue May 13 11:10:55 2008
@@ -24,6 +24,7 @@
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMException;
 import org.apache.axiom.om.OMSourcedElement;
+import org.apache.axiom.om.OMXMLStreamReader;
 import org.apache.axiom.om.util.StAXUtils;
 import org.apache.axis2.datasource.jaxb.JAXBDSContext;
 import org.apache.axis2.datasource.jaxb.JAXBDataSource;
@@ -166,6 +167,19 @@
                 new ByteArrayInputStream(_getBytesFromBO(busObj, busContext, "utf-8"));
         return StAXUtils.createXMLStreamReader(baos, "utf-8");
     }
+    
+    protected XMLStreamReader _getReaderFromOM(OMElement omElement) {
+        XMLStreamReader reader;
+        if (omElement.getBuilder() != null && !omElement.getBuilder().isCompleted())
{
+            reader = omElement.getXMLStreamReaderWithoutCaching();
+        } else {
+            reader = omElement.getXMLStreamReader();
+        }
+        if (reader instanceof OMXMLStreamReader) {
+            ((OMXMLStreamReader)reader).setInlineMTOM(false);  // Optimize attachment usage
+        }
+        return reader;
+    }
 
     protected void _outputFromBO(Object busObject, Object busContext, XMLStreamWriter writer)
         throws XMLStreamException, WebServiceException {

Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/MessagePersistanceTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/MessagePersistanceTests.java?rev=655959&r1=655958&r2=655959&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/MessagePersistanceTests.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/MessagePersistanceTests.java
Tue May 13 11:10:55 2008
@@ -20,10 +20,13 @@
 package org.apache.axis2.jaxws.message;
 
 import junit.framework.TestCase;
+
+import org.apache.axiom.om.OMAttachmentAccessor;
 import org.apache.axiom.om.OMDataSource;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMOutputFormat;
 import org.apache.axiom.om.OMSourcedElement;
+import org.apache.axiom.om.OMXMLStreamReader;
 import org.apache.axiom.om.util.CopyUtils;
 import org.apache.axiom.soap.SOAPBody;
 import org.apache.axiom.soap.SOAPEnvelope;
@@ -47,6 +50,8 @@
 import javax.imageio.ImageIO;
 import javax.imageio.stream.FileImageInputStream;
 import javax.imageio.stream.ImageInputStream;
+import javax.xml.namespace.QName;
+
 import java.awt.*;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
@@ -66,6 +71,8 @@
     DataSource stringDS, imageDS;
     public String imageResourceDir = "test-resources" + File.separator + "image";
     private final String sampleText = "Sample Text";
+    private final static QName XOP_INCLUDE = 
+        new QName("http://www.w3.org/2004/08/xop/include", "Include");
     
     protected void setUp() throws Exception {
         super.setUp();
@@ -455,6 +462,46 @@
         assertTrue(restoredText.indexOf(sampleText) > 0);
         assertTrue(restoredText.indexOf("<soapenv:Body><sendImage xmlns=\"urn://mtom.test.org\"><input><imageData><xop:Include")
> 0);
         
+        // Now try walking the saved envelope as an XMLInputStream.
+        // try to restore the message context again
+        // Now read in the persisted message
+        // Setup an input stream to the file
+        inStream = new FileInputStream(theFile);
+
+        // attach a stream capable of reading objects from the 
+        // stream connected to the file
+        inObjStream = new ObjectInputStream(inStream);
+        System.out.println("restoring a message context again.....");
+
+        restoredMC = 
+            (org.apache.axis2.context.MessageContext) inObjStream.readObject();
+        inObjStream.close();
+        inStream.close();
+        System.out.println("....restored message context.....");    
+        env = restoredMC.getEnvelope();
+        env.build();
+        
+        // Use tree as input to XMLStreamReader
+        OMXMLStreamReader xmlStreamReader = (OMXMLStreamReader) env.getXMLStreamReader();
+        
+        // Issue XOP:Include events for optimized MTOM text nodes
+        xmlStreamReader.setInlineMTOM(false);
+        
+        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 =((OMAttachmentAccessor)xmlStreamReader).getDataHandler(hrefValue);
+                    }
+                }
+            }
+        }
+        
+        assertTrue(dh != null);       
     }
     
     /**
@@ -549,7 +596,7 @@
         assertTrue(!omse.isExpanded());
         ds = omse.getDataSource();
         assertTrue(ds instanceof JAXBDataSource);
-        
+          
         // Simulate transport on the copied message
         baos = new ByteArrayOutputStream();
         outputFormat = new OMOutputFormat();



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message