1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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 }