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

public Class BasicClientConnectionManager

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, java.util.concurrent.atomic.AtomicLong, org.apache.commons.logging.Log, .LogFactory, org.apache.http.HttpClientConnection, org.apache.http.annotation.Contract, .ThreadingBehavior, org.apache.http.conn.ClientConnectionManager, .ClientConnectionOperator, .ClientConnectionRequest, .ManagedClientConnection, .OperatedClientConnection, org.apache.http.conn.routing.HttpRoute, org.apache.http.conn.scheme.SchemeRegistry, org.apache.http.util.Args, .Asserts

Deprecated

(4.3) use BasicHttpClientConnectionManager.

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

This connection manager 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.

This connection manager implementation should be used inside an EJB container instead of PoolingClientConnectionManager.

Since
4.2

Field Summary

Modifier and TypeField and Description
private ManagedClientConnectionImpl
conn

The currently issued managed connection, if any.

private final ClientConnectionOperator
connOperator

The operator for opening and updating connections.

private static final AtomicLong
private final Log
public static final String
MISUSE_MESSAGE

The message to be logged on multiple allocation.

private HttpPoolEntry
poolEntry

The one and only entry in this pool.

private final SchemeRegistry
schemeRegistry

The schemes supported by this connection manager.

private volatile boolean
shutdown

Indicates whether this connection manager is shut down.

Constructor Summary

AccessConstructor and Description
public
BasicClientConnectionManager(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
private void
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
createConnectionOperator(final SchemeRegistry schreg)

Deprecated as a consequence of SchemeRegistry and ClientConnectionOperator being deprecated.
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.
pack-priv ManagedClientConnection
getConnection(final HttpRoute route, final Object state)

Deprecated as a consequence of ManagedClientConnection being deprecated.
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
keepalive
,
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.
public void
shutdown()

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

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

Field Detail

connback to summary
private ManagedClientConnectionImpl conn

Deprecated

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

The currently issued managed connection, if any.

connOperatorback to summary
private final ClientConnectionOperator connOperator

Deprecated

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

The operator for opening and updating connections.

COUNTERback to summary
private static final AtomicLong COUNTER
logback to summary
private final Log log
MISUSE_MESSAGEback to summary
public static final String MISUSE_MESSAGE

The message to be logged on multiple allocation.

poolEntryback to summary
private HttpPoolEntry poolEntry

Deprecated

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

The one and only entry in this pool.

schemeRegistryback to summary
private final SchemeRegistry schemeRegistry

Deprecated

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

The schemes supported by this connection manager.

shutdownback to summary
private volatile boolean shutdown

Indicates whether this connection manager is shut down.

Constructor Detail

BasicClientConnectionManagerback to summary
public BasicClientConnectionManager(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

BasicClientConnectionManagerback to summary
public BasicClientConnectionManager()

Method Detail

assertNotShutdownback to summary
private void assertNotShutdown()
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.

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
pack-priv ManagedClientConnection getConnection(final HttpRoute route, final Object state)

Deprecated

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

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 keepalive, 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

keepalive: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
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
shutdownConnectionback to summary
private void shutdownConnection(final HttpClientConnection conn)