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

public Class SingleClientConnManager

extends Object
implements ClientConnectionManager
Class Inheritance
All Implemented Interfaces
org.apache.http.conn.ClientConnectionManager
Annotations
@Contract
threading:SAFE
@Deprecated
Imports
java.io.IOException, java.util.concurrent.TimeUnit, org.apache.commons.logging.Log, .LogFactory, org.apache.http.annotation.Contract, .ThreadingBehavior, org.apache.http.conn.ClientConnectionManager, .ClientConnectionOperator, .ClientConnectionRequest, .ManagedClientConnection, org.apache.http.conn.routing.HttpRoute, .RouteTracker, org.apache.http.conn.scheme.SchemeRegistry, org.apache.http.params.HttpParams, org.apache.http.util.Args, .Asserts

Deprecated

(4.2) use BasicClientConnectionManager

A connection manager for a single connection. This connection manager maintains only one active connection at a time. Even though this class is thread-safe it ought to be used by one execution thread only.

SingleClientConnManager will make an effort to reuse the connection for subsequent requests with the same route. It will, however, close the existing connection and open it for the given route, if the route of the persistent connection does not match that of the connection request. If the connection has been already been allocated IllegalStateException is thrown.

Since
4.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected class
SingleClientConnManager.ConnAdapter

Deprecated as a consequence of AbstractPooledConnAdapter being deprecated.
The connection adapter used by this manager.
protected class
SingleClientConnManager.PoolEntry

Deprecated as a consequence of AbstractPoolEntry being deprecated.
The pool entry for this connection manager.

Field Summary

Modifier and TypeField and Description
protected final boolean
alwaysShutDown

Whether the connection should be shut down on release.

protected volatile long
connectionExpiresTime

The time the last released connection expires and shouldn't be reused.

protected final ClientConnectionOperator
connOperator

The operator for opening and updating connections.

protected volatile boolean
isShutDown

Indicates whether this connection manager is shut down.

protected volatile long
lastReleaseTime

The time of the last connection release, or -1.

private final Log
protected volatile SingleClientConnManager.ConnAdapter
managedConn

The currently issued managed connection, if any.

public static final String
MISUSE_MESSAGE

The message to be logged on multiple allocation.

protected final SchemeRegistry
schemeRegistry

The schemes supported by this connection manager.

protected volatile SingleClientConnManager.PoolEntry
uniquePoolEntry

The one and only entry in this pool.

Constructor Summary

AccessConstructor and Description
public
SingleClientConnManager(final HttpParams
the parameters for this manager
params
,
final SchemeRegistry
the scheme registry
schreg
)

Creates a new simple connection manager.
public
SingleClientConnManager(final SchemeRegistry
the scheme registry
schreg
)

Deprecated as a consequence of SchemeRegistry being deprecated.
Creates a new simple connection manager.
public

Method Summary

Modifier and TypeMethod and Description
protected final void
assertStillUp()

Asserts that this manager is not shut down.

public void
public void
closeIdleConnections(final long
the idle time of connections to be closed
idletime
,
final TimeUnit
the unit for the idletime
timeUnit
)

Implements org.apache.http.conn.ClientConnectionManager.closeIdleConnections.

Closes idle connections in the pool.
protected ClientConnectionOperator

Returns:

the connection operator to use
createConnectionOperator
(final SchemeRegistry
the scheme registry to use, or null
schreg
)

Deprecated as a consequence of SchemeRegistry and ClientConnectionOperator being deprecated.
Hook for creating the connection operator.
protected void
finalize()

Overrides java.lang.Object.finalize.

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
public ManagedClientConnection

Returns:

a connection that can be used to communicate along the given route
getConnection
(final HttpRoute
where the connection should point to
route
,
final Object state)

Deprecated as a consequence of ManagedClientConnection being deprecated.
Obtains a connection.
public SchemeRegistry
getSchemeRegistry()

Implements org.apache.http.conn.ClientConnectionManager.getSchemeRegistry.

Deprecated as a consequence of SchemeRegistry being deprecated.
Obtains the scheme registry used by this manager.
public void
releaseConnection(final ManagedClientConnection
the connection to release
conn
,
final long
the duration of time this connection is valid for reuse
validDuration
,
final TimeUnit
the unit of time validDuration is measured in
timeUnit
)

Implements org.apache.http.conn.ClientConnectionManager.releaseConnection.

Deprecated as a consequence of ManagedClientConnection being deprecated.
Releases a connection for use by others.
public final ClientConnectionRequest
requestConnection(final HttpRoute route, final Object state)

Implements org.apache.http.conn.ClientConnectionManager.requestConnection.

Deprecated as a consequence of ClientConnectionRequest being deprecated.
Returns a new ClientConnectionRequest, from which a ManagedClientConnection can be obtained or the request can be aborted.
protected void
public void
shutdown()

Implements org.apache.http.conn.ClientConnectionManager.shutdown.

Shuts down this connection manager and releases allocated resources.
Inherited from java.lang.Object:
cloneequalsgetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

alwaysShutDownback to summary
protected final boolean alwaysShutDown

Whether the connection should be shut down on release.

connectionExpiresTimeback to summary
protected volatile long connectionExpiresTime

The time the last released connection expires and shouldn't be reused.

connOperatorback to summary
protected final ClientConnectionOperator connOperator

Deprecated

as a consequence of ClientConnectionOperator being deprecated. See corresponding docs for further information.

The operator for opening and updating connections.

isShutDownback to summary
protected volatile boolean isShutDown

Indicates whether this connection manager is shut down.

lastReleaseTimeback to summary
protected volatile long lastReleaseTime

The time of the last connection release, or -1.

logback to summary
private final Log log
managedConnback to summary
protected volatile SingleClientConnManager.ConnAdapter managedConn

Deprecated

as a consequence of SingleClientConnManager.ConnAdapter being deprecated. See corresponding docs for further information.

The currently issued managed connection, if any.

MISUSE_MESSAGEback to summary
public static final String MISUSE_MESSAGE

The message to be logged on multiple allocation.

schemeRegistryback to summary
protected final SchemeRegistry schemeRegistry

Deprecated

as a consequence of SchemeRegistry being deprecated. See corresponding docs for further information.

The schemes supported by this connection manager.

uniquePoolEntryback to summary
protected volatile SingleClientConnManager.PoolEntry uniquePoolEntry

Deprecated

as a consequence of SingleClientConnManager.PoolEntry being deprecated. See corresponding docs for further information.

The one and only entry in this pool.

Constructor Detail

SingleClientConnManagerback to summary
public SingleClientConnManager(final HttpParams params, final SchemeRegistry schreg)

Creates a new simple connection manager.

Parameters
params:HttpParams

the parameters for this manager

schreg:SchemeRegistry

the scheme registry

Annotations
@Deprecated
SingleClientConnManagerback to summary
public SingleClientConnManager(final SchemeRegistry schreg)

Deprecated

as a consequence of SchemeRegistry being deprecated. See corresponding docs for further information.

Creates a new simple connection manager.

Parameters
schreg:SchemeRegistry

the scheme registry

SingleClientConnManagerback to summary
public SingleClientConnManager()
Since
4.1

Method Detail

assertStillUpback to summary
protected final void assertStillUp() throws IllegalStateException

Asserts that this manager is not shut down.

Exceptions
IllegalStateException:
if this manager is shut down
closeExpiredConnectionsback to summary
public void closeExpiredConnections()

Implements org.apache.http.conn.ClientConnectionManager.closeExpiredConnections.

Doc from org.apache.http.conn.ClientConnectionManager.closeExpiredConnections.

Closes all expired connections in the pool. Open connections in the pool that have not been used for the timespan defined when the connection was released will be closed. Currently allocated connections are not subject to this method. Times will be checked with milliseconds precision.

Annotations
@Override
closeIdleConnectionsback to summary
public void closeIdleConnections(final long idletime, final TimeUnit timeUnit)

Implements org.apache.http.conn.ClientConnectionManager.closeIdleConnections.

Doc from org.apache.http.conn.ClientConnectionManager.closeIdleConnections.

Closes idle connections in the pool. Open connections in the pool that have not been used for the timespan given by the argument will be closed. Currently allocated connections are not subject to this method. Times will be checked with milliseconds precision All expired connections will also be closed.

Parameters
idletime:long

the idle time of connections to be closed

timeUnit:TimeUnit

the unit for the idletime

Annotations
@Override
createConnectionOperatorback to summary
protected ClientConnectionOperator createConnectionOperator(final SchemeRegistry schreg)

Deprecated

as a consequence of SchemeRegistry and ClientConnectionOperator being deprecated. See corresponding docs for further information.

Hook for creating the connection operator. It is called by the constructor. Derived classes can override this method to change the instantiation of the operator. The default implementation here instantiates DefaultClientConnectionOperator.

Parameters
schreg:SchemeRegistry

the scheme registry to use, or null

Returns:ClientConnectionOperator

the connection operator to use

finalizeback to summary
protected void finalize() throws Throwable

Overrides java.lang.Object.finalize.

Doc from java.lang.Object.finalize.

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. A subclass overrides the finalize method to dispose of system resources or to perform other cleanup.

When running in a Java virtual machine in which finalization has been disabled or removed, the garbage collector will never call finalize(). In a Java virtual machine in which finalization is enabled, the garbage collector might call finalize only after an indefinite delay.

The general contract of finalize is that it is invoked if and when the Java virtual machine has determined that there is no longer any means by which this object can be accessed by any thread that has not yet died, except as a result of an action taken by the finalization of some other object or class which is ready to be finalized. The finalize method may take any action, including making this object available again to other threads; the usual purpose of finalize, however, is to perform cleanup actions before the object is irrevocably discarded. For example, the finalize method for an object that represents an input/output connection might perform explicit I/O transactions to break the connection before the object is permanently discarded.

The finalize method of class Object performs no special action; it simply returns normally. Subclasses of Object may override this definition.

The Java programming language does not guarantee which thread will invoke the finalize method for any given object. It is guaranteed, however, that the thread that invokes finalize will not be holding any user-visible synchronization locks when finalize is invoked. If an uncaught exception is thrown by the finalize method, the exception is ignored and finalization of that object terminates.

After the finalize method has been invoked for an object, no further action is taken until the Java virtual machine has again determined that there is no longer any means by which this object can be accessed by any thread that has not yet died, including possible actions by other objects or classes which are ready to be finalized, at which point the object may be discarded.

The finalize method is never invoked more than once by a Java virtual machine for any given object.

Any exception thrown by the finalize method causes the finalization of this object to be halted, but is otherwise ignored.

Annotations
@Override
Exceptions
Throwable:
the Exception raised by this method
getConnectionback to summary
public ManagedClientConnection getConnection(final HttpRoute route, final Object state)

Deprecated

as a consequence of ManagedClientConnection being deprecated. See corresponding docs for further information.

Obtains a connection.

Parameters
route:HttpRoute

where the connection should point to

Returns:ManagedClientConnection

a connection that can be used to communicate along the given route

getSchemeRegistryback to summary
public SchemeRegistry getSchemeRegistry()

Implements org.apache.http.conn.ClientConnectionManager.getSchemeRegistry.

Doc from org.apache.http.conn.ClientConnectionManager.getSchemeRegistry.

Deprecated

as a consequence of SchemeRegistry being deprecated. See corresponding docs for further information.

Obtains the scheme registry used by this manager.

Returns:SchemeRegistry

the scheme registry, never null

Annotations
@Override
releaseConnectionback to summary
public void releaseConnection(final ManagedClientConnection conn, final long validDuration, final TimeUnit timeUnit)

Implements org.apache.http.conn.ClientConnectionManager.releaseConnection.

Doc from org.apache.http.conn.ClientConnectionManager.releaseConnection.

Deprecated

as a consequence of ManagedClientConnection being deprecated. See corresponding docs for further information.

Releases a connection for use by others. You may optionally specify how long the connection is valid to be reused. Values <= 0 are considered to be valid forever. If the connection is not marked as reusable, the connection will not be reused regardless of the valid duration. If the connection has been released before, the call will be ignored.

Parameters
conn:ManagedClientConnection

the connection to release

validDuration:long

the duration of time this connection is valid for reuse

timeUnit:TimeUnit

the unit of time validDuration is measured in

Annotations
@Override
requestConnectionback to summary
public final ClientConnectionRequest requestConnection(final HttpRoute route, final Object state)

Implements org.apache.http.conn.ClientConnectionManager.requestConnection.

Doc from org.apache.http.conn.ClientConnectionManager.requestConnection.

Deprecated

as a consequence of ClientConnectionRequest being deprecated. See corresponding docs for further information.

Returns a new ClientConnectionRequest, from which a ManagedClientConnection can be obtained or the request can be aborted.

Annotations
@Override
revokeConnectionback to summary
protected void revokeConnection()
shutdownback to summary
public void shutdown()

Implements org.apache.http.conn.ClientConnectionManager.shutdown.

Doc from org.apache.http.conn.ClientConnectionManager.shutdown.

Shuts down this connection manager and releases allocated resources. This includes closing all connections, whether they are currently used or not.

Annotations
@Override
org.apache.http.impl.conn back to summary

protected Class SingleClientConnManager.ConnAdapter

extends AbstractPooledConnAdapter
Class Inheritance

Deprecated

as a consequence of AbstractPooledConnAdapter being deprecated. See corresponding docs for further information.

The connection adapter used by this manager.

Field Summary

Inherited from org.apache.http.impl.conn.AbstractPooledConnAdapter:
poolEntry

Constructor Summary

AccessConstructor and Description
protected
ConnAdapter(final SingleClientConnManager.PoolEntry
the pool entry for the connection being wrapped
entry
,
final HttpRoute
the planned route for this connection
route
)

Deprecated as a consequence of SingleClientConnManager.PoolEntry being deprecated.
Creates a new connection adapter.

Method Summary

Inherited from org.apache.http.impl.conn.AbstractPooledConnAdapter:
assertAttachedassertValidclosedetachgetIdgetPoolEntrygetRoutegetStatelayerProtocolopensetStateshutdowntunnelProxytunnelTarget

Constructor Detail

ConnAdapterback to summary
protected ConnAdapter(final SingleClientConnManager.PoolEntry entry, final HttpRoute route)

Deprecated

as a consequence of SingleClientConnManager.PoolEntry being deprecated. See corresponding docs for further information.

Creates a new connection adapter.

Parameters
entry:SingleClientConnManager.PoolEntry

the pool entry for the connection being wrapped

route:HttpRoute

the planned route for this connection

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

protected Class SingleClientConnManager.PoolEntry

extends AbstractPoolEntry
Class Inheritance

Deprecated

as a consequence of AbstractPoolEntry being deprecated. See corresponding docs for further information.

The pool entry for this connection manager.

Field Summary

Inherited from org.apache.http.impl.conn.AbstractPoolEntry:
connectionconnOperatorroutestatetracker

Constructor Summary

AccessConstructor and Description
protected
PoolEntry()

Creates a new pool entry.

Method Summary

Modifier and TypeMethod and Description
protected void
close()

Closes the connection in this pool entry.

protected void
shutdown()

Shuts down the connection in this pool entry.

Inherited from org.apache.http.impl.conn.AbstractPoolEntry:
getStatelayerProtocolopensetStateshutdownEntrytunnelProxytunnelTarget

Constructor Detail

PoolEntryback to summary
protected PoolEntry()

Creates a new pool entry.

Method Detail

closeback to summary
protected void close() throws IOException

Closes the connection in this pool entry.

shutdownback to summary
protected void shutdown() throws IOException

Shuts down the connection in this pool entry.