Package org.apache.http.impl.execchain
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 Summary
FieldsModifier and TypeFieldDescriptionprivate final org.apache.commons.logging.Logprivate final org.apache.http.HttpClientConnectionprivate final HttpClientConnectionManagerprivate final AtomicBooleanprivate booleanprivate Objectprivate TimeUnitprivate long -
Constructor Summary
ConstructorsConstructorDescriptionConnectionHolder(org.apache.commons.logging.Log log, HttpClientConnectionManager manager, org.apache.http.HttpClientConnection managedConn) -
Method Summary
Modifier and TypeMethodDescriptionvoidReleases the connection without the option of keep-alive.booleancancel()voidclose()booleanbooleanvoidvoidvoidReleases the connection with the option of keep-alive.private voidreleaseConnection(boolean reusable) voidvoidsetValidFor(long duration, TimeUnit timeUnit)
-
Field Details
-
log
private final org.apache.commons.logging.Log log -
manager
-
managedConn
private final org.apache.http.HttpClientConnection managedConn -
released
-
reusable
private volatile boolean reusable -
state
-
validDuration
private volatile long validDuration -
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
-
setValidFor
-
releaseConnection
private void releaseConnection(boolean reusable) -
releaseConnection
public void releaseConnection()Description copied from interface:ConnectionReleaseTriggerReleases 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. UseabortConnectionfor a hard release. The connection may be reused as specified by the duration.- Specified by:
releaseConnectionin interfaceConnectionReleaseTrigger
-
abortConnection
public void abortConnection()Description copied from interface:ConnectionReleaseTriggerReleases the connection without the option of keep-alive. This is a "hard" release that implies a shutdown of the connection. UseConnectionReleaseTrigger.releaseConnection()for a graceful release.- Specified by:
abortConnectionin interfaceConnectionReleaseTrigger
-
cancel
public boolean cancel()- Specified by:
cancelin interfaceorg.apache.http.concurrent.Cancellable
-
isReleased
public boolean isReleased() -
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-