IoService
--- Base interface for all IoAcceptors and IoConnectors that provide I/O service and manage IoSessions.
IoAcceptors和IoConnectors的基础接口,提供I/O服务和IoSession管理功能。
IoAcceptor extends IoService
--- Accepts incoming connection,communicates with clients,and fires events to IoHandlers
接收连接请求,与客户端交互并且触发事件到IoHandler
You should bind to the desired socket address to accept in coming connections, and when events for
incoming connections will be sent to the specified default IoHandler.
Threads accept incoming connections start automatically when bind() is invoked ,and stop when unbind()
is invoked.
IoConnector extends IoService
--- Connects to endpoint,communicates with whe server,and fires events to IoHandlers.
You should connect to the desired socket address to start communication,and then events for incoming
connections will be sent to the specified default IoHandler.
Threads connect to endpoint start automatically when connect(SocketAddress) is invoked,and stop when
all connection attempts are finished.
IoHandler
--- Handles all I/O events fired by MINA.
IoSession
--- A handle which represents connection between two end-points regardless of transport types.
IoSession provides user-defined attributes.User-defined attributes are application-specific data
which are associated with a session.It often contains objects that represents the state of a higher-level
protocol and becomes a way to exchange data between filters and handlers.
Adjusting Transport Type Specific Properties
You can simply downcast the session to an appropriate subclass.
Thread Safety
IoSession is thread-safe. But please note that performing more than one write(Object) calls at the
same time will cause the IoFilter#filterWrite(IoFilter.NextFilter,IoSession,WriteRequest) to be
executed simultaneously, and therefore you have to make sure the IoFilter implementations you're useing
are thread-safe, too.
Equality of Sessions
The getId() method is totally wrong.We can't base a method which is designed to create a unique ID
on the hashCode method. equals(Object) and hashCode() shall not be overriden to the default behavior
that is defined in Object.
IoFilter
--- A filter which intercepts IoHandler events like Servlet filters. Filters can be used for these
purposes:Event loging,Performance measurement,Authorization,Overload control,Message transformation
(e.g. encryption and decryption,...), and any more.
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.
The Life Cycle
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 ad the first time.
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.
onPostAdd(IoFilterChain, String, NextFilter) is invoked to notify that the filter is added to the
chain.
The filter is removed from the chain if 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 removed an IoFilter from an IoFilterChain:
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.
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.
IoFilterChain
--- A container of IoFilters that forwards IoHandler events to the consisting filters and terminal
IoHandler sequentially.
Every IoSession has its own IoFilterChain (1-to-1 relationship).
相关推荐
基于spring mina 封装 rest 形式接口服务器,摆脱对tomcat,resin等服务器的依赖,基于spring,mina本身可提供tcp/ip接口,同时封装rest可方面提供http形式rest接口访问服务,方便接入
mina2学习笔记
mina2技术知识非常实用的 不用自己写多线程的东西的
mina2源码
此demo利用springmvc整合mina,实现客户端主动发送消息到服务端,并且以http接口的方式实现,亲测可用。
mina2核心框架5000个并发
不错的MINA2源码呵,带有MINA2的原实例
Apache Mina 2 官方教程翻译
mina2+spring结合实例
Apache Mina 2 完全自学手册
Apache MINA2实用手册 Apache MINA2实用手册
Mina2源码分析,学习mina不可多得的文档资料
关于apache mina2 的学习资料 包括状态机
MINA-2.0.0-M4.chm(英文)中文的实在是没有)+Mina2.0学习笔记(修订版).doc+Apache_Mina_Server_2.0中文参考手册V1.0.pdf+MINA框架新人指南.pdf
mina2推送demo客户端资源,测试过可以使用,正式可靠,比较试用学习
Mina2的中文用户手册,仅供互相学习参考,如有侵权立删
mina2依赖jar包: commons-logging-1.2 log4j-1.2.17 mina-core-2.0.9 slf4j-api-1.7.7 slf4j-log4j12-1.7.21
Mina文件上传的例子 mina mina2 file 文件上传
本源码是《NIO框架入门(二):服务端基于MINA2的UDP双向通信Demo演示》一文的MINA2服务端源码实现,详见:http://www.52im.net/thread-373-1-1.html
SSI+Mina2(Struts2+Spring4+Mybatis3+Mina2)集成,都是最新的包, 发布就可运行,配置文件都写了详细的注释。