org.apache.commons.httpclient

Interface HttpConnectionManager

Known Implementing Classes:
MultiThreadedHttpConnectionManager, SimpleHttpConnectionManager

public interface HttpConnectionManager

An interface for classes that manage HttpConnections.
Since:
2.0
See Also:
HttpConnection, HttpClient.HttpClient(HttpConnectionManager)

Method Summary

void
closeIdleConnections(long idleTimeout)
Closes connections that have been idle for at least the given amount of time.
HttpConnection
getConnection(HostConfiguration hostConfiguration)
Gets an HttpConnection for a given host configuration.
HttpConnection
getConnection(HostConfiguration hostConfiguration, long timeout)
Deprecated. Use #getConnectionWithTimeout(HostConfiguration, long)
HttpConnection
getConnectionWithTimeout(HostConfiguration hostConfiguration, long timeout)
Gets an HttpConnection for a given host configuration.
HttpConnectionManagerParams
getParams()
Returns parameters associated with this connection manager.
void
releaseConnection(HttpConnection conn)
Releases the given HttpConnection for use by other requests.
void
setParams(HttpConnectionManagerParams params)
Assigns parameters for this connection manager.

Method Details

closeIdleConnections

public void closeIdleConnections(long idleTimeout)
Closes connections that have been idle for at least the given amount of time. Only connections that are currently owned, not checked out, are subject to idle timeouts.
Parameters:
idleTimeout - the minimum idle time, in milliseconds, for connections to be closed
Since:
3.0
Usages and Demos :

View More Examples of closeIdleConnections(long idleTimeout)
   1: 
   2: import org.apache.commons.httpclient.HttpConnectionManager;
   3: 
   4:         ...
   5:     
   6:     public synchronized void addConnectionManager(HttpConnectionManager connectionManager) {
   7:         if (shutdown) {
   8:         ...
   9:     
  10:     public synchronized void removeConnectionManager(HttpConnectionManager connectionManager) {
  11:         if (shutdown) {
  12:         ...
  13:     protected void handleCloseIdleConnections(HttpConnectionManager connectionManager) {
  14:         connectionManager.closeIdleConnections(connectionTimeout);

View Full Code Here

getConnection

public HttpConnection getConnection(HostConfiguration hostConfiguration)
Gets an HttpConnection for a given host configuration. If a connection is not available this method will block until one is. The connection manager should be registered with any HttpConnection that is created.
Parameters:
hostConfiguration - the host configuration to use to configure the connection
Returns:
an HttpConnection for the given configuration

getConnection

public HttpConnection getConnection(HostConfiguration hostConfiguration,
                                    long timeout)
            throws HttpException

Deprecated. Use #getConnectionWithTimeout(HostConfiguration, long)

Gets an HttpConnection for a given host configuration. If a connection is not available, this method will block for at most the specified number of milliseconds or until a connection becomes available. The connection manager should be registered with any HttpConnection that is created.
Parameters:
hostConfiguration - the host configuration to use to configure the connection
timeout - - the time (in milliseconds) to wait for a connection to become available, 0 to specify an infinite timeout
Returns:
an HttpConnection for the given configuraiton
Throws:
HttpException - if no connection becomes available before the timeout expires

getConnectionWithTimeout

public HttpConnection getConnectionWithTimeout(HostConfiguration hostConfiguration,
                                               long timeout)
            throws ConnectionPoolTimeoutException
Gets an HttpConnection for a given host configuration. If a connection is not available, this method will block for at most the specified number of milliseconds or until a connection becomes available. The connection manager should be registered with any HttpConnection that is created.
Parameters:
hostConfiguration - the host configuration to use to configure the connection
timeout - - the time (in milliseconds) to wait for a connection to become available, 0 to specify an infinite timeout
Returns:
an HttpConnection for the given configuraiton
Throws:
ConnectionPoolTimeoutException - if no connection becomes available before the timeout expires
Since:
3.0

getParams

public HttpConnectionManagerParams getParams()
Returns parameters associated with this connection manager.
Since:
3.0
Usages and Demos :

View More Examples of getParams()
   1: import org.apache.commons.httpclient.HttpClient;
   2: import org.apache.commons.httpclient.HttpConnectionManager;
   3: import org.apache.commons.httpclient.HttpException;
   4:         ...
   5:     public void start() throws InterruptedException {
   6:         HttpConnectionManager connectionManager = 
   7:                     new MultiThreadedHttpConnectionManager();
   8:         ...
   9:                     
  10:         HttpConnectionManagerParams params = connectionManager.getParams();
  11:         params.setIntParameter( HttpConnectionManagerParams.MAX_HOST_CONNECTIONS, 2 );

View Full Code Here
   1: import org.apache.commons.httpclient.HttpConnection;
   2: import org.apache.commons.httpclient.HttpConnectionManager;
   3: import org.apache.commons.httpclient.HttpException;
   4:         ...
   5:         
   6:         method.getParams().setCookiePolicy(
   7:             (((Boolean)getUncheckedAttribute(curi, ATTR_IGNORE_COOKIES)).
   8:         ...
   9: 
  10:         method.getParams().setVersion(HttpVersion.HTTP_1_0);
  11: 
  12:         ...
  13:         
  14:         method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,

View Full Code Here

releaseConnection

public void releaseConnection(HttpConnection conn)
Releases the given HttpConnection for use by other requests.
Parameters:
conn - - The HttpConnection to make available.

setParams

public void setParams(HttpConnectionManagerParams params)
Assigns parameters for this connection manager.
Since:
3.0