public interface IoFilter
IoHandler events like Servlet
filters. Filters can be used for these purposes:
Please NEVER implement your filters to wrap
IoSessions. Users can cache the reference to the
session, which might malfunction if any filters are added or removed later.
IoFilters are activated only when they are inside IoFilterChain.
When you add an IoFilter to an IoFilterChain:
init() is invoked by ReferenceCountingFilter if
the filter is added at the first time.onPreAdd(IoFilterChain, String, NextFilter) is invoked to notify
that the filter will be added to the chain.onPostAdd(IoFilterChain, String, NextFilter) is invoked to notify
that the filter is added to the chain.onPostAdd(IoFilterChain, String, org.apache.mina.core.filterchain.IoFilter.NextFilter)
threw an exception. destroy() is also invoked by
ReferenceCountingFilter if the filter is the last filter which
was added to IoFilterChains.
When you remove an IoFilter from an IoFilterChain:
onPreRemove(IoFilterChain, String, NextFilter) is invoked to
notify that the filter will be removed from the chain.onPostRemove(IoFilterChain, String, NextFilter) is invoked to
notify that the filter is removed from the chain.destroy() is invoked by ReferenceCountingFilter if
the removed filter was the last one.IoFilterAdapter| Modifier and Type | Interface and Description |
|---|---|
static interface |
IoFilter.NextFilter
Represents the next
IoFilter in IoFilterChain. |
| Modifier and Type | Method and Description |
|---|---|
void |
destroy()
Invoked by
ReferenceCountingFilter when this filter
is not used by any IoFilterChain anymore, so you can destroy
shared resources. |
void |
event(IoFilter.NextFilter nextFilter,
IoSession session,
FilterEvent event)
Propagate an event up to the
IoHandler |
void |
exceptionCaught(IoFilter.NextFilter nextFilter,
IoSession session,
Throwable cause)
Filters
IoHandler.exceptionCaught(IoSession,Throwable) event. |
void |
filterClose(IoFilter.NextFilter nextFilter,
IoSession session)
Filters
IoSession.closeNow() or a IoSession.closeOnFlush() method invocations. |
void |
filterWrite(IoFilter.NextFilter nextFilter,
IoSession session,
WriteRequest writeRequest)
Filters
IoSession.write(Object) method invocation. |
void |
init()
Invoked by
ReferenceCountingFilter when this filter
is added to a IoFilterChain at the first time, so you can
initialize shared resources. |
void |
inputClosed(IoFilter.NextFilter nextFilter,
IoSession session)
Filters
IoHandler.inputClosed(IoSession) event. |
void |
messageReceived(IoFilter.NextFilter nextFilter,
IoSession session,
Object message)
Filters
IoHandler.messageReceived(IoSession,Object) event. |
void |
messageSent(IoFilter.NextFilter nextFilter,
IoSession session,
WriteRequest writeRequest)
Filters
IoHandler.messageSent(IoSession,Object) event. |
void |
onPostAdd(IoFilterChain parent,
String name,
IoFilter.NextFilter nextFilter)
Invoked after this filter is added to the specified
parent. |
void |
onPostRemove(IoFilterChain parent,
String name,
IoFilter.NextFilter nextFilter)
Invoked after this filter is removed from the specified
parent. |
void |
onPreAdd(IoFilterChain parent,
String name,
IoFilter.NextFilter nextFilter)
Invoked before this filter is added to the specified
parent. |
void |
onPreRemove(IoFilterChain parent,
String name,
IoFilter.NextFilter nextFilter)
Invoked before this filter is removed from the specified
parent. |
void |
sessionClosed(IoFilter.NextFilter nextFilter,
IoSession session)
Filters
IoHandler.sessionClosed(IoSession) event. |
void |
sessionCreated(IoFilter.NextFilter nextFilter,
IoSession session)
Filters
IoHandler.sessionCreated(IoSession) event. |
void |
sessionIdle(IoFilter.NextFilter nextFilter,
IoSession session,
IdleStatus status)
Filters
IoHandler.sessionIdle(IoSession,IdleStatus) event. |
void |
sessionOpened(IoFilter.NextFilter nextFilter,
IoSession session)
Filters
IoHandler.sessionOpened(IoSession) event. |
void init() throws Exception
ReferenceCountingFilter when this filter
is added to a IoFilterChain 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 with ReferenceCountingFilter.Exception - If an error occurred while processing the eventvoid destroy()
throws Exception
ReferenceCountingFilter when this filter
is not used by any IoFilterChain anymore, so you can destroy
shared resources. Please note that this method is never called if
you don't wrap a filter with ReferenceCountingFilter.Exception - If an error occurred while processing the eventvoid onPreAdd(IoFilterChain parent, String name, IoFilter.NextFilter nextFilter) throws Exception
parent.
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 before init() is invoked.parent - the parent who called this methodname - the name assigned to this filternextFilter - the IoFilter.NextFilter for this filter. You can reuse
this object until this filter is removed from the chain.Exception - If an error occurred while processing the eventvoid onPostAdd(IoFilterChain parent, String name, IoFilter.NextFilter nextFilter) throws Exception
parent.
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 before init() is invoked.parent - the parent who called this methodname - the name assigned to this filternextFilter - the IoFilter.NextFilter for this filter. You can reuse
this object until this filter is removed from the chain.Exception - If an error occurred while processing the eventvoid onPreRemove(IoFilterChain parent, String name, IoFilter.NextFilter nextFilter) throws Exception
parent.
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 before destroy() is invoked.parent - the parent who called this methodname - the name assigned to this filternextFilter - the IoFilter.NextFilter for this filter. You can reuse
this object until this filter is removed from the chain.Exception - If an error occurred while processing the eventvoid onPostRemove(IoFilterChain parent, String name, IoFilter.NextFilter nextFilter) throws Exception
parent.
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 before destroy() is invoked.parent - the parent who called this methodname - the name assigned to this filternextFilter - the IoFilter.NextFilter for this filter. You can reuse
this object until this filter is removed from the chain.Exception - If an error occurred while processing the eventvoid sessionCreated(IoFilter.NextFilter nextFilter, IoSession session) throws Exception
IoHandler.sessionCreated(IoSession) event.nextFilter - the IoFilter.NextFilter for this filter. You can reuse this
object until this filter is removed from the chain.session - The IoSession which has received this eventException - If an error occurred while processing the eventvoid sessionOpened(IoFilter.NextFilter nextFilter, IoSession session) throws Exception
IoHandler.sessionOpened(IoSession) event.nextFilter - the IoFilter.NextFilter for this filter. You can reuse this
object until this filter is removed from the chain.session - The IoSession which has received this eventException - If an error occurred while processing the eventvoid sessionClosed(IoFilter.NextFilter nextFilter, IoSession session) throws Exception
IoHandler.sessionClosed(IoSession) event.nextFilter - the IoFilter.NextFilter for this filter. You can reuse this
object until this filter is removed from the chain.session - The IoSession which has received this eventException - If an error occurred while processing the eventvoid sessionIdle(IoFilter.NextFilter nextFilter, IoSession session, IdleStatus status) throws Exception
IoHandler.sessionIdle(IoSession,IdleStatus) event.nextFilter - the IoFilter.NextFilter for this filter. You can reuse this
object until this filter is removed from the chain.session - The IoSession which has received this eventstatus - The IdleStatus typeException - If an error occurred while processing the eventvoid exceptionCaught(IoFilter.NextFilter nextFilter, IoSession session, Throwable cause) throws Exception
IoHandler.exceptionCaught(IoSession,Throwable) event.nextFilter - the IoFilter.NextFilter for this filter. You can reuse this
object until this filter is removed from the chain.session - The IoSession which has received this eventcause - The exception that cause this event to be receivedException - If an error occurred while processing the eventvoid inputClosed(IoFilter.NextFilter nextFilter, IoSession session) throws Exception
IoHandler.inputClosed(IoSession) event.nextFilter - the IoFilter.NextFilter for this filter. You can reuse this
object until this filter is removed from the chain.session - The IoSession which has received this eventException - If an error occurred while processing the eventvoid messageReceived(IoFilter.NextFilter nextFilter, IoSession session, Object message) throws Exception
IoHandler.messageReceived(IoSession,Object) event.nextFilter - the IoFilter.NextFilter for this filter. You can reuse this
object until this filter is removed from the chain.session - The IoSession which has received this eventmessage - The received messageException - If an error occurred while processing the eventvoid messageSent(IoFilter.NextFilter nextFilter, IoSession session, WriteRequest writeRequest) throws Exception
IoHandler.messageSent(IoSession,Object) event.nextFilter - the IoFilter.NextFilter for this filter. You can reuse this
object until this filter is removed from the chain.session - The IoSession which has received this eventwriteRequest - The WriteRequest that contains the sent messageException - If an error occurred while processing the eventvoid filterClose(IoFilter.NextFilter nextFilter, IoSession session) throws Exception
IoSession.closeNow() or a IoSession.closeOnFlush() method invocations.nextFilter - the IoFilter.NextFilter for this filter. You can reuse this
object until this filter is removed from the chain.session - The IoSession which has to process this method
invocationException - If an error occurred while processing the eventvoid filterWrite(IoFilter.NextFilter nextFilter, IoSession session, WriteRequest writeRequest) throws Exception
IoSession.write(Object) method invocation.nextFilter - the IoFilter.NextFilter for this filter. You can reuse this
object until this filter is removed from the chain.session - The IoSession which has to process this invocationwriteRequest - The WriteRequest to processException - If an error occurred while processing the eventvoid event(IoFilter.NextFilter nextFilter, IoSession session, FilterEvent event) throws Exception
IoHandlernextFilter - the IoFilter.NextFilter for this filter. You can reuse this
object until this filter is removed from the chain.session - The IoSession which has to process this invocationevent - The event to propagateException - If an error occurred while processing the eventCopyright © 2004–2024 Apache MINA Project. All rights reserved.