org.glassfish.grizzly.samples.simpleauth
Class MultiLineFilter

java.lang.Object
  extended by org.glassfish.grizzly.filterchain.BaseFilter
      extended by org.glassfish.grizzly.samples.simpleauth.MultiLineFilter
All Implemented Interfaces:
Filter

public class MultiLineFilter
extends BaseFilter

The Filter is responsible for a String <-> MultiLinePacket transformations. When reading - filter is gathering single String lines into a MultiLinePacket, when writing - filter breaks MultiLinePacket into a single Strings.

Author:
Alexey Stashok

Constructor Summary
MultiLineFilter(String terminatingLine)
           
 
Method Summary
 NextAction handleRead(FilterChainContext ctx)
          The method is called once we have received a single String line.
 NextAction handleWrite(FilterChainContext ctx)
          The method is called whem we send MultiLinePacket.
 
Methods inherited from class org.glassfish.grizzly.filterchain.BaseFilter
createContext, exceptionOccurred, getFilterChain, getIndex, handleAccept, handleClose, handleConnect, handleEvent, onAdded, onFilterChainChanged, onRemoved
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultiLineFilter

public MultiLineFilter(String terminatingLine)
Method Detail

handleRead

public NextAction handleRead(FilterChainContext ctx)
                      throws IOException
The method is called once we have received a single String line. Filter check if it's MultiLinePacket terminating line, if yes - we assume MultiLinePacket completed and pass control to a next Filter in a chain. If it's not a terminating line - we add another string line to a MultiLinePacket and stop the request processing until more strings will get available.

Specified by:
handleRead in interface Filter
Overrides:
handleRead in class BaseFilter
Parameters:
ctx - Request processing context
Returns:
NextAction
Throws:
IOException

handleWrite

public NextAction handleWrite(FilterChainContext ctx)
                       throws IOException
The method is called whem we send MultiLinePacket. Filter is responsible to split MultiLinePacket into a single Strings and pass each String to a next Filter in chain.

Specified by:
handleWrite in interface Filter
Overrides:
handleWrite in class BaseFilter
Parameters:
ctx - Request processing context
Returns:
NextAction
Throws:
IOException


Copyright © 2013 Oracle Corporation. All Rights Reserved.