public class DefaultIoFilterChainBuilder extends Object implements IoFilterChainBuilder
IoFilterChainBuilder
which is useful
in most cases. DefaultIoFilterChainBuilder
has an identical interface
with IoFilter
; it contains a list of IoFilter
s that you can
modify. The IoFilter
s which are added to this builder will be appended
to the IoFilterChain
when buildFilterChain(IoFilterChain)
is
invoked.
However, the identical interface doesn't mean that it behaves in an exactly
same way with IoFilterChain
. DefaultIoFilterChainBuilder
doesn't manage the life cycle of the IoFilter
s at all, and the
existing IoSession
s won't get affected by the changes in this builder.
IoFilterChainBuilder
s affect only newly created IoSession
s.
IoAcceptor acceptor = ...; DefaultIoFilterChainBuilder builder = acceptor.getFilterChain(); builder.addLast( "myFilter", new MyFilter() ); ...
NOOP
Constructor and Description |
---|
DefaultIoFilterChainBuilder()
Creates a new instance with an empty filter list.
|
DefaultIoFilterChainBuilder(DefaultIoFilterChainBuilder filterChain)
Creates a new copy of the specified
DefaultIoFilterChainBuilder . |
Modifier and Type | Method and Description |
---|---|
void |
addAfter(String baseName,
String name,
IoFilter filter) |
void |
addBefore(String baseName,
String name,
IoFilter filter) |
void |
addFirst(String name,
IoFilter filter) |
void |
addLast(String name,
IoFilter filter) |
void |
buildFilterChain(IoFilterChain chain)
Modifies the specified chain.
|
void |
clear() |
boolean |
contains(Class<? extends IoFilter> filterType) |
boolean |
contains(IoFilter filter) |
boolean |
contains(String name) |
IoFilter |
get(Class<? extends IoFilter> filterType) |
IoFilter |
get(String name) |
List<IoFilterChain.Entry> |
getAll() |
List<IoFilterChain.Entry> |
getAllReversed() |
IoFilterChain.Entry |
getEntry(Class<? extends IoFilter> filterType) |
IoFilterChain.Entry |
getEntry(IoFilter filter) |
IoFilterChain.Entry |
getEntry(String name) |
IoFilter |
remove(Class<? extends IoFilter> filterType) |
IoFilter |
remove(IoFilter filter) |
IoFilter |
remove(String name) |
void |
replace(Class<? extends IoFilter> oldFilterType,
IoFilter newFilter)
Replace a filter by a new one.
|
void |
replace(IoFilter oldFilter,
IoFilter newFilter)
Replace a filter by a new one.
|
IoFilter |
replace(String name,
IoFilter newFilter)
Replace a filter by a new one.
|
void |
setFilters(Map<String,? extends IoFilter> filters)
Clears the current list of filters and adds the specified
filter mapping to this builder.
|
String |
toString() |
public DefaultIoFilterChainBuilder()
public DefaultIoFilterChainBuilder(DefaultIoFilterChainBuilder filterChain)
DefaultIoFilterChainBuilder
.filterChain
- The FilterChain we will copypublic IoFilterChain.Entry getEntry(String name)
name
- The Filter's name we are looking forIoFilterChain.getEntry(String)
public IoFilterChain.Entry getEntry(IoFilter filter)
filter
- The Filter we are looking forIoFilterChain.getEntry(IoFilter)
public IoFilterChain.Entry getEntry(Class<? extends IoFilter> filterType)
filterType
- The FilterType we are looking forIoFilterChain.getEntry(Class)
public IoFilter get(String name)
name
- The Filter's name we are looking forIoFilterChain.get(String)
public IoFilter get(Class<? extends IoFilter> filterType)
filterType
- The FilterType we are looking forIoFilterChain.get(Class)
public List<IoFilterChain.Entry> getAll()
IoFilterChain.getAll()
public List<IoFilterChain.Entry> getAllReversed()
IoFilterChain.getAllReversed()
public boolean contains(String name)
name
- The Filter's name we want to check if it's in the chainIoFilterChain.contains(String)
public boolean contains(IoFilter filter)
filter
- The Filter we want to check if it's in the chainIoFilterChain.contains(IoFilter)
public boolean contains(Class<? extends IoFilter> filterType)
filterType
- The FilterType we want to check if it's in the chainIoFilterChain.contains(Class)
public void addFirst(String name, IoFilter filter)
name
- The filter's namefilter
- The filter to addIoFilterChain.addFirst(String, IoFilter)
public void addLast(String name, IoFilter filter)
name
- The filter's namefilter
- The filter to addIoFilterChain.addLast(String, IoFilter)
public void addBefore(String baseName, String name, IoFilter filter)
baseName
- The filter baseNamename
- The filter's namefilter
- The filter to addIoFilterChain.addBefore(String, String, IoFilter)
public void addAfter(String baseName, String name, IoFilter filter)
baseName
- The filter baseNamename
- The filter's namefilter
- The filter to addIoFilterChain.addAfter(String, String, IoFilter)
public IoFilter remove(String name)
name
- The Filter's name to remove from the list of FiltersIoFilterChain.remove(String)
public IoFilter remove(IoFilter filter)
filter
- The Filter we want to remove from the list of FiltersIoFilterChain.remove(IoFilter)
public IoFilter remove(Class<? extends IoFilter> filterType)
filterType
- The FilterType we want to remove from the list of FiltersIoFilterChain.remove(Class)
public IoFilter replace(String name, IoFilter newFilter)
name
- The name of the filter to replacenewFilter
- The new filter to usepublic void replace(IoFilter oldFilter, IoFilter newFilter)
oldFilter
- The filter to replacenewFilter
- The new filter to usepublic void replace(Class<? extends IoFilter> oldFilterType, IoFilter newFilter)
oldFilterType
- The filter type to replacenewFilter
- The new filter to usepublic void clear()
IoFilterChain.clear()
public void setFilters(Map<String,? extends IoFilter> filters)
Map
implementation that iterates the filter mapping in the
order of insertion such as LinkedHashMap
. Otherwise, it will
throw an IllegalArgumentException
.filters
- The list of filters to setpublic void buildFilterChain(IoFilterChain chain) throws Exception
buildFilterChain
in interface IoFilterChainBuilder
chain
- The chain to modifyException
- If the chain modification failedCopyright © 2004–2022 Apache MINA Project. All rights reserved.