Class ConnectionHolder

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, org.apache.http.concurrent.Cancellable, ConnectionReleaseTrigger

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

      • log

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

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

        private final java.util.concurrent.atomic.AtomicBoolean released
      • reusable

        private volatile boolean reusable
      • state

        private volatile java.lang.Object state
      • validDuration

        private volatile long validDuration
      • timeUnit

        private volatile java.util.concurrent.TimeUnit timeUnit
    • Constructor Detail

      • ConnectionHolder

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

      • isReusable

        public boolean isReusable()
      • markReusable

        public void markReusable()
      • markNonReusable

        public void markNonReusable()
      • setState

        public void setState​(java.lang.Object state)
      • setValidFor

        public void setValidFor​(long duration,
                                java.util.concurrent.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
      • cancel

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

        public boolean isReleased()
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Throws:
        java.io.IOException