FileDocCategorySizeDatePackage
BasicEofSensorWatcher.javaAPI DocAndroid 1.5 API3815Wed May 06 22:41:10 BST 2009org.apache.http.conn

BasicEofSensorWatcher

public class BasicEofSensorWatcher extends Object implements EofSensorWatcher
Basic implementation of {@link EofSensorWatcher EofSensorWatcher}. The underlying connection is released on close or EOF.
author
Roland Weber
version
$Revision: 672367 $
since
4.0

Fields Summary
protected ManagedClientConnection
managedConn
The connection to auto-release.
protected boolean
attemptReuse
Whether to keep the connection alive.
Constructors Summary
public BasicEofSensorWatcher(ManagedClientConnection conn, boolean reuse)
Creates a new watcher for auto-releasing a connection.

param
conn the connection to auto-release
param
reuse whether the connection should be re-used

        if (conn == null)
            throw new IllegalArgumentException
                ("Connection may not be null.");

        managedConn = conn;
        attemptReuse = reuse;
    
Methods Summary
public booleaneofDetected(java.io.InputStream wrapped)


        try {
            if (attemptReuse) {
                // there may be some cleanup required, such as
                // reading trailers after the response body:
                wrapped.close();
                managedConn.markReusable();
            }
        } finally {
            managedConn.releaseConnection();
        }
        return false;
    
public booleanstreamAbort(java.io.InputStream wrapped)


        managedConn.abortConnection();
        return false;
    
public booleanstreamClosed(java.io.InputStream wrapped)


        try {
            if (attemptReuse) {
                // this assumes that closing the stream will
                // consume the remainder of the response body:
                wrapped.close();
                managedConn.markReusable();
            }
        } finally {
            managedConn.releaseConnection();
        }
        return false;