Deprecated
(4.2) do not use
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 and Type | Field and Description |
|---|---|
| private final ClientConnectionManager | connManager
The connection manager. |
| private volatile long | duration
The duration this is valid for while idle (in ms). |
| private volatile boolean | markedReusable
The reusability marker. |
| private volatile boolean | released
True if the connection has been shut down or released. |
| private volatile OperatedClientConnection | wrappedConnection
The wrapped connection. |
| Access | Constructor and Description |
|---|---|
| protected | AbstractClientConnAdapter(final ClientConnectionManager
the connection manager, or mgr, final OperatedClientConnection nullthe connection to wrap, or conn)null
Deprecated
as a consequence of
Creates a new connection adapter.
ClientConnectionManager and OperatedClientConnection being deprecated.
|
| Modifier and Type | Method and Description |
|---|---|
| public synchronized void | abortConnection()
Implements org. |
| protected final void | |
| protected final void | assertValid(final OperatedClientConnection wrappedConn)
Deprecated
as a consequence of
Asserts that there is a valid wrapped connection to delegate to.
OperatedClientConnection being deprecated.
|
| public void | bind(final Socket
the socket to bind the connection to. socket)Implements org. |
| protected synchronized void | |
| public void | flush()
Implements org. |
| public Object | getAttribute(final String
the attribute name. id)Implements org. |
| public InetAddress | |
| public int | |
| protected ClientConnectionManager | |
| public HttpConnectionMetrics | getMetrics()
Implements org. |
| public InetAddress | |
| public int | |
| public Socket | getSocket()
Implements org. |
| public int | getSocketTimeout()
Implements org. |
| public SSLSession | getSSLSession()
Implements org. |
| protected OperatedClientConnection | |
| public boolean | isMarkedReusable()
Implements org. |
| public boolean | |
| protected boolean | |
| public boolean | isResponseAvailable(final int
the maximum time in milliseconds to wait for data timeout)Implements org. |
| public boolean | isSecure()
Implements org. |
| public boolean | isStale()
Implements org. |
| public void | markReusable()
Implements org. |
| public void | receiveResponseEntity(final HttpResponse
the response to attach the entity to response)Implements org. |
| public HttpResponse | receiveResponseHeader()
Implements org. |
| public synchronized void | releaseConnection()
Implements org. |
| public Object | removeAttribute(final String
the attribute name. id)Implements org. |
| public void | sendRequestEntity(final HttpEntityEnclosingRequest
the request whose entity to send. request)Implements org. |
| public void | sendRequestHeader(final HttpRequest
the request whose headers to send. request)Implements org. |
| public void | setAttribute(final String
the attribute name. id, final Object the attribute value. obj)Implements org. |
| public void | setIdleDuration(final long duration, final TimeUnit unit)
Implements org. |
| public void | setSocketTimeout(final int
timeout value in milliseconds timeout)Implements org. |
| public void | unmarkReusable()
Implements org. |
| connManager | back to summary |
|---|---|
| private final ClientConnectionManager connManager
Deprecated as a consequence of The connection manager. | |
| duration | back to summary |
|---|---|
| private volatile long duration The duration this is valid for while idle (in ms). | |
| markedReusable | back to summary |
|---|---|
| private volatile boolean markedReusable The reusability marker. | |
| released | back to summary |
|---|---|
| private volatile boolean released True if the connection has been shut down or released. | |
| wrappedConnection | back to summary |
|---|---|
| private volatile OperatedClientConnection wrappedConnection
Deprecated as a consequence of The wrapped connection. | |
| AbstractClientConnAdapter | back to summary |
|---|---|
| protected AbstractClientConnAdapter(final ClientConnectionManager mgr, final OperatedClientConnection conn)
Deprecated as a consequence of Creates a new connection adapter.
The adapter is initially not
| |
| abortConnection | back to summary |
|---|---|
| public synchronized void abortConnection() Implements org. Doc from org. Releases the connection without the option of keep-alive.
This is a "hard" release that implies a shutdown of the connection.
Use
| |
| assertNotAborted | back to summary |
|---|---|
| protected final void assertNotAborted() throws InterruptedIOException
Deprecated (4.1) use
| |
| assertValid | back to summary |
|---|---|
| protected final void assertValid(final OperatedClientConnection wrappedConn) throws ConnectionShutdownException
Deprecated as a consequence of Asserts that there is a valid wrapped connection to delegate to.
| |
| bind | back to summary |
|---|---|
| public void bind(final Socket socket) throws IOException Implements org. Doc from org. 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. | |
| detach | back to summary |
|---|---|
| protected synchronized void detach() Detaches this adapter from the wrapped connection. This adapter becomes useless. | |
| flush | back to summary |
|---|---|
| public void flush() throws IOException Implements org. Doc from org. Writes out all pending buffered data over the open connection.
| |
| getAttribute | back to summary |
|---|---|
| public Object getAttribute(final String id) Implements org. Doc from org. Obtains attribute with the given name. | |
| getLocalAddress | back to summary |
|---|---|
| public InetAddress getLocalAddress() Implements org.
| |
| getLocalPort | back to summary |
|---|---|
| public int getLocalPort() Implements org.
| |
| getManager | back to summary |
|---|---|
| protected ClientConnectionManager getManager()
Deprecated as a consequence of | |
| getMetrics | back to summary |
|---|---|
| public HttpConnectionMetrics getMetrics() Implements org. Doc from org. Returns a collection of connection metrics.
| |
| getRemoteAddress | back to summary |
|---|---|
| public InetAddress getRemoteAddress() Implements org.
| |
| getRemotePort | back to summary |
|---|---|
| public int getRemotePort() Implements org.
| |
| getSocket | back to summary |
|---|---|
| public Socket getSocket() Implements org. Doc from org. Returns the underlying socket.
| |
| getSocketTimeout | back to summary |
|---|---|
| public int getSocketTimeout() Implements org. Doc from org. Returns the socket timeout value.
| |
| getSSLSession | back to summary |
|---|---|
| public SSLSession getSSLSession() Implements org. Doc from org. Obtains the SSL session of the underlying connection, if any.
If this connection is open, and the underlying socket is an
Note Whether the underlying socket is an SSL socket
can not necessarily be determined via
| |
| getWrappedConnection | back to summary |
|---|---|
| protected OperatedClientConnection getWrappedConnection()
Deprecated as a consequence of | |
| isMarkedReusable | back to summary |
|---|---|
| public boolean isMarkedReusable() Implements org. Doc from org. Indicates whether this connection is in a reusable communication state.
See
| |
| isOpen | back to summary |
|---|---|
| public boolean isOpen() Implements org. Doc from org. Checks if this connection is open.
| |
| isReleased | back to summary |
|---|---|
protected boolean isReleased()
| |
| isResponseAvailable | back to summary |
|---|---|
| public boolean isResponseAvailable(final int timeout) throws IOException Implements org. Doc from org. Checks if response data is available from the connection. May wait for the specified time until some data becomes available. Note that some implementations may completely ignore the timeout parameter.
| |
| isSecure | back to summary |
|---|---|
| public boolean isSecure() Implements org. Doc from org. 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.
| |
| isStale | back to summary |
|---|---|
| public boolean isStale() Implements org. Doc from org. Checks whether this connection has gone down. Network connections may get closed during some time of inactivity for several reasons. The next time a read is attempted on such a connection it will throw an IOException. This method tries to alleviate this inconvenience by trying to find out if a connection is still usable. Implementations may do that by attempting a read with a very small timeout. Thus this method may block for a small amount of time before returning a result. It is therefore an expensive operation.
| |
| markReusable | back to summary |
|---|---|
| public void markReusable() Implements org. Doc from org. 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
| |
| receiveResponseEntity | back to summary |
|---|---|
| public void receiveResponseEntity(final HttpResponse response) throws HttpException, IOException Implements org. Doc from org. Receives the next response entity available from this connection and attaches it to an existing HttpResponse object.
| |
| receiveResponseHeader | back to summary |
|---|---|
| public HttpResponse receiveResponseHeader() throws HttpException, IOException Implements org. Doc from org. Receives the request line and headers of the next response available from this connection. The caller should examine the HttpResponse object to find out if it should try to receive a response entity as well.
| |
| releaseConnection | back to summary |
|---|---|
| public synchronized void releaseConnection() Implements org. Doc from org. 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. Use
| |
| removeAttribute | back to summary |
|---|---|
| public Object removeAttribute(final String id) Implements org. Doc from org. Removes attribute with the given name from the context. | |
| sendRequestEntity | back to summary |
|---|---|
| public void sendRequestEntity(final HttpEntityEnclosingRequest request) throws HttpException, IOException Implements org. Doc from org. Sends the request entity over the connection.
| |
| sendRequestHeader | back to summary |
|---|---|
| public void sendRequestHeader(final HttpRequest request) throws HttpException, IOException Implements org. Doc from org. Sends the request line and all headers over the connection.
| |
| setAttribute | back to summary |
|---|---|
| public void setAttribute(final String id, final Object obj) Implements org. Doc from org. Sets value of the attribute with the given name. | |
| setIdleDuration | back to summary |
|---|---|
| public void setIdleDuration(final long duration, final TimeUnit unit) Implements org. Doc from org. 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.
| |
| setSocketTimeout | back to summary |
|---|---|
| public void setSocketTimeout(final int timeout) Implements org. Doc from org. Sets the socket timeout value.
| |
| unmarkReusable | back to summary |
|---|---|
| public void unmarkReusable() Implements org. Doc from org. 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 a
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
| |