org.apache.commons.httpclient
Class SimpleHttpConnectionManager

java.lang.Object
  extended by org.apache.commons.httpclient.SimpleHttpConnectionManager
All Implemented Interfaces:
HttpConnectionManager

public class SimpleHttpConnectionManager
extends Object
implements HttpConnectionManager

A connection manager that provides access to a single HttpConnection. This manager makes no attempt to provide exclusive access to the contained HttpConnection.

Since:
2.0
Author:
Michael Becke, Eric Johnson, Mike Bowler, Oleg Kalnichevski, Laura Werner

Field Summary
protected  HttpConnection httpConnection
          The http connection
 
Constructor Summary
SimpleHttpConnectionManager()
          Do nothing constructor.
 
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 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

httpConnection

protected HttpConnection httpConnection
The http connection

Constructor Detail

SimpleHttpConnectionManager

public SimpleHttpConnectionManager()
Do nothing constructor.

Method Detail

getConnection

public HttpConnection getConnection(HostConfiguration hostConfiguration)
Description copied from interface: HttpConnectionManager
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.

Specified by:
getConnection in interface HttpConnectionManager
Parameters:
hostConfiguration - the host configuration to use to configure the connection
Returns:
an HttpConnection for the given configuration
See Also:
HttpConnectionManager.getConnection(HostConfiguration)

getConnectionWithTimeout

public HttpConnection getConnectionWithTimeout(HostConfiguration hostConfiguration,
                                               long timeout)
Description copied from interface: HttpConnectionManager
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.

Specified by:
getConnectionWithTimeout in interface HttpConnectionManager
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
Since:
3.0
See Also:
HttpConnectionManager.getConnectionWithTimeout(HostConfiguration, long)

releaseConnection

public void releaseConnection(HttpConnection conn)
Description copied from interface: HttpConnectionManager
Releases the given HttpConnection for use by other requests.

Specified by:
releaseConnection in interface HttpConnectionManager
Parameters:
conn - - The HttpConnection to make available.
See Also:
HttpConnectionManager.releaseConnection(org.apache.commons.httpclient.HttpConnection)

getParams

public HttpConnectionManagerParams getParams()
Returns parameters associated with this connection manager.

Specified by:
getParams in interface HttpConnectionManager
Returns:
all associated parameters
See Also:
HttpConnectionManagerParams

setParams

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

Specified by:
setParams in interface HttpConnectionManager
Parameters:
params - params to set
See Also:
HttpConnectionManagerParams

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.

Specified by:
closeIdleConnections in interface HttpConnectionManager
Parameters:
idleTimeout - the minimum idle time, in milliseconds, for connections to be closed


Copyright (c) 1999-2005 - Apache Software Foundation