Top Description Inners Fields Constructors Methods
org.apache.http.impl.conn

public Class IdleConnectionHandler

extends Object
Class Inheritance
Annotations
@Deprecated
Imports
java.io.IOException, java.util.HashMap, .Map, .Map.Entry, java.util.concurrent.TimeUnit, org.apache.commons.logging.Log, .LogFactory, org.apache.http.HttpConnection

Deprecated

(4.1) no longer used

A helper class for connection managers to track idle connections.

This class is not synchronized.

Since
4.0
See Also
org.apache.http.conn.ClientConnectionManager#closeIdleConnections

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private final Map<HttpConnection, IdleConnectionHandler.TimeValues>
connectionToTimes

Holds connections and the time they were added.

private final Log

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
add(final HttpConnection
the connection to add
connection
,
final long validDuration, final TimeUnit unit)

Registers the given connection with this handler.

public void
public void
closeIdleConnections(final long
the minimum idle time, in milliseconds, for connections to be closed
idleTime
)

Closes connections that have been idle for at least the given amount of time.

public boolean

Returns:

True if the connection is still valid.
remove
(final HttpConnection connection)

Removes the given connection from the list of connections to be closed when idle.

public void
removeAll()

Removes all connections referenced by this handler.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

connectionToTimesback to summary
private final Map<HttpConnection, IdleConnectionHandler.TimeValues> connectionToTimes

Holds connections and the time they were added.

logback to summary
private final Log log

Constructor Detail

IdleConnectionHandlerback to summary
public IdleConnectionHandler()

Method Detail

addback to summary
public void add(final HttpConnection connection, final long validDuration, final TimeUnit unit)

Registers the given connection with this handler. The connection will be held until remove or closeIdleConnections is called.

Parameters
connection:HttpConnection

the connection to add

See Also
remove
closeExpiredConnectionsback to summary
public void closeExpiredConnections()
closeIdleConnectionsback to summary
public void closeIdleConnections(final long idleTime)

Closes connections that have been idle for at least the given amount of time.

Parameters
idleTime:long

the minimum idle time, in milliseconds, for connections to be closed

removeback to summary
public boolean remove(final HttpConnection connection)

Removes the given connection from the list of connections to be closed when idle. This will return true if the connection is still valid, and false if the connection should be considered expired and not used.

Returns:boolean

True if the connection is still valid.

removeAllback to summary
public void removeAll()

Removes all connections referenced by this handler.

org.apache.http.impl.conn back to summary

private Class IdleConnectionHandler.TimeValues

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final long
private final long

Constructor Summary

AccessConstructor and Description
pack-priv
TimeValues(final long
The current time in milliseconds
now
,
final long
The duration this connection is valid for
validDuration
,
final TimeUnit
The unit of time the duration is specified in.
validUnit
)

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

timeAddedback to summary
private final long timeAdded
timeExpiresback to summary
private final long timeExpires

Constructor Detail

TimeValuesback to summary
pack-priv TimeValues(final long now, final long validDuration, final TimeUnit validUnit)
Parameters
now:long

The current time in milliseconds

validDuration:long

The duration this connection is valid for

validUnit:TimeUnit

The unit of time the duration is specified in.