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 di...@apache.org on 2006/03/28 18:52:09 UTC

svn commit: r389539 - in /webservices/axis2/trunk/java/modules: codegen/src/org/apache/axis2/wsdl/template/java/ core/src/org/apache/axis2/transport/http/

Author: dims
Date: Tue Mar 28 08:52:04 2006
New Revision: 389539

URL: http://svn.apache.org/viewcvs?rev=389539&view=rev
Log:
- added a executeMethod in the AbstractHTTPSender class
- Added a mechanism to reuse HttpClient (Store it in ConfigurationContext)
- Caching of HttpClient is switched *OFF* by default
- Call transport cleanup in generated stub.
- Slight cleanup of commented code and constants



Modified:
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/AbstractHTTPSender.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPConstants.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/RESTSender.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/SOAPOverHTTPSender.java

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl?rev=389539&r1=389538&r2=389539&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl Tue Mar 28 08:52:04 2006
@@ -285,6 +285,9 @@
                 <xsl:choose>
                     <xsl:when test="$style='doc'">
                            java.lang.Object object = fromOM(getElement(_returnEnv,"<xsl:value-of select="$style"/>"),<xsl:value-of select="$outputtype"/>.class);
+                          
+                           _messageContext.getTransportOut().getSender().cleanUp(_messageContext);
+
                            return (<xsl:value-of select="$outputtype"/>)object;
                     </xsl:when>
                     <xsl:otherwise>

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/AbstractHTTPSender.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/AbstractHTTPSender.java?rev=389539&r1=389538&r2=389539&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/AbstractHTTPSender.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/AbstractHTTPSender.java Tue Mar 28 08:52:04 2006
@@ -20,6 +20,7 @@
 import org.apache.commons.httpclient.NameValuePair;
 import org.apache.commons.httpclient.UsernamePasswordCredentials;
 import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
+import org.apache.commons.httpclient.HttpMethod;
 import org.apache.commons.httpclient.auth.AuthScope;
 import org.apache.commons.httpclient.methods.RequestEntity;
 import org.apache.commons.logging.Log;
@@ -472,10 +473,19 @@
     }
 
     protected HttpClient getHttpClient(MessageContext msgContext) {
-        MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();
-
-        HttpClient httpClient = new HttpClient(connectionManager);
-
+        HttpClient httpClient = null;
+        Boolean reuse = (Boolean) msgContext.getOptions().getProperty(HTTPConstants.REUSE_HTTP_CLIENT);
+        if(reuse != null && reuse.booleanValue()) {
+            httpClient = (HttpClient) msgContext.getConfigurationContext().getProperty(HTTPConstants.CACHED_HTTP_CLIENT);
+            if(httpClient == null){
+                MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();
+                httpClient = new HttpClient(connectionManager);
+                msgContext.getConfigurationContext().setProperty(HTTPConstants.CACHED_HTTP_CLIENT, httpClient);
+            }
+        } else {
+            httpClient = new HttpClient();
+        }
+        
         // Get the timeout values set in the runtime
         getTimeoutValues(msgContext);
 
@@ -485,5 +495,11 @@
         // timeout for initial connection
         httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(connectionTimeout);
         return httpClient;
+    }
+
+    protected void executeMethod(HttpClient httpClient, MessageContext msgContext, URL url, HttpMethod method) throws IOException {
+        HostConfiguration config = this.getHostConfiguration(httpClient, msgContext, url);
+        msgContext.setProperty(HTTPConstants.HTTP_METHOD, method);
+        httpClient.executeMethod(config, method);
     }
 }

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java?rev=389539&r1=389538&r2=389539&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java Tue Mar 28 08:52:04 2006
@@ -49,7 +49,6 @@
     private static final long serialVersionUID = 7929963795196215199L;
     protected static final String PROXY_HOST_NAME = "proxy_host";
     protected static final String PROXY_PORT = "proxy_port";
-    public static final String HTTP_METHOD = "HTTP_METHOD";
     int soTimeout = HTTPConstants.DEFAULT_SO_TIMEOUT;
 
     /**
@@ -68,7 +67,7 @@
 
     public void cleanUp(MessageContext msgContext) throws AxisFault {
         HttpMethod httpMethod =
-                (HttpMethod) msgContext.getProperty(HTTP_METHOD);
+                (HttpMethod) msgContext.getProperty(HTTPConstants.HTTP_METHOD);
 
         if (httpMethod != null) {
             httpMethod.releaseConnection();

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPConstants.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPConstants.java?rev=389539&r1=389538&r2=389539&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPConstants.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPConstants.java Tue Mar 28 08:52:04 2006
@@ -408,6 +408,21 @@
     public static final String CONNECTION_TIMEOUT = "CONNECTION_TIMEOUT";
 
     /**
+     * Field CACHED_HTTP_CLIENT
+     */
+    public static final String CACHED_HTTP_CLIENT = "CACHED_HTTP_CLIENT";
+
+    /**
+     * Field CACHED_HTTP_CLIENT
+     */
+    public static final String REUSE_HTTP_CLIENT = "REUSE_HTTP_CLIENT";
+
+    /**
+     * Field HTTP_METHOD
+     */
+    public static final String HTTP_METHOD = "HTTP_METHOD";
+    
+    /**
      * Method getBytes.
      *
      * @param data

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/RESTSender.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/RESTSender.java?rev=389539&r1=389538&r2=389539&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/RESTSender.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/RESTSender.java Tue Mar 28 08:52:04 2006
@@ -148,13 +148,7 @@
         }
 
         HttpClient httpClient = getHttpClient(msgContext);
-
-        HostConfiguration hostConfig = this.getHostConfiguration(httpClient, msgContext, url);
-
-        /**
-         * with HostConfiguration
-         */
-        httpClient.executeMethod(hostConfig, getMethod, null);
+        executeMethod(httpClient, msgContext, url, getMethod);
 
         if (getMethod.getStatusCode() == HttpStatus.SC_OK) {
             processResponse(getMethod, msgContext);
@@ -254,9 +248,7 @@
          * main excecution takes place..
          */
         try {
-            HostConfiguration config = this.getHostConfiguration(httpClient, msgContext, url);
-
-            httpClient.executeMethod(config, postMethod);
+            executeMethod(httpClient, msgContext, url, postMethod);
 
             if (postMethod.getStatusCode() == HttpStatus.SC_OK) {
                 processResponse(postMethod, msgContext);

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/SOAPOverHTTPSender.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/SOAPOverHTTPSender.java?rev=389539&r1=389538&r2=389539&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/SOAPOverHTTPSender.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/SOAPOverHTTPSender.java Tue Mar 28 08:52:04 2006
@@ -13,6 +13,7 @@
 import org.apache.commons.httpclient.HttpClient;
 import org.apache.commons.httpclient.HttpStatus;
 import org.apache.commons.httpclient.HttpVersion;
+import org.apache.commons.httpclient.HttpMethod;
 import org.apache.commons.httpclient.methods.PostMethod;
 import org.apache.commons.httpclient.methods.RequestEntity;
 
@@ -73,13 +74,7 @@
         if (httpVersion != null) {
             if (httpVersion.equals(HTTPConstants.HEADER_PROTOCOL_10)) {
                 httpClient.getParams().setVersion(HttpVersion.HTTP_1_0);
-//                postMethod.setRequestHeader(HTTPConstants.HEADER_CONNECTION,
-//                        HTTPConstants.HEADER_CONNECTION_KEEPALIVE);
             } else {
-
-                // allowing keep-alive for 1.1
-//                postMethod.setRequestHeader(HTTPConstants.HEADER_CONNECTION,
-//                        HTTPConstants.HEADER_CONNECTION_KEEPALIVE);
                 postMethod.setRequestHeader(HTTPConstants.HEADER_EXPECT,
                         HTTPConstants.HEADER_EXPECT_100_Continue);
             }
@@ -88,9 +83,7 @@
         /*
          *   main excecution takes place..
          */
-        HostConfiguration config = this.getHostConfiguration(httpClient, msgContext, url);
-
-        httpClient.executeMethod(config, postMethod);
+        executeMethod(httpClient, msgContext, url, postMethod);
 
         /*
          *   Execution is over