Top Description Fields Constructors Methods
org.apache.http.conn

public Class BasicManagedEntity

extends HttpEntityWrapper
implements ConnectionReleaseTrigger, EofSensorWatcher
Class Inheritance
All Implemented Interfaces
org.apache.http.conn.EofSensorWatcher, org.apache.http.conn.ConnectionReleaseTrigger
Annotations
@Deprecated
Imports
java.io.IOException, .InputStream, .OutputStream, java.net.SocketException, org.apache.http.HttpEntity, org.apache.http.entity.HttpEntityWrapper, org.apache.http.util.Args, .EntityUtils

Deprecated

(4.3) do not use.

An entity that releases a connection. A ManagedClientConnection will typically not return a managed entity, but you can replace the unmanaged entity in the response with a managed one.
Since
4.0

Field Summary

Modifier and TypeField and Description
protected final boolean
attemptReuse

Whether to keep the connection alive.

protected ManagedClientConnection
managedConn

The connection to release.

Inherited from org.apache.http.entity.HttpEntityWrapper:
wrappedEntity

Constructor Summary

AccessConstructor and Description
public
BasicManagedEntity(final HttpEntity
the entity of which to wrap the content. Note that the argument entity can no longer be used afterwards, since the content will be taken by this managed entity.
entity
,
final ManagedClientConnection
the connection to release
conn
,
final boolean
whether the connection should be re-used
reuse
)

Deprecated as a consequence of ManagedClientConnection being deprecated.
Creates a new managed entity that can release a connection.

Method Summary

Modifier and TypeMethod and Description
public void
abortConnection()

Implements org.apache.http.conn.ConnectionReleaseTrigger.abortConnection.

Releases the connection without the option of keep-alive.
public void
consumeContent()

Overrides org.apache.http.entity.HttpEntityWrapper.consumeContent.

Implements org.apache.http.HttpEntity.consumeContent.

Deprecated (4.1) Use EntityUtils#consume(HttpEntity)
This method is deprecated since version 4.1.
private void
public boolean
eofDetected(final InputStream
the underlying stream which has reached EOF
wrapped
)

Implements org.apache.http.conn.EofSensorWatcher.eofDetected.

Indicates that EOF is detected.
public InputStream
getContent()

Overrides org.apache.http.entity.HttpEntityWrapper.getContent.

Implements org.apache.http.HttpEntity.getContent.

Returns a content stream of the entity.
public boolean
isRepeatable()

Overrides org.apache.http.entity.HttpEntityWrapper.isRepeatable.

Implements org.apache.http.HttpEntity.isRepeatable.

Tells if the entity is capable of producing its data more than once.
public void
releaseConnection()

Implements org.apache.http.conn.ConnectionReleaseTrigger.releaseConnection.

Releases the connection with the option of keep-alive.
protected void
releaseManagedConnection()

Releases the connection gracefully.

public boolean
streamAbort(final InputStream
the underlying stream which has not reached EOF
wrapped
)

Implements org.apache.http.conn.EofSensorWatcher.streamAbort.

Indicates that the stream is aborted.
public boolean
streamClosed(final InputStream
the underlying stream which has not reached EOF
wrapped
)

Implements org.apache.http.conn.EofSensorWatcher.streamClosed.

Indicates that the stream is closed.
public void
writeTo(final OutputStream
the output stream to write entity content to
outStream
)

Overrides org.apache.http.entity.HttpEntityWrapper.writeTo.

Implements org.apache.http.HttpEntity.writeTo.

Writes the entity content out to the output stream.
Inherited from org.apache.http.entity.HttpEntityWrapper:
getContentEncodinggetContentLengthgetContentTypeisChunkedisStreaming

Field Detail

attemptReuseback to summary
protected final boolean attemptReuse

Whether to keep the connection alive.

managedConnback to summary
protected ManagedClientConnection managedConn

Deprecated

as a consequence of ManagedClientConnection being deprecated. See corresponding docs for further information.

The connection to release.

Constructor Detail

BasicManagedEntityback to summary
public BasicManagedEntity(final HttpEntity entity, final ManagedClientConnection conn, final boolean reuse)

Deprecated

as a consequence of ManagedClientConnection being deprecated. See corresponding docs for further information.

Creates a new managed entity that can release a connection.

Parameters
entity:HttpEntity

the entity of which to wrap the content. Note that the argument entity can no longer be used afterwards, since the content will be taken by this managed entity.

conn:ManagedClientConnection

the connection to release

reuse:boolean

whether the connection should be re-used

Method Detail

abortConnectionback to summary
public void abortConnection() throws IOException

Implements org.apache.http.conn.ConnectionReleaseTrigger.abortConnection.

Doc from org.apache.http.conn.ConnectionReleaseTrigger.abortConnection.

Releases the connection without the option of keep-alive. This is a "hard" release that implies a shutdown of the connection. Use releaseConnection() for a graceful release.

Annotations
@Override
Exceptions
IOException:
in case of an IO problem. The connection will be released anyway.
consumeContentback to summary
public void consumeContent() throws IOException

Overrides org.apache.http.entity.HttpEntityWrapper.consumeContent.

Implements org.apache.http.HttpEntity.consumeContent.

Doc from org.apache.http.HttpEntity.consumeContent.

Deprecated

(4.1) Use EntityUtils#consume(HttpEntity)

This method is deprecated since version 4.1. Please use standard java convention to ensure resource deallocation by calling InputStream#close() on the input stream returned by getContent()

This method is called to indicate that the content of this entity is no longer required. All entity implementations are expected to release all allocated resources as a result of this method invocation. Content streaming entities are also expected to dispose of the remaining content, if any. Wrapping entities should delegate this call to the wrapped entity.

This method is of particular importance for entities being received from a connection. The entity needs to be consumed completely in order to re-use the connection with keep-alive.

Annotations
@Deprecated
@Override
Exceptions
IOException:
if an I/O error occurs.
ensureConsumedback to summary
private void ensureConsumed() throws IOException
eofDetectedback to summary
public boolean eofDetected(final InputStream wrapped) throws IOException

Implements org.apache.http.conn.EofSensorWatcher.eofDetected.

Doc from org.apache.http.conn.EofSensorWatcher.eofDetected.

Indicates that EOF is detected.

Parameters
wrapped:InputStream

the underlying stream which has reached EOF

Returns:boolean

true if wrapped should be closed, false if it should be left alone

Annotations
@Override
Exceptions
IOException:
in case of an IO problem, for example if the watcher itself closes the underlying stream. The caller will leave the wrapped stream alone, as if false was returned.
getContentback to summary
public InputStream getContent() throws IOException

Overrides org.apache.http.entity.HttpEntityWrapper.getContent.

Implements org.apache.http.HttpEntity.getContent.

Doc from org.apache.http.HttpEntity.getContent.

Returns a content stream of the entity. Repeatable entities are expected to create a new instance of InputStream for each invocation of this method and therefore can be consumed multiple times. Entities that are not repeatable are expected to return the same InputStream instance and therefore may not be consumed more than once.

Important Note

Please note all entity implementations must ensure that all allocated resources are properly deallocated after the InputStream#close() method is invoked.

Returns:InputStream

content stream of the entity.

Annotations
@Override
Exceptions
IOException:
if the stream could not be created
isRepeatableback to summary
public boolean isRepeatable()

Overrides org.apache.http.entity.HttpEntityWrapper.isRepeatable.

Implements org.apache.http.HttpEntity.isRepeatable.

Doc from org.apache.http.HttpEntity.isRepeatable.

Tells if the entity is capable of producing its data more than once. A repeatable entity's getContent() and writeTo(OutputStream) methods can be called more than once whereas a non-repeatable entity's can not.

Returns:boolean

true if the entity is repeatable, false otherwise.

Annotations
@Override
releaseConnectionback to summary
public void releaseConnection() throws IOException

Implements org.apache.http.conn.ConnectionReleaseTrigger.releaseConnection.

Doc from org.apache.http.conn.ConnectionReleaseTrigger.releaseConnection.

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.

Annotations
@Override
Exceptions
IOException:
in case of an IO problem. The connection will be released anyway.
releaseManagedConnectionback to summary
protected void releaseManagedConnection() throws IOException

Releases the connection gracefully. The connection attribute will be nullified. Subsequent invocations are no-ops.

Exceptions
IOException:
in case of an IO problem. The connection attribute will be nullified anyway.
streamAbortback to summary
public boolean streamAbort(final InputStream wrapped) throws IOException

Implements org.apache.http.conn.EofSensorWatcher.streamAbort.

Doc from org.apache.http.conn.EofSensorWatcher.streamAbort.

Indicates that the stream is aborted. This method will be called only if EOF was not detected before aborting. Otherwise, eofDetected is called.

This method will also be invoked when an input operation causes an IOException to be thrown to make sure the input stream gets shut down.

Parameters
wrapped:InputStream

the underlying stream which has not reached EOF

Returns:boolean

true if wrapped should be closed, false if it should be left alone

Annotations
@Override
Exceptions
IOException:
in case of an IO problem, for example if the watcher itself closes the underlying stream. The caller will leave the wrapped stream alone, as if false was returned.
streamClosedback to summary
public boolean streamClosed(final InputStream wrapped) throws IOException

Implements org.apache.http.conn.EofSensorWatcher.streamClosed.

Doc from org.apache.http.conn.EofSensorWatcher.streamClosed.

Indicates that the stream is closed. This method will be called only if EOF was not detected before closing. Otherwise, eofDetected is called.

Parameters
wrapped:InputStream

the underlying stream which has not reached EOF

Returns:boolean

true if wrapped should be closed, false if it should be left alone

Annotations
@Override
Exceptions
IOException:
in case of an IO problem, for example if the watcher itself closes the underlying stream. The caller will leave the wrapped stream alone, as if false was returned.
writeToback to summary
public void writeTo(final OutputStream outStream) throws IOException

Overrides org.apache.http.entity.HttpEntityWrapper.writeTo.

Implements org.apache.http.HttpEntity.writeTo.

Doc from org.apache.http.HttpEntity.writeTo.

Writes the entity content out to the output stream.

Important Note

Please note all entity implementations must ensure that all allocated resources are properly deallocated when this method returns.

Parameters
outStream:OutputStream

the output stream to write entity content to

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs