Class AbstractClientExchangeHandler

java.lang.Object
org.apache.http.impl.nio.client.AbstractClientExchangeHandler
All Implemented Interfaces:
Closeable, AutoCloseable, org.apache.http.concurrent.Cancellable, org.apache.http.nio.protocol.HttpAsyncClientExchangeHandler
Direct Known Subclasses:
DefaultClientExchangeHandlerImpl, MinimalClientExchangeHandlerImpl, PipeliningClientExchangeHandlerImpl

abstract class AbstractClientExchangeHandler extends Object implements org.apache.http.nio.protocol.HttpAsyncClientExchangeHandler
Abstract HttpAsyncClientExchangeHandler 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 Details

    • COUNTER

      private static final 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 AtomicReference<Future<org.apache.http.nio.NHttpClientConnection>> connectionFutureRef
    • managedConnRef

      private final AtomicReference<org.apache.http.nio.NHttpClientConnection> managedConnRef
    • routeRef

      private final AtomicReference<org.apache.http.conn.routing.HttpRoute> routeRef
    • routeTrackerRef

      private final AtomicReference<org.apache.http.conn.routing.RouteTracker> routeTrackerRef
    • routeEstablished

      private final AtomicBoolean routeEstablished
    • validDurationRef

      private final AtomicReference<Long> validDurationRef
    • requestRef

      private final AtomicReference<org.apache.http.client.methods.HttpRequestWrapper> requestRef
    • responseRef

      private final AtomicReference<org.apache.http.HttpResponse> responseRef
    • completed

      private final AtomicBoolean completed
    • closed

      private final AtomicBoolean closed
  • Constructor Details

    • 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 Details

    • 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 IOException
      Throws:
      IOException
    • onRouteToProxy

      final void onRouteToProxy() throws IOException
      Throws:
      IOException
    • onRouteUpgrade

      final void onRouteUpgrade() throws IOException
      Throws:
      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(Exception ex)
    • connectionRequestCancelled

      private void connectionRequestCancelled()
    • requestConnection

      final void requestConnection()
    • releaseResources

      abstract void releaseResources()
    • executionFailed

      abstract void executionFailed(Exception ex)
    • executionCancelled

      abstract boolean executionCancelled()
    • close

      public final void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • isDone

      public final boolean isDone()
      Specified by:
      isDone in interface org.apache.http.nio.protocol.HttpAsyncClientExchangeHandler
    • failed

      public final void failed(Exception ex)
      Specified by:
      failed in interface org.apache.http.nio.protocol.HttpAsyncClientExchangeHandler
    • cancel

      public final boolean cancel()
      Specified by:
      cancel in interface org.apache.http.concurrent.Cancellable