|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.http.impl.conn.AbstractClientConnAdapter
public abstract class AbstractClientConnAdapter
Abstract adapter from 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.
| Constructor Summary | |
|---|---|
protected |
AbstractClientConnAdapter(ClientConnectionManager mgr,
OperatedClientConnection conn)
Creates a new connection adapter. |
| Method Summary | |
|---|---|
void |
abortConnection()
Releases the connection without the option of keep-alive. |
protected void |
assertNotAborted()
Asserts that the connection has not been aborted. |
protected void |
assertValid(OperatedClientConnection wrappedConn)
Asserts that there is a wrapped connection to delegate to. |
protected void |
detach()
Detaches this adapter from the wrapped connection. |
void |
flush()
Writes out all pending buffered data over the open connection. |
InetAddress |
getLocalAddress()
|
int |
getLocalPort()
|
protected ClientConnectionManager |
getManager()
|
HttpConnectionMetrics |
getMetrics()
Returns a collection of connection metrcis |
InetAddress |
getRemoteAddress()
|
int |
getRemotePort()
|
int |
getSocketTimeout()
Returns the socket timeout value. |
SSLSession |
getSSLSession()
Obtains the SSL session of the underlying connection, if any. |
protected OperatedClientConnection |
getWrappedConnection()
|
boolean |
isMarkedReusable()
Indicates whether this connection is in a reusable communication state. |
boolean |
isOpen()
Checks if this connection is open. |
boolean |
isResponseAvailable(int timeout)
Checks if response data is available from the connection. |
boolean |
isSecure()
Indicates whether this connection is secure. |
boolean |
isStale()
Checks whether this connection has gone down. |
void |
markReusable()
Marks this connection as being in a reusable communication state. |
void |
receiveResponseEntity(HttpResponse response)
Receives the next response entity available from this connection and attaches it to an existing HttpResponse object. |
HttpResponse |
receiveResponseHeader()
Receives the request line and headers of the next response available from this connection. |
void |
releaseConnection()
Releases the connection with the option of keep-alive. |
void |
sendRequestEntity(HttpEntityEnclosingRequest request)
Sends the request entity over the connection. |
void |
sendRequestHeader(HttpRequest request)
Sends the request line and all headers over the connection. |
void |
setIdleDuration(long duration,
TimeUnit unit)
Sets the duration that this connection can remain idle before it is reused. |
void |
setSocketTimeout(int timeout)
Sets the socket timeout value. |
void |
unmarkReusable()
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.HttpConnection |
|---|
close, shutdown |
| Constructor Detail |
|---|
protected AbstractClientConnAdapter(ClientConnectionManager mgr,
OperatedClientConnection conn)
marked as reusable.
mgr - the connection manager, or nullconn - the connection to wrap, or null| Method Detail |
|---|
protected void detach()
protected OperatedClientConnection getWrappedConnection()
protected ClientConnectionManager getManager()
protected final void assertNotAborted()
throws InterruptedIOException
InterruptedIOException - if the connection has been abortedprotected final void assertValid(OperatedClientConnection wrappedConn)
IllegalStateException - if there is no wrapped connection
or connection has been abortedpublic boolean isOpen()
HttpConnection
isOpen in interface HttpConnectionpublic boolean isStale()
HttpConnection
isStale in interface HttpConnectiontrue if attempts to use this connection are
likely to succeed, or false if they are likely
to fail and this connection should be closedpublic void setSocketTimeout(int timeout)
HttpConnection
setSocketTimeout in interface HttpConnectiontimeout - timeout value in millisecondspublic int getSocketTimeout()
HttpConnection
getSocketTimeout in interface HttpConnection0 if timeout is disabled or -1 if
timeout is undefined.public HttpConnectionMetrics getMetrics()
HttpConnection
getMetrics in interface HttpConnection
public void flush()
throws IOException
HttpClientConnection
flush in interface HttpClientConnectionIOException
public boolean isResponseAvailable(int timeout)
throws IOException
HttpClientConnection
isResponseAvailable in interface HttpClientConnectiontimeout - the maximum time in milliseconds to wait for data
timeout milliseconds.
IOException - if an error happens on the connection
public void receiveResponseEntity(HttpResponse response)
throws HttpException,
IOException
HttpClientConnection
receiveResponseEntity in interface HttpClientConnectionresponse - the response to attach the entity to
HttpException
IOException
public HttpResponse receiveResponseHeader()
throws HttpException,
IOException
HttpClientConnection
receiveResponseHeader in interface HttpClientConnectionHttpException
IOException
public void sendRequestEntity(HttpEntityEnclosingRequest request)
throws HttpException,
IOException
HttpClientConnection
sendRequestEntity in interface HttpClientConnectionrequest - the request whose entity to send.
HttpException
IOException
public void sendRequestHeader(HttpRequest request)
throws HttpException,
IOException
HttpClientConnection
sendRequestHeader in interface HttpClientConnectionrequest - the request whose headers to send.
HttpException
IOExceptionpublic InetAddress getLocalAddress()
getLocalAddress in interface HttpInetConnectionpublic int getLocalPort()
getLocalPort in interface HttpInetConnectionpublic InetAddress getRemoteAddress()
getRemoteAddress in interface HttpInetConnectionpublic int getRemotePort()
getRemotePort in interface HttpInetConnectionpublic boolean isSecure()
ManagedClientConnection
isSecure in interface ManagedClientConnectiontrue if this connection is secure,
false otherwisepublic SSLSession getSSLSession()
ManagedClientConnectionSSLSocket, 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 ManagedClientConnectionnull otherwisepublic void markReusable()
ManagedClientConnectionroute mismatch, the connection being closed,
or other circumstances might prevent reuse.
markReusable in interface ManagedClientConnectionpublic void unmarkReusable()
ManagedClientConnectionreuse strategy.
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 otherwise
public void setIdleDuration(long duration,
TimeUnit unit)
ManagedClientConnection
setIdleDuration 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()
ConnectionReleaseTriggerreleaseConnection for a graceful release.
abortConnection in interface ConnectionReleaseTrigger
|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||