public interface IoFilter
IoHandler
events like Servlet
filters. Filters can be used for these purposes:
Please NEVER implement your filters to wrap
IoSession
s. Users can cache the reference to the
session, which might malfunction if any filters are added or removed later.
IoFilter
s are activated only when they are inside IoFilterChain
.
When you add an IoFilter
to an IoFilterChain
:
init()
is invoked by ReferenceCountingIoFilter
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.common.IoFilter.NextFilter)
threw an exception. destroy()
is also invoked by
ReferenceCountingIoFilter
if the filter is the last filter which
was added to IoFilterChain
s.
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 ReferenceCountingIoFilter
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 . |
static class |
IoFilter.WriteRequest
Represents write request fired by
IoSession.write(Object) . |
Modifier and Type | Method and Description |
---|---|
void |
destroy()
Invoked by
ReferenceCountingIoFilter when this filter
is not used by any IoFilterChain anymore, so you can destroy
shared resources. |
void |
exceptionCaught(IoFilter.NextFilter nextFilter,
IoSession session,
java.lang.Throwable cause)
Filters
IoHandler.exceptionCaught(IoSession,Throwable)
event. |
void |
filterClose(IoFilter.NextFilter nextFilter,
IoSession session)
Filters
IoSession.close() method invocation. |
void |
filterWrite(IoFilter.NextFilter nextFilter,
IoSession session,
IoFilter.WriteRequest writeRequest)
Filters
IoSession.write(Object) method invocation. |
void |
init()
Invoked by
ReferenceCountingIoFilter when this filter
is added to a IoFilterChain at the first time, so you can
initialize shared resources. |
void |
messageReceived(IoFilter.NextFilter nextFilter,
IoSession session,
java.lang.Object message)
Filters
IoHandler.messageReceived(IoSession,Object)
event. |
void |
messageSent(IoFilter.NextFilter nextFilter,
IoSession session,
java.lang.Object message)
Filters
IoHandler.messageSent(IoSession,Object)
event. |
void |
onPostAdd(IoFilterChain parent,
java.lang.String name,
IoFilter.NextFilter nextFilter)
Invoked after this filter is added to the specified parent.
|
void |
onPostRemove(IoFilterChain parent,
java.lang.String name,
IoFilter.NextFilter nextFilter)
Invoked after this filter is removed from the specified parent.
|
void |
onPreAdd(IoFilterChain parent,
java.lang.String name,
IoFilter.NextFilter nextFilter)
Invoked before this filter is added to the specified parent.
|
void |
onPreRemove(IoFilterChain parent,
java.lang.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 java.lang.Exception
ReferenceCountingIoFilter
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 ReferenceCountingIoFilter
.java.lang.Exception
void destroy() throws java.lang.Exception
ReferenceCountingIoFilter
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 ReferenceCountingIoFilter
.java.lang.Exception
void onPreAdd(IoFilterChain parent, java.lang.String name, IoFilter.NextFilter nextFilter) throws java.lang.Exception
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.java.lang.Exception
void onPostAdd(IoFilterChain parent, java.lang.String name, IoFilter.NextFilter nextFilter) throws java.lang.Exception
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.java.lang.Exception
void onPreRemove(IoFilterChain parent, java.lang.String name, IoFilter.NextFilter nextFilter) throws java.lang.Exception
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.java.lang.Exception
void onPostRemove(IoFilterChain parent, java.lang.String name, IoFilter.NextFilter nextFilter) throws java.lang.Exception
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.java.lang.Exception
void sessionCreated(IoFilter.NextFilter nextFilter, IoSession session) throws java.lang.Exception
IoHandler.sessionCreated(IoSession)
event.java.lang.Exception
void sessionOpened(IoFilter.NextFilter nextFilter, IoSession session) throws java.lang.Exception
IoHandler.sessionOpened(IoSession)
event.java.lang.Exception
void sessionClosed(IoFilter.NextFilter nextFilter, IoSession session) throws java.lang.Exception
IoHandler.sessionClosed(IoSession)
event.java.lang.Exception
void sessionIdle(IoFilter.NextFilter nextFilter, IoSession session, IdleStatus status) throws java.lang.Exception
IoHandler.sessionIdle(IoSession,IdleStatus)
event.java.lang.Exception
void exceptionCaught(IoFilter.NextFilter nextFilter, IoSession session, java.lang.Throwable cause) throws java.lang.Exception
IoHandler.exceptionCaught(IoSession,Throwable)
event.java.lang.Exception
void messageReceived(IoFilter.NextFilter nextFilter, IoSession session, java.lang.Object message) throws java.lang.Exception
IoHandler.messageReceived(IoSession,Object)
event.java.lang.Exception
void messageSent(IoFilter.NextFilter nextFilter, IoSession session, java.lang.Object message) throws java.lang.Exception
IoHandler.messageSent(IoSession,Object)
event.java.lang.Exception
void filterClose(IoFilter.NextFilter nextFilter, IoSession session) throws java.lang.Exception
IoSession.close()
method invocation.java.lang.Exception
void filterWrite(IoFilter.NextFilter nextFilter, IoSession session, IoFilter.WriteRequest writeRequest) throws java.lang.Exception
IoSession.write(Object)
method invocation.java.lang.Exception
Copyright © 2004-2019 Apache MINA Project. All Rights Reserved.