|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.commons.httpclient.MultiThreadedHttpConnectionManager
public class MultiThreadedHttpConnectionManager
Manages a set of HttpConnections for various HostConfigurations.
Field Summary | |
---|---|
static int |
DEFAULT_MAX_HOST_CONNECTIONS
The default maximum number of connections allowed per host |
static int |
DEFAULT_MAX_TOTAL_CONNECTIONS
The default maximum number of connections allowed overall |
Constructor Summary | |
---|---|
MultiThreadedHttpConnectionManager()
No-args constructor |
Method Summary | |
---|---|
void |
closeIdleConnections(long idleTimeout)
Closes connections that have been idle for at least the given amount of time. |
void |
deleteClosedConnections()
Deletes all closed connections. |
HttpConnection |
getConnection(HostConfiguration hostConfiguration)
Gets an HttpConnection for a given host configuration. |
HttpConnection |
getConnection(HostConfiguration hostConfiguration,
long timeout)
Deprecated. Use #getConnectionWithTimeout(HostConfiguration, long) |
int |
getConnectionsInPool()
Gets the total number of pooled connections. |
int |
getConnectionsInPool(HostConfiguration hostConfiguration)
Gets the total number of pooled connections for the given host configuration. |
int |
getConnectionsInUse()
Deprecated. Use getConnectionsInPool() |
int |
getConnectionsInUse(HostConfiguration hostConfiguration)
Deprecated. Use getConnectionsInPool(HostConfiguration) |
HttpConnection |
getConnectionWithTimeout(HostConfiguration hostConfiguration,
long timeout)
Gets a connection or waits if one is not available. |
int |
getMaxConnectionsPerHost()
Deprecated. Use HttpConnectionManagerParams.getDefaultMaxConnectionsPerHost() ,
HttpConnectionManager.getParams() . |
int |
getMaxTotalConnections()
Deprecated. Use HttpConnectionManagerParams.getMaxTotalConnections() ,
HttpConnectionManager.getParams() . |
HttpConnectionManagerParams |
getParams()
Returns parameters associated
with this connection manager. |
boolean |
isConnectionStaleCheckingEnabled()
Deprecated. Use HttpConnectionParams.isStaleCheckingEnabled() ,
HttpConnectionManager.getParams() . |
void |
releaseConnection(HttpConnection conn)
Make the given HttpConnection available for use by other requests. |
void |
setConnectionStaleCheckingEnabled(boolean connectionStaleCheckingEnabled)
Deprecated. Use HttpConnectionParams.setStaleCheckingEnabled(boolean) ,
HttpConnectionManager.getParams() . |
void |
setMaxConnectionsPerHost(int maxHostConnections)
Deprecated. Use HttpConnectionManagerParams.setDefaultMaxConnectionsPerHost(int) ,
HttpConnectionManager.getParams() . |
void |
setMaxTotalConnections(int maxTotalConnections)
Deprecated. Use HttpConnectionManagerParams.setMaxTotalConnections(int) ,
HttpConnectionManager.getParams() . |
void |
setParams(HttpConnectionManagerParams params)
Assigns parameters for this
connection manager. |
void |
shutdown()
Shuts down the connection manager and releases all resources. |
static void |
shutdownAll()
Shuts down and cleans up resources used by all instances of MultiThreadedHttpConnectionManager. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_MAX_HOST_CONNECTIONS
public static final int DEFAULT_MAX_TOTAL_CONNECTIONS
Constructor Detail |
---|
public MultiThreadedHttpConnectionManager()
Method Detail |
---|
public static void shutdownAll()
shutdown()
is called on all live instances of
MultiThreadedHttpConnectionManager.
shutdown()
public void shutdown()
The connection manager can no longer be used once shut down.
Calling this method more than once will have no effect.
public boolean isConnectionStaleCheckingEnabled()
HttpConnectionParams.isStaleCheckingEnabled()
,
HttpConnectionManager.getParams()
.
true
if stale checking will be enabled on HttpConnectionsHttpConnection.isStaleCheckingEnabled()
public void setConnectionStaleCheckingEnabled(boolean connectionStaleCheckingEnabled)
HttpConnectionParams.setStaleCheckingEnabled(boolean)
,
HttpConnectionManager.getParams()
.
connectionStaleCheckingEnabled
- true
if stale checking will be enabled
on HttpConnectionsHttpConnection.setStaleCheckingEnabled(boolean)
public void setMaxConnectionsPerHost(int maxHostConnections)
HttpConnectionManagerParams.setDefaultMaxConnectionsPerHost(int)
,
HttpConnectionManager.getParams()
.
maxHostConnections
- the number of connections allowed for each
hostConfigurationpublic int getMaxConnectionsPerHost()
HttpConnectionManagerParams.getDefaultMaxConnectionsPerHost()
,
HttpConnectionManager.getParams()
.
public void setMaxTotalConnections(int maxTotalConnections)
HttpConnectionManagerParams.setMaxTotalConnections(int)
,
HttpConnectionManager.getParams()
.
maxTotalConnections
- the maximum number of connections allowedpublic int getMaxTotalConnections()
HttpConnectionManagerParams.getMaxTotalConnections()
,
HttpConnectionManager.getParams()
.
public HttpConnection getConnection(HostConfiguration hostConfiguration)
HttpConnectionManager
getConnection
in interface HttpConnectionManager
hostConfiguration
- the host configuration to use to configure the
connection
HttpConnectionManager.getConnection(HostConfiguration)
public HttpConnection getConnectionWithTimeout(HostConfiguration hostConfiguration, long timeout) throws ConnectionPoolTimeoutException
getConnectionWithTimeout
in interface HttpConnectionManager
hostConfiguration
- The host configuration specifying the connection
details.timeout
- the number of milliseconds to wait for a connection, 0 to
wait indefinitely
HttpException
- if a connection does not become available in
'timeout' milliseconds
ConnectionPoolTimeoutException
- if no connection becomes available before the
timeout expiresHttpConnection.setHttpConnectionManager(HttpConnectionManager)
public HttpConnection getConnection(HostConfiguration hostConfiguration, long timeout) throws HttpException
HttpConnectionManager
getConnection
in interface HttpConnectionManager
hostConfiguration
- the host configuration to use to configure the
connectiontimeout
- - the time (in milliseconds) to wait for a connection to
become available, 0 to specify an infinite timeout
HttpException
- if no connection becomes available before the
timeout expiresHttpConnectionManager.getConnection(HostConfiguration, long)
public int getConnectionsInPool(HostConfiguration hostConfiguration)
maximum number of connections per
host
.
hostConfiguration
- The host configuration
public int getConnectionsInPool()
maximum number of connections
.
public int getConnectionsInUse(HostConfiguration hostConfiguration)
getConnectionsInPool(HostConfiguration)
hostConfiguration
- the key that connections are tracked on
public int getConnectionsInUse()
getConnectionsInPool()
public void deleteClosedConnections()
HttpConnection.isOpen()
public void closeIdleConnections(long idleTimeout)
HttpConnectionManager
closeIdleConnections
in interface HttpConnectionManager
idleTimeout
- the minimum idle time, in milliseconds, for connections to be closedpublic void releaseConnection(HttpConnection conn)
releaseConnection
in interface HttpConnectionManager
conn
- the HttpConnection to make available.public HttpConnectionManagerParams getParams()
parameters
associated
with this connection manager.
getParams
in interface HttpConnectionManager
HttpConnectionManagerParams
public void setParams(HttpConnectionManagerParams params)
parameters
for this
connection manager.
setParams
in interface HttpConnectionManager
HttpConnectionManagerParams
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |