Package org.apache.mina.core.filterchain
Class IoFilterAdapter
- java.lang.Object
-
- org.apache.mina.core.filterchain.IoFilterAdapter
-
- All Implemented Interfaces:
IoFilter
- Direct Known Subclasses:
AbstractStreamWriteFilter
,BlacklistFilter
,BufferedWriteFilter
,CommonEventFilter
,CompressionFilter
,ConnectionThrottleFilter
,ErrorGeneratingFilter
,ExecutorFilter
,KeepAliveFilter
,LoggingFilter
,NoopFilter
,ProfilerTimerFilter
,ProtocolCodecFilter
,ProxyFilter
,ReferenceCountingFilter
,SessionAttributeInitializingFilter
,SslFilter
,WriteRequestFilter
public class IoFilterAdapter extends Object implements IoFilter
An adapter class forIoFilter
. You can extend this class and selectively override required event filter methods only. All methods forwards events to the next filter by default.- Author:
- Apache MINA Project
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.mina.core.filterchain.IoFilter
IoFilter.NextFilter
-
-
Constructor Summary
Constructors Constructor Description IoFilterAdapter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
destroy()
Invoked byReferenceCountingFilter
when this filter is not used by anyIoFilterChain
anymore, so you can destroy shared resources.void
event(IoFilter.NextFilter nextFilter, IoSession session, FilterEvent event)
Propagate an event up to theIoHandler
void
exceptionCaught(IoFilter.NextFilter nextFilter, IoSession session, Throwable cause)
FiltersIoHandler.exceptionCaught(IoSession,Throwable)
event.void
filterClose(IoFilter.NextFilter nextFilter, IoSession session)
FiltersIoSession.closeNow()
or aIoSession.closeOnFlush()
method invocations.void
filterWrite(IoFilter.NextFilter nextFilter, IoSession session, WriteRequest writeRequest)
FiltersIoSession.write(Object)
method invocation.void
init()
Invoked byReferenceCountingFilter
when this filter is added to aIoFilterChain
at the first time, so you can initialize shared resources.void
inputClosed(IoFilter.NextFilter nextFilter, IoSession session)
FiltersIoHandler.inputClosed(IoSession)
event.void
messageReceived(IoFilter.NextFilter nextFilter, IoSession session, Object message)
FiltersIoHandler.messageReceived(IoSession,Object)
event.void
messageSent(IoFilter.NextFilter nextFilter, IoSession session, WriteRequest writeRequest)
FiltersIoHandler.messageSent(IoSession,Object)
event.void
onPostAdd(IoFilterChain parent, String name, IoFilter.NextFilter nextFilter)
Invoked after this filter is added to the specifiedparent
.void
onPostRemove(IoFilterChain parent, String name, IoFilter.NextFilter nextFilter)
Invoked after this filter is removed from the specifiedparent
.void
onPreAdd(IoFilterChain parent, String name, IoFilter.NextFilter nextFilter)
Invoked before this filter is added to the specifiedparent
.void
onPreRemove(IoFilterChain parent, String name, IoFilter.NextFilter nextFilter)
Invoked before this filter is removed from the specifiedparent
.void
sessionClosed(IoFilter.NextFilter nextFilter, IoSession session)
FiltersIoHandler.sessionClosed(IoSession)
event.void
sessionCreated(IoFilter.NextFilter nextFilter, IoSession session)
FiltersIoHandler.sessionCreated(IoSession)
event.void
sessionIdle(IoFilter.NextFilter nextFilter, IoSession session, IdleStatus status)
FiltersIoHandler.sessionIdle(IoSession,IdleStatus)
event.void
sessionOpened(IoFilter.NextFilter nextFilter, IoSession session)
FiltersIoHandler.sessionOpened(IoSession)
event.String
toString()
-
-
-
Method Detail
-
init
public void init() throws Exception
Invoked byReferenceCountingFilter
when this filter is added to aIoFilterChain
at the first time, so you can initialize shared resources. Please note that this method is never called if you don't wrap a filter withReferenceCountingFilter
.
-
destroy
public void destroy() throws Exception
Invoked byReferenceCountingFilter
when this filter is not used by anyIoFilterChain
anymore, so you can destroy shared resources. Please note that this method is never called if you don't wrap a filter withReferenceCountingFilter
.
-
onPreAdd
public void onPreAdd(IoFilterChain parent, String name, IoFilter.NextFilter nextFilter) throws Exception
Invoked before this filter is added to the specifiedparent
. Please note that this method can be invoked more than once if this filter is added to more than one parents. This method is not invoked beforeIoFilter.init()
is invoked.- Specified by:
onPreAdd
in interfaceIoFilter
- Parameters:
parent
- the parent who called this methodname
- the name assigned to this filternextFilter
- theIoFilter.NextFilter
for this filter. You can reuse this object until this filter is removed from the chain.- Throws:
Exception
- If an error occurred while processing the event
-
onPostAdd
public void onPostAdd(IoFilterChain parent, String name, IoFilter.NextFilter nextFilter) throws Exception
Invoked after this filter is added to the specifiedparent
. Please note that this method can be invoked more than once if this filter is added to more than one parents. This method is not invoked beforeIoFilter.init()
is invoked.- Specified by:
onPostAdd
in interfaceIoFilter
- Parameters:
parent
- the parent who called this methodname
- the name assigned to this filternextFilter
- theIoFilter.NextFilter
for this filter. You can reuse this object until this filter is removed from the chain.- Throws:
Exception
- If an error occurred while processing the event
-
onPreRemove
public void onPreRemove(IoFilterChain parent, String name, IoFilter.NextFilter nextFilter) throws Exception
Invoked before this filter is removed from the specifiedparent
. Please note that this method can be invoked more than once if this filter is removed from more than one parents. This method is always invoked beforeIoFilter.destroy()
is invoked.- Specified by:
onPreRemove
in interfaceIoFilter
- Parameters:
parent
- the parent who called this methodname
- the name assigned to this filternextFilter
- theIoFilter.NextFilter
for this filter. You can reuse this object until this filter is removed from the chain.- Throws:
Exception
- If an error occurred while processing the event
-
onPostRemove
public void onPostRemove(IoFilterChain parent, String name, IoFilter.NextFilter nextFilter) throws Exception
Invoked after this filter is removed from the specifiedparent
. Please note that this method can be invoked more than once if this filter is removed from more than one parents. This method is always invoked beforeIoFilter.destroy()
is invoked.- Specified by:
onPostRemove
in interfaceIoFilter
- Parameters:
parent
- the parent who called this methodname
- the name assigned to this filternextFilter
- theIoFilter.NextFilter
for this filter. You can reuse this object until this filter is removed from the chain.- Throws:
Exception
- If an error occurred while processing the event
-
sessionCreated
public void sessionCreated(IoFilter.NextFilter nextFilter, IoSession session) throws Exception
FiltersIoHandler.sessionCreated(IoSession)
event.- Specified by:
sessionCreated
in interfaceIoFilter
- Parameters:
nextFilter
- theIoFilter.NextFilter
for this filter. You can reuse this object until this filter is removed from the chain.session
- TheIoSession
which has received this event- Throws:
Exception
- If an error occurred while processing the event
-
sessionOpened
public void sessionOpened(IoFilter.NextFilter nextFilter, IoSession session) throws Exception
FiltersIoHandler.sessionOpened(IoSession)
event.- Specified by:
sessionOpened
in interfaceIoFilter
- Parameters:
nextFilter
- theIoFilter.NextFilter
for this filter. You can reuse this object until this filter is removed from the chain.session
- TheIoSession
which has received this event- Throws:
Exception
- If an error occurred while processing the event
-
sessionClosed
public void sessionClosed(IoFilter.NextFilter nextFilter, IoSession session) throws Exception
FiltersIoHandler.sessionClosed(IoSession)
event.- Specified by:
sessionClosed
in interfaceIoFilter
- Parameters:
nextFilter
- theIoFilter.NextFilter
for this filter. You can reuse this object until this filter is removed from the chain.session
- TheIoSession
which has received this event- Throws:
Exception
- If an error occurred while processing the event
-
sessionIdle
public void sessionIdle(IoFilter.NextFilter nextFilter, IoSession session, IdleStatus status) throws Exception
FiltersIoHandler.sessionIdle(IoSession,IdleStatus)
event.- Specified by:
sessionIdle
in interfaceIoFilter
- Parameters:
nextFilter
- theIoFilter.NextFilter
for this filter. You can reuse this object until this filter is removed from the chain.session
- TheIoSession
which has received this eventstatus
- TheIdleStatus
type- Throws:
Exception
- If an error occurred while processing the event
-
exceptionCaught
public void exceptionCaught(IoFilter.NextFilter nextFilter, IoSession session, Throwable cause) throws Exception
FiltersIoHandler.exceptionCaught(IoSession,Throwable)
event.- Specified by:
exceptionCaught
in interfaceIoFilter
- Parameters:
nextFilter
- theIoFilter.NextFilter
for this filter. You can reuse this object until this filter is removed from the chain.session
- TheIoSession
which has received this eventcause
- The exception that cause this event to be received- Throws:
Exception
- If an error occurred while processing the event
-
messageReceived
public void messageReceived(IoFilter.NextFilter nextFilter, IoSession session, Object message) throws Exception
FiltersIoHandler.messageReceived(IoSession,Object)
event.- Specified by:
messageReceived
in interfaceIoFilter
- Parameters:
nextFilter
- theIoFilter.NextFilter
for this filter. You can reuse this object until this filter is removed from the chain.session
- TheIoSession
which has received this eventmessage
- The received message- Throws:
Exception
- If an error occurred while processing the event
-
messageSent
public void messageSent(IoFilter.NextFilter nextFilter, IoSession session, WriteRequest writeRequest) throws Exception
FiltersIoHandler.messageSent(IoSession,Object)
event.- Specified by:
messageSent
in interfaceIoFilter
- Parameters:
nextFilter
- theIoFilter.NextFilter
for this filter. You can reuse this object until this filter is removed from the chain.session
- TheIoSession
which has received this eventwriteRequest
- TheWriteRequest
that contains the sent message- Throws:
Exception
- If an error occurred while processing the event
-
filterWrite
public void filterWrite(IoFilter.NextFilter nextFilter, IoSession session, WriteRequest writeRequest) throws Exception
FiltersIoSession.write(Object)
method invocation.- Specified by:
filterWrite
in interfaceIoFilter
- Parameters:
nextFilter
- theIoFilter.NextFilter
for this filter. You can reuse this object until this filter is removed from the chain.session
- TheIoSession
which has to process this invocationwriteRequest
- TheWriteRequest
to process- Throws:
Exception
- If an error occurred while processing the event
-
filterClose
public void filterClose(IoFilter.NextFilter nextFilter, IoSession session) throws Exception
FiltersIoSession.closeNow()
or aIoSession.closeOnFlush()
method invocations.- Specified by:
filterClose
in interfaceIoFilter
- Parameters:
nextFilter
- theIoFilter.NextFilter
for this filter. You can reuse this object until this filter is removed from the chain.session
- TheIoSession
which has to process this method invocation- Throws:
Exception
- If an error occurred while processing the event
-
inputClosed
public void inputClosed(IoFilter.NextFilter nextFilter, IoSession session) throws Exception
FiltersIoHandler.inputClosed(IoSession)
event.- Specified by:
inputClosed
in interfaceIoFilter
- Parameters:
nextFilter
- theIoFilter.NextFilter
for this filter. You can reuse this object until this filter is removed from the chain.session
- TheIoSession
which has received this event- Throws:
Exception
- If an error occurred while processing the event
-
event
public void event(IoFilter.NextFilter nextFilter, IoSession session, FilterEvent event) throws Exception
Propagate an event up to theIoHandler
- Specified by:
event
in interfaceIoFilter
- Parameters:
nextFilter
- theIoFilter.NextFilter
for this filter. You can reuse this object until this filter is removed from the chain.session
- TheIoSession
which has to process this invocationevent
- The event to propagate- Throws:
Exception
- If an error occurred while processing the event
-
-