Class AbstractClientConnAdapter
- java.lang.Object
-
- org.apache.http.impl.conn.AbstractClientConnAdapter
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,ConnectionReleaseTrigger
,HttpRoutedConnection
,ManagedClientConnection
,ManagedHttpClientConnection
,org.apache.http.HttpClientConnection
,org.apache.http.HttpConnection
,org.apache.http.HttpInetConnection
,org.apache.http.protocol.HttpContext
- Direct Known Subclasses:
AbstractPooledConnAdapter
@Deprecated public abstract class AbstractClientConnAdapter extends java.lang.Object implements ManagedClientConnection, org.apache.http.protocol.HttpContext
Deprecated.(4.2) do not useAbstract adapter fromoperated
tomanaged
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 byisMarkedReusable
. 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.- Since:
- 4.0
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractClientConnAdapter(ClientConnectionManager mgr, OperatedClientConnection conn)
Deprecated.Creates a new connection adapter.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
abortConnection()
Deprecated.Releases the connection without the option of keep-alive.protected void
assertNotAborted()
Deprecated.(4.1) useassertValid(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.org.apache.http.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(org.apache.http.HttpResponse response)
Deprecated.org.apache.http.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(org.apache.http.HttpEntityEnclosingRequest request)
Deprecated.void
sendRequestHeader(org.apache.http.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.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.http.conn.ManagedClientConnection
getRoute, getState, layerProtocol, open, setState, tunnelProxy, tunnelTarget
-
Methods inherited from interface org.apache.http.conn.ManagedHttpClientConnection
getId
-
-
-
-
Constructor Detail
-
AbstractClientConnAdapter
protected AbstractClientConnAdapter(ClientConnectionManager mgr, OperatedClientConnection conn)
Deprecated.Creates a new connection adapter. The adapter is initially notmarked
as reusable.- Parameters:
mgr
- the connection manager, ornull
conn
- the connection to wrap, ornull
-
-
Method Detail
-
detach
protected void detach()
Deprecated.Detaches this adapter from the wrapped connection. This adapter becomes useless.
-
getWrappedConnection
protected OperatedClientConnection getWrappedConnection()
Deprecated.
-
getManager
protected ClientConnectionManager getManager()
Deprecated.
-
assertNotAborted
@Deprecated protected final void assertNotAborted() throws java.io.InterruptedIOException
Deprecated.(4.1) useassertValid(OperatedClientConnection)
- Throws:
java.io.InterruptedIOException
-
isReleased
protected boolean isReleased()
Deprecated.- Returns:
- value of released flag
- Since:
- 4.1
-
assertValid
protected final void assertValid(OperatedClientConnection wrappedConn) throws ConnectionShutdownException
Deprecated.Asserts that there is a valid wrapped connection to delegate to.- Throws:
ConnectionShutdownException
- if there is no wrapped connection or connection has been aborted
-
isOpen
public boolean isOpen()
Deprecated.- Specified by:
isOpen
in interfaceorg.apache.http.HttpConnection
-
isStale
public boolean isStale()
Deprecated.- Specified by:
isStale
in interfaceorg.apache.http.HttpConnection
-
setSocketTimeout
public void setSocketTimeout(int timeout)
Deprecated.- Specified by:
setSocketTimeout
in interfaceorg.apache.http.HttpConnection
-
getSocketTimeout
public int getSocketTimeout()
Deprecated.- Specified by:
getSocketTimeout
in interfaceorg.apache.http.HttpConnection
-
getMetrics
public org.apache.http.HttpConnectionMetrics getMetrics()
Deprecated.- Specified by:
getMetrics
in interfaceorg.apache.http.HttpConnection
-
flush
public void flush() throws java.io.IOException
Deprecated.- Specified by:
flush
in interfaceorg.apache.http.HttpClientConnection
- Throws:
java.io.IOException
-
isResponseAvailable
public boolean isResponseAvailable(int timeout) throws java.io.IOException
Deprecated.- Specified by:
isResponseAvailable
in interfaceorg.apache.http.HttpClientConnection
- Throws:
java.io.IOException
-
receiveResponseEntity
public void receiveResponseEntity(org.apache.http.HttpResponse response) throws org.apache.http.HttpException, java.io.IOException
Deprecated.- Specified by:
receiveResponseEntity
in interfaceorg.apache.http.HttpClientConnection
- Throws:
org.apache.http.HttpException
java.io.IOException
-
receiveResponseHeader
public org.apache.http.HttpResponse receiveResponseHeader() throws org.apache.http.HttpException, java.io.IOException
Deprecated.- Specified by:
receiveResponseHeader
in interfaceorg.apache.http.HttpClientConnection
- Throws:
org.apache.http.HttpException
java.io.IOException
-
sendRequestEntity
public void sendRequestEntity(org.apache.http.HttpEntityEnclosingRequest request) throws org.apache.http.HttpException, java.io.IOException
Deprecated.- Specified by:
sendRequestEntity
in interfaceorg.apache.http.HttpClientConnection
- Throws:
org.apache.http.HttpException
java.io.IOException
-
sendRequestHeader
public void sendRequestHeader(org.apache.http.HttpRequest request) throws org.apache.http.HttpException, java.io.IOException
Deprecated.- Specified by:
sendRequestHeader
in interfaceorg.apache.http.HttpClientConnection
- Throws:
org.apache.http.HttpException
java.io.IOException
-
getLocalAddress
public java.net.InetAddress getLocalAddress()
Deprecated.- Specified by:
getLocalAddress
in interfaceorg.apache.http.HttpInetConnection
-
getLocalPort
public int getLocalPort()
Deprecated.- Specified by:
getLocalPort
in interfaceorg.apache.http.HttpInetConnection
-
getRemoteAddress
public java.net.InetAddress getRemoteAddress()
Deprecated.- Specified by:
getRemoteAddress
in interfaceorg.apache.http.HttpInetConnection
-
getRemotePort
public int getRemotePort()
Deprecated.- Specified by:
getRemotePort
in interfaceorg.apache.http.HttpInetConnection
-
isSecure
public boolean isSecure()
Deprecated.Description copied from interface:ManagedClientConnection
Indicates whether this connection is secure. The return value is well-defined only while the connection is open. It may change even while the connection is open.- Specified by:
isSecure
in interfaceHttpRoutedConnection
- Specified by:
isSecure
in interfaceManagedClientConnection
- Returns:
true
if this connection is secure,false
otherwise
-
bind
public void bind(java.net.Socket socket) throws java.io.IOException
Deprecated.Description copied from interface:ManagedHttpClientConnection
Binds this connection to the given socket. The connection is considered open if it is bound and the underlying socket is connection to a remote host.- Specified by:
bind
in interfaceManagedHttpClientConnection
- Parameters:
socket
- the socket to bind the connection to.- Throws:
java.io.IOException
-
getSocket
public java.net.Socket getSocket()
Deprecated.Description copied from interface:ManagedHttpClientConnection
Returns the underlying socket.- Specified by:
getSocket
in interfaceManagedHttpClientConnection
-
getSSLSession
public javax.net.ssl.SSLSession getSSLSession()
Deprecated.Description copied from interface:ManagedClientConnection
Obtains the SSL session of the underlying connection, if any. If this connection is open, and the underlying socket is anSSLSocket
, 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.- Specified by:
getSSLSession
in interfaceHttpRoutedConnection
- Specified by:
getSSLSession
in interfaceManagedClientConnection
- Specified by:
getSSLSession
in interfaceManagedHttpClientConnection
- Returns:
- the underlying SSL session if available,
null
otherwise
-
markReusable
public void markReusable()
Deprecated.Description copied from interface:ManagedClientConnection
Marks this connection as being in a reusable communication state. The checkpoints for reuseable communication states (in the absence of pipelining) are before sending a request and after receiving the response in its entirety. The connection will automatically clear the checkpoint when used for communication. A call to this method indicates that the next checkpoint has been reached.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.- Specified by:
markReusable
in interfaceManagedClientConnection
-
unmarkReusable
public void unmarkReusable()
Deprecated.Description copied from interface:ManagedClientConnection
Marks this connection as not being in a reusable state. This can be used immediately before releasing this connection to prevent its reuse. Reasons for preventing reuse include error conditions and the evaluation of areuse 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
.- Specified by:
unmarkReusable
in interfaceManagedClientConnection
-
isMarkedReusable
public boolean isMarkedReusable()
Deprecated.Description copied from interface:ManagedClientConnection
Indicates whether this connection is in a reusable communication state. SeemarkReusable
andunmarkReusable
for details.- Specified by:
isMarkedReusable
in interfaceManagedClientConnection
- Returns:
true
if this connection is marked as being in a reusable communication state,false
otherwise
-
setIdleDuration
public void setIdleDuration(long duration, java.util.concurrent.TimeUnit unit)
Deprecated.Description copied from interface:ManagedClientConnection
Sets the duration that this connection can remain idle before it is reused. The connection should not be used again if this time elapses. The idle duration must be reset after each request sent over this connection. The elapsed time starts counting when the connection is released, which is typically after the headers (and any response body, if present) is fully consumed.- Specified by:
setIdleDuration
in interfaceManagedClientConnection
-
releaseConnection
public void releaseConnection()
Deprecated.Description copied from interface:ConnectionReleaseTrigger
Releases the connection with the option of keep-alive. This is a "graceful" release and may cause IO operations for consuming the remainder of a response entity. UseabortConnection
for a hard release. The connection may be reused as specified by the duration.- Specified by:
releaseConnection
in interfaceConnectionReleaseTrigger
-
abortConnection
public void abortConnection()
Deprecated.Description copied from interface:ConnectionReleaseTrigger
Releases the connection without the option of keep-alive. This is a "hard" release that implies a shutdown of the connection. UseConnectionReleaseTrigger.releaseConnection()
for a graceful release.- Specified by:
abortConnection
in interfaceConnectionReleaseTrigger
-
getAttribute
public java.lang.Object getAttribute(java.lang.String id)
Deprecated.- Specified by:
getAttribute
in interfaceorg.apache.http.protocol.HttpContext
-
removeAttribute
public java.lang.Object removeAttribute(java.lang.String id)
Deprecated.- Specified by:
removeAttribute
in interfaceorg.apache.http.protocol.HttpContext
-
setAttribute
public void setAttribute(java.lang.String id, java.lang.Object obj)
Deprecated.- Specified by:
setAttribute
in interfaceorg.apache.http.protocol.HttpContext
-
-