ws-axis-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sc...@apache.org
Subject svn commit: r683433 - in /webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws: client/dispatch/ client/proxy/ core/ message/util/
Date Wed, 06 Aug 2008 22:36:07 GMT
Author: scheu
Date: Wed Aug  6 15:36:06 2008
New Revision: 683433

URL: http://svn.apache.org/viewvc?rev=683433&view=rev
Log:
AXIS2-3966
Contributor:Rich Scheuerle
Ater processing completes on the client proxy/dispatch/asyncResponce, free the input stream
so that the transport.
Freeing the input stream will allow the transport to free/pool its resources.

In this case, freeing the input stream is accomplished by invoking the detach() method on
the DetachableInputStream.

Modified:
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/dispatch/BaseDispatch.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/dispatch/JAXBDispatchAsyncListener.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/dispatch/XMLDispatchAsyncListener.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/MessageContext.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/Reader.java

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/dispatch/BaseDispatch.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/dispatch/BaseDispatch.java?rev=683433&r1=683432&r2=683433&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/dispatch/BaseDispatch.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/dispatch/BaseDispatch.java
Wed Aug  6 15:36:06 2008
@@ -50,6 +50,8 @@
 import javax.xml.ws.WebServiceFeature;
 import javax.xml.ws.http.HTTPBinding;
 import javax.xml.ws.soap.SOAPBinding;
+
+import java.io.IOException;
 import java.util.concurrent.Executor;
 import java.util.concurrent.Future;
 
@@ -165,9 +167,22 @@
                 throw wse;
             }
 
-            Message responseMsg = responseMsgCtx.getMessage();
-            Object returnObj = getValueFromMessage(responseMsg);
-
+            // Get the return object
+            Object returnObj = null;
+            try {
+                Message responseMsg = responseMsgCtx.getMessage();
+                returnObj = getValueFromMessage(responseMsg);
+            }
+            finally {
+                // Free the incoming input stream
+                try {
+                    responseMsgCtx.freeInputStream();
+                }
+                catch (Throwable t) {
+                    throw ExceptionFactory.makeWebServiceException(t);
+                }
+            }
+           
             //Check to see if we need to maintain session state
             checkMaintainSessionState(requestMsgCtx, invocationContext);
 
@@ -424,16 +439,25 @@
      * @return
      */
     public static WebServiceException getFaultResponse(MessageContext msgCtx) {
-        Message msg = msgCtx.getMessage();
-        if (msg != null && msg.isFault()) {
-            //XMLFault fault = msg.getXMLFault();
-            // 4.3.2 conformance bullet 1 requires a ProtocolException here
-            ProtocolException pe =
+        try {
+            Message msg = msgCtx.getMessage();
+            if (msg != null && msg.isFault()) {
+                //XMLFault fault = msg.getXMLFault();
+                // 4.3.2 conformance bullet 1 requires a ProtocolException here
+                ProtocolException pe =
                     MethodMarshallerUtils.createSystemException(msg.getXMLFault(), msg);
-            return pe;
-        } else if (msgCtx.getLocalException() != null) {
-            // use the factory, it'll throw the right thing:
-            return ExceptionFactory.makeWebServiceException(msgCtx.getLocalException());
+                return pe;
+            } else if (msgCtx.getLocalException() != null) {
+                // use the factory, it'll throw the right thing:
+                return ExceptionFactory.makeWebServiceException(msgCtx.getLocalException());
+            }
+        } finally {
+            // Free the incoming input stream
+            try {
+                msgCtx.freeInputStream();
+            } catch (IOException ioe) {
+                return ExceptionFactory.makeWebServiceException(ioe);
+            }
         }
 
         return null;

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/dispatch/JAXBDispatchAsyncListener.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/dispatch/JAXBDispatchAsyncListener.java?rev=683433&r1=683432&r2=683433&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/dispatch/JAXBDispatchAsyncListener.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/dispatch/JAXBDispatchAsyncListener.java
Wed Aug  6 15:36:06 2008
@@ -19,6 +19,7 @@
 
 package org.apache.axis2.jaxws.client.dispatch;
 
+import org.apache.axis2.jaxws.ExceptionFactory;
 import org.apache.axis2.jaxws.client.async.AsyncResponse;
 import org.apache.axis2.jaxws.core.MessageContext;
 import org.apache.axis2.jaxws.description.EndpointDescription;
@@ -48,7 +49,17 @@
     }
 
     public Object getResponseValueObject(MessageContext mc) {
-        return JAXBDispatch.getValue(mc.getMessage(), mode, jaxbContext);
+        try {
+            return JAXBDispatch.getValue(mc.getMessage(), mode, jaxbContext);
+        } finally {
+            // Free the incoming stream
+            try {
+                mc.freeInputStream();
+            }
+            catch (Throwable t) {
+                throw ExceptionFactory.makeWebServiceException(t);
+            }
+        }
     }
 
     public Throwable getFaultResponse(MessageContext mc) {

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/dispatch/XMLDispatchAsyncListener.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/dispatch/XMLDispatchAsyncListener.java?rev=683433&r1=683432&r2=683433&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/dispatch/XMLDispatchAsyncListener.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/dispatch/XMLDispatchAsyncListener.java
Wed Aug  6 15:36:06 2008
@@ -19,6 +19,7 @@
 
 package org.apache.axis2.jaxws.client.dispatch;
 
+import org.apache.axis2.jaxws.ExceptionFactory;
 import org.apache.axis2.jaxws.client.async.AsyncResponse;
 import org.apache.axis2.jaxws.core.MessageContext;
 import org.apache.axis2.jaxws.description.EndpointDescription;
@@ -52,7 +53,17 @@
     }
 
     public Object getResponseValueObject(MessageContext mc) {
-        return XMLDispatch.getValue(mc.getMessage(), mode, blockFactoryType);
+        try {
+            return XMLDispatch.getValue(mc.getMessage(), mode, blockFactoryType);
+        } finally {
+            // Free incoming stream
+            try {
+                mc.freeInputStream();
+            }
+            catch (Throwable t) {
+                throw ExceptionFactory.makeWebServiceException(t);
+            }
+        }
     }
 
     public Throwable getFaultResponse(MessageContext mc) {

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java?rev=683433&r1=683432&r2=683433&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java
Wed Aug  6 15:36:06 2008
@@ -394,6 +394,13 @@
             return object;
         } finally {
             responseMsg.close();
+            // Free incoming stream
+            try {
+                responseContext.freeInputStream();
+            }
+            catch (Throwable t) {
+                throw ExceptionFactory.makeWebServiceException(t);
+            }
         }
     }
 
@@ -405,23 +412,32 @@
         //we will fetch the OperationDescription of the sync method and this should give
us the
         //correct fault description so we can throw the right user defined exception.
 
-        if (opDesc.isJAXWSAsyncClientMethod()) {
-            opDesc = opDesc.getSyncOperation();
-        }
-        if (msg != null && msg.isFault()) {
-            ClassLoader cl = (ClassLoader) msgCtx.getProperty(Constants.CACHE_CLASSLOADER);
-            Object object = MethodMarshallerFactory.getMarshaller(opDesc, true, cl)
-                    .demarshalFaultResponse(msg, opDesc);
-            if (log.isDebugEnabled() && object != null) {
-                log.debug("A fault was found and processed.");
-                log.debug("Throwing a fault of type: " + object.getClass().getName() +
-                        " back to the clent.");
+        try {
+            if (opDesc.isJAXWSAsyncClientMethod()) {
+                opDesc = opDesc.getSyncOperation();
+            }
+            if (msg != null && msg.isFault()) {
+                ClassLoader cl = (ClassLoader) msgCtx.getProperty(Constants.CACHE_CLASSLOADER);
+                Object object = MethodMarshallerFactory.getMarshaller(opDesc, true, cl)
+                .demarshalFaultResponse(msg, opDesc);
+                if (log.isDebugEnabled() && object != null) {
+                    log.debug("A fault was found and processed.");
+                    log.debug("Throwing a fault of type: " + object.getClass().getName()
+
+                    " back to the clent.");
+                }
+
+                return (Throwable)object;
+            } else if (msgCtx.getLocalException() != null) {
+                // use the factory, it'll throw the right thing:
+                return ExceptionFactory.makeWebServiceException(msgCtx.getLocalException());
+            }
+        } finally {
+            try {
+                msgCtx.freeInputStream();
+            }
+            catch (Throwable t) {
+                throw ExceptionFactory.makeWebServiceException(t);
             }
-
-            return (Throwable)object;
-        } else if (msgCtx.getLocalException() != null) {
-            // use the factory, it'll throw the right thing:
-            return ExceptionFactory.makeWebServiceException(msgCtx.getLocalException());
         }
 
         return null;

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/MessageContext.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/MessageContext.java?rev=683433&r1=683432&r2=683433&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/MessageContext.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/MessageContext.java
Wed Aug  6 15:36:06 2008
@@ -19,18 +19,24 @@
 
 package org.apache.axis2.jaxws.core;
 
+import org.apache.axiom.om.util.DetachableInputStream;
 import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.jaxws.description.EndpointDescription;
 import org.apache.axis2.jaxws.description.OperationDescription;
 import org.apache.axis2.jaxws.handler.MEPContext;
 import org.apache.axis2.jaxws.message.Message;
 import org.apache.axis2.jaxws.message.util.MessageUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 import javax.xml.namespace.QName;
 import javax.xml.ws.BindingProvider;
 import javax.xml.ws.Service.Mode;
 import javax.xml.ws.WebServiceException;
+
+import java.io.IOException;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
@@ -48,6 +54,8 @@
  */
 public class MessageContext {
 
+    private static Log log = LogFactory.getLog(MessageContext.class);
+    
     private InvocationContext invocationCtx;
     private org.apache.axis2.context.MessageContext axisMsgCtx;
     private EndpointDescription endpointDesc;
@@ -313,4 +321,23 @@
         this.isServer = isServer;
     }
 
+    /**
+     * Free the resources associated with the incoming input stream. (i.e. HTTPInputStream)
+     * This allows the transport layer to free resources and pool connections
+     */
+    public void freeInputStream() throws IOException {
+        
+        
+        // During builder processing, the original input stream was wrapped with
+        // a detachable input stream.  The detachable input stream's detach method
+        // causes the original stream to be consumed and closed.
+        DetachableInputStream is = (DetachableInputStream) 
+            getProperty(Constants.DETACHABLE_INPUT_STREAM);
+        if (is != null) {
+            if (log.isDebugEnabled()) {
+                log.debug("Detaching inbound input stream " + is);
+            }
+            is.detach();
+        }
+    }
 }

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/Reader.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/Reader.java?rev=683433&r1=683432&r2=683433&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/Reader.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/Reader.java
Wed Aug  6 15:36:06 2008
@@ -258,7 +258,7 @@
     }
 
     public Object getProperty(String arg0) throws IllegalArgumentException {
-    	debug("Entering getProperty....");
+    	debug("Entering getProperty for ..." + arg0);
     	Object o = reader.getProperty(arg0);
     	debug("reader.getProperty(arg0) = "+o);
         return o;



Mime
View raw message