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.Log
private final org.apache.http.HttpClientConnection
private final HttpClientConnectionManager
private final AtomicBoolean
private boolean
private Object
private TimeUnit
private long
-
Constructor Summary
ConstructorsConstructorDescriptionConnectionHolder
(org.apache.commons.logging.Log log, HttpClientConnectionManager manager, org.apache.http.HttpClientConnection managedConn) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Releases the connection without the option of keep-alive.boolean
cancel()
void
close()
boolean
boolean
void
void
void
Releases the connection with the option of keep-alive.private void
releaseConnection
(boolean reusable) void
void
setValidFor
(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: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. UseabortConnection
for a hard release. The connection may be reused as specified by the duration.- Specified by:
releaseConnection
in interfaceConnectionReleaseTrigger
-
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. UseConnectionReleaseTrigger.releaseConnection()
for a graceful release.- Specified by:
abortConnection
in interfaceConnectionReleaseTrigger
-
cancel
public boolean cancel()- Specified by:
cancel
in interfaceorg.apache.http.concurrent.Cancellable
-
isReleased
public boolean isReleased() -
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-