| org.apache.mina.common.IoFilter
All known Subclasses: org.apache.mina.common.IoFilterAdapter, org.apache.mina.filter.util.ReferenceCountingFilter,
IoFilter | public interface IoFilter (Code) | | A filter which intercepts
IoHandler events like Servlet
filters. Filters can be used for these purposes:
- Event logging,
- Performance measurement,
- Authorization,
- Overload control,
- Message transformation (e.g. encryption and decryption, ...),
- and many more.
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.
The Life Cycle
IoFilter s are activated only when they are inside
IoFilterChain .
When you add an
IoFilter to an
IoFilterChain :
-
IoFilter.init() is invoked by
ReferenceCountingFilter if
the filter is added at the first time.
-
IoFilter.onPreAdd(IoFilterChain,String,NextFilter) is invoked to notify
that the filter will be added to the chain.
- The filter is added to the chain, and all events and I/O requests
pass through the filter from now.
-
IoFilter.onPostAdd(IoFilterChain,String,NextFilter) is invoked to notify
that the filter is added to the chain.
- The filter is removed from the chain if
IoFilter.onPostAdd(IoFilterChain,String,org.apache.mina.common.IoFilter.NextFilter) threw an exception.
IoFilter.destroy() is also invoked by
ReferenceCountingFilter if the filter is the last filter which
was added to
IoFilterChain s.
When you remove an
IoFilter from an
IoFilterChain :
-
IoFilter.onPreRemove(IoFilterChain,String,NextFilter) is invoked to
notify that the filter will be removed from the chain.
- The filter is removed from the chain, and any events and I/O requests
don't pass through the filter from now.
-
IoFilter.onPostRemove(IoFilterChain,String,NextFilter) is invoked to
notify that the filter is removed from the chain.
-
IoFilter.destroy() is invoked by
ReferenceCountingFilter if
the removed filter was the last one.
author: The Apache MINA Project (dev@mina.apache.org) version: $Rev: 591770 $, $Date: 2007-11-04 05:22:44 -0700 (Sun, 04 Nov 2007) $ See Also: IoFilterAdapter |
Inner Class :public interface NextFilter | |
Method Summary | |
void | destroy() Invoked by
ReferenceCountingFilter when this filter
is not used by any
IoFilterChain anymore, so you can destroy
shared resources. | void | exceptionCaught(NextFilter nextFilter, IoSession session, Throwable cause) Filters
IoHandler.exceptionCaught(IoSessionThrowable) event. | void | filterClose(NextFilter nextFilter, IoSession session) Filters
IoSession.close method invocation. | void | filterSetTrafficMask(NextFilter nextFilter, IoSession session, TrafficMask trafficMask) Filters
IoSession.setTrafficMask(TrafficMask) method invocation. | void | filterWrite(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 | messageReceived(NextFilter nextFilter, IoSession session, Object message) Filters
IoHandler.messageReceived(IoSessionObject) event. | void | messageSent(NextFilter nextFilter, IoSession session, WriteRequest writeRequest) Filters
IoHandler.messageSent(IoSessionObject) event. | void | onPostAdd(IoFilterChain parent, String name, NextFilter nextFilter) Invoked after this filter is added to the specified parent.
Please note that this method can be invoked more than once if
this filter is added to more than one parents. | void | onPostRemove(IoFilterChain parent, String name, NextFilter nextFilter) Invoked after this filter is removed from the specified 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
IoFilter.destroy() is invoked.
Parameters: parent - the parent who called this method Parameters: name - the name assigned to this filter Parameters: nextFilter - the NextFilter for this filter. | void | onPreAdd(IoFilterChain parent, String name, NextFilter nextFilter) Invoked before this filter is added to the specified parent.
Please note that this method can be invoked more than once if
this filter is added to more than one parents. | void | onPreRemove(IoFilterChain parent, String name, NextFilter nextFilter) Invoked before this filter is removed from the specified 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
IoFilter.destroy() is invoked.
Parameters: parent - the parent who called this method Parameters: name - the name assigned to this filter Parameters: nextFilter - the NextFilter for this filter. | void | sessionClosed(NextFilter nextFilter, IoSession session) Filters
IoHandler.sessionClosed(IoSession) event. | void | sessionCreated(NextFilter nextFilter, IoSession session) Filters
IoHandler.sessionCreated(IoSession) event. | void | sessionIdle(NextFilter nextFilter, IoSession session, IdleStatus status) Filters
IoHandler.sessionIdle(IoSessionIdleStatus) event. | void | sessionOpened(NextFilter nextFilter, IoSession session) Filters
IoHandler.sessionOpened(IoSession) event. |
onPostAdd | void onPostAdd(IoFilterChain parent, String name, NextFilter nextFilter) throws Exception(Code) | | Invoked after this filter is added to the specified 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
IoFilter.init() is invoked.
Parameters: parent - the parent who called this method Parameters: name - the name assigned to this filter Parameters: nextFilter - the NextFilter for this filter. You can reusethis object until this filter is removed from the chain. |
onPostRemove | void onPostRemove(IoFilterChain parent, String name, NextFilter nextFilter) throws Exception(Code) | | Invoked after this filter is removed from the specified 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
IoFilter.destroy() is invoked.
Parameters: parent - the parent who called this method Parameters: name - the name assigned to this filter Parameters: nextFilter - the NextFilter for this filter. You can reusethis object until this filter is removed from the chain. |
onPreAdd | void onPreAdd(IoFilterChain parent, String name, NextFilter nextFilter) throws Exception(Code) | | Invoked before this filter is added to the specified 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
IoFilter.init() is invoked.
Parameters: parent - the parent who called this method Parameters: name - the name assigned to this filter Parameters: nextFilter - the NextFilter for this filter. You can reusethis object until this filter is removed from the chain. |
onPreRemove | void onPreRemove(IoFilterChain parent, String name, NextFilter nextFilter) throws Exception(Code) | | Invoked before this filter is removed from the specified 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
IoFilter.destroy() is invoked.
Parameters: parent - the parent who called this method Parameters: name - the name assigned to this filter Parameters: nextFilter - the NextFilter for this filter. You can reusethis object until this filter is removed from the chain. |
|
|