|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.http.impl.conn.SingleClientConnManager
public class SingleClientConnManager
A connection "manager" for a single connection.
This manager is good only for single-threaded use.
Allocation always returns the connection immediately,
even if it has not been released after the previous allocation.
In that case, a warning
is logged
and the previously issued connection is revoked.
This class is derived from SimpleHttpConnectionManager
in HttpClient 3. See there for original authors.
Nested Class Summary | |
---|---|
protected class |
SingleClientConnManager.ConnAdapter
The connection adapter used by this manager. |
protected class |
SingleClientConnManager.PoolEntry
The pool entry for this connection manager. |
Field Summary | |
---|---|
protected boolean |
alwaysShutDown
Whether the connection should be shut down on release. |
protected long |
connectionExpiresTime
The time the last released connection expires and shouldn't be reused. |
protected ClientConnectionOperator |
connOperator
The operator for opening and updating connections. |
protected boolean |
isShutDown
Indicates whether this connection manager is shut down. |
protected long |
lastReleaseTime
The time of the last connection release, or -1. |
protected SingleClientConnManager.ConnAdapter |
managedConn
The currently issued managed connection, if any. |
static java.lang.String |
MISUSE_MESSAGE
The message to be logged on multiple allocation. |
protected SchemeRegistry |
schemeRegistry
The schemes supported by this connection manager. |
protected SingleClientConnManager.PoolEntry |
uniquePoolEntry
The one and only entry in this pool. |
Constructor Summary | |
---|---|
SingleClientConnManager(org.apache.http.params.HttpParams params,
SchemeRegistry schreg)
Creates a new simple connection manager. |
Method Summary | |
---|---|
protected void |
assertStillUp()
Asserts that this manager is not shut down. |
void |
closeExpiredConnections()
Closes all expired connections in the pool. |
void |
closeIdleConnections(long idletime,
java.util.concurrent.TimeUnit tunit)
Closes idle connections in the pool. |
protected ClientConnectionOperator |
createConnectionOperator(SchemeRegistry schreg)
Hook for creating the connection operator. |
protected void |
finalize()
|
ManagedClientConnection |
getConnection(HttpRoute route,
java.lang.Object state)
Obtains a connection. |
SchemeRegistry |
getSchemeRegistry()
Obtains the scheme registry used by this manager. |
void |
releaseConnection(ManagedClientConnection conn,
long validDuration,
java.util.concurrent.TimeUnit timeUnit)
Releases a connection for use by others. |
ClientConnectionRequest |
requestConnection(HttpRoute route,
java.lang.Object state)
Returns a new ClientConnectionRequest , from which a
ManagedClientConnection can be obtained or the request can be
aborted. |
protected void |
revokeConnection()
Revokes the currently issued connection. |
void |
shutdown()
Shuts down this connection manager and releases allocated resources. |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String MISUSE_MESSAGE
protected SchemeRegistry schemeRegistry
protected ClientConnectionOperator connOperator
protected SingleClientConnManager.PoolEntry uniquePoolEntry
protected SingleClientConnManager.ConnAdapter managedConn
protected long lastReleaseTime
protected long connectionExpiresTime
protected boolean alwaysShutDown
protected volatile boolean isShutDown
Constructor Detail |
---|
public SingleClientConnManager(org.apache.http.params.HttpParams params, SchemeRegistry schreg)
params
- the parameters for this managerschreg
- the scheme registry, or
null
for the default registryMethod Detail |
---|
protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
public SchemeRegistry getSchemeRegistry()
ClientConnectionManager
getSchemeRegistry
in interface ClientConnectionManager
null
protected ClientConnectionOperator createConnectionOperator(SchemeRegistry schreg)
DefaultClientConnectionOperator
.
schreg
- the scheme registry to use, or null
protected final void assertStillUp() throws java.lang.IllegalStateException
java.lang.IllegalStateException
- if this manager is shut downpublic final ClientConnectionRequest requestConnection(HttpRoute route, java.lang.Object state)
ClientConnectionManager
ClientConnectionRequest
, from which a
ManagedClientConnection
can be obtained or the request can be
aborted.
requestConnection
in interface ClientConnectionManager
public ManagedClientConnection getConnection(HttpRoute route, java.lang.Object state)
route
- where the connection should point to
public void releaseConnection(ManagedClientConnection conn, long validDuration, java.util.concurrent.TimeUnit timeUnit)
ClientConnectionManager
releaseConnection
in interface ClientConnectionManager
conn
- the connection to releasevalidDuration
- the duration of time this connection is valid for reusetimeUnit
- the unit of time validDuration is measured inClientConnectionManager.closeExpiredConnections()
public void closeExpiredConnections()
ClientConnectionManager
closeExpiredConnections
in interface ClientConnectionManager
public void closeIdleConnections(long idletime, java.util.concurrent.TimeUnit tunit)
ClientConnectionManager
closeIdleConnections
in interface ClientConnectionManager
idletime
- the idle time of connections to be closedtunit
- the unit for the idletime
ClientConnectionManager.closeExpiredConnections()
public void shutdown()
ClientConnectionManager
shutdown
in interface ClientConnectionManager
protected void revokeConnection()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |