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
PoolingHttpClientConnectionManager.
| Modifier and Type | Field and Description |
|---|---|
| private ManagedHttpClientConnection | |
| private ConnectionConfig | |
| private final HttpClientConnectionOperator | |
| private final HttpConnectionFactory | |
| private long | |
| private final AtomicBoolean | |
| private boolean | |
| private final Log | |
| private HttpRoute | |
| private SocketConfig | |
| private Object | |
| private long |
| Access | Constructor and Description |
|---|---|
| public | BasicHttpClientConnectionManager(final Lookup<ConnectionSocketFactory> socketFactoryRegistry, final HttpConnectionFactory<HttpRoute, ManagedHttpClientConnection> connFactory, final SchemePortResolver schemePortResolver, final DnsResolver dnsResolver)
|
| public | BasicHttpClientConnectionManager(final HttpClientConnectionOperator httpClientConnectionOperator, final HttpConnectionFactory<HttpRoute, ManagedHttpClientConnection> connFactory)
|
| public | BasicHttpClientConnectionManager(final Lookup<ConnectionSocketFactory> socketFactoryRegistry, final HttpConnectionFactory<HttpRoute, ManagedHttpClientConnection> connFactory)
|
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| private void | |
| public void | close()
Implements java. |
| private synchronized void | |
| public synchronized void | closeExpiredConnections()
Implements org. |
| public synchronized void | closeIdleConnections(final long
the idle time of connections to be closed idletime, final TimeUnit the unit for the timeUnit)idletimeImplements org. |
| public void | connect(final HttpClientConnection
the managed connection. conn, final HttpRoute the route of the connection. route, final int connect timeout in milliseconds. connectTimeout, final HttpContext the actual HTTP context. context)Implements org. |
| protected void | finalize()
Overrides java. |
| pack-priv synchronized HttpClientConnection | |
| public synchronized ConnectionConfig | |
| private static Registry | |
| pack-priv HttpRoute | |
| public synchronized SocketConfig | |
| pack-priv Object | |
| public synchronized void | releaseConnection(final HttpClientConnection
the managed connection to release. conn, final Object state, final long the duration of time this connection is valid for reuse. keepalive, final TimeUnit the time unit. timeUnit)Implements org. |
| public final ConnectionRequest | requestConnection(final HttpRoute
HTTP route of the requested connection. route, final Object expected state of the connection or state)null
if the connection is not expected to carry any state.Implements org. ConnectionRequest, from which a
HttpClientConnection can be obtained or the request can be
aborted.
|
| public void | routeComplete(final HttpClientConnection
the managed connection. conn, final HttpRoute the route of the connection. route, final HttpContext the actual HTTP context. context)Implements org. |
| public synchronized void | |
| public synchronized void | |
| public void | shutdown()
Implements org. |
| public void | upgrade(final HttpClientConnection
the managed connection. conn, final HttpRoute the route of the connection. route, final HttpContext the actual HTTP context. context)Implements org. CONNECT method to all
intermediate proxy hops
|
| conn | back to summary |
|---|---|
| private ManagedHttpClientConnection conn | |
| connConfig | back to summary |
|---|---|
| private ConnectionConfig connConfig | |
| connectionOperator | back to summary |
|---|---|
| private final HttpClientConnectionOperator connectionOperator | |
| connFactory | back to summary |
|---|---|
| private final HttpConnectionFactory<HttpRoute, ManagedHttpClientConnection> connFactory | |
| expiry | back to summary |
|---|---|
| private long expiry | |
| isShutdown | back to summary |
|---|---|
| private final AtomicBoolean isShutdown | |
| leased | back to summary |
|---|---|
| private boolean leased | |
| log | back to summary |
|---|---|
| private final Log log | |
| route | back to summary |
|---|---|
| private HttpRoute route | |
| socketConfig | back to summary |
|---|---|
| private SocketConfig socketConfig | |
| state | back to summary |
|---|---|
| private Object state | |
| updated | back to summary |
|---|---|
| private long updated | |
| BasicHttpClientConnectionManager | back to summary |
|---|---|
| public BasicHttpClientConnectionManager(final Lookup<ConnectionSocketFactory> socketFactoryRegistry, final HttpConnectionFactory<HttpRoute, ManagedHttpClientConnection> connFactory, final SchemePortResolver schemePortResolver, final DnsResolver dnsResolver) | |
| BasicHttpClientConnectionManager | back to summary |
|---|---|
public BasicHttpClientConnectionManager(final HttpClientConnectionOperator httpClientConnectionOperator, final HttpConnectionFactory<HttpRoute, ManagedHttpClientConnection> connFactory)
| |
| BasicHttpClientConnectionManager | back to summary |
|---|---|
| public BasicHttpClientConnectionManager(final Lookup<ConnectionSocketFactory> socketFactoryRegistry, final HttpConnectionFactory<HttpRoute, ManagedHttpClientConnection> connFactory) | |
| BasicHttpClientConnectionManager | back to summary |
|---|---|
| public BasicHttpClientConnectionManager(final Lookup<ConnectionSocketFactory> socketFactoryRegistry) | |
| BasicHttpClientConnectionManager | back to summary |
|---|---|
| public BasicHttpClientConnectionManager() | |
| checkExpiry | back to summary |
|---|---|
| private void checkExpiry() | |
| close | back to summary |
|---|---|
| public void close() Implements java. Doc from java. Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect. As noted in
| |
| closeConnection | back to summary |
|---|---|
| private synchronized void closeConnection() | |
| closeExpiredConnections | back to summary |
|---|---|
| public synchronized void closeExpiredConnections() Implements org. Doc from org. 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.
| |
| closeIdleConnections | back to summary |
|---|---|
| public synchronized void closeIdleConnections(final long idletime, final TimeUnit timeUnit) Implements org. Doc from org. 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. | |
| connect | back to summary |
|---|---|
| public void connect(final HttpClientConnection conn, final HttpRoute route, final int connectTimeout, final HttpContext context) throws IOException Implements org. Doc from org. Connects the underlying connection socket to the connection target in case of a direct route or to the first proxy hop in case of a route via a proxy (or multiple proxies).
| |
| finalize | back to summary |
|---|---|
| protected void finalize() throws Throwable Overrides java. Doc from java. 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
When running in a Java virtual machine in which finalization has been
disabled or removed, the garbage collector will never call
The general contract of
The
The Java programming language does not guarantee which thread will
invoke the
After the
The
Any exception thrown by the | |
| getConnection | back to summary |
|---|---|
| pack-priv synchronized HttpClientConnection getConnection(final HttpRoute route, final Object state) | |
| getConnectionConfig | back to summary |
|---|---|
| public synchronized ConnectionConfig getConnectionConfig() | |
| getDefaultRegistry | back to summary |
|---|---|
| private static Registry | |
| getRoute | back to summary |
|---|---|
| pack-priv HttpRoute getRoute() | |
| getSocketConfig | back to summary |
|---|---|
| public synchronized SocketConfig getSocketConfig() | |
| getState | back to summary |
|---|---|
| pack-priv Object getState() | |
| releaseConnection | back to summary |
|---|---|
| public synchronized void releaseConnection(final HttpClientConnection conn, final Object state, final long keepalive, final TimeUnit timeUnit) Implements org. Doc from org. Releases the connection back to the manager making it potentially
re-usable by other consumers. Optionally, the maximum period
of how long the manager should keep the connection alive can be
defined using
| |
| requestConnection | back to summary |
|---|---|
| public final ConnectionRequest requestConnection(final HttpRoute route, final Object state) Implements org. Doc from org. Returns a new
Please note that newly allocated connections can be returned
in the closed state. The consumer of that connection is responsible
for fully establishing the route the to the connection target
by calling | |
| routeComplete | back to summary |
|---|---|
| public void routeComplete(final HttpClientConnection conn, final HttpRoute route, final HttpContext context) throws IOException Implements org. Doc from org. Marks the connection as fully established with all its intermediate hops completed.
| |
| setConnectionConfig | back to summary |
|---|---|
| public synchronized void setConnectionConfig(final ConnectionConfig connConfig) | |
| setSocketConfig | back to summary |
|---|---|
| public synchronized void setSocketConfig(final SocketConfig socketConfig) | |
| shutdown | back to summary |
|---|---|
| public void shutdown() Implements org. Doc from org. Shuts down this connection manager and releases allocated resources. This includes closing all connections, whether they are currently used or not.
| |
| upgrade | back to summary |
|---|---|
| public void upgrade(final HttpClientConnection conn, final HttpRoute route, final HttpContext context) throws IOException Implements org. Doc from org. Upgrades the underlying connection socket to TLS/SSL (or another layering
protocol) after having executed
| |