@ThreadSafe public class BasicHttpClientConnectionManager extends java.lang.Object implements HttpClientConnectionManager, java.io.Closeable
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 tlb
IllegalStateException is thrown.
This connection manager implementation should be used inside an EJB container instead of
PoolingHttpClientConnectionManager.| 构造器和说明 |
|---|
BasicHttpClientConnectionManager() |
BasicHttpClientConnectionManager(Lookup<ConnectionSocketFactory> socketFactoryRegistry) |
BasicHttpClientConnectionManager(Lookup<ConnectionSocketFactory> socketFactoryRegistry,
HttpConnectionFactory<HttpRoute,ManagedHttpClientConnection> connFactory) |
BasicHttpClientConnectionManager(Lookup<ConnectionSocketFactory> socketFactoryRegistry,
HttpConnectionFactory<HttpRoute,ManagedHttpClientConnection> connFactory,
SchemePortResolver schemePortResolver,
DnsResolver dnsResolver) |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
close() |
void |
closeExpiredConnections()
Closes all expired connections in the pool.
|
void |
closeIdleConnections(long idletime,
java.util.concurrent.TimeUnit tunit)
Closes idle connections in the pool.
|
void |
connect(HttpClientConnection conn,
HttpRoute route,
int connectTimeout,
HttpContext context)
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).
|
protected void |
finalize() |
ConnectionConfig |
getConnectionConfig() |
SocketConfig |
getSocketConfig() |
void |
releaseConnection(HttpClientConnection conn,
java.lang.Object state,
long keepalive,
java.util.concurrent.TimeUnit tunit)
Releases the connection back to the manager making it potentially
re-usable by extension consumers.
|
ConnectionRequest |
requestConnection(HttpRoute route,
java.lang.Object state)
Returns a new
ConnectionRequest, from which a
HttpClientConnection can be obtained or the request can be
aborted. |
void |
routeComplete(HttpClientConnection conn,
HttpRoute route,
HttpContext context)
Marks the connection as fully established with all its intermediate
hops completed.
|
void |
setConnectionConfig(ConnectionConfig connConfig) |
void |
setSocketConfig(SocketConfig socketConfig) |
void |
shutdown()
Shuts down this connection manager and releases tlb resources.
|
void |
upgrade(HttpClientConnection conn,
HttpRoute route,
HttpContext context)
Upgrades the underlying connection socket to TLS/SSL (or another layering
protocol) after having executed
CONNECT method to all
intermediate proxy hops |
public BasicHttpClientConnectionManager(Lookup<ConnectionSocketFactory> socketFactoryRegistry, HttpConnectionFactory<HttpRoute,ManagedHttpClientConnection> connFactory, SchemePortResolver schemePortResolver, DnsResolver dnsResolver)
public BasicHttpClientConnectionManager(Lookup<ConnectionSocketFactory> socketFactoryRegistry, HttpConnectionFactory<HttpRoute,ManagedHttpClientConnection> connFactory)
public BasicHttpClientConnectionManager(Lookup<ConnectionSocketFactory> socketFactoryRegistry)
public BasicHttpClientConnectionManager()
protected void finalize()
throws java.lang.Throwable
finalize 在类中 java.lang.Objectjava.lang.Throwablepublic void close()
close 在接口中 java.io.Closeableclose 在接口中 java.lang.AutoCloseablepublic SocketConfig getSocketConfig()
public void setSocketConfig(SocketConfig socketConfig)
public ConnectionConfig getConnectionConfig()
public void setConnectionConfig(ConnectionConfig connConfig)
public final ConnectionRequest requestConnection(HttpRoute route, java.lang.Object state)
HttpClientConnectionManagerConnectionRequest, from which a
HttpClientConnection can be obtained or the request can be
aborted.
Please note that newly tlb 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 connect in order to connect
directly to the target or to the first proxy hop, optionally calling
upgrade method to upgrade
the connection after having executed CONNECT method to
all intermediate proxy hops and and finally calling routeComplete to mark the route
as fully completed.requestConnection 在接口中 HttpClientConnectionManagerroute - HTTP route of the requested connection.state - expected state of the connection or null
if the connection is not expected to carry any state.public void releaseConnection(HttpClientConnection conn, java.lang.Object state, long keepalive, java.util.concurrent.TimeUnit tunit)
HttpClientConnectionManagervalidDuration and timeUnit
parameters.releaseConnection 在接口中 HttpClientConnectionManagerconn - the managed connection to release.keepalive - the duration of time this connection is valid for reuse.tunit - the time unit.HttpClientConnectionManager.closeExpiredConnections()public void connect(HttpClientConnection conn, HttpRoute route, int connectTimeout, HttpContext context) throws java.io.IOException
HttpClientConnectionManagerconnect 在接口中 HttpClientConnectionManagerconn - the managed connection.route - the route of the connection.connectTimeout - connect timeout in milliseconds.context - the actual HTTP context.java.io.IOExceptionpublic void upgrade(HttpClientConnection conn, HttpRoute route, HttpContext context) throws java.io.IOException
HttpClientConnectionManagerCONNECT method to all
intermediate proxy hopsupgrade 在接口中 HttpClientConnectionManagerconn - the managed connection.route - the route of the connection.context - the actual HTTP context.java.io.IOExceptionpublic void routeComplete(HttpClientConnection conn, HttpRoute route, HttpContext context) throws java.io.IOException
HttpClientConnectionManagerrouteComplete 在接口中 HttpClientConnectionManagerconn - the managed connection.route - the route of the connection.context - the actual HTTP context.java.io.IOExceptionpublic void closeExpiredConnections()
HttpClientConnectionManagerpublic void closeIdleConnections(long idletime,
java.util.concurrent.TimeUnit tunit)
HttpClientConnectionManagercloseIdleConnections 在接口中 HttpClientConnectionManageridletime - the idle time of connections to be closedtunit - the unit for the idletimeHttpClientConnectionManager.closeExpiredConnections()public void shutdown()
HttpClientConnectionManagershutdown 在接口中 HttpClientConnectionManager