Class BasicManagedEntity
- java.lang.Object
-
- org.apache.http.entity.HttpEntityWrapper
-
- org.apache.http.conn.BasicManagedEntity
-
- All Implemented Interfaces:
ConnectionReleaseTrigger
,EofSensorWatcher
,HttpEntity
@Deprecated public class BasicManagedEntity extends HttpEntityWrapper implements ConnectionReleaseTrigger, EofSensorWatcher
Deprecated.(4.3) do not use.An entity that releases aconnection
. AManagedClientConnection
will typically not return a managed entity, but you can replace the unmanaged entity in the response with a managed one.- Since:
- 4.0
-
-
Constructor Summary
Constructors Constructor Description BasicManagedEntity(HttpEntity entity, ManagedClientConnection conn, boolean reuse)
Deprecated.Creates a new managed entity that can release a connection.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
abortConnection()
Deprecated.Releases the connection without the option of keep-alive.void
consumeContent()
Deprecated.(4.1) UseEntityUtils.consume(HttpEntity)
boolean
eofDetected(java.io.InputStream wrapped)
Deprecated.Indicates that EOF is detected.java.io.InputStream
getContent()
Deprecated.Returns a content stream of the entity.boolean
isRepeatable()
Deprecated.Tells if the entity is capable of producing its data more than once.void
releaseConnection()
Deprecated.Releases the connection with the option of keep-alive.boolean
streamAbort(java.io.InputStream wrapped)
Deprecated.Indicates that thestream
is aborted.boolean
streamClosed(java.io.InputStream wrapped)
Deprecated.Indicates that thestream
is closed.void
writeTo(java.io.OutputStream outStream)
Deprecated.Writes the entity content out to the output stream.-
Methods inherited from class org.apache.http.entity.HttpEntityWrapper
getContentEncoding, getContentLength, getContentType, isChunked, isStreaming
-
-
-
-
Constructor Detail
-
BasicManagedEntity
public BasicManagedEntity(HttpEntity entity, ManagedClientConnection conn, boolean reuse)
Deprecated.Creates a new managed entity that can release a connection.- Parameters:
entity
- 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
- the connection to releasereuse
- whether the connection should be re-used
-
-
Method Detail
-
isRepeatable
public boolean isRepeatable()
Deprecated.Description copied from interface:HttpEntity
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.- Specified by:
isRepeatable
in interfaceHttpEntity
- Overrides:
isRepeatable
in classHttpEntityWrapper
- Returns:
- true if the entity is repeatable, false otherwise.
-
getContent
public java.io.InputStream getContent() throws java.io.IOException
Deprecated.Description copied from interface:HttpEntity
Returns a content stream of the entity.Repeatable
entities are expected to create a new instance ofInputStream
for each invocation of this method and therefore can be consumed multiple times. Entities that are notrepeatable
are expected to return the sameInputStream
instance and therefore may not be consumed more than once.IMPORTANT: Please note all entity implementations must ensure that all allocated resources are properly deallocated after the
InputStream.close()
method is invoked.- Specified by:
getContent
in interfaceHttpEntity
- Overrides:
getContent
in classHttpEntityWrapper
- Returns:
- content stream of the entity.
- Throws:
java.io.IOException
- if the stream could not be created- See Also:
HttpEntity.isRepeatable()
-
consumeContent
@Deprecated public void consumeContent() throws java.io.IOException
Deprecated.(4.1) UseEntityUtils.consume(HttpEntity)
Description copied from interface:HttpEntity
This method is deprecated since version 4.1. Please use standard java convention to ensure resource deallocation by callingInputStream.close()
on the input stream returned byHttpEntity.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.- Specified by:
consumeContent
in interfaceHttpEntity
- Overrides:
consumeContent
in classHttpEntityWrapper
- Throws:
java.io.IOException
- if an I/O error occurs.- See Also:
and #writeTo(OutputStream)
-
writeTo
public void writeTo(java.io.OutputStream outStream) throws java.io.IOException
Deprecated.Description copied from interface:HttpEntity
Writes the entity content out to the output stream.IMPORTANT: Please note all entity implementations must ensure that all allocated resources are properly deallocated when this method returns.
- Specified by:
writeTo
in interfaceHttpEntity
- Overrides:
writeTo
in classHttpEntityWrapper
- Parameters:
outStream
- the output stream to write entity content to- Throws:
java.io.IOException
- if an I/O error occurs
-
releaseConnection
public void releaseConnection() throws java.io.IOException
Deprecated.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
- Throws:
java.io.IOException
- in case of an IO problem. The connection will be released anyway.
-
abortConnection
public void abortConnection() throws java.io.IOException
Deprecated.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
- Throws:
java.io.IOException
- in case of an IO problem. The connection will be released anyway.
-
eofDetected
public boolean eofDetected(java.io.InputStream wrapped) throws java.io.IOException
Deprecated.Description copied from interface:EofSensorWatcher
Indicates that EOF is detected.- Specified by:
eofDetected
in interfaceEofSensorWatcher
- Parameters:
wrapped
- the underlying stream which has reached EOF- Returns:
true
ifwrapped
should be closed,false
if it should be left alone- Throws:
java.io.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 iffalse
was returned.
-
streamClosed
public boolean streamClosed(java.io.InputStream wrapped) throws java.io.IOException
Deprecated.Description copied from interface:EofSensorWatcher
Indicates that thestream
is closed. This method will be called only if EOF was not detected before closing. Otherwise,eofDetected
is called.- Specified by:
streamClosed
in interfaceEofSensorWatcher
- Parameters:
wrapped
- the underlying stream which has not reached EOF- Returns:
true
ifwrapped
should be closed,false
if it should be left alone- Throws:
java.io.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 iffalse
was returned.
-
streamAbort
public boolean streamAbort(java.io.InputStream wrapped) throws java.io.IOException
Deprecated.Description copied from interface:EofSensorWatcher
Indicates that thestream
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.
- Specified by:
streamAbort
in interfaceEofSensorWatcher
- Parameters:
wrapped
- the underlying stream which has not reached EOF- Returns:
true
ifwrapped
should be closed,false
if it should be left alone- Throws:
java.io.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 iffalse
was returned.
-
-