directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <>
Subject [Directory Wiki] Update of "MinaTutorial" by TrustinLee
Date Sun, 08 May 2005 09:58:30 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Directory Wiki" for change notification.

The following page has been changed by TrustinLee:

The comment on the change is:
Added images

  MINA consists of two layers; I/O layer and protocol layer.  We first implement an echo server
using only I/O layer because protocol layer is usually built on top of I/O layer.
- TODO: I/O Layer diagram here
+ attachment:Arch1.gif
  The above diagram shows interaction between clients and the MINA I/O layer.  IoAcceptor
performs all low-level I/O, translates them into abstract I/O events, and forwards the translated
events with the associated IoSession to IoHandler.
  === IoSession ===
- TODO: IoSession class diagram here
+ attachment:IoSession.gif
  An IoSession represents an I/O connection between a remote peer and your application.  With
IoSession, you can write messages to the remote peer, access session configurations, and store
custom attributes associated with the session.
  === IoHandler ===
- TODO: IoHandler class diagram here
+ attachment:IoHandler.gif
    * sessionCreated: Invoked when a new I/O connection is established.  This method is invoked
before any I/O operation is executed so that any socket parameters or session attributes can
be set first.
    * sessionOpened: Invoked after sessionCreated is invoked.
@@ -132, +132 @@

    * Data transformation (e.g. SSL support)
    * Firewall, ...
- TODO: I/O Layer diagram with filters here
+ attachment:Arch2.gif
  Our echo protocol handler doesn’t log any I/O events.  We could log them by adding a filter
that logs them.  MINA, fortunately, provides IoLoggingFilter that provides that functionality.
 Let’s add a logging filter to ServiceRegistry.
@@ -166, +166 @@

  We learned how to use I/O layer via simplistic echo server example.  But have you ever imagined
how you would implement complex protocols like LDAP?  It must be a nightmare because the I/O
layer doesn’t help you separate message codec and actual business logic such as accessing
a directory database.  MINA provides a Protocol layer to resolve this issue.  The Protocol
layer transforms ByteBuffer events to POJO events which are at a higher-level:
- TODO: Protocol Layer diagram here
+ attachment:Arch3.gif
  You have to implement 5 interfaces: ProtocolHandler, ProtocolProvider, ProtocolCodecFactory,
ProtocolEncoder, and ProtocolDecoder:
- TODO: Class diagram here
+ attachment:ProtocolClasses.gif
  Maybe it looks like overkill, but please note that ProtocolCodecFactory, ProtocolEncoder,
and ProtocolDecoder are fully reusable; Apache ASN1 project provides ASN.1 codec for MINA,
and more common codecs like XML, Java object serialization, and simple text will be provided
in the next release of MINA.  Once you implemente a flexible codec, you can reuse it in future
applications.  Even if you don’t plan to reuse your codec, of course, MINA provides a quite
easy way to implement complex protocols. (Please refer to Advanced Topics)
@@ -178, +178 @@

  === ProtocolSession ===
- TODO: Class diagram here
+ attachment:ProtocolSession.gif
  ProtocolSession is a counterpart of the I/O layer IoSession.  As you must have noticed from
FIGURE X, you write messages as POJO's instead of ByteBuffer's.  ProtocolEncoder encodes message
objects to ByteBuffers so that the I/O layer can write them to underlying sockets.
  === ProtocolHandler ===
- TODO: Class diagram here
+ attachment:ProtocolHandler.gif
  ProtocolHandler is a counterpart of the I/O layer IoHandler.  dataRead and dataWritten methods
are replaced with messageReceived and messageSent.  This is because ProtocolDecoder decodes
ByteBuffers received from I/O layer into message objects.
  === ProtocolEncoder and ProtocolDecoder ===
- TODO: Class diagram here
+ attachment:ProtocolCodec.gif
  ProtocolEncoder and ProtocolDecoder have just one method each.  ProtocolEncoder encodes
message objects into a ByteBuffer, and ProtocolDecoder decodes ByteBuffers into message objects.
 We’ll learn how to implement these interfaces below.
@@ -284, +284 @@

  ProtocolFilter is the counterpart of IoFilter from I/O layer:
- TODO: Protocol Layer Diagram with filters here
+ attachment:Arch4.gif
  Adding IoLoggingFilter logs low-level I/O events which are appropriate for debugging purposes.
 We could use ProtocolLoggingFilter instead to log higher-level events:

View raw message