com.sun.grizzly.filter
Class ParserProtocolFilter

java.lang.Object
  extended by com.sun.grizzly.filter.ReadFilter
      extended by com.sun.grizzly.filter.ParserProtocolFilter
All Implemented Interfaces:
ProtocolFilter
Direct Known Subclasses:
ResourceAllocationFilter

public abstract class ParserProtocolFilter
extends ReadFilter

Simple ProtocolFilter implementation which read the available bytes and delegate the decision of reading more bytes or not to a ProtocolParser. The ProtocolParser will decide if more bytes are required before continuing the invokation of the ProtocolChain.

Author:
Jeanfrancois Arcand

Field Summary
 
Fields inherited from class com.sun.grizzly.filter.ReadFilter
continousExecution, UDP_SOCKETADDRESS
 
Fields inherited from interface com.sun.grizzly.ProtocolFilter
SUCCESSFUL_READ
 
Constructor Summary
ParserProtocolFilter()
           
 
Method Summary
 boolean execute(Context ctx)
          Read available bytes and delegate the processing of them to the next ProtocolFilter in the ProtocolChain.
protected  boolean invokeProtocolParser(Context ctx, ProtocolParser parser)
          Invoke the ProtocolParser.
abstract  ProtocolParser newProtocolParser()
          Return a new or cached ProtocolParser instance.
 boolean postExecute(Context context)
          If no bytes were available, close the connection by cancelling the SelectionKey.
 
Methods inherited from class com.sun.grizzly.filter.ReadFilter
execute, isContinuousExecution, log, setContinuousExecution
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ParserProtocolFilter

public ParserProtocolFilter()
Method Detail

execute

public boolean execute(Context ctx)
                throws IOException
Read available bytes and delegate the processing of them to the next ProtocolFilter in the ProtocolChain.

Specified by:
execute in interface ProtocolFilter
Overrides:
execute in class ReadFilter
Parameters:
ctx - Context
Returns:
true if the next ProtocolFilter on the ProtocolChain need to be invoked.
Throws:
IOException

invokeProtocolParser

protected boolean invokeProtocolParser(Context ctx,
                                       ProtocolParser parser)
Invoke the ProtocolParser. If more bytes are required, register the SelectionKey back to its associated SelectorHandler

Parameters:
ctx - the Context object.
Returns:
true if no more bytes are needed.

postExecute

public boolean postExecute(Context context)
                    throws IOException
Description copied from class: ReadFilter
If no bytes were available, close the connection by cancelling the SelectionKey. If bytes were available, register the SelectionKey for new bytes.

Specified by:
postExecute in interface ProtocolFilter
Overrides:
postExecute in class ReadFilter
Parameters:
context - Context
Returns:
true if the previous ProtocolFilter postExecute method needs to be invoked.
Throws:
IOException

newProtocolParser

public abstract ProtocolParser newProtocolParser()
Return a new or cached ProtocolParser instance.



Copyright © 2008 SUN Microsystems. All Rights Reserved.