what's MINA?

[b]what's MINA?[/b]

Apache [url=http://mina.apache.org/]MINA[/url] 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 is often called:

* NIO framework · library,
* client · server framework · library, or
* a networking · socket library.

the architecture of MINA based application
[img]http://dl.iteye.com/upload/attachment/437064/044b3527-d6cd-3235-a32d-bab1b1afaf71.png[/img]

a deeper dive into the details
[img]http://dl.iteye.com/upload/attachment/437066/736b0177-d3d1-3b41-8fc4-fea5cebbe476.png[/img]

Broadly, MINA based applications are divided into 3 layers
* I/O Service - Performs actual I/O
* I/O Filter Chain - Filters/Transforms bytes into desired Data Structures and vice-versa
* I/O Handler - Here resides the actual business logic

So, how to create a MINA based Application
1. Create I/O service - Choose from already available Services (*Acceptor) or create your own
2. Create Filter Chain - Choose from already existing Filters or create a custom Filter for transforming request/response
3. Create I/O Handler - Write business logic, on handling different messages


[b]Server Architecture[/b]

We have seen, MINA based Application Architecture in previous section. Lets focus on Server Architecture. A Server listens on a port for incoming requests, process them and send replies.
[img]http://dl.iteye.com/upload/attachment/437094/5a17c7de-4710-37b6-96cb-a236d60cc649.png[/img]

* IOAcceptor listens on the network for incoming connections/packets
* For a new connection, a new session is created and all subsequent request from IP Address/Port combination are handled in that Session
* All packets received for a Session, traverses the Filter Chain as specified in the diagram. Filters can be used to modify the content of packets (like converting to Objects, adding/removing information etc). For converting to/from raw bytes to High Level Objects, PacketEncoder/Decoder are particularly useful
* Finally the packet or converted object lands in IOHandler. IOHandlers can be used to full fill business needs.

[b]
Client Architecture[/b]

We had a brief look at MINA based Server Architecture, lets see how Client looks like. Clients need to connect to a Server, send message and process the responses.
[img]http://dl.iteye.com/upload/attachment/437120/902454ad-0741-3aba-a6fa-dedee70fb853.png[/img]

* Client first creates an IOConnector (MINA Construct for connecting to Socket), initiates a bind with Server
* Upon Connection creation, a Session is created and is associated with Connection
* Application/Client writes to the Session, resulting in data being sent to Server, after traversing the Filter Chain
* All the responses/messages received from Server are traverses the Filter Chain and lands at IOHandler, for processing

[url=http://mina.apache.org/user-guide.html]link to user-guide[/url]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值