View Javadoc

1   /*
2    * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//httpclient/src/java/org/apache/commons/httpclient/HttpConnectionManager.java,v 1.24 2004/07/05 22:46:58 olegk Exp $
3    * $Revision: 155418 $
4    * $Date: 2005-02-26 08:01:52 -0500 (Sat, 26 Feb 2005) $
5    *
6    * ====================================================================
7    *
8    *  Copyright 1999-2004 The Apache Software Foundation
9    *
10   *  Licensed under the Apache License, Version 2.0 (the "License");
11   *  you may not use this file except in compliance with the License.
12   *  You may obtain a copy of the License at
13   *
14   *      http://www.apache.org/licenses/LICENSE-2.0
15   *
16   *  Unless required by applicable law or agreed to in writing, software
17   *  distributed under the License is distributed on an "AS IS" BASIS,
18   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19   *  See the License for the specific language governing permissions and
20   *  limitations under the License.
21   * ====================================================================
22   *
23   * This software consists of voluntary contributions made by many
24   * individuals on behalf of the Apache Software Foundation.  For more
25   * information on the Apache Software Foundation, please see
26   * <http://www.apache.org/>.
27   *
28   */
29  
30  package org.apache.commons.httpclient;
31  
32  import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
33  
34  /***
35   * An interface for classes that manage HttpConnections.
36   * 
37   * @see org.apache.commons.httpclient.HttpConnection
38   * @see org.apache.commons.httpclient.HttpClient#HttpClient(HttpConnectionManager)
39   *
40   * @author Michael Becke
41   * @author <a href="mailto:mbowler@GargoyleSoftware.com">Mike Bowler</a>
42   * @author <a href="mailto:oleg@ural.ru">Oleg Kalnichevski</a>
43   * 
44   * @since 2.0
45   */
46  public interface HttpConnectionManager {
47  
48      /***
49       * Gets an HttpConnection for a given host configuration. If a connection is
50       * not available this method will block until one is.
51       *
52       * The connection manager should be registered with any HttpConnection that
53       * is created.
54       *
55       * @param hostConfiguration the host configuration to use to configure the
56       * connection
57       * 
58       * @return an HttpConnection for the given configuration
59       * 
60       * @see HttpConnection#setHttpConnectionManager(HttpConnectionManager)
61       */
62      HttpConnection getConnection(HostConfiguration hostConfiguration);
63  
64      /***
65       * Gets an HttpConnection for a given host configuration. If a connection is
66       * not available, this method will block for at most the specified number of
67       * milliseconds or until a connection becomes available.
68       *
69       * The connection manager should be registered with any HttpConnection that
70       * is created.
71       *
72       * @param hostConfiguration the host configuration to use to configure the
73       * connection
74       * @param timeout - the time (in milliseconds) to wait for a connection to
75       * become available, 0 to specify an infinite timeout
76       * 
77       * @return an HttpConnection for the given configuraiton
78       * 
79       * @throws HttpException if no connection becomes available before the
80       * timeout expires
81       * 
82       * @see HttpConnection#setHttpConnectionManager(HttpConnectionManager)
83       * 
84       * @deprecated Use #getConnectionWithTimeout(HostConfiguration, long) 
85       */
86      HttpConnection getConnection(HostConfiguration hostConfiguration, long timeout)
87          throws HttpException;
88  
89  	/***
90  	 * Gets an HttpConnection for a given host configuration. If a connection is
91  	 * not available, this method will block for at most the specified number of
92  	 * milliseconds or until a connection becomes available.
93  	 *
94  	 * The connection manager should be registered with any HttpConnection that
95  	 * is created.
96  	 *
97  	 * @param hostConfiguration the host configuration to use to configure the
98  	 * connection
99  	 * @param timeout - the time (in milliseconds) to wait for a connection to
100 	 * become available, 0 to specify an infinite timeout
101 	 * 
102 	 * @return an HttpConnection for the given configuraiton
103 	 * 
104 	 * @throws ConnectionPoolTimeoutException if no connection becomes available before the
105 	 * timeout expires
106 	 * 
107 	 * @see HttpConnection#setHttpConnectionManager(HttpConnectionManager)
108      * 
109      * @since 3.0
110 	 */
111 	HttpConnection getConnectionWithTimeout(HostConfiguration hostConfiguration, long timeout)
112 		throws ConnectionPoolTimeoutException;
113 
114     /***
115      * Releases the given HttpConnection for use by other requests.
116      *
117      * @param conn - The HttpConnection to make available.
118      */
119     void releaseConnection(HttpConnection conn);
120 
121     /***
122      * Closes connections that have been idle for at least the given amount of time.  Only
123      * connections that are currently owned, not checked out, are subject to idle timeouts.
124      * 
125      * @param idleTimeout the minimum idle time, in milliseconds, for connections to be closed
126      * 
127      * @since 3.0
128      */
129     void closeIdleConnections(long idleTimeout);
130     
131     /***
132      * Returns {@link HttpConnectionManagerParams parameters} associated 
133      * with this connection manager.
134      * 
135      * @since 3.0
136      * 
137      * @see HttpConnectionManagerParams
138      */
139     HttpConnectionManagerParams getParams();
140 
141     /***
142      * Assigns {@link HttpConnectionManagerParams parameters} for this 
143      * connection manager.
144      * 
145      * @since 3.0
146      * 
147      * @see HttpConnectionManagerParams
148      */
149     void setParams(final HttpConnectionManagerParams params);
150 }