org.apache.http.impl
Class AbstractHttpConnection

java.lang.Object
  extended by org.apache.http.impl.AbstractHttpConnection
All Implemented Interfaces:
HttpConnection
Direct Known Subclasses:
DefaultHttpClientConnection, DefaultHttpServerConnection

abstract class AbstractHttpConnection
extends java.lang.Object
implements HttpConnection

Abstract base class for HTTP connections on the client and server side.

Since:
4.0
Version:
$Revision: 376961 $
Author:
Oleg Kalnichevski

Field Summary
protected  HttpDataReceiver datareceiver
           
protected  HttpDataTransmitter datatransmitter
           
protected  boolean open
           
protected  java.net.Socket socket
           
 
Constructor Summary
protected AbstractHttpConnection()
           
 
Method Summary
protected  void assertNotOpen()
           
protected  void assertOpen()
           
protected  void bind(java.net.Socket socket, HttpParams params)
           
 void close()
          This method will gracefully close the connection.
 boolean isOpen()
          Checks if this connection is open.
 boolean isStale()
          Network connections may get closed during some time of inactivity for several reasons.
 void setReceiverFactory(HttpDataReceiverFactory rcvfactory)
           
 void setTransmitterFactory(HttpDataTransmitterFactory trxfactory)
           
 void shutdown()
          This method will force close the connection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

open

protected volatile boolean open

socket

protected java.net.Socket socket

datatransmitter

protected HttpDataTransmitter datatransmitter

datareceiver

protected HttpDataReceiver datareceiver
Constructor Detail

AbstractHttpConnection

protected AbstractHttpConnection()
Method Detail

setReceiverFactory

public void setReceiverFactory(HttpDataReceiverFactory rcvfactory)

setTransmitterFactory

public void setTransmitterFactory(HttpDataTransmitterFactory trxfactory)

assertNotOpen

protected void assertNotOpen()

assertOpen

protected void assertOpen()

bind

protected void bind(java.net.Socket socket,
                    HttpParams params)
             throws java.io.IOException
Throws:
java.io.IOException

isOpen

public boolean isOpen()
Description copied from interface: HttpConnection
Checks if this connection is open.

Specified by:
isOpen in interface HttpConnection
Returns:
true if it is open, false if it is closed.

shutdown

public void shutdown()
              throws java.io.IOException
Description copied from interface: HttpConnection
This method will force close the connection. This is the only method, which may be called from a different thread to terminate the connection. This method will not attempt to flush the transmitter's internal buffer prior to closing the underlying socket.

Specified by:
shutdown in interface HttpConnection
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Description copied from interface: HttpConnection
This method will gracefully close the connection. It will attempt to flush the transmitter's internal buffer prior to closing the underlying socket. This method MAY NOT be called from a different thread to force shutdown the connection. Use #shutdown() instead.

Specified by:
close in interface HttpConnection
Throws:
java.io.IOException
See Also:
HttpConnection.shutdown()

isStale

public boolean isStale()
Description copied from interface: HttpConnection
Network connections may get closed during some time of inactivity for several reasons. The next time a read is attempted on such a connection it will throw an IOException. This method tries to alleviate this inconvenience by trying to find out if a connection is still usable. Implementations may do that by attempting a read with a very small timeout. Thus this method may block for a small indefinite time before returning a result.

Specified by:
isStale in interface HttpConnection
Returns:
true if attempts to use this connection are likely to succeed, false if they are likely to fail and this connection should be closed and discarded.


Copyright 2005-2005-2006 Apache Software Foundation. All Rights Reserved.