hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r486244 - in /jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/conn: ./ impl/ params/
Date Tue, 12 Dec 2006 17:17:58 GMT
Author: olegk
Date: Tue Dec 12 09:17:57 2006
New Revision: 486244

URL: http://svn.apache.org/viewvc?view=rev&rev=486244
Log:
Ported HttpConnectionManagerParams, MultiThreadedHttpConnectionManager and IdleConnectionHandler classes from HttpClient 3.x to the new API

Added:
    jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/conn/impl/IdleConnectionHandler.java
      - copied, changed from r485243, jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/util/IdleConnectionHandler.java
    jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/conn/impl/MultiThreadedHttpConnectionManager.java
      - copied, changed from r484977, jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/MultiThreadedHttpConnectionManager.java
    jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/conn/params/HttpConnectionManagerParams.java
      - copied, changed from r486176, jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/params/HttpConnectionManagerParams.java
Modified:
    jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/conn/HttpHostConnection.java
    jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/conn/impl/DefaultHttpHostConnection.java
    jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/conn/impl/SimpleHttpConnectionManager.java

Modified: jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/conn/HttpHostConnection.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/conn/HttpHostConnection.java?view=diff&rev=486244&r1=486243&r2=486244
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/conn/HttpHostConnection.java (original)
+++ jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/conn/HttpHostConnection.java Tue Dec 12 09:17:57 2006
@@ -33,9 +33,13 @@
 import java.net.SocketException;
 
 import org.apache.http.HttpClientConnection;
+import org.apache.http.HttpInetConnection;
+import org.apache.http.HttpResponse;
 import org.apache.http.params.HttpParams;
 
-public interface HttpHostConnection extends HttpClientConnection {
+public interface HttpHostConnection extends HttpClientConnection, HttpInetConnection {
+    
+    void setHttpConnectionManager(HttpConnectionManager manager);
     
     HostConfiguration getHostConfiguration();
 
@@ -44,5 +48,15 @@
     void tunnelCreated(HttpParams params) throws IOException;
 
     void setSocketTimeout(int timeout) throws SocketException;
+    
+    HttpResponse getLastResponse();
+    
+    void setLastResponse(HttpResponse response);
+    
+    void setLocked(boolean locked);
+    
+    boolean isLocked();
+    
+    void releaseConnection();
     
 }

Modified: jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/conn/impl/DefaultHttpHostConnection.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/conn/impl/DefaultHttpHostConnection.java?view=diff&rev=486244&r1=486243&r2=486244
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/conn/impl/DefaultHttpHostConnection.java (original)
+++ jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/conn/impl/DefaultHttpHostConnection.java Tue Dec 12 09:17:57 2006
@@ -67,7 +67,7 @@
     private static final Log LOG = LogFactory.getLog(DefaultHttpHostConnection.class);
     
     /** the connection manager that created this connection or null */
-    private final HttpConnectionManager manager;
+    private HttpConnectionManager manager;
     
     private HostConfiguration hostconf;
 
@@ -80,11 +80,14 @@
     
     private HttpResponse lastResponse;
     
-    public DefaultHttpHostConnection(final HttpConnectionManager manager) {
+    public DefaultHttpHostConnection() {
         super();
-        this.manager = manager;
     }
     
+    public void setHttpConnectionManager(final HttpConnectionManager manager) {
+        this.manager = manager;
+    }
+
     public void setHostConfiguration(final HostConfiguration hostconf) {
         assertNotOpen();
         this.hostconf = hostconf;
@@ -246,7 +249,7 @@
      * 
      * @since 3.0
      */
-    protected boolean isLocked() {
+    public boolean isLocked() {
         return locked;
     }
 
@@ -259,7 +262,7 @@
      * 
      * @since 3.0
      */
-    protected void setLocked(boolean locked) {
+    public void setLocked(boolean locked) {
         this.locked = locked;
     }
 

Copied: jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/conn/impl/IdleConnectionHandler.java (from r485243, jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/util/IdleConnectionHandler.java)
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/conn/impl/IdleConnectionHandler.java?view=diff&rev=486244&p1=jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/util/IdleConnectionHandler.java&r1=485243&p2=jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/conn/impl/IdleConnectionHandler.java&r2=486244
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/util/IdleConnectionHandler.java (original)
+++ jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/conn/impl/IdleConnectionHandler.java Tue Dec 12 09:17:57 2006
@@ -1,5 +1,5 @@
 /*
- * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//httpclient/src/java/org/apache/commons/httpclient/util/IdleConnectionHandler.java,v 1.2 2004/05/13 02:40:36 mbecke Exp $
+ * $HeadURL$
  * $Revision$
  * $Date$
  *
@@ -27,15 +27,16 @@
  * <http://www.apache.org/>.
  *
  */
-package org.apache.commons.httpclient.util;
+package org.apache.http.conn.impl;
 
+import java.io.IOException;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
 
-import org.apache.commons.httpclient.HttpConnection;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.http.conn.HttpHostConnection;
 
 /**
  * A helper class for connection managers to track idle connections.
@@ -68,7 +69,7 @@
      * 
      * @see #remove(HttpConnection)
      */
-    public void add(HttpConnection connection) {
+    public void add(HttpHostConnection connection) {
         
         Long timeAdded = new Long(System.currentTimeMillis());
         
@@ -83,7 +84,7 @@
      * Removes the given connection from the list of connections to be closed when idle.
      * @param connection
      */
-    public void remove(HttpConnection connection) {
+    public void remove(HttpHostConnection connection) {
         connectionToAdded.remove(connection);
     }
 
@@ -111,14 +112,18 @@
         Iterator connectionIter = connectionToAdded.keySet().iterator();
         
         while (connectionIter.hasNext()) {
-            HttpConnection conn = (HttpConnection) connectionIter.next();
+            HttpHostConnection conn = (HttpHostConnection) connectionIter.next();
             Long connectionTime = (Long) connectionToAdded.get(conn);
             if (connectionTime.longValue() <= idleTimeout) {
                 if (LOG.isDebugEnabled()) {
                     LOG.debug("Closing connection, connection time: "  + connectionTime);
                 }
                 connectionIter.remove();
-                conn.close();
+                try {
+                    conn.close();
+                } catch (IOException ex) {
+                    LOG.debug("I/O error closing connection", ex);
+                }
             }
         }
     }

Copied: jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/conn/impl/MultiThreadedHttpConnectionManager.java (from r484977, jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/MultiThreadedHttpConnectionManager.java)
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/conn/impl/MultiThreadedHttpConnectionManager.java?view=diff&rev=486244&p1=jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/MultiThreadedHttpConnectionManager.java&r1=484977&p2=jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/conn/impl/MultiThreadedHttpConnectionManager.java&r2=486244
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/MultiThreadedHttpConnectionManager.java (original)
+++ jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/conn/impl/MultiThreadedHttpConnectionManager.java Tue Dec 12 09:17:57 2006
@@ -1,5 +1,5 @@
 /*
- * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//httpclient/src/java/org/apache/commons/httpclient/MultiThreadedHttpConnectionManager.java,v 1.47 2004/12/21 11:27:55 olegk Exp $
+ * $HeadURL$
  * $Revision$
  * $Date$
  *
@@ -28,11 +28,9 @@
  *
  */
 
-package org.apache.commons.httpclient;
+package org.apache.http.conn.impl;
 
 import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
 import java.lang.ref.Reference;
 import java.lang.ref.ReferenceQueue;
 import java.lang.ref.WeakReference;
@@ -45,12 +43,19 @@
 import java.util.Map;
 import java.util.WeakHashMap;
 
-import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
-import org.apache.commons.httpclient.params.HttpConnectionParams;
-import org.apache.commons.httpclient.protocol.Protocol;
-import org.apache.commons.httpclient.util.IdleConnectionHandler;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.http.HttpEntityEnclosingRequest;
+import org.apache.http.HttpException;
+import org.apache.http.HttpRequest;
+import org.apache.http.HttpResponse;
+import org.apache.http.conn.ConnectionPoolTimeoutException;
+import org.apache.http.conn.HostConfiguration;
+import org.apache.http.conn.HttpConnectionManager;
+import org.apache.http.conn.HttpHostConnection;
+import org.apache.http.conn.params.HttpConnectionManagerParams;
+import org.apache.http.impl.DefaultHttpParams;
+import org.apache.http.params.HttpParams;
 
 /**
  * Manages a set of HttpConnections for various HostConfigurations.
@@ -69,12 +74,6 @@
     /** Log object for this class. */
     private static final Log LOG = LogFactory.getLog(MultiThreadedHttpConnectionManager.class);
 
-    /** The default maximum number of connections allowed per host */
-    public static final int DEFAULT_MAX_HOST_CONNECTIONS = 2;   // Per RFC 2616 sec 8.1.4
-
-    /** The default maximum number of connections allowed overall */
-    public static final int DEFAULT_MAX_TOTAL_CONNECTIONS = 20;
-
     /**
      * A mapping from Reference to ConnectionSource.  Used to reclaim resources when connections
      * are lost to the garbage collector.
@@ -138,7 +137,7 @@
      * manager.
      * 
      * <p>A static reference to the connection manager will also be stored.  To ensure that
-     * the connection manager can be GCed {@link #removeReferenceToConnection(HttpConnection)}
+     * the connection manager can be GCed {@link #removeReferenceToConnection(HttpHostConnection)}
      * should be called for all connections that the connection manager is storing a reference
      * to.</p>
      * 
@@ -146,7 +145,7 @@
      * @param hostConfiguration the connection's host config
      * @param connectionPool the connection pool that created the connection
      * 
-     * @see #removeReferenceToConnection(HttpConnection)
+     * @see #removeReferenceToConnection(HttpHostConnection)
      */
     private static void storeReferenceToConnection(
         HttpConnectionWithReference connection,
@@ -191,7 +190,7 @@
                     (ConnectionSource) REFERENCE_TO_CONNECTION_SOURCE.get(ref);
                 if (source.connectionPool == connectionPool) {
                     referenceIter.remove();
-                    HttpConnection connection = (HttpConnection) ref.get();
+                    HttpHostConnection connection = (HttpHostConnection) ref.get();
                     if (connection != null) {
                         connectionsToClose.add(connection);
                     }
@@ -202,8 +201,8 @@
         // close and release the connections outside of the synchronized block to
         // avoid holding the lock for too long
         for (Iterator i = connectionsToClose.iterator(); i.hasNext();) {
-            HttpConnection connection = (HttpConnection) i.next();
-            connection.close();
+            HttpHostConnection connection = (HttpHostConnection) i.next();
+            closeConnection(connection);
             // remove the reference to the connection manager. this ensures
             // that the we don't accidentally end up here again
             connection.setHttpConnectionManager(null);
@@ -217,7 +216,7 @@
      * 
      * @param connection the connection to remove the reference for
      * 
-     * @see #storeReferenceToConnection(HttpConnection, HostConfiguration, ConnectionPool)
+     * @see #storeReferenceToConnection(HttpHostConnection, HostConfiguration, ConnectionPool)
      */
     private static void removeReferenceToConnection(HttpConnectionWithReference connection) {
         
@@ -232,7 +231,7 @@
     /**
      * Collection of parameters associated with this connection manager.
      */
-    private HttpConnectionManagerParams params = new HttpConnectionManagerParams(); 
+    private HttpParams params = new DefaultHttpParams(); 
 
     /** Connection Pool */
     private ConnectionPool connectionPool;
@@ -273,94 +272,13 @@
     }
     
     /**
-     * Gets the staleCheckingEnabled value to be set on HttpConnections that are created.
-     * 
-     * @return <code>true</code> if stale checking will be enabled on HttpConnections
-     * 
-     * @see HttpConnection#isStaleCheckingEnabled()
-     * 
-     * @deprecated Use {@link HttpConnectionManagerParams#isStaleCheckingEnabled()},
-     * {@link HttpConnectionManager#getParams()}.
-     */
-    public boolean isConnectionStaleCheckingEnabled() {
-        return this.params.isStaleCheckingEnabled();
-    }
-
-    /**
-     * Sets the staleCheckingEnabled value to be set on HttpConnections that are created.
-     * 
-     * @param connectionStaleCheckingEnabled <code>true</code> if stale checking will be enabled 
-     * on HttpConnections
-     * 
-     * @see HttpConnection#setStaleCheckingEnabled(boolean)
-     * 
-     * @deprecated Use {@link HttpConnectionManagerParams#setStaleCheckingEnabled(boolean)},
-     * {@link HttpConnectionManager#getParams()}.
-     */
-    public void setConnectionStaleCheckingEnabled(boolean connectionStaleCheckingEnabled) {
-        this.params.setStaleCheckingEnabled(connectionStaleCheckingEnabled);
-    }
-
-    /**
-     * Sets the maximum number of connections allowed for a given
-     * HostConfiguration. Per RFC 2616 section 8.1.4, this value defaults to 2.
-     *
-     * @param maxHostConnections the number of connections allowed for each
-     * hostConfiguration
-     * 
-     * @deprecated Use {@link HttpConnectionManagerParams#setDefaultMaxConnectionsPerHost(int)},
-     * {@link HttpConnectionManager#getParams()}.
-     */
-    public void setMaxConnectionsPerHost(int maxHostConnections) {
-        this.params.setDefaultMaxConnectionsPerHost(maxHostConnections);
-    }
-
-    /**
-     * Gets the maximum number of connections allowed for a given
-     * hostConfiguration.
-     *
-     * @return The maximum number of connections allowed for a given
-     * hostConfiguration.
-     * 
-     * @deprecated Use {@link HttpConnectionManagerParams#getDefaultMaxConnectionsPerHost()},
-     * {@link HttpConnectionManager#getParams()}.
-     */
-    public int getMaxConnectionsPerHost() {
-        return this.params.getDefaultMaxConnectionsPerHost();
-    }
-
-    /**
-     * Sets the maximum number of connections allowed for this connection manager.
-     *
-     * @param maxTotalConnections the maximum number of connections allowed
-     * 
-     * @deprecated Use {@link HttpConnectionManagerParams#setMaxTotalConnections(int)},
-     * {@link HttpConnectionManager#getParams()}.
-     */
-    public void setMaxTotalConnections(int maxTotalConnections) {
-        this.params.setMaxTotalConnections(maxTotalConnections);
-    }
-
-    /**
-     * Gets the maximum number of connections allowed for this connection manager.
-     *
-     * @return The maximum number of connections allowed
-     * 
-     * @deprecated Use {@link HttpConnectionManagerParams#getMaxTotalConnections()},
-     * {@link HttpConnectionManager#getParams()}.
-     */
-    public int getMaxTotalConnections() {
-        return this.params.getMaxTotalConnections();
-    }
-
-    /**
      * @see HttpConnectionManager#getConnection(HostConfiguration)
      */
-    public HttpConnection getConnection(HostConfiguration hostConfiguration) {
+    public HttpHostConnection getConnection(HostConfiguration hostConfiguration) {
 
         while (true) {
             try {
-                return getConnectionWithTimeout(hostConfiguration, 0);
+                return getConnection(hostConfiguration, 0);
             } catch (ConnectionPoolTimeoutException e) {
                 // we'll go ahead and log this, but it should never happen. HttpExceptions
                 // are only thrown when the timeout occurs and since we have no timeout
@@ -384,18 +302,16 @@
      * @param timeout the number of milliseconds to wait for a connection, 0 to
      * wait indefinitely
      *
-     * @return HttpConnection an available connection
+     * @return HttpHostConnection an available connection
      *
      * @throws HttpException if a connection does not become available in
      * 'timeout' milliseconds
      * 
      * @since 3.0
      */
-    public HttpConnection getConnectionWithTimeout(HostConfiguration hostConfiguration, 
+    public HttpHostConnection getConnection(HostConfiguration hostConfiguration, 
         long timeout) throws ConnectionPoolTimeoutException {
 
-        LOG.trace("enter HttpConnectionManager.getConnectionWithTimeout(HostConfiguration, long)");
-
         if (hostConfiguration == null) {
             throw new IllegalArgumentException("hostConfiguration is null");
         }
@@ -405,36 +321,22 @@
                 + hostConfiguration + ", timeout = " + timeout);
         }
 
-        final HttpConnection conn = doGetConnection(hostConfiguration, timeout);
+        final HttpHostConnection conn = doGetConnection(hostConfiguration, timeout);
 
         // wrap the connection in an adapter so we can ensure it is used 
         // only once
         return new HttpConnectionAdapter(conn);
     }
 
-	/**
-	 * @see HttpConnectionManager#getConnection(HostConfiguration, long)
-	 * 
-	 * @deprecated Use #getConnectionWithTimeout(HostConfiguration, long)
-	 */
-	public HttpConnection getConnection(HostConfiguration hostConfiguration, 
-		long timeout) throws HttpException {
-
-		LOG.trace("enter HttpConnectionManager.getConnection(HostConfiguration, long)");
-		try {
-			return getConnectionWithTimeout(hostConfiguration, timeout);
-		} catch(ConnectionPoolTimeoutException e) {
-			throw new HttpException(e.getMessage());
-		}
-	}
-
-    private HttpConnection doGetConnection(HostConfiguration hostConfiguration, 
+    private HttpHostConnection doGetConnection(HostConfiguration hostConfiguration, 
         long timeout) throws ConnectionPoolTimeoutException {
 
-        HttpConnection connection = null;
+        HttpHostConnection connection = null;
 
-        int maxHostConnections = this.params.getMaxConnectionsPerHost(hostConfiguration);
-        int maxTotalConnections = this.params.getMaxTotalConnections();
+        int maxHostConnections = HttpConnectionManagerParams
+            .getMaxConnectionsPerHost(this.params, hostConfiguration);
+        int maxTotalConnections = HttpConnectionManagerParams
+            .getMaxTotalConnections(this.params);
         
         synchronized (connectionPool) {
 
@@ -557,33 +459,10 @@
     }
     
     /**
-     * Gets the number of connections in use for this configuration.
-     *
-     * @param hostConfiguration the key that connections are tracked on
-     * @return the number of connections in use
-     * 
-     * @deprecated Use {@link #getConnectionsInPool(HostConfiguration)}
-     */
-    public int getConnectionsInUse(HostConfiguration hostConfiguration) {
-        return getConnectionsInPool(hostConfiguration);
-    }
-
-    /**
-     * Gets the total number of connections in use.
-     * 
-     * @return the total number of connections in use
-     * 
-     * @deprecated Use {@link #getConnectionsInPool()}
-     */
-    public int getConnectionsInUse() {
-        return getConnectionsInPool();
-    }
-
-    /**
      * Deletes all closed connections.  Only connections currently owned by the connection
      * manager are processed.
      * 
-     * @see HttpConnection#isOpen()
+     * @see HttpHostConnection#isOpen()
      * 
      * @since 3.0
      */
@@ -600,14 +479,13 @@
     }
     
     /**
-     * Make the given HttpConnection available for use by other requests.
+     * Make the given HttpHostConnection available for use by other requests.
      * If another thread is blocked in getConnection() that could use this
      * connection, it will be woken up.
      *
-     * @param conn the HttpConnection to make available.
+     * @param conn the HttpHostConnection to make available.
      */
-    public void releaseConnection(HttpConnection conn) {
-        LOG.trace("enter HttpConnectionManager.releaseConnection(HttpConnection)");
+    public void releaseConnection(HttpHostConnection conn) {
 
         if (conn instanceof HttpConnectionAdapter) {
             // connections given out are wrapped in an HttpConnectionAdapter
@@ -624,50 +502,26 @@
     }
 
     /**
-     * Gets the host configuration for a connection.
-     * @param conn the connection to get the configuration of
-     * @return a new HostConfiguration
-     */
-    private HostConfiguration configurationForConnection(HttpConnection conn) {
-
-        HostConfiguration connectionConfiguration = new HostConfiguration();
-        
-        connectionConfiguration.setHost(
-            conn.getHost(), 
-            conn.getPort(), 
-            conn.getProtocol()
-        );
-        if (conn.getLocalAddress() != null) {
-            connectionConfiguration.setLocalAddress(conn.getLocalAddress());
-        }
-        if (conn.getProxyHost() != null) {
-            connectionConfiguration.setProxy(conn.getProxyHost(), conn.getProxyPort());
-        }
-
-        return connectionConfiguration;
-    }
-
-    /**
-     * Returns {@link HttpConnectionManagerParams parameters} associated 
+     * Returns {@link HttpParams parameters} associated 
      * with this connection manager.
      * 
      * @since 3.0
      * 
      * @see HttpConnectionManagerParams
      */
-    public HttpConnectionManagerParams getParams() {
+    public HttpParams getParams() {
         return this.params;
     }
 
     /**
-     * Assigns {@link HttpConnectionManagerParams parameters} for this 
+     * Assigns {@link HttpParams parameters} for this 
      * connection manager.
      * 
      * @since 3.0
      * 
      * @see HttpConnectionManagerParams
      */
-    public void setParams(final HttpConnectionManagerParams params) {
+    public void setParams(final HttpParams params) {
         if (params == null) {
             throw new IllegalArgumentException("Parameters may not be null");
         }
@@ -704,9 +558,9 @@
             // close all free connections
             Iterator iter = freeConnections.iterator();
             while (iter.hasNext()) {
-                HttpConnection conn = (HttpConnection) iter.next();
+                HttpHostConnection conn = (HttpHostConnection) iter.next();
                 iter.remove();
-                conn.close();
+                closeConnection(conn);
             }
             
             // close all connections that have been checked out
@@ -733,14 +587,12 @@
          * @param hostConfiguration the configuration for the connection
          * @return a new connection or <code>null</code> if none are available
          */
-        public synchronized HttpConnection createConnection(HostConfiguration hostConfiguration) {
+        public synchronized HttpHostConnection createConnection(HostConfiguration hostConfiguration) {
             HostConnectionPool hostPool = getHostPool(hostConfiguration);
             if (LOG.isDebugEnabled()) {
                 LOG.debug("Allocating new connection, hostConfig=" + hostConfiguration);
             }
-            HttpConnectionWithReference connection = new HttpConnectionWithReference(
-                    hostConfiguration);
-            connection.getParams().setDefaults(MultiThreadedHttpConnectionManager.this.params);
+            HttpConnectionWithReference connection = new HttpConnectionWithReference();
             connection.setHttpConnectionManager(MultiThreadedHttpConnectionManager.this);
             numConnections++;
             hostPool.numConnections++;
@@ -772,7 +624,6 @@
          * @return a pool (list) of connections available for the given config
          */
         public synchronized HostConnectionPool getHostPool(HostConfiguration hostConfiguration) {
-            LOG.trace("enter HttpConnectionManager.ConnectionPool.getHostPool(HostConfiguration)");
 
             // Look for a list of connections for the given config
             HostConnectionPool listConnections = (HostConnectionPool) 
@@ -793,7 +644,7 @@
          * @param hostConfiguration the configuraton for the connection pool
          * @return an available connection for the given config
          */
-        public synchronized HttpConnection getFreeConnection(HostConfiguration hostConfiguration) {
+        public synchronized HttpHostConnection getFreeConnection(HostConfiguration hostConfiguration) {
 
             HttpConnectionWithReference connection = null;
             
@@ -826,7 +677,7 @@
             Iterator iter = freeConnections.iterator();
             
             while (iter.hasNext()) {
-                HttpConnection conn = (HttpConnection) iter.next();
+                HttpHostConnection conn = (HttpHostConnection) iter.next();
                 if (!conn.isOpen()) {
                     iter.remove();
                     deleteConnection(conn);
@@ -851,15 +702,15 @@
          * 
          * @param connection The connection to delete
          */
-        private synchronized void deleteConnection(HttpConnection connection) {
+        private synchronized void deleteConnection(HttpHostConnection connection) {
             
-            HostConfiguration connectionConfiguration = configurationForConnection(connection);
+            HostConfiguration connectionConfiguration = connection.getHostConfiguration();
 
             if (LOG.isDebugEnabled()) {
                 LOG.debug("Reclaiming connection, hostConfig=" + connectionConfiguration);
             }
 
-            connection.close();
+            closeConnection(connection);
 
             HostConnectionPool hostPool = getHostPool(connectionConfiguration);
             
@@ -876,7 +727,7 @@
          */
         public synchronized void deleteLeastUsedConnection() {
 
-            HttpConnection connection = (HttpConnection) freeConnections.removeFirst();
+            HttpHostConnection connection = (HttpHostConnection) freeConnections.removeFirst();
 
             if (connection != null) {
                 deleteConnection(connection);
@@ -935,9 +786,9 @@
          * Marks the given connection as free.
          * @param conn a connection that is no longer being used
          */
-        public void freeConnection(HttpConnection conn) {
+        public void freeConnection(HttpHostConnection conn) {
 
-            HostConfiguration connectionConfiguration = configurationForConnection(conn);
+            HostConfiguration connectionConfiguration = conn.getHostConfiguration();
 
             if (LOG.isDebugEnabled()) {
                 LOG.debug("Freeing connection, hostConfig=" + connectionConfiguration);
@@ -948,7 +799,7 @@
                 if (shutdown) {
                     // the connection manager has been shutdown, release the connection's
                     // resources and get out of here
-                    conn.close();
+                    closeConnection(conn);
                     return;
                 }
                 
@@ -981,6 +832,14 @@
             }
         }
     }
+    
+    private static void closeConnection(final HttpHostConnection conn) {
+        try {
+            conn.close();
+        } catch (IOException ex) {
+            LOG.debug("I/O error closing connection", ex);
+        }
+    }
 
     /**
      * A simple struct-like class to combine the objects needed to release a connection's
@@ -1094,34 +953,35 @@
     /**
      * A connection that keeps a reference to itself.
      */
-    private static class HttpConnectionWithReference extends HttpConnection {
+    private static class HttpConnectionWithReference extends DefaultHttpHostConnection {
         
         public WeakReference reference = new WeakReference(this, REFERENCE_QUEUE);
         
         /**
          * @param hostConfiguration
          */
-        public HttpConnectionWithReference(HostConfiguration hostConfiguration) {
-            super(hostConfiguration);
+        public HttpConnectionWithReference() {
+            super();
         }
 
     }
     
     /**
-     * An HttpConnection wrapper that ensures a connection cannot be used
+     * An HttpHostConnection wrapper that ensures a connection cannot be used
      * once released.
      */
-    private static class HttpConnectionAdapter extends HttpConnection {
+    private static class HttpConnectionAdapter implements HttpHostConnection {
 
-        // the wrapped connection
-        private HttpConnection wrappedConnection;
+        /** the wrapped connection
+         */
+        private HttpHostConnection wrappedConnection;
 
         /**
          * Creates a new HttpConnectionAdapter.
          * @param connection the connection to be wrapped
          */
-        public HttpConnectionAdapter(HttpConnection connection) {
-            super(connection.getHost(), connection.getPort(), connection.getProtocol());
+        public HttpConnectionAdapter(HttpHostConnection connection) {
+            super();
             this.wrappedConnection = connection;
         }
 
@@ -1134,13 +994,17 @@
         }
 
         /**
-         * @return HttpConnection
+         * @return HttpHostConnection
          */
-        HttpConnection getWrappedConnection() {
+        HttpHostConnection getWrappedConnection() {
             return wrappedConnection;
         }
+
+        //=======================
+        // HttpConnection methods
+        //=======================
         
-        public void close() {
+        public void close() throws IOException {
             if (hasConnection()) {
                 wrappedConnection.close();
             } else {
@@ -1148,118 +1012,6 @@
             }
         }
 
-        public InetAddress getLocalAddress() {
-            if (hasConnection()) {
-                return wrappedConnection.getLocalAddress();
-            } else {
-                return null;
-            }
-        }
-
-        /**
-         * @deprecated
-         */
-        public boolean isStaleCheckingEnabled() {
-            if (hasConnection()) {
-                return wrappedConnection.isStaleCheckingEnabled();
-            } else {
-                return false;
-            }
-        }
-
-        public void setLocalAddress(InetAddress localAddress) {
-            if (hasConnection()) {
-                wrappedConnection.setLocalAddress(localAddress);
-            } else {
-                throw new IllegalStateException("Connection has been released");
-            }
-        }
-    
-        /**
-         * @deprecated 
-         */
-        public void setStaleCheckingEnabled(boolean staleCheckEnabled) {
-            if (hasConnection()) {
-                wrappedConnection.setStaleCheckingEnabled(staleCheckEnabled);
-            } else {
-                throw new IllegalStateException("Connection has been released");
-            }
-        }
-
-        public String getHost() {
-            if (hasConnection()) {
-                return wrappedConnection.getHost();
-            } else {
-                return null;
-            }
-        }
-
-        public HttpConnectionManager getHttpConnectionManager() {
-            if (hasConnection()) {
-                return wrappedConnection.getHttpConnectionManager();
-            } else {
-                return null;
-            }
-        }
-
-        public InputStream getLastResponseInputStream() {
-            if (hasConnection()) {
-                return wrappedConnection.getLastResponseInputStream();
-            } else {
-                return null;
-            }
-        }
-
-        public int getPort() {
-            if (hasConnection()) {
-                return wrappedConnection.getPort();
-            } else {
-                return -1;
-            }
-        }
-
-        public Protocol getProtocol() {
-            if (hasConnection()) {
-                return wrappedConnection.getProtocol();
-            } else {
-                return null;
-            }
-        }
-
-        public String getProxyHost() {
-            if (hasConnection()) {
-                return wrappedConnection.getProxyHost();
-            } else {
-                return null;
-            }
-        }
-
-        public int getProxyPort() {
-            if (hasConnection()) {
-                return wrappedConnection.getProxyPort();
-            } else {
-                return -1;
-            }
-        }
-
-        public OutputStream getRequestOutputStream()
-            throws IOException, IllegalStateException {
-            if (hasConnection()) {
-                return wrappedConnection.getRequestOutputStream();
-            } else {
-                return null;
-            }
-        }
-
-        public InputStream getResponseInputStream()
-            throws IOException, IllegalStateException {
-            if (hasConnection()) {
-                return wrappedConnection.getResponseInputStream();
-            } else {
-                return null;
-            }
-        }
-
         public boolean isOpen() {
             if (hasConnection()) {
                 return wrappedConnection.isOpen();
@@ -1268,368 +1020,181 @@
             }
         }
 
-        public boolean closeIfStale() throws IOException {
+        public boolean isStale() {
             if (hasConnection()) {
-                return wrappedConnection.closeIfStale();
+                return wrappedConnection.isStale();
             } else {
-                return false;
+                return true;
             }
         }
 
-        public boolean isProxied() {
+        public void shutdown() throws IOException {
             if (hasConnection()) {
-                return wrappedConnection.isProxied();
+                wrappedConnection.shutdown();
             } else {
-                return false;
+                // do nothing
             }
         }
 
-        public boolean isResponseAvailable() throws IOException {
+        //=============================
+        // HttpClientConnection methods
+        //=============================
+        public void flush() throws IOException {
             if (hasConnection()) {
-                return  wrappedConnection.isResponseAvailable();
+                wrappedConnection.flush();
             } else {
-                return false;
+                // do nothing
             }
         }
 
         public boolean isResponseAvailable(int timeout) throws IOException {
             if (hasConnection()) {
-                return  wrappedConnection.isResponseAvailable(timeout);
-            } else {
-                return false;
-            }
-        }
-
-        public boolean isSecure() {
-            if (hasConnection()) {
-                return wrappedConnection.isSecure();
+                return wrappedConnection.isResponseAvailable(timeout);
             } else {
                 return false;
             }
         }
 
-        public boolean isTransparent() {
-            if (hasConnection()) {
-                return wrappedConnection.isTransparent();
-            } else {
-                return false;
-            }
-        }
-
-        public void open() throws IOException {
-            if (hasConnection()) {
-                wrappedConnection.open();
-            } else {
-                throw new IllegalStateException("Connection has been released");
-            }
-        }
-
-        /**
-         * @deprecated
-         */
-        public void print(String data)
-            throws IOException, IllegalStateException {
-            if (hasConnection()) {
-                wrappedConnection.print(data);
-            } else {
-                throw new IllegalStateException("Connection has been released");
-            }
-        }
-
-        public void printLine()
-            throws IOException, IllegalStateException {
-            if (hasConnection()) {
-                wrappedConnection.printLine();
-            } else {
-                throw new IllegalStateException("Connection has been released");
-            }
-        }
-
-        /**
-         * @deprecated
-         */
-        public void printLine(String data)
-            throws IOException, IllegalStateException {
-            if (hasConnection()) {
-                wrappedConnection.printLine(data);
-            } else {
-                throw new IllegalStateException("Connection has been released");
-            }
-        }
-
-        /**
-         * @deprecated
-         */
-        public String readLine() throws IOException, IllegalStateException {
+        public HttpResponse receiveResponseHeader(final HttpParams params) 
+                throws HttpException, IOException {
             if (hasConnection()) {
-                return wrappedConnection.readLine();
+                return wrappedConnection.receiveResponseHeader(params);
             } else {
-                throw new IllegalStateException("Connection has been released");
+                return null;
             }
         }
 
-        public String readLine(String charset) throws IOException, IllegalStateException {
+        public void receiveResponseEntity(final HttpResponse response) 
+                throws HttpException, IOException {
             if (hasConnection()) {
-                return wrappedConnection.readLine(charset);
-            } else {
-                throw new IllegalStateException("Connection has been released");
-            }
-        }
-
-        public void releaseConnection() {
-            if (!isLocked() && hasConnection()) {
-                HttpConnection wrappedConnection = this.wrappedConnection;
-                this.wrappedConnection = null;
-                wrappedConnection.releaseConnection();
+                wrappedConnection.receiveResponseEntity(response);
             } else {
                 // do nothing
             }
         }
 
-        /**
-         * @deprecated
-         */
-        public void setConnectionTimeout(int timeout) {
+        public void sendRequestHeader(final HttpRequest request) 
+                throws HttpException, IOException {
             if (hasConnection()) {
-                wrappedConnection.setConnectionTimeout(timeout);
+                wrappedConnection.sendRequestHeader(request);
             } else {
                 // do nothing
             }
         }
 
-        public void setHost(String host) throws IllegalStateException {
+        public void sendRequestEntity(final HttpEntityEnclosingRequest request) 
+                throws HttpException, IOException {
             if (hasConnection()) {
-                wrappedConnection.setHost(host);
+                wrappedConnection.sendRequestEntity(request);
             } else {
                 // do nothing
             }
         }
 
-        public void setHttpConnectionManager(HttpConnectionManager httpConnectionManager) {
+        //===========================
+        // HttpInetConnection methods
+        //===========================
+        public InetAddress getLocalAddress() {
             if (hasConnection()) {
-                wrappedConnection.setHttpConnectionManager(httpConnectionManager);
+                return wrappedConnection.getLocalAddress();
             } else {
-                // do nothing
+                return null;
             }
         }
 
-        public void setLastResponseInputStream(InputStream inStream) {
+        public InetAddress getRemoteAddress() {
             if (hasConnection()) {
-                wrappedConnection.setLastResponseInputStream(inStream);
+                return wrappedConnection.getRemoteAddress();
             } else {
-                // do nothing
+                return null;
             }
         }
 
-        public void setPort(int port) throws IllegalStateException {
+        //===========================
+        // HttpHostConnection methods
+        //===========================
+        public void setHttpConnectionManager(final HttpConnectionManager httpConnectionManager) {
             if (hasConnection()) {
-                wrappedConnection.setPort(port);
+                wrappedConnection.setHttpConnectionManager(httpConnectionManager);
             } else {
                 // do nothing
             }
         }
 
-        public void setProtocol(Protocol protocol) {
+        public boolean isLocked() {
             if (hasConnection()) {
-                wrappedConnection.setProtocol(protocol);
+                return wrappedConnection.isLocked();
             } else {
-                // do nothing
+                return false;
             }
         }
 
-        public void setProxyHost(String host) throws IllegalStateException {
+        public void setLocked(boolean locked) {
             if (hasConnection()) {
-                wrappedConnection.setProxyHost(host);
+                wrappedConnection.setLocked(locked);
             } else {
                 // do nothing
             }
         }
 
-        public void setProxyPort(int port) throws IllegalStateException {
-            if (hasConnection()) {
-                wrappedConnection.setProxyPort(port);
+        public void releaseConnection() {
+            HttpHostConnection conn = this.wrappedConnection;
+            if (conn != null && !conn.isLocked()) {
+                this.wrappedConnection = null;
+                conn.releaseConnection();
             } else {
                 // do nothing
             }
         }
 
-        /**
-         * @deprecated
-         */
-        public void setSoTimeout(int timeout)
-            throws SocketException, IllegalStateException {
+        public HostConfiguration getHostConfiguration() {
             if (hasConnection()) {
-                wrappedConnection.setSoTimeout(timeout);
+                return wrappedConnection.getHostConfiguration();
             } else {
-                // do nothing
+                return null;
             }
         }
 
-        /**
-         * @deprecated
-         */
-        public void shutdownOutput() {
+        public void open(final HttpParams params) throws IOException {
             if (hasConnection()) {
-                wrappedConnection.shutdownOutput();
+                wrappedConnection.open(params);
             } else {
                 // do nothing
             }
         }
 
-        public void tunnelCreated() throws IllegalStateException, IOException {
+        public void tunnelCreated(final HttpParams params) throws IOException {
             if (hasConnection()) {
-                wrappedConnection.tunnelCreated();
+                wrappedConnection.tunnelCreated(params);
             } else {
                 // do nothing
             }
         }
 
-        public void write(byte[] data, int offset, int length)
-            throws IOException, IllegalStateException {
-            if (hasConnection()) {
-                wrappedConnection.write(data, offset, length);
-            } else {
-                throw new IllegalStateException("Connection has been released");
-            }
-        }
-
-        public void write(byte[] data)
-            throws IOException, IllegalStateException {
-            if (hasConnection()) {
-                wrappedConnection.write(data);
-            } else {
-                throw new IllegalStateException("Connection has been released");
-            }
-        }
-
-        public void writeLine()
-            throws IOException, IllegalStateException {
-            if (hasConnection()) {
-                wrappedConnection.writeLine();
-            } else {
-                throw new IllegalStateException("Connection has been released");
-            }
-        }
-
-        public void writeLine(byte[] data)
-            throws IOException, IllegalStateException {
-            if (hasConnection()) {
-                wrappedConnection.writeLine(data);
-            } else {
-                throw new IllegalStateException("Connection has been released");
-            }
-        }
-
-        public void flushRequestOutputStream() throws IOException {
-            if (hasConnection()) {
-                wrappedConnection.flushRequestOutputStream();
-            } else {
-                throw new IllegalStateException("Connection has been released");
-            }
-        }
-
-        /**
-         * @deprecated
-         */
-        public int getSoTimeout() throws SocketException {
-            if (hasConnection()) {
-                return wrappedConnection.getSoTimeout();
-            } else {
-                throw new IllegalStateException("Connection has been released");
-            }
-        }
-
-        /**
-         * @deprecated
-         */
-        public String getVirtualHost() {
-            if (hasConnection()) {
-                return wrappedConnection.getVirtualHost();
-            } else {
-                throw new IllegalStateException("Connection has been released");
-            }
-        }
-
-        /**
-         * @deprecated
-         */
-        public void setVirtualHost(String host) throws IllegalStateException {
-            if (hasConnection()) {
-                wrappedConnection.setVirtualHost(host);
-            } else {
-                throw new IllegalStateException("Connection has been released");
-            }
-        }
-
-        public int getSendBufferSize() throws SocketException {
+        public void setSocketTimeout(int timeout) throws SocketException {
             if (hasConnection()) {
-                return wrappedConnection.getSendBufferSize();
-            } else {
-                throw new IllegalStateException("Connection has been released");
-            }
-        }
-
-        /**
-         * @deprecated
-         */
-        public void setSendBufferSize(int sendBufferSize) throws SocketException {
-            if (hasConnection()) {
-                wrappedConnection.setSendBufferSize(sendBufferSize);
-            } else {
-                throw new IllegalStateException("Connection has been released");
-            }
-        }
-
-        public HttpConnectionParams getParams() {
-            if (hasConnection()) {
-                return wrappedConnection.getParams();
-            } else {
-                throw new IllegalStateException("Connection has been released");
-            }
-        }
-
-        public void setParams(final HttpConnectionParams params) {
-            if (hasConnection()) {
-                wrappedConnection.setParams(params);
-            } else {
-                throw new IllegalStateException("Connection has been released");
-            }
-        }
-
-        /* (non-Javadoc)
-         * @see org.apache.commons.httpclient.HttpConnection#print(java.lang.String, java.lang.String)
-         */
-        public void print(String data, String charset) throws IOException, IllegalStateException {
-            if (hasConnection()) {
-                wrappedConnection.print(data, charset);
+                wrappedConnection.setSocketTimeout(timeout);
             } else {
-                throw new IllegalStateException("Connection has been released");
+                // do nothing
             }
         }
 
-        /* (non-Javadoc)
-         * @see org.apache.commons.httpclient.HttpConnection#printLine(java.lang.String, java.lang.String)
-         */
-        public void printLine(String data, String charset)
-            throws IOException, IllegalStateException {
+        public HttpResponse getLastResponse() {
             if (hasConnection()) {
-                wrappedConnection.printLine(data, charset);
+                return wrappedConnection.getLastResponse();
             } else {
-                throw new IllegalStateException("Connection has been released");
+                return null;
             }
         }
 
-        /* (non-Javadoc)
-         * @see org.apache.commons.httpclient.HttpConnection#setSocketTimeout(int)
-         */
-        public void setSocketTimeout(int timeout) throws SocketException, IllegalStateException {
+        public void setLastResponse(final HttpResponse response) {
             if (hasConnection()) {
-                wrappedConnection.setSocketTimeout(timeout);
+                wrappedConnection.setLastResponse(response);
             } else {
-                throw new IllegalStateException("Connection has been released");
+                // do nothing
             }
         }
-
+        
     }
 
 }

Modified: jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/conn/impl/SimpleHttpConnectionManager.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/conn/impl/SimpleHttpConnectionManager.java?view=diff&rev=486244&r1=486243&r2=486244
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/conn/impl/SimpleHttpConnectionManager.java (original)
+++ jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/conn/impl/SimpleHttpConnectionManager.java Tue Dec 12 09:17:57 2006
@@ -69,7 +69,7 @@
      * consume it now.
      * @param conn The connection
      */
-    private void finishLastResponse(DefaultHttpHostConnection conn) {
+    protected static void finishLastResponse(HttpHostConnection conn) {
         HttpResponse lastResponse = conn.getLastResponse();
         if (lastResponse != null) {
             conn.setLastResponse(null);
@@ -158,7 +158,8 @@
         HostConfiguration hostConfiguration, long timeout) {
 
         if (httpConnection == null) {
-            httpConnection = new DefaultHttpHostConnection(this);
+            httpConnection = new DefaultHttpHostConnection();
+            httpConnection.setHttpConnectionManager(this);
         } else {
             // make sure the host and proxy are correct for this connection
             // close it and set the values if they are not

Copied: jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/conn/params/HttpConnectionManagerParams.java (from r486176, jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/params/HttpConnectionManagerParams.java)
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/conn/params/HttpConnectionManagerParams.java?view=diff&rev=486244&p1=jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/params/HttpConnectionManagerParams.java&r1=486176&p2=jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/conn/params/HttpConnectionManagerParams.java&r2=486244
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/params/HttpConnectionManagerParams.java (original)
+++ jakarta/httpcomponents/httpclient/trunk/src/java/org/apache/http/conn/params/HttpConnectionManagerParams.java Tue Dec 12 09:17:57 2006
@@ -1,5 +1,5 @@
 /*
- * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//httpclient/src/java/org/apache/commons/httpclient/params/HttpConnectionManagerParams.java,v 1.9 2004/09/13 16:25:20 olegk Exp $
+ * $HeadURL$
  * $Revision$
  * $Date$
  *
@@ -28,29 +28,35 @@
  *
  */
 
-package org.apache.commons.httpclient.params;
+package org.apache.http.conn.params;
 
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.commons.httpclient.HostConfiguration;
-import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
+import org.apache.http.conn.HostConfiguration;
+import org.apache.http.params.HttpParams;
 
 /**
  * This class represents a collection of HTTP protocol parameters applicable to 
- * {@link org.apache.commons.httpclient.HttpConnectionManager HTTP connection managers}. 
+ * {@link HttpConnectionManager HTTP connection managers}. 
  * Protocol parameters may be linked together to form a hierarchy. If a particular 
  * parameter value has not been explicitly defined in the collection itself, its 
  * value will be drawn from the parent collection of parameters.
  * 
- * @author <a href="mailto:oleg@ural.ru">Oleg Kalnichevski</a>
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
  * @author Michael Becke
  * 
  * @version $Revision$
  * 
  * @since 3.0
  */
-public class HttpConnectionManagerParams extends HttpConnectionParams {
+public final class HttpConnectionManagerParams {
+
+    /** The default maximum number of connections allowed per host */
+    public static final int DEFAULT_MAX_HOST_CONNECTIONS = 2;   // Per RFC 2616 sec 8.1.4
+
+    /** The default maximum number of connections allowed overall */
+    public static final int DEFAULT_MAX_TOTAL_CONNECTIONS = 20;
 
     /** 
      * Defines the maximum number of connections allowed per host configuration. 
@@ -58,9 +64,9 @@
      * of HttpConnectionManager.
      * <p>
      * This parameter expects a value of type {@link java.util.Map}.  The value
-     * should map instances of {@link org.apache.commons.httpclient.HostConfiguration}
+     * should map instances of {@link HostConfiguration}
      * to {@link Integer integers}.  The default value can be specified using
-     * {@link org.apache.commons.httpclient.HostConfiguration#ANY_HOST_CONFIGURATION}.
+     * {@link HostConfiguration#ANY_HOST_CONFIGURATION}.
      * </p>
      */
     public static final String MAX_HOST_CONNECTIONS = "http.connection-manager.max-per-host";
@@ -82,8 +88,13 @@
      * 
      * @see #MAX_HOST_CONNECTIONS
      */
-    public void setDefaultMaxConnectionsPerHost(int maxHostConnections) {
-        setMaxConnectionsPerHost(HostConfiguration.ANY_HOST_CONFIGURATION, maxHostConnections);
+    public static void setDefaultMaxConnectionsPerHost(
+            final HttpParams params, 
+            int maxHostConnections) {
+        setMaxConnectionsPerHost(
+                params, 
+                HostConfiguration.ANY_HOST_CONFIGURATION, 
+                maxHostConnections);
     }
 
     /**
@@ -96,15 +107,19 @@
      * 
      * @see #MAX_HOST_CONNECTIONS
      */
-    public void setMaxConnectionsPerHost(
-        HostConfiguration hostConfiguration,
-        int maxHostConnections) {
+    public static void setMaxConnectionsPerHost(
+            final HttpParams params,
+            final HostConfiguration hostConfiguration,
+            int maxHostConnections) {
         
+        if (params == null) {
+            throw new IllegalArgumentException("HTTP parameters may not be null");
+        }
         if (maxHostConnections <= 0) {
             throw new IllegalArgumentException("maxHostConnections must be greater than 0");
         }
         
-        Map currentValues = (Map) getParameter(MAX_HOST_CONNECTIONS);
+        Map currentValues = (Map) params.getParameter(MAX_HOST_CONNECTIONS);
         // param values are meant to be immutable so we'll make a copy
         // to modify
         Map newValues = null;
@@ -114,7 +129,7 @@
             newValues = new HashMap(currentValues);
         }
         newValues.put(hostConfiguration, new Integer(maxHostConnections));
-        setParameter(MAX_HOST_CONNECTIONS, newValues);
+        params.setParameter(MAX_HOST_CONNECTIONS, newValues);
     }
     
     /**
@@ -125,8 +140,11 @@
      * 
      * @see #MAX_HOST_CONNECTIONS
      */
-    public int getDefaultMaxConnectionsPerHost() {
-        return getMaxConnectionsPerHost(HostConfiguration.ANY_HOST_CONFIGURATION);
+    public static int getDefaultMaxConnectionsPerHost(
+            final HttpParams params) {
+        return getMaxConnectionsPerHost(
+                params, 
+                HostConfiguration.ANY_HOST_CONFIGURATION);
     }
 
     /**
@@ -139,22 +157,27 @@
      * 
      * @see #MAX_HOST_CONNECTIONS
      */
-    public int getMaxConnectionsPerHost(HostConfiguration hostConfiguration) {
+    public static int getMaxConnectionsPerHost(
+            final HttpParams params,
+            final HostConfiguration hostConfiguration) {
         
-        Map m = (Map) getParameter(MAX_HOST_CONNECTIONS);
+        if (params == null) {
+            throw new IllegalArgumentException("HTTP parameters may not be null");
+        }
+        Map m = (Map) params.getParameter(MAX_HOST_CONNECTIONS);
         if (m == null) {
             // MAX_HOST_CONNECTIONS have not been configured, using the default value
-            return MultiThreadedHttpConnectionManager.DEFAULT_MAX_HOST_CONNECTIONS;
+            return DEFAULT_MAX_HOST_CONNECTIONS;
         } else {
             Integer max = (Integer) m.get(hostConfiguration);
             if (max == null && hostConfiguration != HostConfiguration.ANY_HOST_CONFIGURATION) {
                 // the value has not been configured specifically for this host config,
                 // use the default value
-                return getMaxConnectionsPerHost(HostConfiguration.ANY_HOST_CONFIGURATION);
+                return getMaxConnectionsPerHost(params, HostConfiguration.ANY_HOST_CONFIGURATION);
             } else {
                 return (
                         max == null 
-                        ? MultiThreadedHttpConnectionManager.DEFAULT_MAX_HOST_CONNECTIONS 
+                        ? DEFAULT_MAX_HOST_CONNECTIONS 
                         : max.intValue()
                     );
             }
@@ -168,8 +191,13 @@
      * 
      * @see #MAX_TOTAL_CONNECTIONS
      */
-    public void setMaxTotalConnections(int maxTotalConnections) {
-        setIntParameter(
+    public static void setMaxTotalConnections(
+            final HttpParams params,
+            int maxTotalConnections) {
+        if (params == null) {
+            throw new IllegalArgumentException("HTTP parameters may not be null");
+        }
+        params.setIntParameter(
             HttpConnectionManagerParams.MAX_TOTAL_CONNECTIONS,
             maxTotalConnections);
     }
@@ -181,10 +209,14 @@
      * 
      * @see #MAX_TOTAL_CONNECTIONS
      */
-    public int getMaxTotalConnections() {
-        return getIntParameter(
+    public static int getMaxTotalConnections(
+            final HttpParams params) {
+        if (params == null) {
+            throw new IllegalArgumentException("HTTP parameters may not be null");
+        }
+        return params.getIntParameter(
             HttpConnectionManagerParams.MAX_TOTAL_CONNECTIONS,
-            MultiThreadedHttpConnectionManager.DEFAULT_MAX_TOTAL_CONNECTIONS);
+            DEFAULT_MAX_TOTAL_CONNECTIONS);
     }
 
 }



Mime
View raw message