标签:
1.mina 是什么?
apach mina 是一个网络应用框架,使开发者更容易开发出高性能可扩展的网络应用。它通过java NIO提供了一个抽象的基于事件驱动的异步API,在例如 TCP/IP ,UDP/IP 等各种传输协议之上.
Apache MINA is a network application framework which helps users develop high performance and high scalability network applications easily. It provides an abstract event-driven asynchronous API over various transports such as TCP/IP and UDP/IP via Java NIO.
Apache MINA 经常被称为 :
NIO framework library,
client server framework library, or
a networking socket library
Apache MINA 伴随着很多子项目 :
Asyncweb : An HTTP server build on top of MINA asynchronous framework
FtpServer : A FTP server
SSHd : A Java library supporting the SSH protocol
Vysper : An XMPP server
2.使用mina之前我们应该了解什么?
首先我们需要了解是MINA在NIO 1的基础上进行设计的(可能3.0版本会加入java 7,NIO-2 的特性吧)。那么第一个问题来了 NIO VS BIO
BIO(Blocking IO) : BIO 在调用者进行socket读写等操作时会阻塞调用者直到调用结束。
NIO : 采用非阻塞模式 使一个线程从某通道发送请求读取数据,但是它仅能得到目前可用的数据,如果目前没有数据可用时,就什么都不会获取。而不是保持线程阻塞,所以直至数据变的可以读取之前,该线程可 以继续做其他的事情。 非阻塞写也是如此。一个线程请求写入一些数据到某通道,但不需要等待它完全写入,这个线程同时可以去做别的事情。 线程通常将非阻塞IO的空闲时间用于在其它通道上执行IO操作,所以 一个单独的线程现在可以管理多个输入和输出通道(channel)。
Java NIO 由以下几个核心部分组成:
Channels
Buffers
Selectors
MINA 特性
MINA is a simple yet full-featured network application framework which provides:
Unified API for various transport types:
TCP/IP & UDP/IP via Java NIO
Serial communication (RS232) via RXTX
In-VM pipe communication
You can implement your own!
Filter interface as an extension point; similar to Servlet filters
Low-level and high-level API:
Low-level: uses ByteBuffers
High-level: uses user-defined message objects and codecs
Highly customizable thread model:
Single thread
One thread pool
More than one thread pools (i.e. SEDA)
Out-of-the-box SSL · TLS · StartTLS support using Java 5 SSLEngine
Overload shielding & traffic throttling
Unit testability using mock objects
JMX managability
Stream-based I/O support via StreamIoHandler
Integration with well known containers such as PicoContainer and Spring
Smooth migration from Netty, an ancestor of Apache MINA.
文章内容来源及参考 :
http://mina.apache.org/mina-project/userguide
http://blog.csdn.net/keda8997110/article/details/19549493
http://ifeve.com/overview/ Java NIO系列教程
http://docs.oracle.com/javase/6/docs/api/
标签:
原文地址:http://www.cnblogs.com/far-away/p/4353272.html