English | Site Directory

Android - An Open Handset Alliance Project

org.apache.http.conn
public class

org.apache.http.conn.BasicManagedEntity

java.lang.Object
org.apache.http.entity.HttpEntityWrapper HttpEntity
org.apache.http.conn.BasicManagedEntity HttpEntity ConnectionReleaseTrigger EofSensorWatcher

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.

Summary

Fields

protected      boolean  attemptReuse  Whether to keep the connection alive. 
protected      ManagedClientConnection  managedConn  The connection to release. 
Fields inherited from class org.apache.http.entity.HttpEntityWrapper

Public Constructors

          BasicManagedEntity(HttpEntity entity, ManagedClientConnection conn, boolean reuse)
Creates a new managed entity that can release a connection.

Public Methods

        void  abortConnection()
Releases the connection without the option of keep-alive.
        void  consumeContent()
Consumes the remaining content of a streamed entity.
        boolean  eofDetected(InputStream wrapped)
Indicates that EOF is detected.
        InputStream  getContent()
Creates a new InputStream object of the entity.
        boolean  isRepeatable()
Tells if the entity is capable to produce its data more than once.
        void  releaseConnection()
Releases the connection with the option of keep-alive.
        boolean  streamAbort(InputStream wrapped)
Indicates that the stream is aborted.
        boolean  streamClosed(InputStream wrapped)
Indicates that the stream is closed.

Protected Methods

        void  releaseManagedConnection()
Releases the connection gracefully.
Methods inherited from class org.apache.http.entity.HttpEntityWrapper
Methods inherited from class java.lang.Object
Methods inherited from interface org.apache.http.HttpEntity
Methods inherited from interface org.apache.http.conn.ConnectionReleaseTrigger
Methods inherited from interface org.apache.http.conn.EofSensorWatcher

Details

Fields

protected boolean attemptReuse

Whether to keep the connection alive.

protected ManagedClientConnection managedConn

The connection to release.

Public Constructors

public BasicManagedEntity(HttpEntity entity, ManagedClientConnection conn, boolean reuse)

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 release
reuse whether the connection should be re-used

Public Methods

public void 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.

Throws

IOException

public void consumeContent()

Consumes the remaining content of a streamed entity. This method is called to indicate that the content of this entity is no longer required. Streamed entities should dispose of the remaining content, if any. Self-contained entities can release allocated resources, but are not required to do anything. 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.

Throws

IOException

public boolean eofDetected(InputStream wrapped)

Indicates that EOF is detected.

Throws

IOException

public InputStream getContent()

Creates a new InputStream object of the entity. It is a programming error to return the same InputStream object more than once. Entities that are not repeatable will throw an exception if this method is called multiple times.

Throws

IOException

public boolean isRepeatable()

Tells if the entity is capable to produce 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.

public void 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.

Throws

IOException

public boolean streamAbort(InputStream wrapped)

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.

Throws

IOException

public boolean streamClosed(InputStream wrapped)

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

Throws

IOException

Protected Methods

protected void releaseManagedConnection()

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

Throws

IOException in case of an IO problem. The connection attribute will be nullified anyway.
Build m5-rc15i - 10 Jun 2008 13:54