org.glassfish.grizzly.filterchain
Class DefaultFilterChain

java.lang.Object
  extended by org.glassfish.grizzly.filterchain.AbstractFilterChain
      extended by org.glassfish.grizzly.filterchain.ListFacadeFilterChain
          extended by org.glassfish.grizzly.filterchain.DefaultFilterChain
All Implemented Interfaces:
java.lang.Iterable<Filter>, java.util.Collection<Filter>, java.util.List<Filter>, FilterChain, Processor<Context>

public final class DefaultFilterChain
extends ListFacadeFilterChain

Default FilterChain implementation

Author:
Alexey Stashok
See Also:
FilterChain, Filter

Nested Class Summary
static class DefaultFilterChain.FILTER_STATE_TYPE
           
static class DefaultFilterChain.FiltersState
           
static class DefaultFilterChain.FilterStateElement
           
 
Field Summary
 
Fields inherited from class org.glassfish.grizzly.filterchain.ListFacadeFilterChain
filters
 
Fields inherited from class org.glassfish.grizzly.filterchain.AbstractFilterChain
interestedIoEventsMask
 
Constructor Summary
DefaultFilterChain()
           
DefaultFilterChain(java.util.Collection<Filter> initialFilters)
           
 
Method Summary
 ProcessorResult execute(FilterChainContext ctx)
          Execute this FilterChain.
protected  org.glassfish.grizzly.filterchain.DefaultFilterChain.FilterExecution executeChainPart(FilterChainContext ctx, FilterExecutor executor, int start, int end, DefaultFilterChain.FiltersState filtersState)
          Sequentially lets each Filter in chain to process IOEvent.
protected  NextAction executeFilter(FilterExecutor executor, Filter currentFilter, FilterChainContext ctx)
          Execute the Filter, using specific FilterExecutor and FilterChainContext.
 void fail(FilterChainContext context, java.lang.Throwable failure)
           
 void fireEventDownstream(Connection connection, FilterChainEvent event, CompletionHandler<FilterChainContext> completionHandler)
           
 void fireEventUpstream(Connection connection, FilterChainEvent event, CompletionHandler<FilterChainContext> completionHandler)
           
 void flush(Connection connection, CompletionHandler<WriteResult> completionHandler)
           
protected static int indexOfRemainder(DefaultFilterChain.FiltersState filtersState, FilterChainContext.Operation operation, int start, int end)
          Locates a message remainder in the FilterChain, associated with the Connection.
protected static boolean prepareRemainder(FilterChainContext ctx, DefaultFilterChain.FiltersState filtersState, int start, int end)
          Locates a message remainder in the FilterChain, associated with the Connection and prepares the Context for remainder processing.
 ProcessorResult process(Context context)
          Method will be called by framework to process some event, which occurred on a connection
 void read(Connection connection, CompletionHandler<ReadResult> completionHandler)
           
 ReadResult read(FilterChainContext context)
           
 DefaultFilterChain subList(int fromIndex, int toIndex)
           
 void write(Connection connection, java.lang.Object dstAddress, java.lang.Object message, CompletionHandler completionHandler, PushBackHandler pushBackHandler)
           
 
Methods inherited from class org.glassfish.grizzly.filterchain.ListFacadeFilterChain
add, add, addAll, addAll, clear, contains, containsAll, get, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, notifyChangedExcept, remove, remove, removeAll, retainAll, set, size, toArray, toArray
 
Methods inherited from class org.glassfish.grizzly.filterchain.AbstractFilterChain
finalize, indexOfType, isInterested, obtainContext, obtainFilterChainContext, setInterested
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.List
equals, hashCode
 

Constructor Detail

DefaultFilterChain

public DefaultFilterChain()

DefaultFilterChain

public DefaultFilterChain(java.util.Collection<Filter> initialFilters)
Method Detail

process

public ProcessorResult process(Context context)
Description copied from interface: Processor
Method will be called by framework to process some event, which occurred on a connection

Parameters:
context - processing context
Returns:
the result of I/O event processing

execute

public ProcessorResult execute(FilterChainContext ctx)
Execute this FilterChain.

Parameters:
ctx - FilterChainContext processing context
Returns:
ProcessorResult
Throws:
java.lang.Exception

executeChainPart

protected final org.glassfish.grizzly.filterchain.DefaultFilterChain.FilterExecution executeChainPart(FilterChainContext ctx,
                                                                                                      FilterExecutor executor,
                                                                                                      int start,
                                                                                                      int end,
                                                                                                      DefaultFilterChain.FiltersState filtersState)
                                                                                               throws java.io.IOException
Sequentially lets each Filter in chain to process IOEvent.

Parameters:
ctx - FilterChainContext processing context
executor - FilterExecutor, which will call appropriate filter operation to process IOEvent.
Returns:
TODO: Update
Throws:
java.io.IOException

executeFilter

protected NextAction executeFilter(FilterExecutor executor,
                                   Filter currentFilter,
                                   FilterChainContext ctx)
                            throws java.io.IOException
Execute the Filter, using specific FilterExecutor and FilterChainContext.

Parameters:
executor -
currentFilter -
ctx -
Returns:
NextAction.
Throws:
java.io.IOException

prepareRemainder

protected static boolean prepareRemainder(FilterChainContext ctx,
                                          DefaultFilterChain.FiltersState filtersState,
                                          int start,
                                          int end)
Locates a message remainder in the FilterChain, associated with the Connection and prepares the Context for remainder processing.


indexOfRemainder

protected static int indexOfRemainder(DefaultFilterChain.FiltersState filtersState,
                                      FilterChainContext.Operation operation,
                                      int start,
                                      int end)
Locates a message remainder in the FilterChain, associated with the Connection.


read

public void read(Connection connection,
                 CompletionHandler<ReadResult> completionHandler)

read

public ReadResult read(FilterChainContext context)
                throws java.io.IOException
Throws:
java.io.IOException

write

public void write(Connection connection,
                  java.lang.Object dstAddress,
                  java.lang.Object message,
                  CompletionHandler completionHandler,
                  PushBackHandler pushBackHandler)

flush

public void flush(Connection connection,
                  CompletionHandler<WriteResult> completionHandler)

fireEventDownstream

public void fireEventDownstream(Connection connection,
                                FilterChainEvent event,
                                CompletionHandler<FilterChainContext> completionHandler)

fireEventUpstream

public void fireEventUpstream(Connection connection,
                              FilterChainEvent event,
                              CompletionHandler<FilterChainContext> completionHandler)

fail

public void fail(FilterChainContext context,
                 java.lang.Throwable failure)

subList

public DefaultFilterChain subList(int fromIndex,
                                  int toIndex)


Copyright © 2012 Oracle Corporation. All Rights Reserved.