com.caucho.network.listen
Class AbstractProtocolConnection

java.lang.Object
  extended by com.caucho.network.listen.AbstractProtocolConnection
All Implemented Interfaces:
ProtocolConnection
Direct Known Subclasses:
HmtpRequest, SnmpRequest, XmppRequest

public abstract class AbstractProtocolConnection
extends java.lang.Object
implements ProtocolConnection

Protocol specific information for each request. ServerRequest is reused to reduce memory allocations.

ServerRequests are created by Server.createRequest()


Constructor Summary
AbstractProtocolConnection()
           
 
Method Summary
 java.lang.String getProtocolRequestURL()
          Returns a default debugging identifier for the connection
abstract  boolean handleRequest()
          Handles a new connection.
 boolean handleResume()
          Handles a resumption of the connection for an async/comet request.
 void init()
          Initialize the connection.
 void onCloseConnection()
          Handles a close event when the connection is closed.
 void onStartConnection()
          Called when the connection starts, i.e.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.caucho.network.listen.ProtocolConnection
isWaitForRead
 

Constructor Detail

AbstractProtocolConnection

public AbstractProtocolConnection()
Method Detail

init

public void init()
Initialize the connection. At this point, the current thread is the connection thread.

Specified by:
init in interface ProtocolConnection

onStartConnection

public void onStartConnection()
Description copied from interface: ProtocolConnection
Called when the connection starts, i.e. just after the accept

Specified by:
onStartConnection in interface ProtocolConnection

getProtocolRequestURL

public java.lang.String getProtocolRequestURL()
Returns a default debugging identifier for the connection

Specified by:
getProtocolRequestURL in interface ProtocolConnection

handleRequest

public abstract boolean handleRequest()
                               throws java.io.IOException
Handles a new connection. The controlling TcpServer may call handleConnection again after the connection completes, so the implementation must initialize any variables for each connection.

Specified by:
handleRequest in interface ProtocolConnection
Parameters:
conn - Information about the connection, including buffered read and write streams.
Throws:
java.io.IOException

handleResume

public boolean handleResume()
                     throws java.io.IOException
Handles a resumption of the connection for an async/comet request.

Specified by:
handleResume in interface ProtocolConnection
Throws:
java.io.IOException

onCloseConnection

public void onCloseConnection()
Handles a close event when the connection is closed.

Specified by:
onCloseConnection in interface ProtocolConnection