hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r820971 [1/2] - in /httpcomponents/httpclient/trunk: ./ httpclient/src/examples/org/apache/http/examples/client/ httpclient/src/examples/org/apache/http/examples/conn/ httpclient/src/main/java/org/apache/http/conn/params/ httpclient/src/mai...
Date Fri, 02 Oct 2009 11:33:01 GMT
Author: olegk
Date: Fri Oct  2 11:33:00 2009
New Revision: 820971

URL: http://svn.apache.org/viewvc?rev=820971&view=rev
Log:
Simplified configuration of connection managers. Total connection maximum and maximum connection per route limits can be set using methods of the class instead of HTTP parameters

Modified:
    httpcomponents/httpclient/trunk/RELEASE_NOTES.txt
    httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientEvictExpiredConnections.java
    httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientMultiThreadedExecution.java
    httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/conn/ManagerConnectDirect.java
    httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/conn/ManagerConnectProxy.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnManagerPNames.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnManagerParamBean.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnManagerParams.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnPerRouteBean.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultHttpClient.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/SingleClientConnManager.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/AbstractConnPool.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/TestConnectionAutoRelease.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/TestConnectionReuse.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestContentCodings.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultClientRequestDirector.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestStatefulConnManagement.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestSCMWithServer.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestTSCCMNoServer.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestTSCCMWithServer.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/tsccm/TestConnPoolByRoute.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/tsccm/TestSpuriousWakeup.java
    httpcomponents/httpclient/trunk/src/docbkx/connmgmt.xml

Modified: httpcomponents/httpclient/trunk/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/RELEASE_NOTES.txt?rev=820971&r1=820970&r2=820971&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/RELEASE_NOTES.txt (original)
+++ httpcomponents/httpclient/trunk/RELEASE_NOTES.txt Fri Oct  2 11:33:00 2009
@@ -1,6 +1,11 @@
 Changes since 4.0
 -------------------
 
+* Simplified configuration of connection managers. Total connection maximum
+  and maximum connection per route limits can be set using methods of 
+  the class instead of HTTP parameters.
+  Contributed by Oleg Kalnichevski <olegk at apache.org>
+
 * Added parameters to define the order of preference for supported auth 
   schemes for target host and proxy authentication.
   Contributed by Oleg Kalnichevski <olegk at apache.org>

Modified: httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientEvictExpiredConnections.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientEvictExpiredConnections.java?rev=820971&r1=820970&r2=820971&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientEvictExpiredConnections.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientEvictExpiredConnections.java Fri Oct  2 11:33:00 2009
@@ -30,19 +30,14 @@
 
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpResponse;
-import org.apache.http.HttpVersion;
 import org.apache.http.client.HttpClient;
 import org.apache.http.client.methods.HttpGet;
 import org.apache.http.conn.ClientConnectionManager;
-import org.apache.http.conn.params.ConnManagerParams;
 import org.apache.http.conn.scheme.PlainSocketFactory;
 import org.apache.http.conn.scheme.Scheme;
 import org.apache.http.conn.scheme.SchemeRegistry;
 import org.apache.http.impl.client.DefaultHttpClient;
 import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
-import org.apache.http.params.BasicHttpParams;
-import org.apache.http.params.HttpParams;
-import org.apache.http.params.HttpProtocolParams;
 
 /**
  * Example demonstrating how to evict expired and idle connections
@@ -51,18 +46,15 @@
 public class ClientEvictExpiredConnections {
 
     public static void main(String[] args) throws Exception {
-        // Create and initialize HTTP parameters
-        HttpParams params = new BasicHttpParams();
-        ConnManagerParams.setMaxTotalConnections(params, 100);
-        HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
-        
         // Create and initialize scheme registry 
         SchemeRegistry schemeRegistry = new SchemeRegistry();
         schemeRegistry.register(
                 new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
         
-        ClientConnectionManager cm = new ThreadSafeClientConnManager(params, schemeRegistry);
-        HttpClient httpclient = new DefaultHttpClient(cm, params);
+        ThreadSafeClientConnManager cm = new ThreadSafeClientConnManager(schemeRegistry);
+        cm.setMaxTotalConnections(100);
+        
+        HttpClient httpclient = new DefaultHttpClient(cm);
         
         // create an array of URIs to perform GETs on
         String[] urisToGet = {

Modified: httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientMultiThreadedExecution.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientMultiThreadedExecution.java?rev=820971&r1=820970&r2=820971&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientMultiThreadedExecution.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientMultiThreadedExecution.java Fri Oct  2 11:33:00 2009
@@ -28,21 +28,15 @@
 
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpResponse;
-import org.apache.http.HttpVersion;
 import org.apache.http.client.HttpClient;
 import org.apache.http.client.methods.HttpGet;
-import org.apache.http.conn.ClientConnectionManager;
-import org.apache.http.conn.params.ConnManagerParams;
 import org.apache.http.conn.scheme.PlainSocketFactory;
 import org.apache.http.conn.scheme.Scheme;
 import org.apache.http.conn.scheme.SchemeRegistry;
 import org.apache.http.impl.client.DefaultHttpClient;
 import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
-import org.apache.http.params.BasicHttpParams;
-import org.apache.http.params.HttpParams;
-import org.apache.http.params.HttpProtocolParams;
-import org.apache.http.protocol.HttpContext;
 import org.apache.http.protocol.BasicHttpContext;
+import org.apache.http.protocol.HttpContext;
 import org.apache.http.util.EntityUtils;
 
 /**
@@ -52,11 +46,6 @@
 public class ClientMultiThreadedExecution {
 
     public static void main(String[] args) throws Exception {
-        // Create and initialize HTTP parameters
-        HttpParams params = new BasicHttpParams();
-        ConnManagerParams.setMaxTotalConnections(params, 100);
-        HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
-        
         // Create and initialize scheme registry 
         SchemeRegistry schemeRegistry = new SchemeRegistry();
         schemeRegistry.register(
@@ -65,8 +54,10 @@
         // Create an HttpClient with the ThreadSafeClientConnManager.
         // This connection manager must be used if more than one thread will
         // be using the HttpClient.
-        ClientConnectionManager cm = new ThreadSafeClientConnManager(params, schemeRegistry);
-        HttpClient httpClient = new DefaultHttpClient(cm, params);
+        ThreadSafeClientConnManager cm = new ThreadSafeClientConnManager(schemeRegistry);
+        cm.setMaxTotalConnections(100);
+        
+        HttpClient httpClient = new DefaultHttpClient(cm);
         
         // create an array of URIs to perform GETs on
         String[] urisToGet = {

Modified: httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/conn/ManagerConnectDirect.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/conn/ManagerConnectDirect.java?rev=820971&r1=820970&r2=820971&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/conn/ManagerConnectDirect.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/conn/ManagerConnectDirect.java Fri Oct  2 11:33:00 2009
@@ -145,7 +145,7 @@
 
     private final static ClientConnectionManager createManager() {
 
-        return new ThreadSafeClientConnManager(getParams(), supportedSchemes);
+        return new ThreadSafeClientConnManager(supportedSchemes);
     }
 
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/conn/ManagerConnectProxy.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/conn/ManagerConnectProxy.java?rev=820971&r1=820970&r2=820971&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/conn/ManagerConnectProxy.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/conn/ManagerConnectProxy.java Fri Oct  2 11:33:00 2009
@@ -173,7 +173,7 @@
 
     private final static ClientConnectionManager createManager() {
 
-        return new ThreadSafeClientConnManager(getParams(), supportedSchemes);
+        return new ThreadSafeClientConnManager(supportedSchemes);
     }
 
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnManagerPNames.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnManagerPNames.java?rev=820971&r1=820970&r2=820971&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnManagerPNames.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnManagerPNames.java Fri Oct  2 11:33:00 2009
@@ -51,6 +51,7 @@
      * This parameter expects a value of type {@link ConnPerRoute}.
      * </p>
      */
+    @Deprecated
     public static final String MAX_CONNECTIONS_PER_ROUTE = "http.conn-manager.max-per-route";
 
     /** 
@@ -61,6 +62,7 @@
      * This parameter expects a value of type {@link Integer}.
      * </p>
      */
+    @Deprecated
     public static final String MAX_TOTAL_CONNECTIONS = "http.conn-manager.max-total";
 
 }

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnManagerParamBean.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnManagerParamBean.java?rev=820971&r1=820970&r2=820971&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnManagerParamBean.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnManagerParamBean.java Fri Oct  2 11:33:00 2009
@@ -51,11 +51,13 @@
     }
 
     /** @see ConnManagerPNames#MAX_TOTAL_CONNECTIONS */
+    @Deprecated
     public void setMaxTotalConnections (final int maxConnections) {
         params.setIntParameter(ConnManagerPNames.MAX_TOTAL_CONNECTIONS, maxConnections);
     }
     
     /** @see ConnManagerPNames#MAX_CONNECTIONS_PER_ROUTE */
+    @Deprecated
     public void setConnectionsPerRoute(final ConnPerRouteBean connPerRoute) {
         params.setParameter(ConnManagerPNames.MAX_CONNECTIONS_PER_ROUTE, connPerRoute);
     }

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnManagerParams.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnManagerParams.java?rev=820971&r1=820970&r2=820971&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnManagerParams.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnManagerParams.java Fri Oct  2 11:33:00 2009
@@ -74,6 +74,7 @@
     }
 
     /** The default maximum number of connections allowed per host */
+    @Deprecated
     private static final ConnPerRoute DEFAULT_CONN_PER_ROUTE = new ConnPerRoute() {
         
         public int getMaxForRoute(HttpRoute route) {
@@ -89,8 +90,11 @@
      * @param connPerRoute lookup interface for maximum number of connections allowed 
      *        per route
      * 
+     * @deprecated do not use
+     * 
      * @see ConnManagerPNames#MAX_CONNECTIONS_PER_ROUTE
      */
+    @Deprecated
     public static void setMaxConnectionsPerRoute(final HttpParams params,
                                                 final ConnPerRoute connPerRoute) {
         if (params == null) {
@@ -107,8 +111,11 @@
      * 
      * @return lookup interface for maximum number of connections allowed per route.
      * 
+     * @deprecated do not use
+     * 
      * @see ConnManagerPNames#MAX_CONNECTIONS_PER_ROUTE
      */
+    @Deprecated
     public static ConnPerRoute getMaxConnectionsPerRoute(final HttpParams params) {
         if (params == null) {
             throw new IllegalArgumentException
@@ -128,8 +135,11 @@
      * @param params HTTP parameters
      * @param maxTotalConnections The maximum number of connections allowed.
      * 
+     * @deprecated do not use
+     * 
      * @see ConnManagerPNames#MAX_TOTAL_CONNECTIONS
      */
+    @Deprecated
     public static void setMaxTotalConnections(
             final HttpParams params,
             int maxTotalConnections) {
@@ -147,8 +157,11 @@
      *
      * @return The maximum number of connections allowed.
      * 
+     * @deprecated do not use
+     * 
      * @see ConnManagerPNames#MAX_TOTAL_CONNECTIONS
      */
+    @Deprecated
     public static int getMaxTotalConnections(
             final HttpParams params) {
         if (params == null) {

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnPerRouteBean.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnPerRouteBean.java?rev=820971&r1=820970&r2=820971&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnPerRouteBean.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/params/ConnPerRouteBean.java Fri Oct  2 11:33:00 2009
@@ -29,7 +29,8 @@
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.http.annotation.NotThreadSafe;
+import org.apache.http.annotation.GuardedBy;
+import org.apache.http.annotation.ThreadSafe;
 
 import org.apache.http.conn.routing.HttpRoute;
 
@@ -41,14 +42,16 @@
  * 
  * @since 4.0
  */
-@NotThreadSafe // maxPerHostMap and defaultMax
+@ThreadSafe
 public final class ConnPerRouteBean implements ConnPerRoute {
 
     /** The default maximum number of connections allowed per host */
     public static final int DEFAULT_MAX_CONNECTIONS_PER_ROUTE = 2;   // Per RFC 2616 sec 8.1.4
     
+    @GuardedBy("this")
     private final Map<HttpRoute, Integer> maxPerHostMap;
     
+    @GuardedBy("this")
     private int defaultMax;
     
     public ConnPerRouteBean(int defaultMax) {
@@ -61,11 +64,19 @@
         this(DEFAULT_MAX_CONNECTIONS_PER_ROUTE);
     }
     
-    public int getDefaultMax() {
+    @Deprecated
+    public synchronized int getDefaultMax() {
         return this.defaultMax;
     }
 
-    public void setDefaultMaxPerRoute(int max) {
+    /**
+     * @since 4.1
+     */
+    public synchronized int getDefaultMaxPerRoute() {
+        return this.defaultMax;
+    }
+
+    public synchronized void setDefaultMaxPerRoute(int max) {
         if (max < 1) {
             throw new IllegalArgumentException
                 ("The maximum must be greater than 0.");
@@ -73,7 +84,7 @@
         this.defaultMax = max;
     }
 
-    public void setMaxForRoute(final HttpRoute route, int max) {
+    public synchronized void setMaxForRoute(final HttpRoute route, int max) {
         if (route == null) {
             throw new IllegalArgumentException
                 ("HTTP route may not be null.");
@@ -85,7 +96,7 @@
         this.maxPerHostMap.put(route, Integer.valueOf(max));
     }
 
-    public int getMaxForRoute(final HttpRoute route) {
+    public synchronized int getMaxForRoute(final HttpRoute route) {
         if (route == null) {
             throw new IllegalArgumentException
                 ("HTTP route may not be null.");
@@ -98,7 +109,7 @@
         }
     }
     
-    public void setMaxForRoutes(final Map<HttpRoute, Integer> map) {
+    public synchronized void setMaxForRoutes(final Map<HttpRoute, Integer> map) {
         if (map == null) {
             return;
         }
@@ -106,9 +117,9 @@
         this.maxPerHostMap.putAll(map);
     }
 
-	@Override
-	public String toString() {
-		return this.maxPerHostMap.toString();
-	}
+    @Override
+    public synchronized String toString() {
+        return this.maxPerHostMap.toString();
+    }
     
 }

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultHttpClient.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultHttpClient.java?rev=820971&r1=820970&r2=820971&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultHttpClient.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultHttpClient.java Fri Oct  2 11:33:00 2009
@@ -134,8 +134,6 @@
  *  <li>{@link org.apache.http.conn.params.ConnRoutePNames#LOCAL_ADDRESS}</li>
  *  <li>{@link org.apache.http.conn.params.ConnRoutePNames#DEFAULT_PROXY}</li>
  *  <li>{@link org.apache.http.conn.params.ConnManagerPNames#TIMEOUT}</li>
- *  <li>{@link org.apache.http.conn.params.ConnManagerPNames#MAX_CONNECTIONS_PER_ROUTE}</li>
- *  <li>{@link org.apache.http.conn.params.ConnManagerPNames#MAX_TOTAL_CONNECTIONS}</li>
  *  <li>{@link org.apache.http.cookie.params.CookieSpecPNames#DATE_PATTERNS}</li>
  *  <li>{@link org.apache.http.cookie.params.CookieSpecPNames#SINGLE_COOKIE_HEADER}</li>
  *  <li>{@link org.apache.http.auth.params.AuthPNames#CREDENTIAL_CHARSET}</li>
@@ -155,7 +153,6 @@
 @ThreadSafe
 public class DefaultHttpClient extends AbstractHttpClient {
 
-
     /**
      * Creates a new HTTP client from parameters and a connection manager.
      *
@@ -168,6 +165,15 @@
         super(conman, params);
     }
     
+    
+    /**
+     * @since 4.1
+     */
+    public DefaultHttpClient(
+            final ClientConnectionManager conman) {
+        super(conman, null);
+    }
+    
        
     public DefaultHttpClient(final HttpParams params) {
         super(null, params);
@@ -241,7 +247,7 @@
         if (factory != null) {
             connManager = factory.newInstance(params, registry);
         } else {
-            connManager = new SingleClientConnManager(getParams(), registry); 
+            connManager = new SingleClientConnManager(registry); 
         }
         
         return connManager;

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/SingleClientConnManager.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/SingleClientConnManager.java?rev=820971&r1=820970&r2=820971&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/SingleClientConnManager.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/SingleClientConnManager.java Fri Oct  2 11:33:00 2009
@@ -102,9 +102,21 @@
      * @param params    the parameters for this manager
      * @param schreg    the scheme registry, or
      *                  <code>null</code> for the default registry
+     *                  
+     * @deprecated use {@link SingleClientConnManager#SingleClientConnManager(SchemeRegistry)}
      */
+    @Deprecated
     public SingleClientConnManager(HttpParams params,
                                    SchemeRegistry schreg) {
+        this(schreg);
+    }
+    /**
+     * Creates a new simple connection manager.
+     *
+     * @param schreg    the scheme registry, or
+     *                  <code>null</code> for the default registry
+     */
+    public SingleClientConnManager(final SchemeRegistry schreg) {
         if (schreg == null) {
             throw new IllegalArgumentException
                 ("Scheme registry must not be null.");
@@ -236,8 +248,8 @@
     }
 
     public synchronized void releaseConnection(
-    		ManagedClientConnection conn, 
-    		long validDuration, TimeUnit timeUnit) {
+            ManagedClientConnection conn, 
+            long validDuration, TimeUnit timeUnit) {
         assertStillUp();
 
         if (!(conn instanceof ConnAdapter)) {

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/AbstractConnPool.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/AbstractConnPool.java?rev=820971&r1=820970&r2=820971&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/AbstractConnPool.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/AbstractConnPool.java Fri Oct  2 11:33:00 2009
@@ -60,7 +60,7 @@
 @SuppressWarnings("deprecation")
 public abstract class AbstractConnPool implements RefQueueHandler {
 
-    private final Log log = LogFactory.getLog(getClass());
+    private final Log log;
 
     /**
      * The global lock for this pool.
@@ -95,11 +95,11 @@
      * Creates a new connection pool.
      */
     protected AbstractConnPool() {
-        leasedConnections = new HashSet<BasicPoolEntry>();
-        idleConnHandler = new IdleConnectionHandler();
-
-        boolean fair = false; //@@@ check parameters to decide
-        poolLock = new ReentrantLock(fair);
+        super();
+        this.log = LogFactory.getLog(getClass());
+        this.leasedConnections = new HashSet<BasicPoolEntry>();
+        this.idleConnHandler = new IdleConnectionHandler();
+        this.poolLock = new ReentrantLock();
     }
 
     /**

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java?rev=820971&r1=820970&r2=820971&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java Fri Oct  2 11:33:00 2009
@@ -37,6 +37,8 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.http.annotation.GuardedBy;
+import org.apache.http.annotation.ThreadSafe;
 import org.apache.http.conn.routing.HttpRoute;
 import org.apache.http.conn.ClientConnectionOperator;
 import org.apache.http.conn.ConnectionPoolTimeoutException;
@@ -60,14 +62,16 @@
  *
  * @since 4.0
  */
+@ThreadSafe
 public class ConnPoolByRoute extends AbstractConnPool {
         
     private final Log log = LogFactory.getLog(getClass());
 
-    private final HttpParams params;
-    
     /** Connection operator for this pool */
     protected final ClientConnectionOperator operator;
+
+    /** Connections per route lookup */
+    protected final ConnPerRoute connPerRoute;
     
     /** The list of free connections */
     protected final Queue<BasicPoolEntry> freeConnections;
@@ -80,24 +84,47 @@
      * Keys are of class {@link HttpRoute},
      * values of class {@link RouteSpecificPool}.
      */
+    @GuardedBy("poolLock")
     protected final Map<HttpRoute, RouteSpecificPool> routeToPool;
 
+    @GuardedBy("poolLock")
+    protected volatile int maxTotalConnections;
+    
     /**
      * Creates a new connection pool, managed by route.
+     * 
+     * @since 4.1
      */
-    public ConnPoolByRoute(final ClientConnectionOperator operator, final HttpParams params) {
+    public ConnPoolByRoute(
+            final ClientConnectionOperator operator, 
+            final ConnPerRoute connPerRoute,
+            int maxTotalConnections) {
         super();
         if (operator == null) {
             throw new IllegalArgumentException("Connection operator may not be null");
         }
+        if (connPerRoute == null) {
+            throw new IllegalArgumentException("Connections per route may not be null");
+        }
         this.operator = operator;
-        this.params = params;
-        
-        freeConnections = createFreeConnQueue();
-        waitingThreads  = createWaitingThreadQueue();
-        routeToPool     = createRouteToPoolMap();
+        this.connPerRoute = connPerRoute;
+        this.maxTotalConnections = maxTotalConnections;
+        this.freeConnections = createFreeConnQueue();
+        this.waitingThreads  = createWaitingThreadQueue();
+        this.routeToPool     = createRouteToPoolMap();
     }
 
+    /**
+     * Creates a new connection pool, managed by route.
+     * 
+     * @deprecated use {@link ConnPoolByRoute#ConnPoolByRoute(ClientConnectionOperator, ConnPerRoute)}
+     */
+    @Deprecated
+    public ConnPoolByRoute(final ClientConnectionOperator operator, final HttpParams params) {
+        this(operator, 
+                ConnManagerParams.getMaxConnectionsPerRoute(params),
+                ConnManagerParams.getMaxTotalConnections(params));
+    }
 
     /**
      * Creates the queue for {@link #freeConnections}.
@@ -139,8 +166,7 @@
      * @return  the new pool
      */
     protected RouteSpecificPool newRouteSpecificPool(HttpRoute route) {
-        ConnPerRoute connPerRoute = ConnManagerParams.getMaxConnectionsPerRoute(params);
-        return new RouteSpecificPool(route, connPerRoute.getMaxForRoute(route));
+        return new RouteSpecificPool(route, this.connPerRoute.getMaxForRoute(route));
     }
 
 
@@ -255,8 +281,6 @@
                                    WaitingThreadAborter aborter)
         throws ConnectionPoolTimeoutException, InterruptedException {
 
-        int maxTotalConnections = ConnManagerParams.getMaxTotalConnections(params);
-        
         Date deadline = null;
         if (timeout > 0) {
             deadline = new Date
@@ -685,6 +709,26 @@
         }
     }
 
+    /**
+     * since 4.1
+     */
+    public void setMaxTotalConnections(int max) {
+        poolLock.lock();
+        try {
+            maxTotalConnections = max;
+        } finally {
+            poolLock.unlock();
+        }
+    }
+    
+
+    /**
+     * since 4.1
+     */
+    public int getMaxTotalConnections() {
+        return maxTotalConnections;
+    }
+    
 
 } // class ConnPoolByRoute
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java?rev=820971&r1=820970&r2=820971&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java Fri Oct  2 11:33:00 2009
@@ -31,6 +31,8 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.http.annotation.ThreadSafe;
+import org.apache.http.conn.params.ConnPerRouteBean;
 import org.apache.http.conn.routing.HttpRoute;
 import org.apache.http.conn.scheme.SchemeRegistry;
 import org.apache.http.conn.ClientConnectionManager;
@@ -57,53 +59,69 @@
  * these limits may prove too constraining, especially if they use HTTP
  * as a transport protocol for their services. Connection limits, however,
  * can be adjusted using HTTP parameters.
- * <p>
- * The following parameters can be used to customize the behavior of this 
- * class: 
- * <ul>
- *  <li>{@link org.apache.http.conn.params.ConnManagerPNames#MAX_TOTAL_CONNECTIONS}</li>
- *  <li>{@link org.apache.http.conn.params.ConnManagerPNames#MAX_CONNECTIONS_PER_ROUTE}</li>
- * </ul>
- *
- * @see org.apache.http.conn.params.ConnPerRoute 
- * @see org.apache.http.conn.params.ConnPerRouteBean
  *
  * @since 4.0
  */
+@ThreadSafe
 public class ThreadSafeClientConnManager implements ClientConnectionManager {
 
-    private final Log log = LogFactory.getLog(getClass());
+    private final Log log;
 
     /** The schemes supported by this connection manager. */
     protected final SchemeRegistry schemeRegistry; // @ThreadSafe
     
-    /** The pool of connections being managed. */
+    @Deprecated
     protected final AbstractConnPool connectionPool;
 
+    /** The pool of connections being managed. */
+    protected final ConnPoolByRoute pool;
+
     /** The operator for opening and updating connections. */
     protected final ClientConnectionOperator connOperator; // DefaultClientConnectionOperator is @ThreadSafe
     
+    protected final ConnPerRouteBean connPerRoute;
+    
+    /**
+     * Creates a new thread safe connection manager.
+     *
+     * @param params    the parameters for this manager.
+     * @param schreg    the scheme registry.
+     */
+    public ThreadSafeClientConnManager(final SchemeRegistry schreg) {
+        super();
+        if (schreg == null) {
+            throw new IllegalArgumentException("Scheme registry may not be null");
+        }
+        this.log = LogFactory.getLog(getClass());
+        this.schemeRegistry = schreg;
+        this.connPerRoute = new ConnPerRouteBean();
+        this.connOperator = createConnectionOperator(schreg);
+        this.pool = createConnectionPool() ;
+        this.connectionPool = this.pool;
+    }
+
     /**
      * Creates a new thread safe connection manager.
      *
      * @param params    the parameters for this manager.
      * @param schreg    the scheme registry.
+     * 
+     * @deprecated use {@link ThreadSafeClientConnManager#ThreadSafeClientConnManager(SchemeRegistry)}
      */
+    @Deprecated
     public ThreadSafeClientConnManager(HttpParams params,
                                        SchemeRegistry schreg) {
-
-        if (params == null) {
-            throw new IllegalArgumentException("HTTP parameters may not be null");
-        }
         if (schreg == null) {
             throw new IllegalArgumentException("Scheme registry may not be null");
         }
+        this.log = LogFactory.getLog(getClass());
         this.schemeRegistry = schreg;
-        this.connOperator   = createConnectionOperator(schreg);
-        this.connectionPool = createConnectionPool(params);
-
+        this.connPerRoute = new ConnPerRouteBean();
+        this.connOperator = createConnectionOperator(schreg);
+        this.pool = (ConnPoolByRoute) createConnectionPool(params) ;
+        this.connectionPool = this.pool;
     }
-
+    
     @Override
     protected void finalize() throws Throwable {
         try {
@@ -117,12 +135,25 @@
      * Hook for creating the connection pool.
      *
      * @return  the connection pool to use
+     * 
+     * @deprecated use {@link #createConnectionPool(ConnPerRouteBean)}
      */
     protected AbstractConnPool createConnectionPool(final HttpParams params) {
         return new ConnPoolByRoute(connOperator, params);
     }
 
     /**
+     * Hook for creating the connection pool.
+     *
+     * @return  the connection pool to use
+     * 
+     * @since 4.1
+     */
+    protected ConnPoolByRoute createConnectionPool() {
+        return new ConnPoolByRoute(connOperator, connPerRoute, 20);
+    }
+
+    /**
      * Hook for creating the connection operator.
      * It is called by the constructor.
      * Derived classes can override this method to change the
@@ -148,7 +179,7 @@
             final HttpRoute route, 
             final Object state) {
         
-        final PoolEntryRequest poolRequest = connectionPool.requestPoolEntry(
+        final PoolEntryRequest poolRequest = pool.requestPoolEntry(
                 route, state);
         
         return new ClientConnectionRequest() {
@@ -220,14 +251,14 @@
             }
             hca.detach();
             if (entry != null) {
-                connectionPool.freeEntry(entry, reusable, validDuration, timeUnit);
+                pool.freeEntry(entry, reusable, validDuration, timeUnit);
             }
         }
     }
 
     public void shutdown() {
         log.debug("Shutting down");
-        connectionPool.shutdown();
+        pool.shutdown();
     }
 
     /**
@@ -240,9 +271,8 @@
      *
      * @return  the total number of pooled connections for that route
      */
-    public int getConnectionsInPool(HttpRoute route) {
-        return ((ConnPoolByRoute)connectionPool).getConnectionsInPool(
-                route);
+    public int getConnectionsInPool(final HttpRoute route) {
+        return pool.getConnectionsInPool(route);
     }
 
     /**
@@ -254,25 +284,68 @@
      * @return the total number of pooled connections
      */
     public int getConnectionsInPool() {
-        int count;
-        connectionPool.poolLock.lock();
-        count = connectionPool.numConnections; //@@@
-        connectionPool.poolLock.unlock();
-        return count;
+        pool.poolLock.lock();
+        try {
+            return pool.numConnections;
+        } finally {
+            pool.poolLock.unlock();
+        }
     }
 
     public void closeIdleConnections(long idleTimeout, TimeUnit tunit) {
         if (log.isDebugEnabled()) {
             log.debug("Closing connections idle for " + idleTimeout + " " + tunit);
         }
-        connectionPool.closeIdleConnections(idleTimeout, tunit);
-        connectionPool.deleteClosedConnections();
+        pool.closeIdleConnections(idleTimeout, tunit);
+        pool.deleteClosedConnections();
     }
     
     public void closeExpiredConnections() {
         log.debug("Closing expired connections");
-        connectionPool.closeExpiredConnections();
-        connectionPool.deleteClosedConnections();
+        pool.closeExpiredConnections();
+        pool.deleteClosedConnections();
+    }
+
+    /**
+     * since 4.1
+     */
+    public int getMaxTotalConnections() {
+        return pool.getMaxTotalConnections();
+    }
+    
+    /**
+     * since 4.1
+     */
+    public void setMaxTotalConnections(int max) {
+        pool.setMaxTotalConnections(max);
+    }
+    
+    /**
+     * @since 4.1
+     */
+    public int getDefaultMaxPerRoute() {
+        return connPerRoute.getDefaultMaxPerRoute();
+    }
+
+    /**
+     * @since 4.1
+     */
+    public void setDefaultMaxPerRoute(int max) {
+        connPerRoute.setDefaultMaxPerRoute(max);
+    }
+
+    /**
+     * @since 4.1
+     */
+    public int getMaxForRoute(final HttpRoute route) {
+        return connPerRoute.getMaxForRoute(route);
+    }
+    
+    /**
+     * @since 4.1
+     */
+    public void setMaxForRoute(final HttpRoute route, int max) {
+        connPerRoute.setMaxForRoute(route, max);
     }
 
 }

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/TestConnectionAutoRelease.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/TestConnectionAutoRelease.java?rev=820971&r1=820970&r2=820971&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/TestConnectionAutoRelease.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/TestConnectionAutoRelease.java Fri Oct  2 11:33:00 2009
@@ -42,8 +42,6 @@
 import org.apache.http.HttpResponse;
 import org.apache.http.MalformedChunkCodingException;
 import org.apache.http.client.methods.HttpGet;
-import org.apache.http.conn.params.ConnPerRouteBean;
-import org.apache.http.conn.params.ConnManagerParams;
 import org.apache.http.conn.routing.HttpRoute;
 import org.apache.http.conn.scheme.SchemeRegistry;
 import org.apache.http.entity.BasicHttpEntity;
@@ -51,7 +49,6 @@
 import org.apache.http.impl.client.DefaultHttpClient;
 import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
 import org.apache.http.localserver.ServerTestBase;
-import org.apache.http.params.HttpParams;
 import org.apache.http.protocol.ExecutionContext;
 import org.apache.http.protocol.HttpContext;
 import org.apache.http.protocol.HttpRequestHandler;
@@ -72,27 +69,21 @@
         return new TestSuite(TestConnectionAutoRelease.class);
     }
 
-    public ThreadSafeClientConnManager createTSCCM(HttpParams params,
-                                                   SchemeRegistry schreg) {
-        if (params == null)
-            params = defaultParams;
+    public ThreadSafeClientConnManager createTSCCM(SchemeRegistry schreg) {
         if (schreg == null)
             schreg = supportedSchemes;
-        return new ThreadSafeClientConnManager(params, schreg);
+        return new ThreadSafeClientConnManager(schreg);
     }
 
     public void testReleaseOnEntityConsumeContent() throws Exception {
-        HttpParams params = defaultParams.copy();
-        ConnManagerParams.setMaxTotalConnections
-            (params, 1);
-        ConnManagerParams.setMaxConnectionsPerRoute
-            (params, new ConnPerRouteBean(1));
-        ThreadSafeClientConnManager mgr = createTSCCM(params, null);
+        ThreadSafeClientConnManager mgr = createTSCCM(null);
+        mgr.setDefaultMaxPerRoute(1);
+        mgr.setMaxTotalConnections(1);
 
         // Zero connections in the pool
         assertEquals(0, mgr.getConnectionsInPool());
         
-        DefaultHttpClient client = new DefaultHttpClient(mgr, params); 
+        DefaultHttpClient client = new DefaultHttpClient(mgr); 
 
         // Get some random data
         HttpGet httpget = new HttpGet("/random/20000"); 
@@ -124,17 +115,14 @@
     }
     
     public void testReleaseOnEntityWriteTo() throws Exception {
-        HttpParams params = defaultParams.copy();
-        ConnManagerParams.setMaxTotalConnections
-            (params, 1);
-        ConnManagerParams.setMaxConnectionsPerRoute
-            (params, new ConnPerRouteBean(1));
-        ThreadSafeClientConnManager mgr = createTSCCM(params, null);
+        ThreadSafeClientConnManager mgr = createTSCCM(null);
+        mgr.setDefaultMaxPerRoute(1);
+        mgr.setMaxTotalConnections(1);
 
         // Zero connections in the pool
         assertEquals(0, mgr.getConnectionsInPool());
         
-        DefaultHttpClient client = new DefaultHttpClient(mgr, params); 
+        DefaultHttpClient client = new DefaultHttpClient(mgr); 
 
         // Get some random data
         HttpGet httpget = new HttpGet("/random/20000"); 
@@ -167,17 +155,14 @@
     }
     
     public void testReleaseOnAbort() throws Exception {
-        HttpParams params = defaultParams.copy();
-        ConnManagerParams.setMaxTotalConnections
-            (params, 1);
-        ConnManagerParams.setMaxConnectionsPerRoute
-            (params, new ConnPerRouteBean(1));
-        ThreadSafeClientConnManager mgr = createTSCCM(params, null);
+        ThreadSafeClientConnManager mgr = createTSCCM(null);
+        mgr.setDefaultMaxPerRoute(1);
+        mgr.setMaxTotalConnections(1);
 
         // Zero connections in the pool
         assertEquals(0, mgr.getConnectionsInPool());
         
-        DefaultHttpClient client = new DefaultHttpClient(mgr, params); 
+        DefaultHttpClient client = new DefaultHttpClient(mgr); 
 
         // Get some random data
         HttpGet httpget = new HttpGet("/random/20000"); 
@@ -242,17 +227,14 @@
             
         });
         
-        HttpParams params = defaultParams.copy();
-        ConnManagerParams.setMaxTotalConnections
-            (params, 1);
-        ConnManagerParams.setMaxConnectionsPerRoute
-            (params, new ConnPerRouteBean(1));
-        ThreadSafeClientConnManager mgr = createTSCCM(params, null);
+        ThreadSafeClientConnManager mgr = createTSCCM(null);
+        mgr.setDefaultMaxPerRoute(1);
+        mgr.setMaxTotalConnections(1);
 
         // Zero connections in the pool
         assertEquals(0, mgr.getConnectionsInPool());
         
-        DefaultHttpClient client = new DefaultHttpClient(mgr, params); 
+        DefaultHttpClient client = new DefaultHttpClient(mgr); 
 
         // Get some random data
         HttpGet httpget = new HttpGet("/dropdead"); 

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/TestConnectionReuse.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/TestConnectionReuse.java?rev=820971&r1=820970&r2=820971&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/TestConnectionReuse.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/conn/TestConnectionReuse.java Fri Oct  2 11:33:00 2009
@@ -44,8 +44,6 @@
 import org.apache.http.HttpVersion;
 import org.apache.http.client.HttpClient;
 import org.apache.http.client.methods.HttpGet;
-import org.apache.http.conn.params.ConnManagerParams;
-import org.apache.http.conn.params.ConnPerRouteBean;
 import org.apache.http.conn.scheme.PlainSocketFactory;
 import org.apache.http.conn.scheme.Scheme;
 import org.apache.http.conn.scheme.SchemeRegistry;
@@ -110,16 +108,14 @@
         HttpProtocolParams.setUserAgent(params, "TestAgent/1.1");
         HttpProtocolParams.setUseExpectContinue(params, false);
         HttpConnectionParams.setStaleCheckingEnabled(params, false);
-        ConnManagerParams.setMaxTotalConnections(params, 5);
-        ConnManagerParams.setMaxConnectionsPerRoute(params, 
-                new ConnPerRouteBean(5));
         
         SchemeRegistry supportedSchemes = new SchemeRegistry();
         SocketFactory sf = PlainSocketFactory.getSocketFactory();
         supportedSchemes.register(new Scheme("http", sf, 80));
         
-        ThreadSafeClientConnManager mgr = new ThreadSafeClientConnManager(
-                params, supportedSchemes);
+        ThreadSafeClientConnManager mgr = new ThreadSafeClientConnManager(supportedSchemes);
+        mgr.setMaxTotalConnections(5);
+        mgr.setDefaultMaxPerRoute(5);
 
         DefaultHttpClient client = new DefaultHttpClient(mgr, params); 
 
@@ -182,16 +178,14 @@
         HttpProtocolParams.setUserAgent(params, "TestAgent/1.1");
         HttpProtocolParams.setUseExpectContinue(params, false);
         HttpConnectionParams.setStaleCheckingEnabled(params, false);
-        ConnManagerParams.setMaxTotalConnections(params, 5);
-        ConnManagerParams.setMaxConnectionsPerRoute(params, 
-                new ConnPerRouteBean(5));
         
         SchemeRegistry supportedSchemes = new SchemeRegistry();
         SocketFactory sf = PlainSocketFactory.getSocketFactory();
         supportedSchemes.register(new Scheme("http", sf, 80));
         
-        ThreadSafeClientConnManager mgr = new ThreadSafeClientConnManager(
-                params, supportedSchemes);
+        ThreadSafeClientConnManager mgr = new ThreadSafeClientConnManager(supportedSchemes);
+        mgr.setMaxTotalConnections(5);
+        mgr.setDefaultMaxPerRoute(5);
 
         DefaultHttpClient client = new DefaultHttpClient(mgr, params); 
 
@@ -244,16 +238,14 @@
         HttpProtocolParams.setUserAgent(params, "TestAgent/1.1");
         HttpProtocolParams.setUseExpectContinue(params, false);
         HttpConnectionParams.setStaleCheckingEnabled(params, false);
-        ConnManagerParams.setMaxTotalConnections(params, 5);
-        ConnManagerParams.setMaxConnectionsPerRoute(params, 
-                new ConnPerRouteBean(5));
         
         SchemeRegistry supportedSchemes = new SchemeRegistry();
         SocketFactory sf = PlainSocketFactory.getSocketFactory();
         supportedSchemes.register(new Scheme("http", sf, 80));
         
-        ThreadSafeClientConnManager mgr = new ThreadSafeClientConnManager(
-                params, supportedSchemes);
+        ThreadSafeClientConnManager mgr = new ThreadSafeClientConnManager(supportedSchemes);
+        mgr.setMaxTotalConnections(5);
+        mgr.setDefaultMaxPerRoute(5);
 
         DefaultHttpClient client = new DefaultHttpClient(mgr, params); 
 
@@ -307,16 +299,14 @@
         HttpProtocolParams.setUserAgent(params, "TestAgent/1.1");
         HttpProtocolParams.setUseExpectContinue(params, false);
         HttpConnectionParams.setStaleCheckingEnabled(params, false);
-        ConnManagerParams.setMaxTotalConnections(params, 1);
-        ConnManagerParams.setMaxConnectionsPerRoute(params, 
-                new ConnPerRouteBean(1));
         
         SchemeRegistry supportedSchemes = new SchemeRegistry();
         SocketFactory sf = PlainSocketFactory.getSocketFactory();
         supportedSchemes.register(new Scheme("http", sf, 80));
         
-        ThreadSafeClientConnManager mgr = new ThreadSafeClientConnManager(
-                params, supportedSchemes);
+        ThreadSafeClientConnManager mgr = new ThreadSafeClientConnManager(supportedSchemes);
+        mgr.setMaxTotalConnections(1);
+        mgr.setDefaultMaxPerRoute(1);
 
         DefaultHttpClient client = new DefaultHttpClient(mgr, params);
         HttpHost target = new HttpHost(saddress.getHostName(), saddress.getPort(), "http");

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestContentCodings.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestContentCodings.java?rev=820971&r1=820970&r2=820971&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestContentCodings.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestContentCodings.java Fri Oct  2 11:33:00 2009
@@ -37,9 +37,6 @@
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.zip.Deflater;
-
-/* Don't use Java 6 functionality, even in tests. */
-//import java.util.zip.DeflaterInputStream;
 import java.util.zip.GZIPOutputStream;
 
 import org.apache.http.Header;
@@ -51,12 +48,10 @@
 import org.apache.http.HttpResponse;
 import org.apache.http.HttpResponseInterceptor;
 import org.apache.http.HttpStatus;
-import org.apache.http.HttpVersion;
 import org.apache.http.client.HttpClient;
+import org.apache.http.client.entity.DeflateDecompressingEntity;
 import org.apache.http.client.methods.HttpGet;
 import org.apache.http.client.protocol.RequestAcceptEncoding;
-import org.apache.http.conn.ClientConnectionManager;
-import org.apache.http.conn.params.ConnManagerParams;
 import org.apache.http.conn.scheme.PlainSocketFactory;
 import org.apache.http.conn.scheme.Scheme;
 import org.apache.http.conn.scheme.SchemeRegistry;
@@ -64,9 +59,6 @@
 import org.apache.http.entity.StringEntity;
 import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
 import org.apache.http.localserver.ServerTestBase;
-import org.apache.http.params.BasicHttpParams;
-import org.apache.http.params.HttpParams;
-import org.apache.http.params.HttpProtocolParams;
 import org.apache.http.protocol.HttpContext;
 import org.apache.http.protocol.HttpRequestHandler;
 import org.apache.http.util.EntityUtils;
@@ -192,15 +184,13 @@
          */
         int clients = 100;
 
-        HttpParams params = new BasicHttpParams();
-        ConnManagerParams.setMaxTotalConnections(params, clients);
-        HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
-
         SchemeRegistry schemeRegistry = new SchemeRegistry();
         schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
 
-        ClientConnectionManager cm = new ThreadSafeClientConnManager(params, schemeRegistry);
-        final HttpClient httpClient = new DefaultHttpClient(cm, params);
+        ThreadSafeClientConnManager cm = new ThreadSafeClientConnManager(schemeRegistry);
+        cm.setMaxTotalConnections(clients);
+        
+        final HttpClient httpClient = new DefaultHttpClient(cm);
 
         ExecutorService executor = Executors.newFixedThreadPool(clients);
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultClientRequestDirector.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultClientRequestDirector.java?rev=820971&r1=820970&r2=820971&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultClientRequestDirector.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultClientRequestDirector.java Fri Oct  2 11:33:00 2009
@@ -152,7 +152,7 @@
         SchemeRegistry registry = new SchemeRegistry();
         registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
         
-        SingleClientConnManager conMan = new SingleClientConnManager(new BasicHttpParams(), registry);
+        SingleClientConnManager conMan = new SingleClientConnManager(registry);
         final AtomicReference<Throwable> throwableRef = new AtomicReference<Throwable>();
         final CountDownLatch getLatch = new CountDownLatch(1);
         final DefaultHttpClient client = new DefaultHttpClient(conMan, new BasicHttpParams()); 
@@ -192,7 +192,7 @@
         SchemeRegistry registry = new SchemeRegistry();
         registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
         
-        SingleClientConnManager conMan = new SingleClientConnManager(new BasicHttpParams(), registry);
+        SingleClientConnManager conMan = new SingleClientConnManager(registry);
         final AtomicReference<Throwable> throwableRef = new AtomicReference<Throwable>();
         final CountDownLatch getLatch = new CountDownLatch(1);
         final CountDownLatch startLatch = new CountDownLatch(1);
@@ -240,7 +240,7 @@
         
         CountDownLatch connLatch = new CountDownLatch(1);
         CountDownLatch awaitLatch = new CountDownLatch(1);
-        ConnMan4 conMan = new ConnMan4(new BasicHttpParams(), registry, connLatch, awaitLatch);
+        ConnMan4 conMan = new ConnMan4(registry, connLatch, awaitLatch);
         final AtomicReference<Throwable> throwableRef = new AtomicReference<Throwable>();
         final CountDownLatch getLatch = new CountDownLatch(1);
         final DefaultHttpClient client = new DefaultHttpClient(conMan, new BasicHttpParams()); 
@@ -297,7 +297,7 @@
         SchemeRegistry registry = new SchemeRegistry();
         registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
         
-        ConnMan3 conMan = new ConnMan3(new BasicHttpParams(), registry);
+        ConnMan3 conMan = new ConnMan3(registry);
         DefaultHttpClient client = new DefaultHttpClient(conMan, new BasicHttpParams());
         HttpGet httpget = new HttpGet("/a");
 
@@ -351,9 +351,9 @@
         private final CountDownLatch connLatch;
         private final CountDownLatch awaitLatch;
         
-        public ConnMan4(HttpParams params, SchemeRegistry schreg,
+        public ConnMan4(SchemeRegistry schreg,
                 CountDownLatch connLatch, CountDownLatch awaitLatch) {
-            super(params, schreg);
+            super(schreg);
             this.connLatch = connLatch;
             this.awaitLatch = awaitLatch;
         }
@@ -398,8 +398,8 @@
         private ManagedClientConnection allocatedConnection;
         private ManagedClientConnection releasedConnection;
         
-        public ConnMan3(HttpParams params, SchemeRegistry schreg) {
-            super(params, schreg);
+        public ConnMan3(SchemeRegistry schreg) {
+            super(schreg);
         }
         
         @Override

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestStatefulConnManagement.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestStatefulConnManagement.java?rev=820971&r1=820970&r2=820971&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestStatefulConnManagement.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestStatefulConnManagement.java Fri Oct  2 11:33:00 2009
@@ -40,11 +40,11 @@
 import org.apache.http.client.UserTokenHandler;
 import org.apache.http.client.methods.HttpGet;
 import org.apache.http.conn.ManagedClientConnection;
-import org.apache.http.conn.params.ConnPerRouteBean;
 import org.apache.http.conn.params.ConnManagerParams;
 import org.apache.http.entity.StringEntity;
 import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
 import org.apache.http.localserver.ServerTestBase;
+import org.apache.http.params.BasicHttpParams;
 import org.apache.http.params.HttpParams;
 import org.apache.http.protocol.BasicHttpContext;
 import org.apache.http.protocol.ExecutionContext;
@@ -95,14 +95,13 @@
 
         HttpHost target = new HttpHost("localhost", port);
         
-        HttpParams params = defaultParams.copy();
-        ConnManagerParams.setMaxTotalConnections(params, workerCount);
-        ConnManagerParams.setMaxConnectionsPerRoute(params, 
-                new ConnPerRouteBean(workerCount));
+        HttpParams params = new BasicHttpParams();
         ConnManagerParams.setTimeout(params, 10L);
         
-        ThreadSafeClientConnManager mgr = new ThreadSafeClientConnManager(
-                params, supportedSchemes);        
+        ThreadSafeClientConnManager mgr = new ThreadSafeClientConnManager(supportedSchemes);
+        mgr.setMaxTotalConnections(workerCount);
+        mgr.setDefaultMaxPerRoute(workerCount);
+        
         
         DefaultHttpClient client = new DefaultHttpClient(mgr, params); 
         

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestSCMWithServer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestSCMWithServer.java?rev=820971&r1=820970&r2=820971&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestSCMWithServer.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestSCMWithServer.java Fri Oct  2 11:33:00 2009
@@ -38,12 +38,10 @@
 import org.apache.http.HttpStatus;
 import org.apache.http.HttpVersion;
 import org.apache.http.conn.ManagedClientConnection;
-import org.apache.http.conn.params.ConnManagerParams;
 import org.apache.http.conn.routing.HttpRoute;
 import org.apache.http.conn.scheme.SchemeRegistry;
 import org.apache.http.localserver.ServerTestBase;
 import org.apache.http.message.BasicHttpRequest;
-import org.apache.http.params.HttpParams;
 import org.apache.http.protocol.ExecutionContext;
 import org.apache.http.util.EntityUtils;
 
@@ -72,14 +70,10 @@
      *
      * @return  a connection manager to test
      */
-    public SingleClientConnManager createSCCM(HttpParams params,
-                                              SchemeRegistry schreg) {
-        if (params == null)
-            params = defaultParams;
+    public SingleClientConnManager createSCCM(SchemeRegistry schreg) {
         if (schreg == null)
             schreg = supportedSchemes;
-
-        return new SingleClientConnManager(params, schreg);
+        return new SingleClientConnManager(schreg);
     }
     
     /**
@@ -87,10 +81,7 @@
      * a connection was aborted.
      */
     public void testOpenAfterAbort() throws Exception {
-        HttpParams mgrpar = defaultParams.copy();
-        ConnManagerParams.setMaxTotalConnections(mgrpar, 1);
-
-        SingleClientConnManager mgr = createSCCM(mgrpar, null);
+        SingleClientConnManager mgr = createSCCM(null);
 
         final HttpHost target = getServerHttp();
         final HttpRoute route = new HttpRoute(target, null, false);
@@ -112,10 +103,7 @@
      */
     public void testReleaseConnectionWithTimeLimits() throws Exception {
 
-        HttpParams mgrpar = defaultParams.copy();
-        ConnManagerParams.setMaxTotalConnections(mgrpar, 1);
-
-        SingleClientConnManager mgr = createSCCM(mgrpar, null);
+        SingleClientConnManager mgr = createSCCM(null);
 
         final HttpHost target = getServerHttp();
         final HttpRoute route = new HttpRoute(target, null, false);
@@ -207,10 +195,7 @@
 
     public void testCloseExpiredConnections() throws Exception {
 
-        HttpParams mgrpar = defaultParams.copy();
-        ConnManagerParams.setMaxTotalConnections(mgrpar, 1);
-
-        SingleClientConnManager mgr = createSCCM(mgrpar, null);
+        SingleClientConnManager mgr = createSCCM(null);
 
         final HttpHost target = getServerHttp();
         final HttpRoute route = new HttpRoute(target, null, false);
@@ -235,10 +220,7 @@
     
     public void testAlreadyLeased() throws Exception {
 
-        HttpParams mgrpar = defaultParams.copy();
-        ConnManagerParams.setMaxTotalConnections(mgrpar, 1);
-
-        SingleClientConnManager mgr = createSCCM(mgrpar, null);
+        SingleClientConnManager mgr = createSCCM(null);
 
         final HttpHost target = getServerHttp();
         final HttpRoute route = new HttpRoute(target, null, false);

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestTSCCMNoServer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestTSCCMNoServer.java?rev=820971&r1=820970&r2=820971&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestTSCCMNoServer.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestTSCCMNoServer.java Fri Oct  2 11:33:00 2009
@@ -39,8 +39,6 @@
 import org.apache.http.conn.ClientConnectionRequest;
 import org.apache.http.conn.ConnectionPoolTimeoutException;
 import org.apache.http.conn.ManagedClientConnection;
-import org.apache.http.conn.params.ConnPerRouteBean;
-import org.apache.http.conn.params.ConnManagerParams;
 import org.apache.http.conn.routing.HttpRoute;
 import org.apache.http.conn.scheme.PlainSocketFactory;
 import org.apache.http.conn.scheme.Scheme;
@@ -51,7 +49,6 @@
 import org.apache.http.params.HttpParams;
 import org.apache.http.params.HttpProtocolParams;
 
-
 /**
  * Tests for <code>ThreadSafeClientConnManager</code> that do not require
  * a server to communicate with.
@@ -98,14 +95,10 @@
      *
      * @return  a connection manager to test
      */
-    public ThreadSafeClientConnManager createTSCCM(HttpParams params,
-                                                   SchemeRegistry schreg) {
-        if (params == null)
-            params = createDefaultParams();
+    public ThreadSafeClientConnManager createTSCCM(SchemeRegistry schreg) {
         if (schreg == null)
             schreg = createSchemeRegistry();
-
-        return new ThreadSafeClientConnManager(params, schreg);
+        return new ThreadSafeClientConnManager(schreg);
     }
 
 
@@ -139,37 +132,28 @@
 
 
     public void testConstructor() {
-        HttpParams     params = createDefaultParams();
         SchemeRegistry schreg = createSchemeRegistry();
 
-        ThreadSafeClientConnManager mgr =
-            new ThreadSafeClientConnManager(params, schreg);
+        ThreadSafeClientConnManager mgr = new ThreadSafeClientConnManager(schreg);
         assertNotNull(mgr);
         mgr.shutdown();
         mgr = null;
 
         try {
-            mgr = new ThreadSafeClientConnManager(null, schreg);
-            fail("null parameters not detected");
+            mgr = new ThreadSafeClientConnManager(null);
+            fail("null parameter not detected");
         } catch (IllegalArgumentException iax) {
             // expected
         } finally {
             if (mgr != null)
                 mgr.shutdown();
         }
-        mgr = null;
-
-        mgr = new ThreadSafeClientConnManager(params, schreg);
-        assertNotNull(mgr);
-        mgr.shutdown();
-        mgr = null;
-
     } // testConstructor
 
 
     public void testGetConnection() 
             throws InterruptedException, ConnectionPoolTimeoutException {
-        ThreadSafeClientConnManager mgr = createTSCCM(null, null);
+        ThreadSafeClientConnManager mgr = createTSCCM(null);
 
         HttpHost target = new HttpHost("www.test.invalid", 80, "http");
         HttpRoute route = new HttpRoute(target, null, false);
@@ -198,11 +182,9 @@
     public void testMaxConnTotal() 
             throws InterruptedException, ConnectionPoolTimeoutException {
 
-        HttpParams params = createDefaultParams();
-        ConnManagerParams.setMaxConnectionsPerRoute(params, new ConnPerRouteBean(1));
-        ConnManagerParams.setMaxTotalConnections(params, 2);
-
-        ThreadSafeClientConnManager mgr = createTSCCM(params, null);
+        ThreadSafeClientConnManager mgr = createTSCCM(null);
+        mgr.setMaxTotalConnections(2);
+        mgr.setDefaultMaxPerRoute(1);
 
         HttpHost target1 = new HttpHost("www.test1.invalid", 80, "http");
         HttpRoute route1 = new HttpRoute(target1, null, false);
@@ -247,16 +229,11 @@
         HttpHost target3 = new HttpHost("www.test3.invalid", 80, "http");
         HttpRoute route3 = new HttpRoute(target3, null, false);
         
-        HttpParams params = createDefaultParams();
-        ConnManagerParams.setMaxTotalConnections(params, 100);
-        
-        ConnPerRouteBean connPerRoute = new ConnPerRouteBean(1);
-        connPerRoute.setMaxForRoute(route2, 2);
-        connPerRoute.setMaxForRoute(route3, 3);
-        
-        ConnManagerParams.setMaxConnectionsPerRoute(params, connPerRoute);
-
-        ThreadSafeClientConnManager mgr = createTSCCM(params, null);
+        ThreadSafeClientConnManager mgr = createTSCCM(null);
+        mgr.setMaxTotalConnections(100);
+        mgr.setDefaultMaxPerRoute(1);
+        mgr.setMaxForRoute(route2, 2);
+        mgr.setMaxForRoute(route3, 3);
 
         // route 3, limit 3
         ManagedClientConnection conn1 =
@@ -318,11 +295,9 @@
 
     public void testReleaseConnection() throws Exception {
 
-        HttpParams params = createDefaultParams();
-        ConnManagerParams.setMaxConnectionsPerRoute(params, new ConnPerRouteBean(1));
-        ConnManagerParams.setMaxTotalConnections(params, 3);
-
-        ThreadSafeClientConnManager mgr = createTSCCM(params, null);
+        ThreadSafeClientConnManager mgr = createTSCCM(null);
+        mgr.setMaxTotalConnections(3);
+        mgr.setDefaultMaxPerRoute(1);
 
         HttpHost target1 = new HttpHost("www.test1.invalid", 80, "http");
         HttpRoute route1 = new HttpRoute(target1, null, false);
@@ -389,7 +364,7 @@
     public void testDeleteClosedConnections()
             throws InterruptedException, ConnectionPoolTimeoutException {
         
-        ThreadSafeClientConnManager mgr = createTSCCM(null, null);
+        ThreadSafeClientConnManager mgr = createTSCCM(null);
 
         HttpHost target = new HttpHost("www.test.invalid", 80, "http");
         HttpRoute route = new HttpRoute(target, null, false);
@@ -421,11 +396,9 @@
     public void testShutdown() throws Exception {
         // 3.x: TestHttpConnectionManager.testShutdown
 
-        HttpParams params = createDefaultParams();
-        ConnManagerParams.setMaxConnectionsPerRoute(params, new ConnPerRouteBean(1));
-        ConnManagerParams.setMaxTotalConnections(params, 1);
-
-        ThreadSafeClientConnManager mgr = createTSCCM(params, null);
+        ThreadSafeClientConnManager mgr = createTSCCM(null);
+        mgr.setMaxTotalConnections(1);
+        mgr.setDefaultMaxPerRoute(1);
 
         HttpHost target = new HttpHost("www.test.invalid", 80, "http");
         HttpRoute route = new HttpRoute(target, null, false);
@@ -469,10 +442,8 @@
     public void testInterruptThread() throws Exception {
         // 3.x: TestHttpConnectionManager.testWaitingThreadInterrupted
 
-        HttpParams params = createDefaultParams();
-        ConnManagerParams.setMaxTotalConnections(params, 1);
-
-        ThreadSafeClientConnManager mgr = createTSCCM(params, null);
+        ThreadSafeClientConnManager mgr = createTSCCM(null);
+        mgr.setMaxTotalConnections(1);
 
         HttpHost target = new HttpHost("www.test.invalid", 80, "http");
         HttpRoute route = new HttpRoute(target, null, false);
@@ -517,10 +488,8 @@
     public void testReusePreference() throws Exception {
         // 3.x: TestHttpConnectionManager.testHostReusePreference
 
-        HttpParams params = createDefaultParams();
-        ConnManagerParams.setMaxTotalConnections(params, 1);
-
-        ThreadSafeClientConnManager mgr = createTSCCM(params, null);
+        ThreadSafeClientConnManager mgr = createTSCCM(null);
+        mgr.setMaxTotalConnections(1);
 
         HttpHost target1 = new HttpHost("www.test1.invalid", 80, "http");
         HttpRoute route1 = new HttpRoute(target1, null, false);
@@ -557,10 +526,8 @@
     }
     
     public void testAbortAfterRequestStarts() throws Exception {
-        HttpParams params = createDefaultParams();
-        ConnManagerParams.setMaxTotalConnections(params, 1);
-
-        ThreadSafeClientConnManager mgr = createTSCCM(params, null);
+        ThreadSafeClientConnManager mgr = createTSCCM(null);
+        mgr.setMaxTotalConnections(1);
 
         HttpHost target = new HttpHost("www.test.invalid", 80, "http");
         HttpRoute route = new HttpRoute(target, null, false);
@@ -598,15 +565,12 @@
     }
     
     public void testAbortBeforeRequestStarts() throws Exception {
-        HttpParams params = createDefaultParams();
-        ConnManagerParams.setMaxTotalConnections(params, 1);
-
-        ThreadSafeClientConnManager mgr = createTSCCM(params, null);
+        ThreadSafeClientConnManager mgr = createTSCCM(null);
+        mgr.setMaxTotalConnections(1);
 
         HttpHost target = new HttpHost("www.test.invalid", 80, "http");
         HttpRoute route = new HttpRoute(target, null, false);
         
-
         // get the only connection, then start an extra thread
         ManagedClientConnection conn = getConnection(mgr, route, 1L, TimeUnit.MILLISECONDS);
         ClientConnectionRequest request = mgr.requestConnection(route, null);

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestTSCCMWithServer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestTSCCMWithServer.java?rev=820971&r1=820970&r2=820971&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestTSCCMWithServer.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/TestTSCCMWithServer.java Fri Oct  2 11:33:00 2009
@@ -27,7 +27,6 @@
 
 package org.apache.http.impl.conn;
 
-
 import java.io.IOException;
 import java.lang.ref.WeakReference;
 import java.net.InetAddress;
@@ -53,8 +52,6 @@
 import org.apache.http.conn.ConnectionPoolTimeoutException;
 import org.apache.http.conn.ManagedClientConnection;
 import org.apache.http.conn.OperatedClientConnection;
-import org.apache.http.conn.params.ConnPerRouteBean;
-import org.apache.http.conn.params.ConnManagerParams;
 import org.apache.http.conn.routing.HttpRoute;
 import org.apache.http.conn.scheme.PlainSocketFactory;
 import org.apache.http.conn.scheme.Scheme;
@@ -69,7 +66,6 @@
 import org.apache.http.protocol.HttpContext;
 import org.apache.http.util.EntityUtils;
 
-
 /**
  * Tests for <code>ThreadSafeClientConnManager</code> that do require
  * a server to communicate with.
@@ -114,14 +110,10 @@
      *
      * @return  a connection manager to test
      */
-    public ThreadSafeClientConnManager createTSCCM(HttpParams params,
-                                                   SchemeRegistry schreg) {
-        if (params == null)
-            params = defaultParams;
+    public ThreadSafeClientConnManager createTSCCM(SchemeRegistry schreg) {
         if (schreg == null)
             schreg = supportedSchemes;
-
-        return new ThreadSafeClientConnManager(params, schreg);
+        return new ThreadSafeClientConnManager(schreg);
     }
 
 
@@ -134,12 +126,9 @@
 
         final int COUNT = 8; // adjust to execute more requests
 
-        HttpParams mgrpar = defaultParams.copy();
-        ConnManagerParams.setMaxTotalConnections
-            (mgrpar, COUNT/2);
-        ConnManagerParams.setMaxConnectionsPerRoute
-            (mgrpar, new ConnPerRouteBean(COUNT/2));
-        ThreadSafeClientConnManager mgr = createTSCCM(mgrpar, null);
+        ThreadSafeClientConnManager mgr = createTSCCM(null);
+        mgr.setMaxTotalConnections(COUNT/2);
+        mgr.setDefaultMaxPerRoute(COUNT/2);
 
         final HttpHost target = getServerHttp();
         final HttpRoute route = new HttpRoute(target, null, false);
@@ -209,10 +198,8 @@
      */
     public void testReleaseConnection() throws Exception {
 
-        HttpParams mgrpar = defaultParams.copy();
-        ConnManagerParams.setMaxTotalConnections(mgrpar, 1);
-
-        ThreadSafeClientConnManager mgr = createTSCCM(mgrpar, null);
+        ThreadSafeClientConnManager mgr = createTSCCM(null);
+        mgr.setMaxTotalConnections(1);
 
         final HttpHost target = getServerHttp();
         final HttpRoute route = new HttpRoute(target, null, false);
@@ -296,10 +283,8 @@
      */
     public void testReleaseConnectionWithTimeLimits() throws Exception {
 
-        HttpParams mgrpar = defaultParams.copy();
-        ConnManagerParams.setMaxTotalConnections(mgrpar, 1);
-
-        ThreadSafeClientConnManager mgr = createTSCCM(mgrpar, null);
+        ThreadSafeClientConnManager mgr = createTSCCM(null);
+        mgr.setMaxTotalConnections(1);
 
         final HttpHost target = getServerHttp();
         final HttpRoute route = new HttpRoute(target, null, false);
@@ -400,10 +385,8 @@
 
     public void testCloseExpiredConnections() throws Exception {
 
-        HttpParams mgrpar = defaultParams.copy();
-        ConnManagerParams.setMaxTotalConnections(mgrpar, 1);
-
-        ThreadSafeClientConnManager mgr = createTSCCM(mgrpar, null);
+        ThreadSafeClientConnManager mgr = createTSCCM(null);
+        mgr.setMaxTotalConnections(1);
 
         final HttpHost target = getServerHttp();
         final HttpRoute route = new HttpRoute(target, null, false);
@@ -443,10 +426,8 @@
      */
     public void testReleaseConnectionOnAbort() throws Exception {
 
-        HttpParams mgrpar = defaultParams.copy();
-        ConnManagerParams.setMaxTotalConnections(mgrpar, 1);
-
-        ThreadSafeClientConnManager mgr = createTSCCM(mgrpar, null);
+        ThreadSafeClientConnManager mgr = createTSCCM(null);
+        mgr.setMaxTotalConnections(1);
 
         final HttpHost target = getServerHttp();
         final HttpRoute route = new HttpRoute(target, null, false);
@@ -495,7 +476,7 @@
     public void testConnectionManagerGC() throws Exception {
         // 3.x: TestHttpConnectionManager.testDroppedThread
 
-        ThreadSafeClientConnManager mgr = createTSCCM(null, null);
+        ThreadSafeClientConnManager mgr = createTSCCM(null);
 
         final HttpHost target = getServerHttp();
         final HttpRoute route = new HttpRoute(target, null, false);
@@ -539,16 +520,14 @@
     }
     
     public void testAbortDuringConnecting() throws Exception {
-        HttpParams mgrpar = defaultParams.copy();
-        ConnManagerParams.setMaxTotalConnections(mgrpar, 1);
-        
         final CountDownLatch connectLatch = new CountDownLatch(1);        
         final StallingSocketFactory stallingSocketFactory = new StallingSocketFactory(connectLatch, WaitPolicy.BEFORE_CONNECT, PlainSocketFactory.getSocketFactory());
         Scheme scheme = new Scheme("http", stallingSocketFactory, 80);
         SchemeRegistry registry = new SchemeRegistry();
         registry.register(scheme);
 
-        ThreadSafeClientConnManager mgr = createTSCCM(mgrpar, registry);
+        ThreadSafeClientConnManager mgr = createTSCCM(registry);
+        mgr.setMaxTotalConnections(1);
 
         final HttpHost target = getServerHttp();
         final HttpRoute route = new HttpRoute(target, null, false);
@@ -603,16 +582,14 @@
     }
     
     public void testAbortBeforeSocketCreate() throws Exception {
-        HttpParams mgrpar = defaultParams.copy();
-        ConnManagerParams.setMaxTotalConnections(mgrpar, 1);
-        
         final CountDownLatch connectLatch = new CountDownLatch(1);        
         final StallingSocketFactory stallingSocketFactory = new StallingSocketFactory(connectLatch, WaitPolicy.BEFORE_CREATE, PlainSocketFactory.getSocketFactory());
         Scheme scheme = new Scheme("http", stallingSocketFactory, 80);
         SchemeRegistry registry = new SchemeRegistry();
         registry.register(scheme);
 
-        ThreadSafeClientConnManager mgr = createTSCCM(mgrpar, registry);
+        ThreadSafeClientConnManager mgr = createTSCCM(registry);
+        mgr.setMaxTotalConnections(1);
 
         final HttpHost target = getServerHttp();
         final HttpRoute route = new HttpRoute(target, null, false);
@@ -669,16 +646,14 @@
     }
     
     public void testAbortAfterSocketConnect() throws Exception {
-        HttpParams mgrpar = defaultParams.copy();
-        ConnManagerParams.setMaxTotalConnections(mgrpar, 1);
-        
         final CountDownLatch connectLatch = new CountDownLatch(1);        
         final StallingSocketFactory stallingSocketFactory = new StallingSocketFactory(connectLatch, WaitPolicy.AFTER_CONNECT, PlainSocketFactory.getSocketFactory());
         Scheme scheme = new Scheme("http", stallingSocketFactory, 80);
         SchemeRegistry registry = new SchemeRegistry();
         registry.register(scheme);
 
-        ThreadSafeClientConnManager mgr = createTSCCM(mgrpar, registry);
+        ThreadSafeClientConnManager mgr = createTSCCM(registry);
+        mgr.setMaxTotalConnections(1);
 
         final HttpHost target = getServerHttp();
         final HttpRoute route = new HttpRoute(target, null, false);
@@ -740,13 +715,10 @@
     }
     
     public void testAbortAfterOperatorOpen() throws Exception {
-        HttpParams mgrpar = defaultParams.copy();
-        ConnManagerParams.setMaxTotalConnections(mgrpar, 1);
-        
         final CountDownLatch connectLatch = new CountDownLatch(1);
         final AtomicReference<StallingOperator> operatorRef = new AtomicReference<StallingOperator>();
         
-        ThreadSafeClientConnManager mgr = new ThreadSafeClientConnManager(mgrpar, supportedSchemes) {
+        ThreadSafeClientConnManager mgr = new ThreadSafeClientConnManager(supportedSchemes) {
             @Override
             protected ClientConnectionOperator createConnectionOperator(
                     SchemeRegistry schreg) {
@@ -754,6 +726,7 @@
                 return operatorRef.get();
             }
         };
+        mgr.setMaxTotalConnections(1);
         assertNotNull(operatorRef.get());
 
         final HttpHost target = getServerHttp();

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/tsccm/TestConnPoolByRoute.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/tsccm/TestConnPoolByRoute.java?rev=820971&r1=820970&r2=820971&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/tsccm/TestConnPoolByRoute.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/tsccm/TestConnPoolByRoute.java Fri Oct  2 11:33:00 2009
@@ -36,11 +36,9 @@
 import org.apache.http.conn.ClientConnectionOperator;
 import org.apache.http.conn.ConnectionPoolTimeoutException;
 import org.apache.http.conn.params.ConnPerRouteBean;
-import org.apache.http.conn.params.ConnManagerParams;
 import org.apache.http.conn.routing.HttpRoute;
 import org.apache.http.impl.conn.DefaultClientConnectionOperator;
 import org.apache.http.localserver.ServerTestBase;
-import org.apache.http.params.BasicHttpParams;
 
 public class TestConnPoolByRoute extends ServerTestBase {
 
@@ -64,11 +62,8 @@
         ClientConnectionOperator operator = new DefaultClientConnectionOperator(
                 supportedSchemes);
         
-        BasicHttpParams params = new BasicHttpParams(); 
         ConnPerRouteBean connPerRoute = new ConnPerRouteBean(3); 
-        ConnManagerParams.setMaxConnectionsPerRoute(params, connPerRoute);
-        
-        ConnPoolByRoute connPool = new ConnPoolByRoute(operator, params);
+        ConnPoolByRoute connPool = new ConnPoolByRoute(operator, connPerRoute, 20);
         try {
             // Allocate max possible entries
             PoolEntryRequest r1 = connPool.requestPoolEntry(route, null);
@@ -111,11 +106,8 @@
         ClientConnectionOperator operator = new DefaultClientConnectionOperator(
                 supportedSchemes);
         
-        BasicHttpParams params = new BasicHttpParams(); 
         ConnPerRouteBean connPerRoute = new ConnPerRouteBean(3); 
-        ConnManagerParams.setMaxConnectionsPerRoute(params, connPerRoute);
-        
-        ConnPoolByRoute connPool = new ConnPoolByRoute(operator, params);
+        ConnPoolByRoute connPool = new ConnPoolByRoute(operator, connPerRoute, 20);
         try {
             // Allocate max possible entries
             PoolEntryRequest r1 = connPool.requestPoolEntry(route, null);

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/tsccm/TestSpuriousWakeup.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/tsccm/TestSpuriousWakeup.java?rev=820971&r1=820970&r2=820971&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/tsccm/TestSpuriousWakeup.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/conn/tsccm/TestSpuriousWakeup.java Fri Oct  2 11:33:00 2009
@@ -35,7 +35,6 @@
 import junit.framework.TestSuite;
 
 import org.apache.http.HttpHost;
-import org.apache.http.HttpVersion;
 import org.apache.http.conn.ClientConnectionOperator;
 import org.apache.http.conn.ClientConnectionRequest;
 import org.apache.http.conn.ManagedClientConnection;
@@ -44,17 +43,10 @@
 import org.apache.http.conn.scheme.Scheme;
 import org.apache.http.conn.scheme.SchemeRegistry;
 import org.apache.http.conn.scheme.SocketFactory;
-import org.apache.http.conn.params.ConnPerRouteBean;
-import org.apache.http.conn.params.ConnManagerParams;
-import org.apache.http.params.BasicHttpParams;
-import org.apache.http.params.HttpParams;
-import org.apache.http.params.HttpProtocolParams;
+import org.apache.http.conn.params.ConnPerRoute;
 
-// test imports
 import org.apache.http.impl.conn.GetConnThread;
 
-
-
 /**
  * Tests for spurious wakeups in <code>WaitingThread</code>.
  * Requires some wrapping code to get at the lock and condition,
@@ -93,8 +85,11 @@
         protected WaitingThread newestWT;
 
 
-        public XConnPoolByRoute(ClientConnectionOperator operator, HttpParams params) {
-            super(operator, params);
+        public XConnPoolByRoute(
+                final ClientConnectionOperator operator, 
+                final ConnPerRoute connPerRoute,
+                int maxTotalConnections) {
+            super(operator, connPerRoute, maxTotalConnections);
         }
 
         @Override
@@ -118,13 +113,13 @@
         protected XConnPoolByRoute extendedCPBR;
 
 
-        public XTSCCM(HttpParams params, SchemeRegistry schreg) {
-            super(params, schreg);
+        public XTSCCM(SchemeRegistry schreg) {
+            super(schreg);
         }
 
         @Override
-        protected AbstractConnPool createConnectionPool(HttpParams params) {
-            extendedCPBR = new XConnPoolByRoute(connOperator, params);
+        protected ConnPoolByRoute createConnectionPool() {
+            extendedCPBR = new XConnPoolByRoute(connOperator, connPerRoute, 20);
             // no connection GC required
             return extendedCPBR;
         }
@@ -134,21 +129,15 @@
 
 
     public void testSpuriousWakeup() throws Exception {
-
-        // parameters with connection limit 1
-        HttpParams params = new BasicHttpParams();
-        HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
-        HttpProtocolParams.setUseExpectContinue(params, false);
-        ConnManagerParams.setMaxConnectionsPerRoute(params, new ConnPerRouteBean(1));
-        ConnManagerParams.setMaxTotalConnections(params, 1);
-
         SchemeRegistry schreg = new SchemeRegistry();
         SocketFactory sf = PlainSocketFactory.getSocketFactory();
         schreg.register(new Scheme("http", sf, 80));
 
-        XTSCCM mgr = new XTSCCM(params, schreg);
-
+        XTSCCM mgr = new XTSCCM(schreg);
         try {
+            mgr.setMaxTotalConnections(1);
+            mgr.setDefaultMaxPerRoute(1);
+            
             // take out the only connection
             ClientConnectionRequest connRequest = mgr.requestConnection(ROUTE, null);
             ManagedClientConnection conn = connRequest.getConnection(0, null);



Mime
View raw message