org.glassfish.grizzly.filterchain
Class FilterChainContext

java.lang.Object
  extended by org.glassfish.grizzly.Context
      extended by org.glassfish.grizzly.filterchain.FilterChainContext
All Implemented Interfaces:
PoolableObject

public class FilterChainContext
extends Context

FilterChain Context implementation.

Author:
Alexey Stashok
See Also:
Context, FilterChain

Constructor Summary
FilterChainContext(ObjectPool parentPool)
           
 
Method Summary
 Object getAddress()
          Get address, associated with the current IOEvent processing.
 Filter getCurrentFilter()
          Get Filter, which is currently running.
 int getCurrentFilterIdx()
          Get index of the currently executing Filter in the filters list.
 List<Filter> getExecutedFilters()
          Get List of executed Filters.
 FilterChain getFilterChain()
          Get FilterChain, which runs the Filter.
 List<Filter> getFilters()
          Get List of Filters.
 NextAction getInvokeAction()
          Get NextAction implementation, which instructs FilterChain to process next Filter in chain.
 NextAction getInvokeAction(List<Filter> filters)
          Get NextAction implementation, which instructs FilterChain to process next Filter in chain.
 NextAction getInvokeAction(List<Filter> filters, int nextFilterIdx)
          Get NextAction implementation, which instructs FilterChain to process next Filter in chain.
 Object getMessage()
          Get message object, associated with the current processing.
 NextAction getRerunChainAction()
          Get NextAction implementation, which is expected only on post processing phase.
 NextAction getStopAction()
          Get NextAction implementation, which instructs FilterChain to stop executing phase and start post executing filters.
 StreamReader getStreamReader()
          Get the StreamReader, associated with processing.
 StreamWriter getStreamWriter()
          Get the StreamWriter, associated with processing.
 NextAction getSuspendAction()
          Get NextAction, which instructs FilterChain to suspend filter chain execution, both execute and post-execute phases.
 void release()
          Release the context associated resources.
 void setAddress(Object address)
          Set address, associated with the current IOEvent processing.
protected  void setCurrentFilter(Filter currentFilter)
          Set Filter, which is currently running.
 void setCurrentFilterIdx(int currentFilterIdx)
          Set index of the currently executing Filter in the filters list.
protected  void setExecutedFilters(List<Filter> executedFilters)
          Set List of executed Filters.
 void setFilters(List<Filter> filters)
          Set List of Filters.
 void setMessage(Object message)
          Set message object, associated with the current processing.
 void setStreamReader(StreamReader streamReader)
          Set the StreamReader, associated with processing.
 void setStreamWriter(StreamWriter streamWriter)
          Set the StreamWriter, associated with processing.
 String toString()
           
 
Methods inherited from class org.glassfish.grizzly.Context
getAttributes, getConnection, getIoEvent, getPostProcessor, getProcessor, getProcessorRunnable, initializeAttributeHolder, obtainAttributes, offerToPool, prepare, setAttributes, setConnection, setIoEvent, setPostProcessor, setProcessor, setProcessorRunnable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FilterChainContext

public FilterChainContext(ObjectPool parentPool)
Method Detail

getExecutedFilters

public List<Filter> getExecutedFilters()
Get List of executed Filters.

Returns:
List of executed Filters.

setExecutedFilters

protected void setExecutedFilters(List<Filter> executedFilters)
Set List of executed Filters.

Parameters:
executedFilters - List of executed Filters.

getFilters

public List<Filter> getFilters()
Get List of Filters.

Returns:
List of Filters.

setFilters

public void setFilters(List<Filter> filters)
Set List of Filters.

Parameters:
filters - List of Filters.

getCurrentFilterIdx

public int getCurrentFilterIdx()
Get index of the currently executing Filter in the filters list.

Returns:
index of the currently executing Filter in the filters list.

setCurrentFilterIdx

public void setCurrentFilterIdx(int currentFilterIdx)
Set index of the currently executing Filter in the filters list.

Parameters:
currentFilterIdx - index of the currently executing Filter in the filters list.

getFilterChain

public FilterChain getFilterChain()
Get FilterChain, which runs the Filter.

Returns:
FilterChain, which runs the Filter.

getCurrentFilter

public Filter getCurrentFilter()
Get Filter, which is currently running.

Returns:
Filter, which is currently running.

setCurrentFilter

protected void setCurrentFilter(Filter currentFilter)
Set Filter, which is currently running.

Parameters:
currentFilter - Filter, which is currently running.

getMessage

public Object getMessage()
Get message object, associated with the current processing. Usually FilterChain represents sequence of parser and process Filters. Each parser can change the message representation until it will come to processor Filter.

Returns:
message object, associated with the current processing.

setMessage

public void setMessage(Object message)
Set message object, associated with the current processing. Usually FilterChain represents sequence of parser and process Filters. Each parser can change the message representation until it will come to processor Filter.

Parameters:
message - message object, associated with the current processing.

getAddress

public Object getAddress()
Get address, associated with the current IOEvent processing. When we process IOEvent#READ event - it represents sender address, or when process IOEvent#WRITE - address of receiver.

Returns:
address, associated with the current IOEvent processing.

setAddress

public void setAddress(Object address)
Set address, associated with the current IOEvent processing. When we process IOEvent#READ event - it represents sender address, or when process IOEvent#WRITE - address of receiver.

Parameters:
address - address, associated with the current IOEvent processing.

getStreamReader

public StreamReader getStreamReader()
Get the StreamReader, associated with processing. Filters are allowed to change context associated StreamReader. For example SSLFilter wraps original FilterChainContext's StreamReader with SSLStreamReader and next filter on chain will work with SSL-enabled StreamReader.

Returns:
the StreamReader, associated with processing.

setStreamReader

public void setStreamReader(StreamReader streamReader)
Set the StreamReader, associated with processing. Filters are allowed to change context associated StreamReader. For example SSLFilter wraps original FilterChainContext's StreamReader with SSLStreamReader and next filter on chain will work with SSL-enabled StreamReader.

Parameters:
streamReader - the StreamReader, associated with processing.

getStreamWriter

public StreamWriter getStreamWriter()
Get the StreamWriter, associated with processing. Filters are allowed to change context associated StreamWriter.

Returns:
the StreamWriter, associated with processing.

setStreamWriter

public void setStreamWriter(StreamWriter streamWriter)
Set the StreamWriter, associated with processing. Filters are allowed to change context associated StreamWriter.

Parameters:
streamWriter - the StreamWriter, associated with processing.

getInvokeAction

public NextAction getInvokeAction()
Get NextAction implementation, which instructs FilterChain to process next Filter in chain. Normally, after receiving this instruction from Filter, FilterChain takes Filter with index: AbstractNextAction.getNextFilterIdx() from AbstractNextAction.getFilters() chain. Any Filter implementation is free to change the Filter execution sequence.

Returns:
NextAction implementation, which instructs FilterChain to process next Filter in chain.
See Also:
getInvokeAction(java.util.List), getInvokeAction(java.util.List, int)

getInvokeAction

public NextAction getInvokeAction(List<Filter> filters)
Get NextAction implementation, which instructs FilterChain to process next Filter in chain. Normally, after receiving this instruction from Filter, FilterChain takes Filter with index: AbstractNextAction.getNextFilterIdx() from AbstractNextAction.getFilters() chain. Any Filter implementation is free to change the Filter execution sequence.

Parameters:
filters - new list of the filters to be invoked in the chain processing
Returns:
NextAction implementation, which instructs FilterChain to process next Filter in chain.
See Also:
getInvokeAction(), getInvokeAction(java.util.List, int)

getInvokeAction

public NextAction getInvokeAction(List<Filter> filters,
                                  int nextFilterIdx)
Get NextAction implementation, which instructs FilterChain to process next Filter in chain. Normally, after receiving this instruction from Filter, FilterChain takes Filter with index: AbstractNextAction.getNextFilterIdx() from AbstractNextAction.getFilters() chain. Any Filter implementation is free to change the Filter execution sequence.

Parameters:
filters - new list of the filters to be invoked in the chain processing
nextFilterIdx - new index of the Filter in NextAction.getFilters() list, which should be executed next.
Returns:
NextAction implementation, which instructs FilterChain to process next Filter in chain.
See Also:
getInvokeAction(), getInvokeAction(java.util.List)

getRerunChainAction

public NextAction getRerunChainAction()
Get NextAction implementation, which is expected only on post processing phase. This implementation instructs FilterChain to re-process the IOEvent processing again from the beginning.

Returns:
NextAction implementation, which instructs FilterChain to re-process the IOEvent processing again from the beginning.

getStopAction

public NextAction getStopAction()
Get NextAction implementation, which instructs FilterChain to stop executing phase and start post executing filters.

Returns:
NextAction implementation, which instructs FilterChain to stop executing phase and start post executing filters.

getSuspendAction

public NextAction getSuspendAction()
Get NextAction, which instructs FilterChain to suspend filter chain execution, both execute and post-execute phases.

Returns:
NextAction, which instructs FilterChain to suspend filter chain execution, both execute and post-execute phases.

release

public void release()
Release the context associated resources.

Specified by:
release in interface PoolableObject
Overrides:
release in class Context

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2009 SUN Microsystems. All Rights Reserved.