You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by da...@apache.org on 2008/08/07 22:38:46 UTC

svn commit: r683709 - /webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java

Author: damrhei
Date: Thu Aug  7 13:38:46 2008
New Revision: 683709

URL: http://svn.apache.org/viewvc?rev=683709&view=rev
Log:
Provide new signature TransportUtils.createSOAPMessage(MessageContext, boolean). This will allow the caller to dictate if the underlying DetachableInputStream should be detached upon return. If set to true is specified, and there is a DetachableInputStream present on the MessageContext, the 'detach' mehtod will be called before close.

Modified:
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java?rev=683709&r1=683708&r2=683709&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/TransportUtils.java Thu Aug  7 13:38:46 2008
@@ -27,6 +27,7 @@
 import org.apache.axiom.om.OMException;
 import org.apache.axiom.om.OMOutputFormat;
 import org.apache.axiom.om.impl.builder.StAXBuilder;
+import org.apache.axiom.om.util.DetachableInputStream;
 import org.apache.axiom.soap.SOAP11Constants;
 import org.apache.axiom.soap.SOAP12Constants;
 import org.apache.axiom.soap.SOAPEnvelope;
@@ -61,6 +62,18 @@
     private static final Log log = LogFactory.getLog(TransportUtils.class);
 
     public static SOAPEnvelope createSOAPMessage(MessageContext msgContext) throws AxisFault {
+        return createSOAPMessage(msgContext, false);
+    }
+    
+    /**
+     * This method will create a SOAPEnvelope based on the InputStream stored on
+     * the MessageContext. The 'detach' parameter controls whether or not the 
+     * underlying DetachableInputStream is detached at the end of the method. Note,
+     * detaching the DetachableInputStream closes the underlying InputStream that
+     * is stored on the MessageContext.
+     */
+    public static SOAPEnvelope createSOAPMessage(MessageContext msgContext,
+                                                 boolean detach) throws AxisFault {
         try {
             InputStream inStream = (InputStream) msgContext
                     .getProperty(MessageContext.TRANSPORT_IN);
@@ -85,7 +98,20 @@
             }
             msgContext.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING, charSetEnc);
 
-            return createSOAPMessage(msgContext, inStream, contentType);
+            SOAPEnvelope env = createSOAPMessage(msgContext, inStream, contentType);
+            
+            // if we were told to detach, we will make the call here, this is only applicable
+            // if a DetachableInputStream instance is found on the MessageContext
+            if(detach) {
+                DetachableInputStream dis = (DetachableInputStream) msgContext.getProperty(Constants.DETACHABLE_INPUT_STREAM);
+                if(dis != null) {
+                    if(log.isDebugEnabled()) {
+                        log.debug("Detaching input stream after SOAPEnvelope construction");
+                    }
+                    dis.detach();
+                }
+            }
+            return env;
         } catch (Exception e) {
             throw AxisFault.makeFault(e);
         }