Class DefaultIoFilterChainBuilder
java.lang.Object
org.apache.mina.core.filterchain.DefaultIoFilterChainBuilder
- All Implemented Interfaces:
IoFilterChainBuilder
The default implementation of
IoFilterChainBuilder which is useful
in most cases. DefaultIoFilterChainBuilder has an identical interface
with IoFilter; it contains a list of IoFilters that you can
modify. The IoFilters 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 IoFilters at all, and the
existing IoSessions won't get affected by the changes in this builder.
IoFilterChainBuilders affect only newly created IoSessions.
IoAcceptor acceptor = ...; DefaultIoFilterChainBuilder builder = acceptor.getFilterChain(); builder.addLast( "myFilter", new MyFilter() ); ...
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final List<IoFilterChain.Entry> The list of filtersprivate static final org.slf4j.LoggerThe loggerFields inherited from interface IoFilterChainBuilder
NOOP -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance with an empty filter list.DefaultIoFilterChainBuilder(DefaultIoFilterChainBuilder filterChain) Creates a new copy of the specifiedDefaultIoFilterChainBuilder. -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidvoidvoidvoidbuildFilterChain(IoFilterChain chain) Modifies the specifiedchain.private voidcheckBaseName(String baseName) voidclear()booleanbooleanbooleangetAll()private booleanisOrderedMap(Map<String, ? extends IoFilter> map) private voidregister(int index, IoFilterChain.Entry e) voidReplace a filter by a new one.Replace a filter by a new one.voidReplace 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.toString()
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGERThe logger -
entries
The list of filters
-
-
Constructor Details
-
DefaultIoFilterChainBuilder
public DefaultIoFilterChainBuilder()Creates a new instance with an empty filter list. -
DefaultIoFilterChainBuilder
Creates a new copy of the specifiedDefaultIoFilterChainBuilder.- Parameters:
filterChain- The FilterChain we will copy
-
-
Method Details
-
getEntry
- Parameters:
name- The Filter's name we are looking for- Returns:
- The found Entry
- See Also:
-
getEntry
- Parameters:
filter- The Filter we are looking for- Returns:
- The found Entry
- See Also:
-
getEntry
- Parameters:
filterType- The FilterType we are looking for- Returns:
- The found Entry
- See Also:
-
get
-
get
-
getAll
- Returns:
- The list of Filters
- See Also:
-
getAllReversed
- Returns:
- The list of Filters, reversed
- See Also:
-
contains
- 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:
-
contains
- Parameters:
filter- The Filter we want to check if it's in the chain- Returns:
trueif the chain contains the given filter- See Also:
-
contains
-
addFirst
-
addLast
-
addBefore
-
addAfter
-
remove
-
remove
-
remove
-
replace
-
replace
-
replace
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:
-
setFilters
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
-
isOrderedMap
-
buildFilterChain
Modifies the specifiedchain.- Specified by:
buildFilterChainin interfaceIoFilterChainBuilder- Parameters:
chain- The chain to modify- Throws:
Exception- If the chain modification failed
-
toString
-
checkBaseName
-
register
-