Package org.apache.mina.core.filterchain
Class DefaultIoFilterChainBuilder
- java.lang.Object
-
- org.apache.mina.core.filterchain.DefaultIoFilterChainBuilder
-
- All Implemented Interfaces:
IoFilterChainBuilder
public class DefaultIoFilterChainBuilder extends Object implements IoFilterChainBuilder
The default implementation ofIoFilterChainBuilderwhich is useful in most cases.DefaultIoFilterChainBuilderhas an identical interface withIoFilter; it contains a list ofIoFilters that you can modify. TheIoFilters which are added to this builder will be appended to theIoFilterChainwhenbuildFilterChain(IoFilterChain)is invoked.However, the identical interface doesn't mean that it behaves in an exactly same way with
IoFilterChain.DefaultIoFilterChainBuilderdoesn't manage the life cycle of theIoFilters at all, and the existingIoSessions won't get affected by the changes in this builder.IoFilterChainBuilders affect only newly createdIoSessions.IoAcceptor acceptor = ...; DefaultIoFilterChainBuilder builder = acceptor.getFilterChain(); builder.addLast( "myFilter", new MyFilter() ); ...
- Author:
- Apache MINA Project
-
-
Field Summary
-
Fields inherited from interface org.apache.mina.core.filterchain.IoFilterChainBuilder
NOOP
-
-
Constructor Summary
Constructors Constructor Description DefaultIoFilterChainBuilder()Creates a new instance with an empty filter list.DefaultIoFilterChainBuilder(DefaultIoFilterChainBuilder filterChain)Creates a new copy of the specifiedDefaultIoFilterChainBuilder.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAfter(String baseName, String name, IoFilter filter)voidaddBefore(String baseName, String name, IoFilter filter)voidaddFirst(String name, IoFilter filter)voidaddLast(String name, IoFilter filter)voidbuildFilterChain(IoFilterChain chain)Modifies the specifiedchain.voidclear()booleancontains(Class<? extends IoFilter> filterType)booleancontains(String name)booleancontains(IoFilter filter)IoFilterget(Class<? extends IoFilter> filterType)IoFilterget(String name)List<IoFilterChain.Entry>getAll()List<IoFilterChain.Entry>getAllReversed()IoFilterChain.EntrygetEntry(Class<? extends IoFilter> filterType)IoFilterChain.EntrygetEntry(String name)IoFilterChain.EntrygetEntry(IoFilter filter)IoFilterremove(Class<? extends IoFilter> filterType)IoFilterremove(String name)IoFilterremove(IoFilter filter)voidreplace(Class<? extends IoFilter> oldFilterType, IoFilter newFilter)Replace a filter by a new one.IoFilterreplace(String name, IoFilter newFilter)Replace a filter by a new one.voidreplace(IoFilter oldFilter, IoFilter newFilter)Replace a filter by a new one.voidsetFilters(Map<String,? extends IoFilter> filters)Clears the current list of filters and adds the specified filter mapping to this builder.StringtoString()
-
-
-
Constructor Detail
-
DefaultIoFilterChainBuilder
public DefaultIoFilterChainBuilder()
Creates a new instance with an empty filter list.
-
DefaultIoFilterChainBuilder
public DefaultIoFilterChainBuilder(DefaultIoFilterChainBuilder filterChain)
Creates a new copy of the specifiedDefaultIoFilterChainBuilder.- Parameters:
filterChain- The FilterChain we will copy
-
-
Method Detail
-
getEntry
public IoFilterChain.Entry getEntry(String name)
- Parameters:
name- The Filter's name we are looking for- Returns:
- The found Entry
- See Also:
IoFilterChain.getEntry(String)
-
getEntry
public IoFilterChain.Entry getEntry(IoFilter filter)
- Parameters:
filter- The Filter we are looking for- Returns:
- The found Entry
- See Also:
IoFilterChain.getEntry(IoFilter)
-
getEntry
public IoFilterChain.Entry getEntry(Class<? extends IoFilter> filterType)
- Parameters:
filterType- The FilterType we are looking for- Returns:
- The found Entry
- See Also:
IoFilterChain.getEntry(Class)
-
get
public IoFilter get(String name)
- Parameters:
name- The Filter's name we are looking for- Returns:
- The found Filter, or null
- See Also:
IoFilterChain.get(String)
-
get
public IoFilter get(Class<? extends IoFilter> filterType)
- Parameters:
filterType- The FilterType we are looking for- Returns:
- The found Filter, or null
- See Also:
IoFilterChain.get(Class)
-
getAll
public List<IoFilterChain.Entry> getAll()
- Returns:
- The list of Filters
- See Also:
IoFilterChain.getAll()
-
getAllReversed
public List<IoFilterChain.Entry> getAllReversed()
- Returns:
- The list of Filters, reversed
- See Also:
IoFilterChain.getAllReversed()
-
contains
public boolean contains(String name)
- Parameters:
name- The Filter's name we want to check if it's in the chain- Returns:
trueif the chain contains the given filter name- See Also:
IoFilterChain.contains(String)
-
contains
public boolean contains(IoFilter filter)
- Parameters:
filter- The Filter we want to check if it's in the chain- Returns:
trueif the chain contains the given filter- See Also:
IoFilterChain.contains(IoFilter)
-
contains
public boolean contains(Class<? extends IoFilter> filterType)
- Parameters:
filterType- The FilterType we want to check if it's in the chain- Returns:
trueif the chain contains the given filterType- See Also:
IoFilterChain.contains(Class)
-
addFirst
public void addFirst(String name, IoFilter filter)
- Parameters:
name- The filter's namefilter- The filter to add- See Also:
IoFilterChain.addFirst(String, IoFilter)
-
addLast
public void addLast(String name, IoFilter filter)
- Parameters:
name- The filter's namefilter- The filter to add- See Also:
IoFilterChain.addLast(String, IoFilter)
-
addBefore
public void addBefore(String baseName, String name, IoFilter filter)
- Parameters:
baseName- The filter baseNamename- The filter's namefilter- The filter to add- See Also:
IoFilterChain.addBefore(String, String, IoFilter)
-
addAfter
public void addAfter(String baseName, String name, IoFilter filter)
- Parameters:
baseName- The filter baseNamename- The filter's namefilter- The filter to add- See Also:
IoFilterChain.addAfter(String, String, IoFilter)
-
remove
public IoFilter remove(String name)
- Parameters:
name- The Filter's name to remove from the list of Filters- Returns:
- The removed IoFilter
- See Also:
IoFilterChain.remove(String)
-
remove
public IoFilter remove(IoFilter filter)
- Parameters:
filter- The Filter we want to remove from the list of Filters- Returns:
- The removed IoFilter
- See Also:
IoFilterChain.remove(IoFilter)
-
remove
public IoFilter remove(Class<? extends IoFilter> filterType)
- Parameters:
filterType- The FilterType we want to remove from the list of Filters- Returns:
- The removed IoFilter
- See Also:
IoFilterChain.remove(Class)
-
replace
public IoFilter replace(String name, IoFilter newFilter)
Replace a filter by a new one.- Parameters:
name- The name of the filter to replacenewFilter- The new filter to use- Returns:
- The replaced filter
-
replace
public void replace(IoFilter oldFilter, IoFilter newFilter)
Replace a filter by a new one.- Parameters:
oldFilter- The filter to replacenewFilter- The new filter to use
-
replace
public void replace(Class<? extends IoFilter> oldFilterType, IoFilter newFilter)
Replace a filter by a new one. We are looking for a filter type, but if we have more than one with the same type, only the first found one will be replaced- Parameters:
oldFilterType- The filter type to replacenewFilter- The new filter to use
-
clear
public void clear()
- See Also:
IoFilterChain.clear()
-
setFilters
public void setFilters(Map<String,? extends IoFilter> filters)
Clears the current list of filters and adds the specified filter mapping to this builder. Please note that you must specify aMapimplementation that iterates the filter mapping in the order of insertion such asLinkedHashMap. Otherwise, it will throw anIllegalArgumentException.- Parameters:
filters- The list of filters to set
-
buildFilterChain
public void buildFilterChain(IoFilterChain chain) throws Exception
Modifies the specifiedchain.- Specified by:
buildFilterChainin interfaceIoFilterChainBuilder- Parameters:
chain- The chain to modify- Throws:
Exception- If the chain modification failed
-
-