Package org.apache.http.impl.nio.client
Class AbstractClientExchangeHandler
- java.lang.Object
-
- org.apache.http.impl.nio.client.AbstractClientExchangeHandler
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,org.apache.http.concurrent.Cancellable
,org.apache.http.nio.protocol.HttpAsyncClientExchangeHandler
- Direct Known Subclasses:
DefaultClientExchangeHandlerImpl
,MinimalClientExchangeHandlerImpl
,PipeliningClientExchangeHandlerImpl
abstract class AbstractClientExchangeHandler extends java.lang.Object implements org.apache.http.nio.protocol.HttpAsyncClientExchangeHandler
AbstractHttpAsyncClientExchangeHandler
class that implements connection management aspects shared by all HTTP exchange handlers.Instances of this class are expected to be accessed by one thread at a time only. The
cancel()
method can be called concurrently by multiple threads.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.atomic.AtomicBoolean
closed
private java.util.concurrent.atomic.AtomicBoolean
completed
private java.util.concurrent.atomic.AtomicReference<java.util.concurrent.Future<org.apache.http.nio.NHttpClientConnection>>
connectionFutureRef
private NHttpClientConnectionManager
connmgr
private org.apache.http.ConnectionReuseStrategy
connReuseStrategy
private static java.util.concurrent.atomic.AtomicLong
COUNTER
private long
id
private org.apache.http.conn.ConnectionKeepAliveStrategy
keepaliveStrategy
private org.apache.http.client.protocol.HttpClientContext
localContext
protected org.apache.commons.logging.Log
log
private java.util.concurrent.atomic.AtomicReference<org.apache.http.nio.NHttpClientConnection>
managedConnRef
private java.util.concurrent.atomic.AtomicReference<org.apache.http.client.methods.HttpRequestWrapper>
requestRef
private java.util.concurrent.atomic.AtomicReference<org.apache.http.HttpResponse>
responseRef
private java.util.concurrent.atomic.AtomicBoolean
routeEstablished
private java.util.concurrent.atomic.AtomicReference<org.apache.http.conn.routing.HttpRoute>
routeRef
private java.util.concurrent.atomic.AtomicReference<org.apache.http.conn.routing.RouteTracker>
routeTrackerRef
private java.util.concurrent.atomic.AtomicReference<java.lang.Long>
validDurationRef
-
Constructor Summary
Constructors Constructor Description AbstractClientExchangeHandler(org.apache.commons.logging.Log log, org.apache.http.client.protocol.HttpClientContext localContext, NHttpClientConnectionManager connmgr, org.apache.http.ConnectionReuseStrategy connReuseStrategy, org.apache.http.conn.ConnectionKeepAliveStrategy keepaliveStrategy)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
cancel()
void
close()
private void
connectionAllocated(org.apache.http.nio.NHttpClientConnection managedConn)
private void
connectionRequestCancelled()
private void
connectionRequestFailed(java.lang.Exception ex)
(package private) void
discardConnection()
(package private) abstract boolean
executionCancelled()
(package private) abstract void
executionFailed(java.lang.Exception ex)
void
failed(java.lang.Exception ex)
(package private) org.apache.http.conn.routing.HttpRoute
getActualRoute()
(package private) org.apache.http.nio.NHttpClientConnection
getConnection()
(package private) org.apache.http.client.methods.HttpRequestWrapper
getCurrentRequest()
(package private) org.apache.http.HttpResponse
getCurrentResponse()
(package private) long
getId()
(package private) org.apache.http.conn.routing.HttpRoute
getRoute()
(package private) boolean
isCompleted()
boolean
isDone()
(package private) boolean
isRouteEstablished()
(package private) boolean
manageConnectionPersistence()
(package private) void
markCompleted()
(package private) void
markConnectionNonReusable()
(package private) void
onRouteComplete()
(package private) void
onRouteToProxy()
(package private) void
onRouteToTarget()
(package private) void
onRouteTunnelToTarget()
(package private) void
onRouteUpgrade()
(package private) void
releaseConnection()
(package private) abstract void
releaseResources()
(package private) void
requestConnection()
(package private) void
setCurrentRequest(org.apache.http.client.methods.HttpRequestWrapper request)
(package private) void
setCurrentResponse(org.apache.http.HttpResponse response)
(package private) void
setRoute(org.apache.http.conn.routing.HttpRoute route)
(package private) void
verifytRoute()
-
-
-
Field Detail
-
COUNTER
private static final java.util.concurrent.atomic.AtomicLong COUNTER
-
log
protected final org.apache.commons.logging.Log log
-
id
private final long id
-
localContext
private final org.apache.http.client.protocol.HttpClientContext localContext
-
connmgr
private final NHttpClientConnectionManager connmgr
-
connReuseStrategy
private final org.apache.http.ConnectionReuseStrategy connReuseStrategy
-
keepaliveStrategy
private final org.apache.http.conn.ConnectionKeepAliveStrategy keepaliveStrategy
-
connectionFutureRef
private final java.util.concurrent.atomic.AtomicReference<java.util.concurrent.Future<org.apache.http.nio.NHttpClientConnection>> connectionFutureRef
-
managedConnRef
private final java.util.concurrent.atomic.AtomicReference<org.apache.http.nio.NHttpClientConnection> managedConnRef
-
routeRef
private final java.util.concurrent.atomic.AtomicReference<org.apache.http.conn.routing.HttpRoute> routeRef
-
routeTrackerRef
private final java.util.concurrent.atomic.AtomicReference<org.apache.http.conn.routing.RouteTracker> routeTrackerRef
-
routeEstablished
private final java.util.concurrent.atomic.AtomicBoolean routeEstablished
-
validDurationRef
private final java.util.concurrent.atomic.AtomicReference<java.lang.Long> validDurationRef
-
requestRef
private final java.util.concurrent.atomic.AtomicReference<org.apache.http.client.methods.HttpRequestWrapper> requestRef
-
responseRef
private final java.util.concurrent.atomic.AtomicReference<org.apache.http.HttpResponse> responseRef
-
completed
private final java.util.concurrent.atomic.AtomicBoolean completed
-
closed
private final java.util.concurrent.atomic.AtomicBoolean closed
-
-
Constructor Detail
-
AbstractClientExchangeHandler
AbstractClientExchangeHandler(org.apache.commons.logging.Log log, org.apache.http.client.protocol.HttpClientContext localContext, NHttpClientConnectionManager connmgr, org.apache.http.ConnectionReuseStrategy connReuseStrategy, org.apache.http.conn.ConnectionKeepAliveStrategy keepaliveStrategy)
-
-
Method Detail
-
getId
final long getId()
-
isCompleted
final boolean isCompleted()
-
markCompleted
final void markCompleted()
-
markConnectionNonReusable
final void markConnectionNonReusable()
-
isRouteEstablished
final boolean isRouteEstablished()
-
getRoute
final org.apache.http.conn.routing.HttpRoute getRoute()
-
setRoute
final void setRoute(org.apache.http.conn.routing.HttpRoute route)
-
getCurrentRequest
final org.apache.http.client.methods.HttpRequestWrapper getCurrentRequest()
-
setCurrentRequest
final void setCurrentRequest(org.apache.http.client.methods.HttpRequestWrapper request)
-
getCurrentResponse
final org.apache.http.HttpResponse getCurrentResponse()
-
setCurrentResponse
final void setCurrentResponse(org.apache.http.HttpResponse response)
-
getActualRoute
final org.apache.http.conn.routing.HttpRoute getActualRoute()
-
verifytRoute
final void verifytRoute()
-
onRouteToTarget
final void onRouteToTarget() throws java.io.IOException
- Throws:
java.io.IOException
-
onRouteToProxy
final void onRouteToProxy() throws java.io.IOException
- Throws:
java.io.IOException
-
onRouteUpgrade
final void onRouteUpgrade() throws java.io.IOException
- Throws:
java.io.IOException
-
onRouteTunnelToTarget
final void onRouteTunnelToTarget()
-
onRouteComplete
final void onRouteComplete()
-
getConnection
final org.apache.http.nio.NHttpClientConnection getConnection()
-
releaseConnection
final void releaseConnection()
-
discardConnection
final void discardConnection()
-
manageConnectionPersistence
final boolean manageConnectionPersistence()
-
connectionAllocated
private void connectionAllocated(org.apache.http.nio.NHttpClientConnection managedConn)
-
connectionRequestFailed
private void connectionRequestFailed(java.lang.Exception ex)
-
connectionRequestCancelled
private void connectionRequestCancelled()
-
requestConnection
final void requestConnection()
-
releaseResources
abstract void releaseResources()
-
executionFailed
abstract void executionFailed(java.lang.Exception ex)
-
executionCancelled
abstract boolean executionCancelled()
-
close
public final void close()
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
-
isDone
public final boolean isDone()
- Specified by:
isDone
in interfaceorg.apache.http.nio.protocol.HttpAsyncClientExchangeHandler
-
failed
public final void failed(java.lang.Exception ex)
- Specified by:
failed
in interfaceorg.apache.http.nio.protocol.HttpAsyncClientExchangeHandler
-
cancel
public final boolean cancel()
- Specified by:
cancel
in interfaceorg.apache.http.concurrent.Cancellable
-
-