@Deprecated @NotThreadSafe public abstract class AbstractClientConnAdapter extends Object implements ManagedClientConnection, HttpContext
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.
RESERVED_PREFIX
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(Socket socket)
Deprecated.
Binds this connection to the given socket.
|
protected void |
detach()
Deprecated.
Detaches this adapter from the wrapped connection.
|
void |
flush()
Deprecated.
|
Object |
getAttribute(String id)
Deprecated.
|
InetAddress |
getLocalAddress()
Deprecated.
|
int |
getLocalPort()
Deprecated.
|
protected ClientConnectionManager |
getManager()
Deprecated.
|
HttpConnectionMetrics |
getMetrics()
Deprecated.
|
InetAddress |
getRemoteAddress()
Deprecated.
|
int |
getRemotePort()
Deprecated.
|
Socket |
getSocket()
Deprecated.
Returns the underlying socket.
|
int |
getSocketTimeout()
Deprecated.
|
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.
|
Object |
removeAttribute(String id)
Deprecated.
|
void |
sendRequestEntity(HttpEntityEnclosingRequest request)
Deprecated.
|
void |
sendRequestHeader(HttpRequest request)
Deprecated.
|
void |
setAttribute(String id,
Object obj)
Deprecated.
|
void |
setIdleDuration(long duration,
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, wait
getRoute, getState, layerProtocol, open, setState, tunnelProxy, tunnelTarget
getId
close, shutdown
protected AbstractClientConnAdapter(ClientConnectionManager mgr, OperatedClientConnection conn)
marked
as reusable.mgr
- the connection manager, or null
conn
- the connection to wrap, or null
protected void detach()
protected OperatedClientConnection getWrappedConnection()
protected ClientConnectionManager getManager()
@Deprecated protected final void assertNotAborted() throws InterruptedIOException
assertValid(OperatedClientConnection)
InterruptedIOException
protected boolean isReleased()
protected final void assertValid(OperatedClientConnection wrappedConn) throws ConnectionShutdownException
ConnectionShutdownException
- if there is no wrapped connection
or connection has been abortedpublic boolean isOpen()
isOpen
in interface HttpConnection
public boolean isStale()
isStale
in interface HttpConnection
public void setSocketTimeout(int timeout)
setSocketTimeout
in interface HttpConnection
public int getSocketTimeout()
getSocketTimeout
in interface HttpConnection
public HttpConnectionMetrics getMetrics()
getMetrics
in interface HttpConnection
public void flush() throws IOException
flush
in interface HttpClientConnection
IOException
public boolean isResponseAvailable(int timeout) throws IOException
isResponseAvailable
in interface HttpClientConnection
IOException
public void receiveResponseEntity(HttpResponse response) throws HttpException, IOException
receiveResponseEntity
in interface HttpClientConnection
HttpException
IOException
public HttpResponse receiveResponseHeader() throws HttpException, IOException
receiveResponseHeader
in interface HttpClientConnection
HttpException
IOException
public void sendRequestEntity(HttpEntityEnclosingRequest request) throws HttpException, IOException
sendRequestEntity
in interface HttpClientConnection
HttpException
IOException
public void sendRequestHeader(HttpRequest request) throws HttpException, IOException
sendRequestHeader
in interface HttpClientConnection
HttpException
IOException
public InetAddress getLocalAddress()
getLocalAddress
in interface HttpInetConnection
public int getLocalPort()
getLocalPort
in interface HttpInetConnection
public InetAddress getRemoteAddress()
getRemoteAddress
in interface HttpInetConnection
public int getRemotePort()
getRemotePort
in interface HttpInetConnection
public boolean isSecure()
ManagedClientConnection
isSecure
in interface HttpRoutedConnection
isSecure
in interface ManagedClientConnection
true
if this connection is secure,
false
otherwisepublic void bind(Socket socket) throws IOException
ManagedHttpClientConnection
bind
in interface ManagedHttpClientConnection
socket
- the socket to bind the connection to.IOException
public Socket getSocket()
ManagedHttpClientConnection
getSocket
in interface ManagedHttpClientConnection
public SSLSession getSSLSession()
ManagedClientConnection
SSLSocket
, the SSL session of
that socket is obtained. This is a potentially blocking operation.
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 HttpRoutedConnection
getSSLSession
in interface ManagedClientConnection
getSSLSession
in interface ManagedHttpClientConnection
null
otherwisepublic void markReusable()
ManagedClientConnection
route
mismatch, the connection being closed,
or other circumstances might prevent reuse.markReusable
in interface ManagedClientConnection
public void unmarkReusable()
ManagedClientConnection
reuse strategy
.
markReusable
.unmarkReusable
in interface ManagedClientConnection
public boolean isMarkedReusable()
ManagedClientConnection
markReusable
and
unmarkReusable
for details.isMarkedReusable
in interface ManagedClientConnection
true
if this connection is marked as being in
a reusable communication state,
false
otherwisepublic void setIdleDuration(long duration, TimeUnit unit)
ManagedClientConnection
setIdleDuration
in interface ManagedClientConnection
public void releaseConnection()
ConnectionReleaseTrigger
abortConnection
for a hard release. The
connection may be reused as specified by the duration.releaseConnection
in interface ConnectionReleaseTrigger
public void abortConnection()
ConnectionReleaseTrigger
ConnectionReleaseTrigger.releaseConnection()
for a graceful release.abortConnection
in interface ConnectionReleaseTrigger
public Object getAttribute(String id)
getAttribute
in interface HttpContext
public Object removeAttribute(String id)
removeAttribute
in interface HttpContext
public void setAttribute(String id, Object obj)
setAttribute
in interface HttpContext
Copyright © 1999–2013 The Apache Software Foundation. All rights reserved.