Package org.apache.mina.common.support
Class AbstractIoFilterChain
- java.lang.Object
-
- org.apache.mina.common.support.AbstractIoFilterChain
-
- All Implemented Interfaces:
IoFilterChain
- Direct Known Subclasses:
VmPipeFilterChain
public abstract class AbstractIoFilterChain extends java.lang.Object implements IoFilterChain
An abstract implementation ofIoFilterChainthat provides common operations for developers to implement their own transport layer.The only method a developer should implement is
doWrite(IoSession, IoFilter.WriteRequest). This method is invoked when filter chain is evaluated forIoFilter.filterWrite(NextFilter, IoSession, IoFilter.WriteRequest)and finally to be written out.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.mina.common.IoFilterChain
IoFilterChain.Entry
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCONNECT_FUTUREA session attribute that stores aConnectFuturerelated with theIoSession.
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractIoFilterChain(IoSession session)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddAfter(java.lang.String baseName, java.lang.String name, IoFilter filter)Adds the specified filter with the specified name just after the filter whose name isbaseNamein this chain.voidaddBefore(java.lang.String baseName, java.lang.String name, IoFilter filter)Adds the specified filter with the specified name just before the filter whose name isbaseNamein this chain.voidaddFirst(java.lang.String name, IoFilter filter)Adds the specified filter with the specified name at the beginning of this chain.voidaddLast(java.lang.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(java.lang.Class<? extends IoFilter> filterType)Returns true if this chain contains anIoFilterof the specified filterType.booleancontains(java.lang.String name)Returns true if this chain contains anIoFilterwith the specified name.booleancontains(IoFilter filter)Returns true if this chain contains the specified filter.protected abstract voiddoClose(IoSession session)protected abstract voiddoWrite(IoSession session, IoFilter.WriteRequest writeRequest)protected voidfinalize()voidfireExceptionCaught(IoSession session, java.lang.Throwable cause)Fires aIoHandler.exceptionCaught(IoSession, Throwable)event.voidfireFilterClose(IoSession session)Fires aIoSession.close()event.voidfireFilterWrite(IoSession session, IoFilter.WriteRequest writeRequest)Fires aIoSession.write(Object)event.voidfireMessageReceived(IoSession session, java.lang.Object message)Fires aIoFilterChain.fireMessageReceived(IoSession, Object)event.voidfireMessageSent(IoSession session, IoFilter.WriteRequest request)Fires aIoHandler.sessionOpened(IoSession)event.voidfireSessionClosed(IoSession session)Fires aIoHandler.sessionClosed(IoSession)event.voidfireSessionCreated(IoSession session)Fires aIoHandler.sessionCreated(IoSession)event.voidfireSessionIdle(IoSession session, IdleStatus status)Fires aIoHandler.sessionIdle(IoSession, IdleStatus)event.voidfireSessionOpened(IoSession session)Fires aIoHandler.sessionOpened(IoSession)event.IoFilterget(java.lang.String name)Returns theIoFilterwith the specified name in this chain.java.util.List<IoFilterChain.Entry>getAll()Returns the list of allIoFilterChain.Entrys this chain contains.java.util.List<IoFilterChain.Entry>getAllReversed()Returns the reversed list of allIoFilterChain.Entrys this chain contains.IoFilterChain.EntrygetEntry(java.lang.String name)Returns theIoFilterChain.Entrywith the specified name in this chain.IoFilter.NextFiltergetNextFilter(java.lang.String name)Returns theIoFilter.NextFilterof theIoFilterwith the specified name in this chain.IoSessiongetSession()Returns the parentIoSessionof this chain.IoFilterremove(java.lang.String name)Removes the filter with the specified name from this chain.java.lang.StringtoString()
-
-
-
Field Detail
-
CONNECT_FUTURE
public static final java.lang.String CONNECT_FUTURE
A session attribute that stores aConnectFuturerelated with theIoSession.AbstractIoFilterChainclears this attribute and notifies the future whenfireSessionOpened(IoSession)orfireExceptionCaught(IoSession, Throwable)is invoked
-
-
Constructor Detail
-
AbstractIoFilterChain
protected AbstractIoFilterChain(IoSession session)
-
-
Method Detail
-
getSession
public IoSession getSession()
Description copied from interface:IoFilterChainReturns the parentIoSessionof this chain.- Specified by:
getSessionin interfaceIoFilterChain- Returns:
IoSession
-
getEntry
public IoFilterChain.Entry getEntry(java.lang.String name)
Description copied from interface:IoFilterChainReturns theIoFilterChain.Entrywith the specified name in this chain.- Specified by:
getEntryin interfaceIoFilterChain- Returns:
- null if there's no such name in this chain
-
get
public IoFilter get(java.lang.String name)
Description copied from interface:IoFilterChainReturns theIoFilterwith the specified name in this chain.- Specified by:
getin interfaceIoFilterChain- Returns:
- null if there's no such name in this chain
-
getNextFilter
public IoFilter.NextFilter getNextFilter(java.lang.String name)
Description copied from interface:IoFilterChainReturns theIoFilter.NextFilterof theIoFilterwith the specified name in this chain.- Specified by:
getNextFilterin interfaceIoFilterChain- Returns:
- null if there's no such name in this chain
-
addFirst
public void addFirst(java.lang.String name, IoFilter filter)Description copied from interface:IoFilterChainAdds the specified filter with the specified name at the beginning of this chain.- Specified by:
addFirstin interfaceIoFilterChain
-
addLast
public void addLast(java.lang.String name, IoFilter filter)Description copied from interface:IoFilterChainAdds the specified filter with the specified name at the end of this chain.- Specified by:
addLastin interfaceIoFilterChain
-
addBefore
public void addBefore(java.lang.String baseName, java.lang.String name, IoFilter filter)Description copied from interface:IoFilterChainAdds the specified filter with the specified name just before the filter whose name isbaseNamein this chain.- Specified by:
addBeforein interfaceIoFilterChain
-
addAfter
public void addAfter(java.lang.String baseName, java.lang.String name, IoFilter filter)Description copied from interface:IoFilterChainAdds the specified filter with the specified name just after the filter whose name isbaseNamein this chain.- Specified by:
addAfterin interfaceIoFilterChain
-
remove
public IoFilter remove(java.lang.String name)
Description copied from interface:IoFilterChainRemoves the filter with the specified name from this chain.- Specified by:
removein interfaceIoFilterChain
-
clear
public void clear() throws java.lang.ExceptionDescription copied from interface:IoFilterChainRemoves all filters added to this chain.- Specified by:
clearin interfaceIoFilterChain- Throws:
java.lang.Exception- ifIoFilter.onPostRemove(IoFilterChain, String, NextFilter)thrown an exception.
-
fireSessionCreated
public void fireSessionCreated(IoSession session)
Description copied from interface:IoFilterChainFires 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(IoSession session)
Description copied from interface:IoFilterChainFires 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
-
fireSessionClosed
public void fireSessionClosed(IoSession session)
Description copied from interface:IoFilterChainFires 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(IoSession session, IdleStatus status)
Description copied from interface:IoFilterChainFires 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
-
fireMessageReceived
public void fireMessageReceived(IoSession session, java.lang.Object message)
Description copied from interface:IoFilterChainFires aIoFilterChain.fireMessageReceived(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
-
fireMessageSent
public void fireMessageSent(IoSession session, IoFilter.WriteRequest request)
Description copied from interface:IoFilterChainFires 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:
fireMessageSentin interfaceIoFilterChain
-
fireExceptionCaught
public void fireExceptionCaught(IoSession session, java.lang.Throwable cause)
Description copied from interface:IoFilterChainFires 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
-
fireFilterWrite
public void fireFilterWrite(IoSession session, IoFilter.WriteRequest writeRequest)
Description copied from interface:IoFilterChainFires 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
-
fireFilterClose
public void fireFilterClose(IoSession session)
Description copied from interface:IoFilterChainFires aIoSession.close()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 java.util.List<IoFilterChain.Entry> getAll()
Description copied from interface:IoFilterChainReturns the list of allIoFilterChain.Entrys this chain contains.- Specified by:
getAllin interfaceIoFilterChain
-
getAllReversed
public java.util.List<IoFilterChain.Entry> getAllReversed()
Description copied from interface:IoFilterChainReturns the reversed list of allIoFilterChain.Entrys this chain contains.- Specified by:
getAllReversedin interfaceIoFilterChain
-
contains
public boolean contains(java.lang.String name)
Description copied from interface:IoFilterChainReturns true if this chain contains anIoFilterwith the specified name.- Specified by:
containsin interfaceIoFilterChain
-
contains
public boolean contains(IoFilter filter)
Description copied from interface:IoFilterChainReturns true if this chain contains the specified filter.- Specified by:
containsin interfaceIoFilterChain
-
contains
public boolean contains(java.lang.Class<? extends IoFilter> filterType)
Description copied from interface:IoFilterChainReturns true if this chain contains anIoFilterof the specified filterType.- Specified by:
containsin interfaceIoFilterChain
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
finalize
protected void finalize() throws java.lang.Throwable- Overrides:
finalizein classjava.lang.Object- Throws:
java.lang.Throwable
-
doWrite
protected abstract void doWrite(IoSession session, IoFilter.WriteRequest writeRequest) throws java.lang.Exception
- Throws:
java.lang.Exception
-
doClose
protected abstract void doClose(IoSession session) throws java.lang.Exception
- Throws:
java.lang.Exception
-
-