Author: veithen
Date: Sun Jul  4 12:44:11 2010
New Revision: 960334

URL: http://svn.apache.org/viewvc?rev=960334&view=rev
Log:
Reverted r958696 (related to AXIS2-4751) because this change causes a 
regression in Rampart.
Modified:
    
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/AbstractHTTPSender.java

Modified: 
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/AbstractHTTPSender.java
URL: 
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/AbstractHTTPSender.java?rev=960334&r1=960333&r2=960334&view=diff
==============================================================================
--- 
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/AbstractHTTPSender.java
 (original)
+++ 
axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/AbstractHTTPSender.java
 Sun Jul  4 12:44:11 2010
@@ -25,7 +25,6 @@ import org.apache.axiom.om.OMOutputForma
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.Constants;
 import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.context.OperationContext;
 import org.apache.axis2.description.TransportOutDescription;
 import org.apache.axis2.i18n.Messages;
@@ -486,50 +485,44 @@ public abstract class AbstractHTTPSender
     }
 
     protected HttpClient getHttpClient(MessageContext msgContext) {
-        ConfigurationContext configContext = 
msgContext.getConfigurationContext();
-
-        HttpClient httpClient = (HttpClient) 
msgContext.getProperty(HTTPConstants.CACHED_HTTP_CLIENT);
-        if (httpClient == null) {
-            httpClient = (HttpClient) 
configContext.getProperty(HTTPConstants.CACHED_HTTP_CLIENT);
-        }
-        if (httpClient != null) {
-            return httpClient;
-        }
-
-        HttpConnectionManager connManager =
-            (HttpConnectionManager) msgContext.getProperty(
-                 HTTPConstants.MULTITHREAD_HTTP_CONNECTION_MANAGER);
-        if (connManager == null) {
-            connManager =
-                (HttpConnectionManager) msgContext.getProperty(
-                     HTTPConstants.MUTTITHREAD_HTTP_CONNECTION_MANAGER);
-        }
-        if (connManager == null) {
-            // reuse HttpConnectionManager
-            synchronized (configContext) {
-                connManager = (HttpConnectionManager) 
configContext.getProperty(
-                                   
HTTPConstants.MULTITHREAD_HTTP_CONNECTION_MANAGER);
-                if (connManager == null) {
-                    log.trace("Making new ConnectionManager");
-                    connManager = new MultiThreadedHttpConnectionManager();
-                    
configContext.setProperty(HTTPConstants.MULTITHREAD_HTTP_CONNECTION_MANAGER, 
-                                              connManager);
-                }
+        HttpClient httpClient;
+        Object reuse = 
msgContext.getOptions().getProperty(HTTPConstants.REUSE_HTTP_CLIENT);
+        if (reuse == null) {
+            reuse = 
msgContext.getConfigurationContext().getProperty(HTTPConstants.REUSE_HTTP_CLIENT);
+        }
+        if (reuse != null && JavaUtils.isTrueExplicitly(reuse)) {
+            httpClient = (HttpClient) 
msgContext.getOptions().getProperty(HTTPConstants.CACHED_HTTP_CLIENT);
+            if (httpClient == null) {
+                httpClient = (HttpClient) msgContext.getConfigurationContext()
+                        .getProperty(HTTPConstants.CACHED_HTTP_CLIENT);
+            }
+            if (httpClient != null)
+                return httpClient;
+            MultiThreadedHttpConnectionManager connectionManager =
+                new MultiThreadedHttpConnectionManager();
+            httpClient = new HttpClient(connectionManager);
+            msgContext.getConfigurationContext()
+                .setProperty(HTTPConstants.CACHED_HTTP_CLIENT, httpClient);
+        } else {
+            HttpConnectionManager connManager =
+                    (HttpConnectionManager) msgContext.getProperty(
+                            HTTPConstants.MULTITHREAD_HTTP_CONNECTION_MANAGER);
+            if (connManager == null) {
+                connManager =
+                        (HttpConnectionManager) msgContext.getProperty(
+                                
HTTPConstants.MUTTITHREAD_HTTP_CONNECTION_MANAGER);
+            }
+            if(connManager != null){
+                httpClient = new HttpClient(connManager);
+            } else {
+                //Multi threaded http connection manager has set as the 
default 
+                connManager = new MultiThreadedHttpConnectionManager();
+                httpClient = new HttpClient(connManager);
             }
         }
 
-        /*
-         * Create a new instance of HttpClient since it is not
-         * used in thread-safe way here. 
-         */
-        httpClient = new HttpClient(connManager);
-
-        // Set the default timeout in case we have a connection pool 
starvation to 30sec
-        httpClient.getParams().setConnectionManagerTimeout(30000);
-
         // Get the timeout values set in the runtime
         initializeTimeouts(msgContext, httpClient);
-
         return httpClient;
     }
 


Reply via email to