Class ConnectionHolder

java.lang.Object
org.apache.http.impl.execchain.ConnectionHolder
All Implemented Interfaces:
Closeable, AutoCloseable, org.apache.http.concurrent.Cancellable, ConnectionReleaseTrigger

@Contract(threading=SAFE) class ConnectionHolder extends Object implements ConnectionReleaseTrigger, org.apache.http.concurrent.Cancellable, Closeable
Internal connection holder.
Since:
4.3
  • Field Details

    • log

      private final org.apache.commons.logging.Log log
    • manager

      private final HttpClientConnectionManager manager
    • managedConn

      private final org.apache.http.HttpClientConnection managedConn
    • released

      private final AtomicBoolean released
    • reusable

      private volatile boolean reusable
    • state

      private volatile Object state
    • validDuration

      private volatile long validDuration
    • timeUnit

      private volatile TimeUnit timeUnit
  • Constructor Details

    • ConnectionHolder

      public ConnectionHolder(org.apache.commons.logging.Log log, HttpClientConnectionManager manager, org.apache.http.HttpClientConnection managedConn)
  • Method Details

    • isReusable

      public boolean isReusable()
    • markReusable

      public void markReusable()
    • markNonReusable

      public void markNonReusable()
    • setState

      public void setState(Object state)
    • setValidFor

      public void setValidFor(long duration, TimeUnit timeUnit)
    • releaseConnection

      private void releaseConnection(boolean reusable)
    • releaseConnection

      public void releaseConnection()
      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. Use abortConnection for a hard release. The connection may be reused as specified by the duration.
      Specified by:
      releaseConnection in interface ConnectionReleaseTrigger
    • abortConnection

      public void abortConnection()
      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. Use ConnectionReleaseTrigger.releaseConnection() for a graceful release.
      Specified by:
      abortConnection in interface ConnectionReleaseTrigger
    • cancel

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

      public boolean isReleased()
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException