apache mina: IoSession结构剖析
来源:互联网 发布:养生软件下载 编辑:程序博客网 时间:2024/06/04 13:13
NioSocketSession.<init>(IoService, IoProcessor<NioSession>, SocketChannel)
NioSocketAcceptor.accept(IoProcessor<NioSession>, ServerSocketChannel)
NioSocketAcceptor.accept(IoProcessor, Object)
AbstractPollingIoAcceptor$Acceptor.processHandles(Iterator<H>)
AbstractPollingIoAcceptor$Acceptor.run()
public abstract class NioSession extends AbstractIoSession {
/** An id generator guaranteed to generate unique IDs for the session */
private static AtomicLong idGenerator = new AtomicLong(0);
/** The FilterChain created for this session */
private final IoFilterChain filterChain;
/**
*
* Creates a new instance of NioSession, with its associated IoProcessor.
* <br>
* This method is only called by the inherited class.
*
* @param processor The associated IoProcessor
*/
protected NioSession(IoProcessor<NioSession> processor, IoService service, Channel channel) {
super(service);
this.channel = channel;
this.processor = processor;
filterChain = new DefaultIoFilterChain(this);
// Set a new ID for this session
sessionId = idGenerator.incrementAndGet();
}
}
在创建IoSession时,每一个IoSession都有自己独立的DefaultIoFilterChain。
在IoSession中有2个重要的成员变量。DefaultIoSessionAttributeMap 是通过ConcurrentHashMap实现的。
DefaultWriteRequestQueue是通过ConcurrentLinkedQueue实现的。
Provides data structures to a newly created session.
public interface IoSessionDataStructureFactory
{
IoSessionAttributeMap getAttributeMap(IoSession session) throws Exception;
WriteRequestQueue getWriteRequestQueue(IoSession session) throws Exception;
}
public class DefaultIoSessionDataStructureFactory implements IoSessionDataStructureFactory {
public IoSessionAttributeMap getAttributeMap(IoSession session) throws Exception {
return new DefaultIoSessionAttributeMap();
}
public WriteRequestQueue getWriteRequestQueue(IoSession session) throws Exception {
return new DefaultWriteRequestQueue();
}
}
private static class DefaultIoSessionAttributeMap implements IoSessionAttributeMap {
private final ConcurrentHashMap<Object, Object> attributes = new ConcurrentHashMap<Object, Object>(4);
}
private static class DefaultWriteRequestQueue implements WriteRequestQueue {
/** A queue to store incoming write requests */
private final Queue<WriteRequest> q = new ConcurrentLinkedQueue<WriteRequest>();
}
- apache mina: IoSession结构剖析
- Apache Mina 源码再读2 IoSession创建过程源代码剖析
- Apache Mina 源码再读4 IoSession.write()源码剖析
- Apache Mina 源码再读5 IoSession.close() 源码剖析
- Mina学习之IoSession
- mina源码学习之IoSession
- (四)Mina源码解析之IoSession
- Mina IoSession所扮演的角色说明
- NIO流行框架 Mina IOSession接口
- mina框架中对iosession的封装
- mina长连接ConnectFutrueUntil(获取Iosession工具类)类
- mina学习笔记四:交互的核心IoSession
- mina学习笔记四:交互的核心IoSession
- mina学习笔记四:交互的核心IoSession
- Apache mina 源码再读3 I/O Service 源码剖析
- Apache Mina
- Apache Mina
- Apache Mina
- 配置ntpd提供网络授时服务
- MySQL移动数据库位置
- Android WebView开发需要注意的地方和优化
- Zabbix邮件报警设置方法
- Android访问网络,使用HttpURLConnection还是HttpClient
- apache mina: IoSession结构剖析
- shell逻辑判断式与表达式
- linux curl模拟登录网页
- Java File.separator 用法
- Cloudstack 安装记录
- 统计分析:偏度和峰度
- shell脚本超时控制
- shell中$0,$?,$!等的特殊用法
- Rsyslog+LogAnalyzer+MySQL部署日志服务器