Package org.apache.mina.core.filterchain
Class DefaultIoFilterChain
- java.lang.Object
-
- org.apache.mina.core.filterchain.DefaultIoFilterChain
-
- All Implemented Interfaces:
IoFilterChain
- Direct Known Subclasses:
VmPipeFilterChain
public class DefaultIoFilterChain extends Object implements IoFilterChain
A default implementation ofIoFilterChainthat provides all operations for developers who want to implement their own transport layer once used withAbstractIoSession.- Author:
- Apache MINA Project
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.mina.core.filterchain.IoFilterChain
IoFilterChain.Entry
-
-
Field Summary
Fields Modifier and Type Field Description static AttributeKeySESSION_CREATED_FUTURE
-
Constructor Summary
Constructors Constructor Description DefaultIoFilterChain(AbstractIoSession session)Create a new default chain, associated with a session.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAfter(String baseName, String name, IoFilter filter)Adds the specified filter with the specified name just after the filter whose name isbaseNamein this chain.voidaddBefore(String baseName, String name, IoFilter filter)Adds the specified filter with the specified name just before the filter whose name isbaseNamein this chain.voidaddFirst(String name, IoFilter filter)Adds the specified filter with the specified name at the beginning of this chain.voidaddLast(String name, IoFilter filter)Adds the specified filter with the specified name at the end of this chain.voidclear()Removes all filters added to this chain.booleancontains(Class<? extends IoFilter> filterType)booleancontains(String name)booleancontains(IoFilter filter)voidfireEvent(FilterEvent event)Fires aIoHandler.event(IoSession, FilterEvent)event.voidfireExceptionCaught(Throwable cause)Fires aIoHandler.exceptionCaught(IoSession, Throwable)event.voidfireFilterClose()Fires aIoSession.closeNow()or aIoSession.closeOnFlush()event.voidfireFilterWrite(WriteRequest writeRequest)Fires aIoSession.write(Object)event.voidfireInputClosed()Fires aIoHandler.inputClosed(IoSession)event.voidfireMessageReceived(Object message)Fires aIoHandler.messageReceived(IoSession, Object)event.voidfireMessageSent(WriteRequest request)Fires aIoHandler.messageSent(IoSession, Object)event.voidfireSessionClosed()Fires aIoHandler.sessionClosed(IoSession)event.voidfireSessionCreated()Fires aIoHandler.sessionCreated(IoSession)event.voidfireSessionIdle(IdleStatus status)Fires aIoHandler.sessionIdle(IoSession, IdleStatus)event.voidfireSessionOpened()Fires aIoHandler.sessionOpened(IoSession)event.IoFilterget(Class<? extends IoFilter> filterType)Returns theIoFilterwith the specifiedfilterTypein this chain.IoFilterget(String name)Returns theIoFilterwith the specifiednamein this chain.List<IoFilterChain.Entry>getAll()List<IoFilterChain.Entry>getAllReversed()IoFilterChain.EntrygetEntry(Class<? extends IoFilter> filterType)Returns theIoFilterChain.Entrywith the specifiedfilterTypein this chain.IoFilterChain.EntrygetEntry(String name)Returns theIoFilterChain.Entrywith the specifiednamein this chain.IoFilterChain.EntrygetEntry(IoFilter filter)Returns theIoFilterChain.Entrywith the specifiedfilterin this chain.IoFilter.NextFiltergetNextFilter(Class<? extends IoFilter> filterType)Returns theIoFilter.NextFilterof the specifiedfilterTypein this chain.IoFilter.NextFiltergetNextFilter(String name)IoFilter.NextFiltergetNextFilter(IoFilter filter)Returns theIoFilter.NextFilterof the specifiedIoFilterin this chain.IoSessiongetSession()IoFilterremove(Class<? extends IoFilter> filterType)Replace the filter of the specified type with the specified new filter.IoFilterremove(String name)Removes the filter with the specified name from this chain.voidremove(IoFilter filter)Replace the filter with the specified name with the specified new filter.IoFilterreplace(Class<? extends IoFilter> oldFilterType, IoFilter newFilter)Replace the filter of the specified type with the specified new filter.IoFilterreplace(String name, IoFilter newFilter)Replace the filter with the specified name with the specified new filter.voidreplace(IoFilter oldFilter, IoFilter newFilter)Replace the filter with the specified name with the specified new filter.StringtoString()
-
-
-
Field Detail
-
SESSION_CREATED_FUTURE
public static final AttributeKey SESSION_CREATED_FUTURE
A session attribute that stores anIoFuturerelated with theIoSession.DefaultIoFilterChainclears this attribute and notifies the future whenfireSessionCreated()orfireExceptionCaught(Throwable)is invoked.
-
-
Constructor Detail
-
DefaultIoFilterChain
public DefaultIoFilterChain(AbstractIoSession session)
Create a new default chain, associated with a session. It will only contain a HeadFilter and a TailFilter.- Parameters:
session- The session associated with the created filter chain
-
-
Method Detail
-
getSession
public IoSession getSession()
- Specified by:
getSessionin interfaceIoFilterChain- Returns:
- the parent
IoSessionof this chain.
-
getEntry
public IoFilterChain.Entry getEntry(String name)
Returns theIoFilterChain.Entrywith the specifiednamein this chain.- Specified by:
getEntryin interfaceIoFilterChain- Parameters:
name- The filter's name we are looking for- Returns:
nullif there's no such name in this chain
-
getEntry
public IoFilterChain.Entry getEntry(IoFilter filter)
Returns theIoFilterChain.Entrywith the specifiedfilterin this chain.- Specified by:
getEntryin interfaceIoFilterChain- Parameters:
filter- The Filter we are looking for- Returns:
nullif there's no such filter in this chain
-
getEntry
public IoFilterChain.Entry getEntry(Class<? extends IoFilter> filterType)
Returns theIoFilterChain.Entrywith the specifiedfilterTypein this chain. If there's more than one filter with the specified type, the first match will be chosen.- Specified by:
getEntryin interfaceIoFilterChain- Parameters:
filterType- The filter class we are looking for- Returns:
nullif there's no such name in this chain
-
get
public IoFilter get(String name)
Returns theIoFilterwith the specifiednamein this chain.- Specified by:
getin interfaceIoFilterChain- Parameters:
name- the filter's name- Returns:
nullif there's no such name in this chain
-
get
public IoFilter get(Class<? extends IoFilter> filterType)
Returns theIoFilterwith the specifiedfilterTypein this chain. If there's more than one filter with the specified type, the first match will be chosen.- Specified by:
getin interfaceIoFilterChain- Parameters:
filterType- The filter class- Returns:
nullif there's no such name in this chain
-
getNextFilter
public IoFilter.NextFilter getNextFilter(String name)
- Specified by:
getNextFilterin interfaceIoFilterChain- Parameters:
name- The filter's name we want the next filter- Returns:
nullif there's no such name in this chain
-
getNextFilter
public IoFilter.NextFilter getNextFilter(IoFilter filter)
Returns theIoFilter.NextFilterof the specifiedIoFilterin this chain.- Specified by:
getNextFilterin interfaceIoFilterChain- Parameters:
filter- The filter for which we want the next filter- Returns:
nullif there's no such name in this chain
-
getNextFilter
public IoFilter.NextFilter getNextFilter(Class<? extends IoFilter> filterType)
Returns theIoFilter.NextFilterof the specifiedfilterTypein this chain. If there's more than one filter with the specified type, the first match will be chosen.- Specified by:
getNextFilterin interfaceIoFilterChain- Parameters:
filterType- The Filter class for which we want the next filter- Returns:
nullif there's no such name in this chain
-
addFirst
public void addFirst(String name, IoFilter filter)
Adds the specified filter with the specified name at the beginning of this chain.- Specified by:
addFirstin interfaceIoFilterChain- Parameters:
name- The filter's namefilter- The filter to add
-
addLast
public void addLast(String name, IoFilter filter)
Adds the specified filter with the specified name at the end of this chain.- Specified by:
addLastin interfaceIoFilterChain- Parameters:
name- The filter's namefilter- The filter to add
-
addBefore
public void addBefore(String baseName, String name, IoFilter filter)
Adds the specified filter with the specified name just before the filter whose name isbaseNamein this chain.- Specified by:
addBeforein interfaceIoFilterChain- Parameters:
baseName- The targeted Filter's namename- The filter's namefilter- The filter to add
-
addAfter
public void addAfter(String baseName, String name, IoFilter filter)
Adds the specified filter with the specified name just after the filter whose name isbaseNamein this chain.- Specified by:
addAfterin interfaceIoFilterChain- Parameters:
baseName- The targeted Filter's namename- The filter's namefilter- The filter to add
-
remove
public IoFilter remove(String name)
Removes the filter with the specified name from this chain.- Specified by:
removein interfaceIoFilterChain- Parameters:
name- The name of the filter to remove- Returns:
- The removed filter
-
remove
public void remove(IoFilter filter)
Replace the filter with the specified name with the specified new filter.- Specified by:
removein interfaceIoFilterChain- Parameters:
filter- The filter to remove
-
remove
public IoFilter remove(Class<? extends IoFilter> filterType)
Replace the filter of the specified type with the specified new filter. If there's more than one filter with the specified type, the first match will be replaced.- Specified by:
removein interfaceIoFilterChain- Parameters:
filterType- The filter class to remove- Returns:
- The removed filter
-
replace
public IoFilter replace(String name, IoFilter newFilter)
Replace the filter with the specified name with the specified new filter.- Specified by:
replacein interfaceIoFilterChain- Parameters:
name- The name of the filter we want to replacenewFilter- The new filter- Returns:
- the old filter
-
replace
public void replace(IoFilter oldFilter, IoFilter newFilter)
Replace the filter with the specified name with the specified new filter.- Specified by:
replacein interfaceIoFilterChain- Parameters:
oldFilter- The filter we want to replacenewFilter- The new filter
-
replace
public IoFilter replace(Class<? extends IoFilter> oldFilterType, IoFilter newFilter)
Replace the filter of the specified type with the specified new filter. If there's more than one filter with the specified type, the first match will be replaced.- Specified by:
replacein interfaceIoFilterChain- Parameters:
oldFilterType- The filter class we want to replacenewFilter- The new filter- Returns:
- The replaced IoFilter
-
clear
public void clear() throws ExceptionRemoves all filters added to this chain.- Specified by:
clearin interfaceIoFilterChain- Throws:
Exception- If we weren't able to clear the filters
-
fireSessionCreated
public void fireSessionCreated()
Fires aIoHandler.sessionCreated(IoSession)event. Most users don't need to call this method at all. Please use this method only when you implement a new transport or fire a virtual event.- Specified by:
fireSessionCreatedin interfaceIoFilterChain
-
fireSessionOpened
public void fireSessionOpened()
Fires aIoHandler.sessionOpened(IoSession)event. Most users don't need to call this method at all. Please use this method only when you implement a new transport or fire a virtual event.- Specified by:
fireSessionOpenedin interfaceIoFilterChain
-
fireEvent
public void fireEvent(FilterEvent event)
Fires aIoHandler.event(IoSession, FilterEvent)event. Most users don't need to call this method at all. Please use this method only when you implement a new transport or fire a virtual event.- Specified by:
fireEventin interfaceIoFilterChain- Parameters:
event- The specific event being fired
-
fireSessionClosed
public void fireSessionClosed()
Fires aIoHandler.sessionClosed(IoSession)event. Most users don't need to call this method at all. Please use this method only when you implement a new transport or fire a virtual event.- Specified by:
fireSessionClosedin interfaceIoFilterChain
-
fireSessionIdle
public void fireSessionIdle(IdleStatus status)
Fires aIoHandler.sessionIdle(IoSession, IdleStatus)event. Most users don't need to call this method at all. Please use this method only when you implement a new transport or fire a virtual event.- Specified by:
fireSessionIdlein interfaceIoFilterChain- Parameters:
status- The current status to propagate
-
fireMessageReceived
public void fireMessageReceived(Object message)
Fires aIoHandler.messageReceived(IoSession, Object)event. Most users don't need to call this method at all. Please use this method only when you implement a new transport or fire a virtual event.- Specified by:
fireMessageReceivedin interfaceIoFilterChain- Parameters:
message- The received message
-
fireMessageSent
public void fireMessageSent(WriteRequest request)
Fires aIoHandler.messageSent(IoSession, Object)event. Most users don't need to call this method at all. Please use this method only when you implement a new transport or fire a virtual event.- Specified by:
fireMessageSentin interfaceIoFilterChain- Parameters:
request- The sent request
-
fireExceptionCaught
public void fireExceptionCaught(Throwable cause)
Fires aIoHandler.exceptionCaught(IoSession, Throwable)event. Most users don't need to call this method at all. Please use this method only when you implement a new transport or fire a virtual event.- Specified by:
fireExceptionCaughtin interfaceIoFilterChain- Parameters:
cause- The exception cause
-
fireInputClosed
public void fireInputClosed()
Fires aIoHandler.inputClosed(IoSession)event. Most users don't need to call this method at all. Please use this method only when you implement a new transport or fire a virtual event.- Specified by:
fireInputClosedin interfaceIoFilterChain
-
fireFilterWrite
public void fireFilterWrite(WriteRequest writeRequest)
Fires aIoSession.write(Object)event. Most users don't need to call this method at all. Please use this method only when you implement a new transport or fire a virtual event.- Specified by:
fireFilterWritein interfaceIoFilterChain- Parameters:
writeRequest- The message to write
-
fireFilterClose
public void fireFilterClose()
Fires aIoSession.closeNow()or aIoSession.closeOnFlush()event. Most users don't need to call this method at all. Please use this method only when you implement a new transport or fire a virtual event.- Specified by:
fireFilterClosein interfaceIoFilterChain
-
getAll
public List<IoFilterChain.Entry> getAll()
- Specified by:
getAllin interfaceIoFilterChain- Returns:
- The list of all
IoFilterChain.Entrys this chain contains.
-
getAllReversed
public List<IoFilterChain.Entry> getAllReversed()
- Specified by:
getAllReversedin interfaceIoFilterChain- Returns:
- The reversed list of all
IoFilterChain.Entrys this chain contains.
-
contains
public boolean contains(String name)
- Specified by:
containsin interfaceIoFilterChain- Parameters:
name- The filter's name we are looking for- Returns:
trueif this chain contains anIoFilterwith the specifiedname.
-
contains
public boolean contains(IoFilter filter)
- Specified by:
containsin interfaceIoFilterChain- Parameters:
filter- The filter we are looking for- Returns:
trueif this chain contains the specifiedfilter.
-
contains
public boolean contains(Class<? extends IoFilter> filterType)
- Specified by:
containsin interfaceIoFilterChain- Parameters:
filterType- The filter's class we are looking for- Returns:
trueif this chain contains anIoFilterof the specifiedfilterType.
-
-