Index: examples/ClientApp.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/examples/ClientApp.java,v retrieving revision 1.12 diff -u -r1.12 ClientApp.java --- examples/ClientApp.java 3 Oct 2003 20:57:35 -0000 1.12 +++ examples/ClientApp.java 25 Oct 2003 11:37:12 -0000 @@ -121,7 +121,8 @@ public HttpClientFrame() { client = new HttpClient(new MultiThreadedHttpConnectionManager()); - client.getParams().setConnectionTimeout(30000); + client.getHttpConnectionManager(). + getParams().setConnectionTimeout(30000); JPanel panInput = new JPanel(new FlowLayout()); Index: examples/CookieDemoApp.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/examples/CookieDemoApp.java,v retrieving revision 1.12 diff -u -r1.12 CookieDemoApp.java --- examples/CookieDemoApp.java 20 Oct 2003 22:17:11 -0000 1.12 +++ examples/CookieDemoApp.java 25 Oct 2003 11:37:13 -0000 @@ -111,7 +111,8 @@ // Get HTTP client instance HttpClient httpclient = new HttpClient(); - httpclient.getParams().setConnectionTimeout(30000); + httpclient.getHttpConnectionManager(). + getParams().setConnectionTimeout(30000); httpclient.setState(initialState); // RFC 2101 cookie management spec is used per default Index: examples/MultipartFileUploadApp.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/examples/MultipartFileUploadApp.java,v retrieving revision 1.7 diff -u -r1.7 MultipartFileUploadApp.java --- examples/MultipartFileUploadApp.java 3 Oct 2003 20:57:35 -0000 1.7 +++ examples/MultipartFileUploadApp.java 25 Oct 2003 11:37:15 -0000 @@ -188,7 +188,8 @@ appendMessage("Uploading " + targetFile.getName() + " to " + targetURL); filePost.addParameter(targetFile.getName(), targetFile); HttpClient client = new HttpClient(); - client.getParams().setConnectionTimeout(5000); + client.getHttpConnectionManager(). + getParams().setConnectionTimeout(5000); int status = client.executeMethod(filePost); if (status == HttpStatus.SC_OK) { appendMessage( Index: examples/TrivialApp.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/examples/TrivialApp.java,v retrieving revision 1.14 diff -u -r1.14 TrivialApp.java --- examples/TrivialApp.java 3 Oct 2003 20:57:35 -0000 1.14 +++ examples/TrivialApp.java 25 Oct 2003 11:37:16 -0000 @@ -110,7 +110,8 @@ HttpClient client = new HttpClient(); //establish a connection within 5 seconds - client.getParams().setConnectionTimeout(5000); + client.getHttpConnectionManager(). + getParams().setConnectionTimeout(5000); //set the default credentials if (creds != null) { Index: java/org/apache/commons/httpclient/HttpClient.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpClient.java,v retrieving revision 1.87 diff -u -r1.87 HttpClient.java --- java/org/apache/commons/httpclient/HttpClient.java 22 Oct 2003 19:31:00 -0000 1.87 +++ java/org/apache/commons/httpclient/HttpClient.java 25 Oct 2003 11:37:19 -0000 @@ -296,12 +296,12 @@ * * @param newTimeoutInMilliseconds Timeout in milliseconds * - * @deprecated Use {@link HttpClientParams#setSoTimeout(int)}, - * {@link HttpClient#getParams()}. + * @deprecated Use {@link HttpConnectionManagerParams#setSoTimeout(int)}, + * {@link HttpConnectionManager#getParams()}. * */ public synchronized void setTimeout(int newTimeoutInMilliseconds) { - this.params.setSoTimeout(newTimeoutInMilliseconds); + this.httpConnectionManager.getParams().setSoTimeout(newTimeoutInMilliseconds); } /** @@ -327,11 +327,11 @@ * @see HttpConnection#setConnectionTimeout(int) * @param newTimeoutInMilliseconds Timeout in milliseconds. * - * @deprecated Use {@link HttpClientParams#setConnectionTimeout(int)}, - * {@link HttpClient#getParams()}. + * @deprecated Use {@link HttpConnectionManagerParams#setConnectionTimeout(int)}, + * {@link HttpConnectionManager#getParams()}. */ public synchronized void setConnectionTimeout(int newTimeoutInMilliseconds) { - this.params.setConnectionTimeout(newTimeoutInMilliseconds); + this.httpConnectionManager.getParams().setConnectionTimeout(newTimeoutInMilliseconds); } // --------------------------------------------------------- Public Methods Index: java/org/apache/commons/httpclient/MultiThreadedHttpConnectionManager.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/MultiThreadedHttpConnectionManager.java,v retrieving revision 1.26 diff -u -r1.26 MultiThreadedHttpConnectionManager.java --- java/org/apache/commons/httpclient/MultiThreadedHttpConnectionManager.java 22 Oct 2003 19:31:00 -0000 1.26 +++ java/org/apache/commons/httpclient/MultiThreadedHttpConnectionManager.java 25 Oct 2003 11:37:26 -0000 @@ -111,12 +111,6 @@ */ private HttpConnectionManagerParams params = new HttpConnectionManagerParams(); - /** Maximum number of connections allowed per host */ - private int maxHostConnections = DEFAULT_MAX_HOST_CONNECTIONS; - - /** Maximum number of connections allowed overall */ - private int maxTotalConnections = DEFAULT_MAX_TOTAL_CONNECTIONS; - /** Connection Pool */ private ConnectionPool connectionPool; @@ -177,9 +171,14 @@ * * @param maxHostConnections the number of connections allowed for each * hostConfiguration + * + * @deprecated Use {@link HttpConnectionManagerParams#MAX_HOST_CONNECTIONS}, + * {@link HttpConnectionManager#getParams()}. */ public void setMaxConnectionsPerHost(int maxHostConnections) { - this.maxHostConnections = maxHostConnections; + this.params.setIntParameter( + HttpConnectionManagerParams.MAX_HOST_CONNECTIONS, + maxHostConnections); } /** @@ -188,27 +187,42 @@ * * @return The maximum number of connections allowed for a given * hostConfiguration. + * + * @deprecated Use {@link HttpConnectionManagerParams#MAX_HOST_CONNECTIONS}, + * {@link HttpConnectionManager#getParams()}. */ public int getMaxConnectionsPerHost() { - return maxHostConnections; + return this.params.getIntParameter( + HttpConnectionManagerParams.MAX_HOST_CONNECTIONS, + DEFAULT_MAX_HOST_CONNECTIONS); } /** * Sets the maximum number of connections allowed in the system. * * @param maxTotalConnections the maximum number of connections allowed + * + * @deprecated Use {@link HttpConnectionManagerParams#MAX_TOTAL_CONNECTIONS}, + * {@link HttpConnectionManager#getParams()}. */ public void setMaxTotalConnections(int maxTotalConnections) { - this.maxTotalConnections = maxTotalConnections; + this.params.setIntParameter( + HttpConnectionManagerParams.MAX_TOTAL_CONNECTIONS, + maxTotalConnections); } /** * Gets the maximum number of connections allowed in the system. * * @return The maximum number of connections allowed + * + * @deprecated Use {@link HttpConnectionManagerParams#MAX_TOTAL_CONNECTIONS}, + * {@link HttpConnectionManager#getParams()}. */ public int getMaxTotalConnections() { - return maxTotalConnections; + return this.params.getIntParameter( + HttpConnectionManagerParams.MAX_TOTAL_CONNECTIONS, + DEFAULT_MAX_TOTAL_CONNECTIONS); } /** @@ -291,6 +305,13 @@ HttpConnection connection = null; + int maxHostConnections = this.params.getIntParameter( + HttpConnectionManagerParams.MAX_HOST_CONNECTIONS, + DEFAULT_MAX_HOST_CONNECTIONS); + int maxTotalConnections = this.params.getIntParameter( + HttpConnectionManagerParams.MAX_TOTAL_CONNECTIONS, + DEFAULT_MAX_TOTAL_CONNECTIONS); + synchronized (connectionPool) { // we clone the hostConfiguration Index: java/org/apache/commons/httpclient/params/HttpClientParams.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/params/HttpClientParams.java,v retrieving revision 1.2 diff -u -r1.2 HttpClientParams.java --- java/org/apache/commons/httpclient/params/HttpClientParams.java 23 Sep 2003 19:51:49 -0000 1.2 +++ java/org/apache/commons/httpclient/params/HttpClientParams.java 25 Oct 2003 11:37:28 -0000 @@ -83,21 +83,6 @@ private static final Log LOG = LogFactory.getLog(HttpParams.class); /** - * Sets the socket timeout (SO_TIMEOUT) in milliseconds which is the - * timeout for waiting for data. A timeout value of zero is interpreted as an - * infinite timeout. - * This parameter expects a value of type {@link Integer}. - */ - public static final String SO_TIMEOUT = "http.socket.timeout"; - - /** - * Sets the timeout until a connection is etablished. A value of zero - * means the timeout is not used. The default value is zero. - * This parameter expects a value of type {@link Integer}. - */ - public static final String CONNECTION_TIMEOUT = "http.connection.timeout"; - - /** * Sets the timeout in milliseconds used when retrieving an * {@link org.apache.commons.httpclient.HttpConnection HTTP connection} from the * {@link org.apache.commons.httpclient.HttpConnectionManager HTTP connection manager}. @@ -150,48 +135,6 @@ */ public HttpClientParams(HttpParams defaults) { super(defaults); - } - - /** - * Returns the socket timeout (SO_TIMEOUT) in milliseconds which is the - * timeout for waiting for data. A timeout value of zero is interpreted as an - * infinite timeout. - * - * @return timeout in milliseconds - */ - public int getSoTimeout() { - return getIntParameter(SO_TIMEOUT, 0); - } - - /** - * Sets the socket timeout (SO_TIMEOUT) in milliseconds which is the - * timeout for waiting for data. A timeout value of zero is interpreted as an - * infinite timeout. - * - * @param timeout Timeout in milliseconds - */ - public void setSoTimeout(int timeout) { - setIntParameter(SO_TIMEOUT, timeout); - } - - /** - * Returns the timeout until a connection is etablished. A value of zero - * means the timeout is not used. The default value is zero. - * - * @return timeout in milliseconds. - */ - public int getConnectionTimeout() { - return getIntParameter(CONNECTION_TIMEOUT, 0); - } - - /** - * Sets the timeout until a connection is etablished. A value of zero - * means the timeout is not used. The default value is zero. - * - * @param timeout Timeout in milliseconds. - */ - public void setConnectionTimeout(int timeout) { - setIntParameter(CONNECTION_TIMEOUT, timeout); } /** Index: java/org/apache/commons/httpclient/params/HttpConnectionManagerParams.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/params/HttpConnectionManagerParams.java,v retrieving revision 1.1 diff -u -r1.1 HttpConnectionManagerParams.java --- java/org/apache/commons/httpclient/params/HttpConnectionManagerParams.java 22 Oct 2003 19:35:33 -0000 1.1 +++ java/org/apache/commons/httpclient/params/HttpConnectionManagerParams.java 25 Oct 2003 11:37:29 -0000 @@ -75,4 +75,21 @@ * @version $Revision: 1.1 $ */ public class HttpConnectionManagerParams extends HttpConnectionParams { + + /** + * Defines the maximum number of connections allowed per host + *

+ * This parameter expects a value of type {@link Integer}. + *

+ */ + public static String MAX_HOST_CONNECTIONS = "http.connection-mananer.max-per-host"; + + /** + * Defines the maximum number of connections allowed overall + *

+ * This parameter expects a value of type {@link Integer}. + *

+ */ + public static String MAX_TOTAL_CONNECTIONS = "http.connection-mananer.max-total"; + } Index: test/org/apache/commons/httpclient/TestHttpConnection.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestHttpConnection.java,v retrieving revision 1.12 diff -u -r1.12 TestHttpConnection.java --- test/org/apache/commons/httpclient/TestHttpConnection.java 22 Oct 2003 19:31:00 -0000 1.12 +++ test/org/apache/commons/httpclient/TestHttpConnection.java 25 Oct 2003 11:37:31 -0000 @@ -129,7 +129,7 @@ connectionManager.setConnection(new HttpConnection(getHost(), getPort(), testProtocol)); HttpClient client = createHttpClient(connectionManager); client.getHostConfiguration().setHost(getHost(), getPort(), testProtocol); - client.getParams().setConnectionTimeout(1); + client.getHttpConnectionManager().getParams().setConnectionTimeout(1); try { GetMethod get = new GetMethod(); Index: test/org/apache/commons/httpclient/TestHttpConnectionManager.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestHttpConnectionManager.java,v retrieving revision 1.11 diff -u -r1.11 TestHttpConnectionManager.java --- test/org/apache/commons/httpclient/TestHttpConnectionManager.java 3 Oct 2003 20:57:36 -0000 1.11 +++ test/org/apache/commons/httpclient/TestHttpConnectionManager.java 25 Oct 2003 11:37:34 -0000 @@ -71,6 +71,7 @@ import junit.framework.TestSuite; import org.apache.commons.httpclient.methods.GetMethod; +import org.apache.commons.httpclient.params.HttpConnectionManagerParams; import org.apache.commons.httpclient.protocol.Protocol; import org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory; @@ -102,17 +103,6 @@ // ----------------------------------------------------------- Test Methods - // Test the accessor methods - public void testMaxConnectionsAccessors() { - MultiThreadedHttpConnectionManager mgr = new MultiThreadedHttpConnectionManager(); - - // First test the default value - assertEquals("Default MaxConnections", 2, mgr.getMaxConnectionsPerHost()); - - mgr.setMaxConnectionsPerHost(10); - assertEquals("MaxConnections", 10, mgr.getMaxConnectionsPerHost()); - } - /** * Test that the ConnectMethod correctly releases connections when * CONNECT fails. @@ -120,7 +110,8 @@ public void testConnectMethodFailureRelease() { MultiThreadedHttpConnectionManager mgr = new MultiThreadedHttpConnectionManager(); - mgr.setMaxTotalConnections(1); + mgr.getParams().setIntParameter( + HttpConnectionManagerParams.MAX_TOTAL_CONNECTIONS, 1); HttpClient client = createHttpClient(mgr); // we're going to execute a connect method against the localhost, assuming @@ -226,7 +217,8 @@ public void testReleaseConnection() { MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); - connectionManager.setMaxConnectionsPerHost(1); + connectionManager.getParams().setIntParameter( + HttpConnectionManagerParams.MAX_HOST_CONNECTIONS, 1); HttpClient client = createHttpClient(connectionManager); // we shouldn't have to wait if a connection is available @@ -275,7 +267,8 @@ public void testResponseAutoRelease() { MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); - connectionManager.setMaxConnectionsPerHost(1); + connectionManager.getParams().setIntParameter( + HttpConnectionManagerParams.MAX_HOST_CONNECTIONS, 1); HttpClient client = createHttpClient(connectionManager); // we shouldn't have to wait if a connection is available @@ -312,8 +305,10 @@ public void testConnectionReclaiming() { MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); - connectionManager.setMaxConnectionsPerHost(1); - connectionManager.setMaxTotalConnections(1); + connectionManager.getParams().setIntParameter( + HttpConnectionManagerParams.MAX_HOST_CONNECTIONS, 1); + connectionManager.getParams().setIntParameter( + HttpConnectionManagerParams.MAX_TOTAL_CONNECTIONS, 1); HostConfiguration host1 = new HostConfiguration(); host1.setHost("host1", -1, "http"); @@ -342,8 +337,10 @@ public void testMaxConnections() { MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); - connectionManager.setMaxConnectionsPerHost(1); - connectionManager.setMaxTotalConnections(2); + connectionManager.getParams().setIntParameter( + HttpConnectionManagerParams.MAX_HOST_CONNECTIONS, 1); + connectionManager.getParams().setIntParameter( + HttpConnectionManagerParams.MAX_TOTAL_CONNECTIONS, 2); HostConfiguration host1 = new HostConfiguration(); host1.setHost("host1", -1, "http"); @@ -378,8 +375,10 @@ public void testHostReusePreference() { final MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); - connectionManager.setMaxConnectionsPerHost(1); - connectionManager.setMaxTotalConnections(1); + connectionManager.getParams().setIntParameter( + HttpConnectionManagerParams.MAX_HOST_CONNECTIONS, 1); + connectionManager.getParams().setIntParameter( + HttpConnectionManagerParams.MAX_TOTAL_CONNECTIONS, 1); final HostConfiguration host1 = new HostConfiguration(); host1.setHost("host1", -1, "http"); @@ -426,7 +425,8 @@ public void testMaxConnectionsPerServer() { MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); - connectionManager.setMaxConnectionsPerHost(1); + connectionManager.getParams().setIntParameter( + HttpConnectionManagerParams.MAX_HOST_CONNECTIONS, 1); HttpClient client = createHttpClient(connectionManager); // we shouldn't have to wait if a connection is available @@ -458,7 +458,8 @@ public void testReclaimUnusedConnection() { MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); - connectionManager.setMaxConnectionsPerHost(1); + connectionManager.getParams().setIntParameter( + HttpConnectionManagerParams.MAX_TOTAL_CONNECTIONS, 1); HttpClient client = createHttpClient(connectionManager); // we shouldn't have to wait if a connection is available @@ -520,7 +521,8 @@ public void testTimeout() { MultiThreadedHttpConnectionManager mgr = new MultiThreadedHttpConnectionManager(); - mgr.setMaxConnectionsPerHost(2); + mgr.getParams().setIntParameter( + HttpConnectionManagerParams.MAX_HOST_CONNECTIONS, 2); try{ HostConfiguration hostConfig = new HostConfiguration();