com.sun.faban.harness.logging
Interface ProtocolHandler

All Known Implementing Classes:
LogHandler

public interface ProtocolHandler

The protocol handler interface defines the standard interface for protocol handlers. No matter what protocol, all stream-based handlers will have the followings called, in-order

  1. doProcessRequest - one or more times
  2. doProcessResponse
  3. doContinueResponse - zero or more times
  4. requestPending
This scheme allows for multiple read-writes by a protocol handler before the whole interaction is done.

Author:
Akara Sucharitakul

Method Summary
 boolean doContinueResponse()
          Continues writing the response to the channel.
 boolean doProcessRequest(ByteBuffer buffer, int count)
          Analyzes the buffer and return read active status.
 boolean doProcessResponse()
          Creates and writes the response to the channel.
 boolean requestPending()
          Tests the handler whether it needs to further process this request.
 void setConfig(LogConfig config)
          Sets the config object.
 void setKey(SelectionKey key)
          Sets the selection key for subsequent invocations.
 

Method Detail

setConfig

void setConfig(LogConfig config)
Sets the config object.

Parameters:
config - The singleton config object

setKey

void setKey(SelectionKey key)
Sets the selection key for subsequent invocations.

Parameters:
key - The nio selection key

doProcessRequest

boolean doProcessRequest(ByteBuffer buffer,
                         int count)
Analyzes the buffer and return read active status.

Parameters:
buffer - The buffer to look at
count - The number of new bytes in the buffer
Returns:
True if still active, false if done processing

doProcessResponse

boolean doProcessResponse()
                          throws IOException
Creates and writes the response to the channel. Returns write active status. This method should return true if and only if the non-blocking channel cannot take all the response to be written.

Returns:
True if still active, false if done processing
Throws:
IOException - Cannot write response to channel

doContinueResponse

boolean doContinueResponse()
                           throws IOException
Continues writing the response to the channel. This method is only called if the initial write did not manage to write everything to the non-blocking channel.

Returns:
True if still active, false if done processing
Throws:
IOException - Cannot write response to channel

requestPending

boolean requestPending()
Tests the handler whether it needs to further process this request.

Returns:
True if the handler still needs to proceed, false if it is done