[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]
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]