Modified: mina/site/trunk/content/mina/userguide/ch8-iobuffer/ch8-iobuffer.mdtext URL: http://svn.apache.org/viewvc/mina/site/trunk/content/mina/userguide/ch8-iobuffer/ch8-iobuffer.mdtext?rev=1404465&r1=1404464&r2=1404465&view=diff ============================================================================== --- mina/site/trunk/content/mina/userguide/ch8-iobuffer/ch8-iobuffer.mdtext (original) +++ mina/site/trunk/content/mina/userguide/ch8-iobuffer/ch8-iobuffer.mdtext Thu Nov 1 05:13:12 2012 @@ -45,6 +45,7 @@ This is a replacement for [ByteBuffer](h IoBuffer is an abstract class, hence can't be instantiated directly. To allocate IoBuffer, we need to use one of the two allocate() methods. + :::java // Allocates a new buffer with a specific size, defining its type (direct or heap) public static IoBuffer allocate(int capacity, boolean direct) @@ -60,6 +61,7 @@ The default buffer allocation is handled Alternatively, following form can also be used + :::java // Allocates heap buffer by default. IoBuffer.setUseDirectBuffer(false); // A new heap buffer is returned. @@ -73,6 +75,7 @@ Creating auto expanding buffer is not ve Lets see how to create an auto expanding buffer : + :::java IoBuffer buffer = IoBuffer.allocate(8); buffer.setAutoExpand(true); buffer.putString("12345678", encoder); @@ -91,6 +94,7 @@ There are situations which calls for rel Lets see this in action : + :::java IoBuffer buffer = IoBuffer.allocate(16); buffer.setAutoShrink(true); buffer.put((byte)1); @@ -106,6 +110,7 @@ We have initially allocated a capacity a Lets see the output of this : + :::java Initial Buffer capacity = 16 Initial Buffer capacity after shrink = 16 Buffer capacity after incrementing capacity to 32 = 32
Modified: mina/site/trunk/content/mina/userguide/ch9-codec-filter/ch9-codec-filter.mdtext URL: http://svn.apache.org/viewvc/mina/site/trunk/content/mina/userguide/ch9-codec-filter/ch9-codec-filter.mdtext?rev=1404465&r1=1404464&r2=1404465&view=diff ============================================================================== --- mina/site/trunk/content/mina/userguide/ch9-codec-filter/ch9-codec-filter.mdtext (original) +++ mina/site/trunk/content/mina/userguide/ch9-codec-filter/ch9-codec-filter.mdtext Thu Nov 1 05:13:12 2012 @@ -53,20 +53,9 @@ In this tutorial we will use the first a We will develop a (pretty useless) graphical chargen server to illustrate how to implement your own protocol codec (ProtocolEncoder, ProtocolDecoder, and ProtocolCodecFactory). The protocol is really simple. This is the layout of a request message: -<DIV class="table-wrap"> -<TABLE class="confluenceTable"><TBODY> -<TR> -<TH class="confluenceTh">4 bytes</TH> -<TH class="confluenceTh">4 bytes</TH> -<TH class="confluenceTh">4 bytes</TH> -</TR> -<TR> -<TD class="confluenceTd">width</TD> -<TD class="confluenceTd">height</TD> -<TD class="confluenceTd">numchars</TD> -</TR> -</TBODY></TABLE> -</DIV> +| 4 bytes | 4 bytes | 4 bytes | +|---|---|---| +| width | height | numchars | * width: the width of the requested image (an integer in network byte-order) * height: the height of the requested image (an integer in network byte-order) @@ -75,22 +64,9 @@ The protocol is really simple. This is t The server responds with two images of the requested dimensions, with the requested number of characters painted on it. This is the layout of a response message: -<DIV class="table-wrap"> -<TABLE class="confluenceTable"><TBODY> -<TR> -<TH class="confluenceTh">4 bytes</TH> -<TH class="confluenceTh">variable length body</TH> -<TH class="confluenceTh">4 bytes</TH> -<TH class="confluenceTh">variable length body</TH> -</TR> -<TR> -<TD class="confluenceTd">length1</TD> -<TD class="confluenceTd">image1</TD> -<TD class="confluenceTd">length2</TD> -<TD class="confluenceTd">image2</TD> -</TR> -</TBODY></TABLE> -</DIV> +| 4 bytes | variable length body | 4 bytes | variable length body | +|---|---|---|---| +| length1 | image1 | length2 | image2 | Overview of the classes we need for encoding and decoding requests and responses: @@ -104,6 +80,7 @@ Overview of the classes we need for enco Here is the ImageRequest class : + :::java public class ImageRequest { private int width; @@ -131,6 +108,7 @@ Overview of the classes we need for enco Encoding is usually simpler than decoding, so let's start with the ImageRequestEncoder: + :::java public class ImageRequestEncoder implements ProtocolEncoder { public void encode(IoSession session, Object message, ProtocolEncoderOutput out) throws Exception { @@ -159,6 +137,7 @@ Remarks: Now let's have a look at the decoder. The CumulativeProtocolDecoder is a great help for writing your own decoder: it will buffer all incoming data until your decoder decides it can do something with it. In this case the message has a fixed size, so it's easiest to wait until all data is available: + :::java public class ImageRequestDecoder extends CumulativeProtocolDecoder { protected boolean doDecode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) throws Exception { @@ -183,6 +162,7 @@ Remarks: The response is also a very simple POJO: + :::java public class ImageResponse { private BufferedImage image1; @@ -205,6 +185,7 @@ The response is also a very simple POJO: Encoding the response is also trivial: + :::java public class ImageResponseEncoder extends ProtocolEncoderAdapter { public void encode(IoSession session, Object message, ProtocolEncoderOutput out) throws Exception { @@ -235,6 +216,7 @@ Remarks: Now let's have a look at decoding the response: + :::java public class ImageResponseDecoder extends CumulativeProtocolDecoder { private static final String DECODER_STATE_KEY = ImageResponseDecoder.class.getName() + ".STATE"; @@ -298,6 +280,7 @@ see <http://www.nabble.com/Tutorial-on-P If the response would consist of a single image, we would not need to store decoder state: + :::java protected boolean doDecode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) throws Exception { if (in.prefixedDataAvailable(4)) { int length = in.getInt(); @@ -315,6 +298,7 @@ If the response would consist of a singl Now let's glue it all together: + :::java public class ImageCodecFactory implements ProtocolCodecFactory { private ProtocolEncoder encoder; private ProtocolDecoder decoder; @@ -345,6 +329,7 @@ Remarks: This is how the server would use the ProtocolCodecFactory: + :::java public class ImageServer { public static final int PORT = 33789; @@ -361,6 +346,7 @@ This is how the server would use the Pro Usage by the client is identical: + :::java public class ImageClient extends IoHandlerAdapter { public static final int CONNECT_TIMEOUT = 3000; @@ -387,6 +373,7 @@ Usage by the client is identical: For completeness, I will add the code for the server-side IoHandler: + :::java public class ImageServerIoHandler extends IoHandlerAdapter { private final static String characters = "mina rocks abcdefghijklmnopqrstuvwxyz0123456789"; Modified: mina/site/trunk/content/mina/userguide/codec-repo.mdtext URL: http://svn.apache.org/viewvc/mina/site/trunk/content/mina/userguide/codec-repo.mdtext?rev=1404465&r1=1404464&r2=1404465&view=diff ============================================================================== --- mina/site/trunk/content/mina/userguide/codec-repo.mdtext (original) +++ mina/site/trunk/content/mina/userguide/codec-repo.mdtext Thu Nov 1 05:13:12 2012 @@ -28,97 +28,22 @@ This page captures known MINA Codecs ava The table below summarizes some of the known codecs -<DIV class="table-wrap"> -<TABLE class="confluenceTable"><TBODY> -<TR> -<TH class="confluenceTh"> Protocol </TH> -<TH class="confluenceTh"> Project </TH> -<TH class="confluenceTh"> Description </TH> -</TR> -<TR> -<TD class="confluenceTd"> Prefixed String </TD> -<TD class="confluenceTd"> <A href="http://mina.apache.org/" class="external-link" rel="nofollow">Apache MINA</A> </TD> -<TD class="confluenceTd"> Encodes/Decodes a a String with fixed length prefix </TD> -</TR> -<TR> -<TD class="confluenceTd"> Object Serializer </TD> -<TD class="confluenceTd"> <A href="http://mina.apache.org/" class="external-link" rel="nofollow">Apache MINA</A> </TD> -<TD class="confluenceTd"> Serializes and deserializes Java objects </TD> -</TR> -<TR> -<TD class="confluenceTd"> Text Line </TD> -<TD class="confluenceTd"> <A href="http://mina.apache.org/" class="external-link" rel="nofollow">Apache MINA</A> </TD> -<TD class="confluenceTd"> Encoding/Decoding between a text line data and a Java string object </TD> -</TR> -<TR> -<TD class="confluenceTd"> Ftp </TD> -<TD class="confluenceTd"> <A href="http://mina.apache.org/ftpserver/" class="external-link" rel="nofollow">Apache FtpServer</A> </TD> -<TD class="confluenceTd"> FTP codecs </TD> -</TR> -<TR> -<TD class="confluenceTd"> LDAP </TD> -<TD class="confluenceTd"> <A href="http://directory.apache.org/" class="external-link" rel="nofollow">Apache Directory</A> </TD> -<TD class="confluenceTd"> LDAP protocol Codecs </TD> -</TR> -<TR> -<TD class="confluenceTd"> DNS </TD> -<TD class="confluenceTd"> <A href="http://directory.apache.org/" class="external-link" rel="nofollow">Apache Directory</A> </TD> -<TD class="confluenceTd"> DNS protocol Codecs </TD> -</TR> -<TR> -<TD class="confluenceTd"> Kerberos </TD> -<TD class="confluenceTd"> <A href="http://directory.apache.org/" class="external-link" rel="nofollow">Apache Directory</A> </TD> -<TD class="confluenceTd"> Kerberos protocol Codecs </TD> -</TR> -<TR> -<TD class="confluenceTd"> NTP </TD> -<TD class="confluenceTd"> <A href="http://directory.apache.org/" class="external-link" rel="nofollow">Apache Directory</A> </TD> -<TD class="confluenceTd"> NTP protocol Codecs </TD> -</TR> -<TR> -<TD class="confluenceTd"> DHCP </TD> -<TD class="confluenceTd"> <A href="http://directory.apache.org/" class="external-link" rel="nofollow">Apache Directory</A> </TD> -<TD class="confluenceTd"> DHCP protocol Codecs </TD> -</TR> -<TR> -<TD class="confluenceTd"> <A href="http://jira.red5.org/confluence/display/docs/Chapter%2016.%20Clustering" class="external-link" rel="nofollow">MRTMP</A> </TD> -<TD class="confluenceTd"> <A href="http://www.red5.org/" class="external-link" rel="nofollow">Red5</A> </TD> -<TD class="confluenceTd"> Codecs for Multiplexing RTMP </TD> -</TR> -<TR> -<TD class="confluenceTd"> RTMP </TD> -<TD class="confluenceTd"> <A href="http://www.red5.org/" class="external-link" rel="nofollow">Red5</A> </TD> -<TD class="confluenceTd"> Codecs for RTMP </TD> -</TR> -<TR> -<TD class="confluenceTd"> RTSP </TD> -<TD class="confluenceTd"> <A href="http://www.red5.org/" class="external-link" rel="nofollow">Red5</A> </TD> -<TD class="confluenceTd"> Codecs for RTSP </TD> -</TR> -<TR> -<TD class="confluenceTd"> SMTP </TD> -<TD class="confluenceTd"> <A href="http://tedorg.free.fr/en/projects.php?section=smtp" class="external-link" rel="nofollow">MailsterSMTP</A> </TD> -<TD class="confluenceTd"> SMTP Codecs </TD> -</TR> -<TR> -<TD class="confluenceTd"> AMQP </TD> -<TD class="confluenceTd"> <A href="http://cwiki.apache.org/qpid/" class="external-link" rel="nofollow">Apache Qpid</A> </TD> -<TD class="confluenceTd"> AMQP Codecs </TD> -</TR> -<TR> -<TD class="confluenceTd"> XMPP </TD> -<TD class="confluenceTd"> <A href="http://www.jivesoftware.com/products/openfire/" class="external-link" rel="nofollow">Jive Software Openfire</A> </TD> -<TD class="confluenceTd"> XMPP Codecs </TD> -</TR> -<TR> -<TD class="confluenceTd"> XMPP </TD> -<TD class="confluenceTd"> Apache Vysper </TD> -<TD class="confluenceTd"> XMPP/XML Codecs. Subproject of MINA. Still in <A href="http://svn.apache.org/repos/asf/mina/sandbox/vysper/" class="external-link" rel="nofollow">sanbox</A> </TD> -</TR> -<TR> -<TD class="confluenceTd"> Google Protocol Buffers </TD> -<TD class="confluenceTd"> Apache MINA </TD> -<TD class="confluenceTd"> Codecs are still in <A href="http://svn.apache.org/repos/asf/mina/sandbox/protocol-buffers/" class="external-link" rel="nofollow">sandbox</A> </TD> -</TR> -</TBODY></TABLE> -</DIV> +| Protocol | Project | Description | +|---|---|---| +| Prefixed String | [Apache MINA](http://mina.apache.org/) | Encodes/Decodes a a String with fixed length prefix | +| Object Serializer | [Apache MINA](http://mina.apache.org/) | Serializes and deserializes Java objects | +| Text Line | [Apache MINA](http://mina.apache.org/) | Encoding/Decoding between a text line data and a Java string object | +| Ftp | [Apache FtpServer](http://mina.apache.org/ftpserver) | FTP codecs | +| LDAP | [Apache Directory](http://directory.apache.org/)| LDAP protocol Codecs | +| DNS | [Apache Directory](http://directory.apache.org/)| DNS protocol Codecs | +| Kerberos | [Apache Directory](http://directory.apache.org/)| Kerberos protocol Codecs | +| NTP | [Apache Directory](http://directory.apache.org/) | NTP protocol Codecs | +| DHCP | [Apache Directory](http://directory.apache.org/) | DHCP protocol Codecs | +| [MRTMP](http://jira.red5.org/confluence/display/docs/Chapter%2016.%20Clustering)| [Red5](http://www.red5.org/) | Codecs for Multiplexing RTMP | +| RTMP | [Red5](http://www.red5.org/) | Codecs for RTMP | +| RTSP | [Red5](http://www.red5.org/) | Codecs for RTSP | +| SMTP | [MailsterSMTP](http://tedorg.free.fr/en/projects.php?section=smtp)</A> | SMTP Codecs | +| AMQP | [Apache Qpid](http://cwiki.apache.org/qpid/)</A> | AMQP Codecs | +| XMPP | <A href="" class="external-link" rel="nofollow">[Jive Software Openfire](http://www.jivesoftware.com/products/openfire/)| XMPP Codecs | + | XMPP | [Vysper](http://mina.apache.org/vysper)| XMPP/XML Codecs. Subproject of MINA. | +| Google Protocol Buffers | Apache MINA | Codecs are still in [sandbox](http://svn.apache.org/repos/asf/mina/sandbox/protocol-buffers/)</A> | Modified: mina/site/trunk/content/special-thanks.mdtext URL: http://svn.apache.org/viewvc/mina/site/trunk/content/special-thanks.mdtext?rev=1404465&r1=1404464&r2=1404465&view=diff ============================================================================== --- mina/site/trunk/content/special-thanks.mdtext (original) +++ mina/site/trunk/content/special-thanks.mdtext Thu Nov 1 05:13:12 2012 @@ -34,26 +34,7 @@ Thanks ! We would also like to thank the oganizations who provided some tools and images for free : -<DIV class="table-wrap"> -<TABLE class="confluenceTable"><TBODY> -<TR> -<TH class="confluenceTh"> Company/Organization </TH> -<TH class="confluenceTh"> Donation type </TH> -<TH class="confluenceTh"> Organization contact </TH> -<TH class="confluenceTh"> Apache contact </TH> -</TR> -<TR> -<TD class="confluenceTd"><A href="http://www.yourkit.com/" title="www.yourkit.com" class="external-link" rel="nofollow"><SPAN class="image-wrap" style=""><IMG src="staticresources/images/YourKit_logo.png" style="border: 0px solid black"></SPAN></A> </TD> -<TD class="confluenceTd"> Licenses for YourKit </TD> -<TD class="confluenceTd"> Vladimir Kondratyev <BR> -(sales at yourkit.com) </TD> -<TD class="confluenceTd"> Emmanuel Lécharny </TD> -</TR> -<TR> -<TD class="confluenceTd"><A href="http://www.famfamfam.com/lab/icons/silk/" title="www.famfamfam.com" class="external-link" rel="nofollow"><SPAN class="image-wrap" style=""><IMG src="staticresources/images/FAMFAMFAM_logo.png" style="border: 0px solid black"></SPAN></A></TD> -<TD class="confluenceTd">[http://creativecommons.org/licenses/by/2.5/](http://creativecommons.org/licenses/by/2.5/)</TD> -<TD class="confluenceTd"> Mark James </TD> -<TD class="confluenceTd"> Emmanuel Lécharny</TD> -</TR> -</TBODY></TABLE> -</DIV> \ No newline at end of file +| Company/Organization | Donation type | Organization contact | Apache contact | +|---|---|---|---| +| | Licenses for YourKit | Vladimir Kondratyev <BR/> (sales at yourkit.com) | Emmanuel Lécharny | +||[http://creativecommons.org/licenses/by/2.5/](http://creativecommons.org/licenses/by/2.5/)| Mark James | Emmanuel Lécharny|
