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 05:24:49 UTC

svn commit: r389378 - in /webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http: AbstractHTTPSender.java RESTSender.java SOAPOverHTTPSender.java

Author: dims
Date: Mon Mar 27 19:24:46 2006
New Revision: 389378

URL: http://svn.apache.org/viewcvs?rev=389378&view=rev
Log:
localize the creation of HttpClient to one method in the abstract class

Modified:
    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/RESTSender.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/SOAPOverHTTPSender.java

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=389378&r1=389377&r2=389378&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 Mon Mar 27 19:24:46 2006
@@ -19,6 +19,7 @@
 import org.apache.commons.httpclient.NTCredentials;
 import org.apache.commons.httpclient.NameValuePair;
 import org.apache.commons.httpclient.UsernamePasswordCredentials;
+import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
 import org.apache.commons.httpclient.auth.AuthScope;
 import org.apache.commons.httpclient.methods.RequestEntity;
 import org.apache.commons.logging.Log;
@@ -50,7 +51,6 @@
     protected TransportOutDescription proxyOutSetting = null;
     protected OMOutputFormat format = new OMOutputFormat();
     int connectionTimeout = HTTPConstants.DEFAULT_CONNECTION_TIMEOUT;
-    protected HttpClient httpClient;
 
     public void setChunked(boolean chunked) {
         this.chunked = chunked;
@@ -469,5 +469,21 @@
         public boolean isRepeatable() {
             return true;
         }
+    }
+
+    protected HttpClient getHttpClient(MessageContext msgContext) {
+        MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();
+
+        HttpClient httpClient = new HttpClient(connectionManager);
+
+        // Get the timeout values set in the runtime
+        getTimeoutValues(msgContext);
+
+        // SO_TIMEOUT -- timeout for blocking reads
+        httpClient.getHttpConnectionManager().getParams().setSoTimeout(soTimeout);
+
+        // timeout for initial connection
+        httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(connectionTimeout);
+        return httpClient;
     }
 }

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=389378&r1=389377&r2=389378&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 Mon Mar 27 19:24:46 2006
@@ -147,23 +147,14 @@
                                        + charEncoding);
         }
 
-        this.httpClient = new HttpClient();
+        HttpClient httpClient = getHttpClient(msgContext);
 
         HostConfiguration hostConfig = this.getHostConfiguration(httpClient, msgContext, url);
 
-        // Get the timeout values set in the runtime
-        getTimeoutValues(msgContext);
-
-        // SO_TIMEOUT -- timeout for blocking reads
-        httpClient.getHttpConnectionManager().getParams().setSoTimeout(soTimeout);
-
-        // timeout for initial connection
-        httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(connectionTimeout);
-
         /**
          * with HostConfiguration
          */
-        this.httpClient.executeMethod(hostConfig, getMethod, null);
+        httpClient.executeMethod(hostConfig, getMethod, null);
 
         if (getMethod.getStatusCode() == HttpStatus.SC_OK) {
             processResponse(getMethod, msgContext);
@@ -192,16 +183,7 @@
 
         // execute the HtttpMethodBase - a connection manager can be given for
         // handle multiple
-        httpClient = new HttpClient();
-
-        // Get the timeout values set in the runtime
-        getTimeoutValues(msgContext);
-
-        // SO_TIMEOUT -- timeout for blocking reads
-        httpClient.getHttpConnectionManager().getParams().setSoTimeout(soTimeout);
-
-        // timeout for initial connection
-        httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(connectionTimeout);
+        HttpClient httpClient = getHttpClient(msgContext);
 
         // todo giving proxy and NTLM support
         PostMethod postMethod = new PostMethod(url.toString());
@@ -274,7 +256,7 @@
         try {
             HostConfiguration config = this.getHostConfiguration(httpClient, msgContext, url);
 
-            this.httpClient.executeMethod(config, postMethod);
+            httpClient.executeMethod(config, 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=389378&r1=389377&r2=389378&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 Mon Mar 27 19:24:46 2006
@@ -32,17 +32,7 @@
 
         // execute the HtttpMethodBase - a connection manager can be given for
         // handle multiple
-        httpClient = new HttpClient();
-
-        // Get the timeout values set in the runtime
-        getTimeoutValues(msgContext);
-
-        // SO_TIMEOUT -- timeout for blocking reads
-        httpClient.getHttpConnectionManager().getParams().setSoTimeout(soTimeout);
-
-        // timeout for initial connection
-        httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(connectionTimeout);
-
+        HttpClient httpClient = getHttpClient(msgContext);
         PostMethod postMethod = new PostMethod(url.toString());
 
         String charEncoding =
@@ -100,7 +90,7 @@
          */
         HostConfiguration config = this.getHostConfiguration(httpClient, msgContext, url);
 
-        this.httpClient.executeMethod(config, postMethod);
+        httpClient.executeMethod(config, postMethod);
 
         /*
          *   Execution is over