org.apache.commons.httpclient

Class SimpleHttpConnectionManager

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

Field Summary

protected HttpConnection
httpConnection
The http connection

Constructor Summary

SimpleHttpConnectionManager()
The connection manager created with this constructor will always try to keep the connection open (alive) between consecutive requests.
SimpleHttpConnectionManager(boolean alwaysClose)
The connection manager created with this constructor will try to keep the connection open (alive) between consecutive requests if the alwaysClose parameter is set to false.

Method Summary

void
closeIdleConnections(long idleTimeout)
HttpConnection
getConnection(HostConfiguration hostConfiguration)
HttpConnection
getConnection(HostConfiguration hostConfiguration, long timeout)
Deprecated. Use #getConnectionWithTimeout(HostConfiguration, long)
HttpConnection
getConnectionWithTimeout(HostConfiguration hostConfiguration, long timeout)
This method always returns the same connection object.
HttpConnectionManagerParams
getParams()
Returns parameters associated with this connection manager.
boolean
isConnectionStaleCheckingEnabled()
Deprecated. Use HttpConnectionManagerParams.isStaleCheckingEnabled(), HttpConnectionManager.getParams().
void
releaseConnection(HttpConnection conn)
void
setConnectionStaleCheckingEnabled(boolean connectionStaleCheckingEnabled)
Deprecated. Use HttpConnectionManagerParams.setStaleCheckingEnabled(boolean), HttpConnectionManager.getParams().
void
setParams(HttpConnectionManagerParams params)
Assigns parameters for this connection manager.
void
shutdown()
since 3.1

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

httpConnection

protected HttpConnection httpConnection
The http connection

Constructor Details

SimpleHttpConnectionManager

public SimpleHttpConnectionManager()
The connection manager created with this constructor will always try to keep the connection open (alive) between consecutive requests.
Usages and Demos :

View More Examples of SimpleHttpConnectionManager()
   1:         {
   2:             httpClient = new HttpClient(new SimpleHttpConnectionManager());
   3:             map.put(hc, httpClient);
   4:         }

View Full Code Here

SimpleHttpConnectionManager

public SimpleHttpConnectionManager(boolean alwaysClose)
The connection manager created with this constructor will try to keep the connection open (alive) between consecutive requests if the alwaysClose parameter is set to false. Otherwise the connection manager will always close connections upon release.
Parameters:
alwaysClose - if set true, the connection manager will always close connections upon release.

Method Details

closeIdleConnections

public void closeIdleConnections(long idleTimeout)
Specified by:
closeIdleConnections in interface HttpConnectionManager
Since:
3.0

getConnection

public HttpConnection getConnection(HostConfiguration hostConfiguration)
Specified by:
getConnection in interface HttpConnectionManager

getConnection

public HttpConnection getConnection(HostConfiguration hostConfiguration,
                                    long timeout)

Deprecated. Use #getConnectionWithTimeout(HostConfiguration, long)

Specified by:
getConnection in interface HttpConnectionManager

getConnectionWithTimeout

public HttpConnection getConnectionWithTimeout(HostConfiguration hostConfiguration,
                                               long timeout)
This method always returns the same connection object. If the connection is already open, it will be closed and the new host configuration will be applied.
Specified by:
getConnectionWithTimeout in interface HttpConnectionManager
Parameters:
hostConfiguration - The host configuration specifying the connection details.
timeout - this parameter has no effect. The connection is always returned immediately.
Since:
3.0

getParams

public HttpConnectionManagerParams getParams()
Returns parameters associated with this connection manager.
Specified by:
getParams in interface HttpConnectionManager
Since:
2.1

isConnectionStaleCheckingEnabled

public boolean isConnectionStaleCheckingEnabled()

Deprecated. Use HttpConnectionManagerParams.isStaleCheckingEnabled(), HttpConnectionManager.getParams().

Gets the staleCheckingEnabled value to be set on HttpConnections that are created.
Returns:
true if stale checking will be enabled on HttpConections

releaseConnection

public void releaseConnection(HttpConnection conn)
Specified by:
releaseConnection in interface HttpConnectionManager

setConnectionStaleCheckingEnabled

public void setConnectionStaleCheckingEnabled(boolean connectionStaleCheckingEnabled)

Deprecated. Use HttpConnectionManagerParams.setStaleCheckingEnabled(boolean), HttpConnectionManager.getParams().

Sets the staleCheckingEnabled value to be set on HttpConnections that are created.
Parameters:
connectionStaleCheckingEnabled - true if stale checking will be enabled on HttpConections

setParams

public void setParams(HttpConnectionManagerParams params)
Assigns parameters for this connection manager.
Specified by:
setParams in interface HttpConnectionManager
Since:
2.1

shutdown

public void shutdown()
since 3.1