@Deprecated public abstract class AbstractClientConnAdapter extends java.lang.Object implements ManagedClientConnection
operated to
managed client connections.
Read and write methods are delegated to the wrapped connection.
Operations affecting the connection state have to be implemented
by derived classes. Operations for querying the connection state
are delegated to the wrapped connection if there is one, or
return a default value if there is none.
This adapter tracks the checkpoints for reusable communication states,
as indicated by markReusable and queried by
isMarkedReusable.
All send and receive operations will automatically clear the mark.
Connection release calls are delegated to the connection manager,
if there is one. abortConnection will
clear the reusability mark first. The connection manager is
expected to tolerate multiple calls to the release method.
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractClientConnAdapter(ClientConnectionManager mgr,
OperatedClientConnection conn)
Deprecated.
Creates a new connection adapter.
|
| Modifier and Type | Method and Description |
|---|---|
void |
abortConnection()
Deprecated.
Releases the connection without the option of keep-alive.
|
protected void |
assertNotAborted()
Deprecated.
(4.1) use
assertValid(OperatedClientConnection) |
protected void |
assertValid(OperatedClientConnection wrappedConn)
Deprecated.
Asserts that there is a valid wrapped connection to delegate to.
|
void |
bind(java.net.Socket socket)
Deprecated.
Binds this connection to the given socket.
|
protected void |
detach()
Deprecated.
Detaches this adapter from the wrapped connection.
|
void |
flush()
Deprecated.
|
java.lang.Object |
getAttribute(java.lang.String id)
Deprecated.
|
java.net.InetAddress |
getLocalAddress()
Deprecated.
|
int |
getLocalPort()
Deprecated.
|
protected ClientConnectionManager |
getManager()
Deprecated.
|
HttpConnectionMetrics |
getMetrics()
Deprecated.
|
java.net.InetAddress |
getRemoteAddress()
Deprecated.
|
int |
getRemotePort()
Deprecated.
|
java.net.Socket |
getSocket()
Deprecated.
Returns the underlying socket.
|
int |
getSocketTimeout()
Deprecated.
|
javax.net.ssl.SSLSession |
getSSLSession()
Deprecated.
Obtains the SSL session of the underlying connection, if any.
|
protected OperatedClientConnection |
getWrappedConnection()
Deprecated.
|
boolean |
isMarkedReusable()
Deprecated.
Indicates whether this connection is in a reusable communication state.
|
boolean |
isOpen()
Deprecated.
|
protected boolean |
isReleased()
Deprecated.
|
boolean |
isResponseAvailable(int timeout)
Deprecated.
|
boolean |
isSecure()
Deprecated.
Indicates whether this connection is secure.
|
boolean |
isStale()
Deprecated.
|
void |
markReusable()
Deprecated.
Marks this connection as being in a reusable communication state.
|
void |
receiveResponseEntity(HttpResponse response)
Deprecated.
|
HttpResponse |
receiveResponseHeader()
Deprecated.
|
void |
releaseConnection()
Deprecated.
Releases the connection with the option of keep-alive.
|
java.lang.Object |
removeAttribute(java.lang.String id)
Deprecated.
|
void |
sendRequestEntity(HttpEntityEnclosingRequest request)
Deprecated.
|
void |
sendRequestHeader(HttpRequest request)
Deprecated.
|
void |
setAttribute(java.lang.String id,
java.lang.Object obj)
Deprecated.
|
void |
setIdleDuration(long duration,
java.util.concurrent.TimeUnit unit)
Deprecated.
Sets the duration that this connection can remain idle before it is
reused.
|
void |
setSocketTimeout(int timeout)
Deprecated.
|
void |
unmarkReusable()
Deprecated.
Marks this connection as not being in a reusable state.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetRoute, getState, layerProtocol, open, setState, tunnelProxy, tunnelTargetgetIdprotected AbstractClientConnAdapter(ClientConnectionManager mgr, OperatedClientConnection conn)
marked as reusable.mgr - the connection manager, or nullconn - the connection to wrap, or nullprotected void detach()
protected OperatedClientConnection getWrappedConnection()
protected ClientConnectionManager getManager()
@Deprecated
protected final void assertNotAborted()
throws java.io.InterruptedIOException
assertValid(OperatedClientConnection)java.io.InterruptedIOExceptionprotected boolean isReleased()
protected final void assertValid(OperatedClientConnection wrappedConn) throws ConnectionShutdownException
ConnectionShutdownException - if there is no wrapped connection
or connection has been abortedpublic boolean isOpen()
public boolean isStale()
public void setSocketTimeout(int timeout)
public int getSocketTimeout()
public HttpConnectionMetrics getMetrics()
public void flush()
throws java.io.IOException
java.io.IOExceptionpublic boolean isResponseAvailable(int timeout)
throws java.io.IOException
java.io.IOExceptionpublic void receiveResponseEntity(HttpResponse response)
throws HttpException,
java.io.IOException
HttpExceptionjava.io.IOExceptionpublic HttpResponse receiveResponseHeader()
throws HttpException,
java.io.IOException
HttpExceptionjava.io.IOExceptionpublic void sendRequestEntity(HttpEntityEnclosingRequest request)
throws HttpException,
java.io.IOException
HttpExceptionjava.io.IOExceptionpublic void sendRequestHeader(HttpRequest request)
throws HttpException,
java.io.IOException
HttpExceptionjava.io.IOExceptionpublic java.net.InetAddress getLocalAddress()
public int getLocalPort()
public java.net.InetAddress getRemoteAddress()
public int getRemotePort()
public boolean isSecure()
ManagedClientConnectionisSecure in interface HttpRoutedConnectionisSecure in interface ManagedClientConnectiontrue if this connection is secure,
false otherwisepublic void bind(java.net.Socket socket)
throws java.io.IOException
ManagedHttpClientConnectionbind in interface ManagedHttpClientConnectionsocket - the socket to bind the connection to.java.io.IOExceptionpublic java.net.Socket getSocket()
ManagedHttpClientConnectiongetSocket in interface ManagedHttpClientConnectionpublic javax.net.ssl.SSLSession getSSLSession()
ManagedClientConnectionSSLSocket, the SSL session of
that socket is obtained. This is a potentially blocking operation.
Note: Whether the underlying socket is an SSL socket
can not necessarily be determined via ManagedClientConnection.isSecure().
Plain sockets may be considered secure, for example if they are
connected to a known host in the same network segment.
On the other hand, SSL sockets may be considered insecure,
for example depending on the chosen cipher suite.
getSSLSession in interface HttpRoutedConnectiongetSSLSession in interface ManagedClientConnectiongetSSLSession in interface ManagedHttpClientConnectionnull otherwisepublic void markReusable()
ManagedClientConnection
A reusable communication state is necessary but not sufficient
for the connection to be reused.
A route mismatch, the connection being closed,
or other circumstances might prevent reuse.
markReusable in interface ManagedClientConnectionpublic void unmarkReusable()
ManagedClientConnectionreuse strategy.
Note:
It is not necessary to call here before writing to
or reading from this connection. Communication attempts will
automatically unmark the state as non-reusable. It can then
be switched back using markReusable.
unmarkReusable in interface ManagedClientConnectionpublic boolean isMarkedReusable()
ManagedClientConnectionmarkReusable and
unmarkReusable for details.isMarkedReusable in interface ManagedClientConnectiontrue if this connection is marked as being in
a reusable communication state,
false otherwisepublic void setIdleDuration(long duration,
java.util.concurrent.TimeUnit unit)
ManagedClientConnectionsetIdleDuration in interface ManagedClientConnectionpublic void releaseConnection()
ConnectionReleaseTriggerabortConnection for a hard release. The
connection may be reused as specified by the duration.releaseConnection in interface ConnectionReleaseTriggerpublic void abortConnection()
ConnectionReleaseTriggerConnectionReleaseTrigger.releaseConnection() for a graceful release.abortConnection in interface ConnectionReleaseTriggerpublic java.lang.Object getAttribute(java.lang.String id)
public java.lang.Object removeAttribute(java.lang.String id)
public void setAttribute(java.lang.String id,
java.lang.Object obj)