org.norther.tammi.spray.filter
Interface Pipe

All Superinterfaces:
Filter
All Known Implementing Classes:
DefaultPipe

public interface Pipe
extends Filter

Pipe describes a collection of Filters that should be processed in sequence when the doFilter method is called. It is required that a filter somewhere in the pipe (often the last one) must process the request and create the corresponding response, rather than trying to pass the request on.

Pipe extends Filter making it possible to use pipe implementations in place of pure filter implementations where applicable.

Author:
Ilkka Priha

Method Summary
 void addFilterName(int index, ObjectName name)
          Adds a new filter to the given location.
 void addFilterName(ObjectName name)
          Adds a new filter to the end of the pipe.
 void clearFilterNames()
          Clears all filters from the pipe.
 void closeNamedFilter(ObjectName filter)
          Closes the named filter.
 void closeNamedFilter(ObjectName filter, int index)
          Closes the indexed filter.
 boolean containsFilterName(ObjectName filter)
          Checks whether the specified filter is in the pipe.
 void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
          Causes the specified request and response to be processed by the filters associated with this pipe, until one of these filters causes the response to be created and returned.
 ObjectName getFilterName(int index)
          Gets the indexed filter in the pipe.
 List getFilterNames()
          Gets filters in the pipe.
 Filter getFirstFilter()
          Gets the first registered filter in the pipe.
 Filter getFirstFilter(Class clazz)
          Gets the first registered filter of the specified class in the pipe.
 Filter getLastFilter()
          Gets the last registered filter in the pipe.
 Filter getLastFilter(Class clazz)
          Gets the last registered filter of the specified class in the pipe.
 Filter getNextFilter(int index)
          Gets the next registered filter following the given location.
 Filter getNextFilter(int index, Class clazz)
          Gets the next registered filter of the specified class following the given location.
 Filter getPreviousFilter(int index)
          Gets the previous registered filter preceding the given location.
 Filter getPreviousFilter(int index, Class clazz)
          Gets the previous registered filter of the specified class preceding the given location.
 boolean isNamedFilterOpen(ObjectName filter)
          Checks whether the named filter is open.
 boolean isNamedFilterOpen(ObjectName filter, int index)
          Checks whether the indexed filter is open.
 int locateFilter(Class clazz)
          Locates the first registered filter of the specified class in the pipe.
 int locateFilter(int index, Class clazz)
          Locates the next registered filter of the specified class following the given location.
 int locateNamedFilter(ObjectName filter)
          Locates the named filter in the pipe.
 int locateNamedFilter(ObjectName filter, int index)
          Locates the named filter in the pipe from the given location.
 void openNamedFilter(ObjectName filter)
          Opens the named filter.
 void openNamedFilter(ObjectName filter, int index)
          Opens the indexed filter.
 Filter queryFilter(String pattern)
          Queries for a specified filter in the pipe.
 void removeFilterName(int index)
          Removes the indexed filter from the pipe.
 void removeFilterName(ObjectName name)
          Removes the first filter with the specified name from the pipe.
 void setFilterName(int index, ObjectName name)
          Sets the indexed filter in the pipe.
 void setFilterNames(List names)
          Sets filters in the pipe.
 
Methods inherited from interface javax.servlet.Filter
destroy, init
 

Method Detail

getFilterNames

List getFilterNames()
Gets filters in the pipe.

Returns:
a list of object names of filters.

setFilterNames

void setFilterNames(List names)
Sets filters in the pipe.

Parameters:
names - a list of object names of filters.

addFilterName

void addFilterName(ObjectName name)
Adds a new filter to the end of the pipe.

Parameters:
name - the object name of the new filter.

addFilterName

void addFilterName(int index,
                   ObjectName name)
Adds a new filter to the given location.

Parameters:
index - the index of the location.
name - the object name of the new filter.
Throws:
IndexOutOfBoundsException - for an incorrect index.

containsFilterName

boolean containsFilterName(ObjectName filter)
Checks whether the specified filter is in the pipe.

Parameters:
filter - the object name of the filter.
Returns:
true, if the filter is found.

getFilterName

ObjectName getFilterName(int index)
Gets the indexed filter in the pipe.

Parameters:
index - the index of the location.
Returns:
the object name of the filter.
Throws:
IndexOutOfBoundsException - for an incorrect index.

setFilterName

void setFilterName(int index,
                   ObjectName name)
Sets the indexed filter in the pipe.

Parameters:
index - the index of the location.
name - the object name of the filter.
Throws:
IndexOutOfBoundsException - for an incorrect index.

removeFilterName

void removeFilterName(ObjectName name)
Removes the first filter with the specified name from the pipe.

Parameters:
name - the object name of the filter.

removeFilterName

void removeFilterName(int index)
Removes the indexed filter from the pipe.

Parameters:
index - the index of the location.
Throws:
IndexOutOfBoundsException - for an incorrect index.

clearFilterNames

void clearFilterNames()
Clears all filters from the pipe.


locateNamedFilter

int locateNamedFilter(ObjectName filter)
Locates the named filter in the pipe.

Parameters:
filter - the object name of the filter.
Returns:
the index of the filter or -1.

locateNamedFilter

int locateNamedFilter(ObjectName filter,
                      int index)
Locates the named filter in the pipe from the given location.

Parameters:
filter - the object name of the filter.
index - the start index of the location.
Returns:
the index of the filter or -1.
Throws:
IndexOutOfBoundsException - for an incorrect index.

locateFilter

int locateFilter(Class clazz)
Locates the first registered filter of the specified class in the pipe.

Parameters:
clazz - the class or interface.
Returns:
the index of the filter or -1.

locateFilter

int locateFilter(int index,
                 Class clazz)
Locates the next registered filter of the specified class following the given location. The filter in the given location is included in the search.

Parameters:
index - the start index of the location.
clazz - the class or interface.
Returns:
the index of the filter or -1.
Throws:
IndexOutOfBoundsException - for an incorrect index.

queryFilter

Filter queryFilter(String pattern)
Queries for a specified filter in the pipe.

Parameters:
pattern - the name pattern.
Returns:
the found filter or null.

getFirstFilter

Filter getFirstFilter()
Gets the first registered filter in the pipe.

Returns:
the found filter or null.

getFirstFilter

Filter getFirstFilter(Class clazz)
Gets the first registered filter of the specified class in the pipe.

Parameters:
clazz - the class or interface.
Returns:
the found filter or null.

getLastFilter

Filter getLastFilter()
Gets the last registered filter in the pipe.

Returns:
the found filter or null.

getLastFilter

Filter getLastFilter(Class clazz)
Gets the last registered filter of the specified class in the pipe.

Parameters:
clazz - the class or interface.
Returns:
the found filter or null.

getNextFilter

Filter getNextFilter(int index)
Gets the next registered filter following the given location. The filter in the given location is included in the search.

Parameters:
index - the index of the location.
Returns:
the found filter or null.
Throws:
IndexOutOfBoundsException - for an incorrect index.

getNextFilter

Filter getNextFilter(int index,
                     Class clazz)
Gets the next registered filter of the specified class following the given location. The filter in the given location is included in the search.

Parameters:
clazz - the class or interface.
index - the index of the location.
Returns:
the found filter or null.
Throws:
IndexOutOfBoundsException - for an incorrect index.

getPreviousFilter

Filter getPreviousFilter(int index)
Gets the previous registered filter preceding the given location. The filter in the given location is included in the search.

Parameters:
index - the index the location.
Returns:
the found filter or null.
Throws:
IndexOutOfBoundsException - for an incorrect index.

getPreviousFilter

Filter getPreviousFilter(int index,
                         Class clazz)
Gets the previous registered filter of the specified class preceding the given location. The filter in the given location is included in the search.

Parameters:
clazz - the class or interface.
index - the index of the location.
Returns:
the found filter or null.
Throws:
IndexOutOfBoundsException - for an incorrect index.

isNamedFilterOpen

boolean isNamedFilterOpen(ObjectName filter)
Checks whether the named filter is open.

Parameters:
filter - the object name of the filter.
Returns:
true if open, false otherwise.

isNamedFilterOpen

boolean isNamedFilterOpen(ObjectName filter,
                          int index)
Checks whether the indexed filter is open.

Parameters:
filter - the object name of the filter.
index - the start index of the location.
Returns:
true if open, false otherwise.
Throws:
IndexOutOfBoundsException - for an incorrect index.

openNamedFilter

void openNamedFilter(ObjectName filter)
Opens the named filter.

Parameters:
filter - the object name of the filter.

closeNamedFilter

void closeNamedFilter(ObjectName filter)
Closes the named filter.

Parameters:
filter - the object name of the filter.

openNamedFilter

void openNamedFilter(ObjectName filter,
                     int index)
Opens the indexed filter.

Parameters:
filter - the object name of the filter.
index - the start index of the location.
Throws:
IndexOutOfBoundsException - for an incorrect index.

closeNamedFilter

void closeNamedFilter(ObjectName filter,
                      int index)
Closes the indexed filter.

Parameters:
filter - the object name of the filter.
index - the start index of the location.
Throws:
IndexOutOfBoundsException - for an incorrect index.

doFilter

void doFilter(ServletRequest request,
              ServletResponse response,
              FilterChain chain)
              throws ServletException,
                     IOException
Causes the specified request and response to be processed by the filters associated with this pipe, until one of these filters causes the response to be created and returned. The implementation must ensure that multiple simultaneous requests (on different threads) can be processed through the same pipe without interfering with each other's filter chain.

Note that changes to the list of filters in the pipe during one request will be effective only for forthcoming requests.

Specified by:
doFilter in interface Filter
Parameters:
request - the request to process.
response - the response to return.
chain - the filter chain from preceding pipes.
Throws:
ServletException - for servlet errors.
IOException - for general errors.


Copyright © 2004 The Norther Organization. All rights reserved.