<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ashish's Tech Blog &#187; CumulativeProtocolDecoder</title>
	<atom:link href="http://www.ashishpaliwal.com/blog/tag/cumulativeprotocoldecoder/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ashishpaliwal.com/blog</link>
	<description>From Programmer, For Programmers</description>
	<lastBuildDate>Tue, 17 Aug 2010 12:04:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Apache MINA &#8211; CumulativeProtocolDecoder Explained</title>
		<link>http://www.ashishpaliwal.com/blog/2008/11/apache-mina-cumulativeprotocoldecoder-explained/</link>
		<comments>http://www.ashishpaliwal.com/blog/2008/11/apache-mina-cumulativeprotocoldecoder-explained/#comments</comments>
		<pubDate>Sat, 08 Nov 2008 15:37:32 +0000</pubDate>
		<dc:creator>ashish</dc:creator>
				<category><![CDATA[Apache MINA]]></category>
		<category><![CDATA[CumulativeProtocolDecoder]]></category>

		<guid isPermaLink="false">http://www.ashishpaliwal.com/blog/?p=211</guid>
		<description><![CDATA[Apache MINA uses the concept of Protocol Decoder to decoder read bytes into High Level Message objects. There are conditions in which a single packet may not contain the complete bytes to convert raw message into High Level Objects. For such situations, CumulativeProtocolDecoder can be used. Basically, encoder makes the framework buffer the data, till [...]]]></description>
			<content:encoded><![CDATA[<p>Apache MINA uses the concept of Protocol Decoder to decoder read bytes into High Level Message objects. There are conditions in which a single packet may not contain the complete bytes to convert raw message into High Level Objects. For such situations, <em>CumulativeProtocolDecoder</em> can be used. Basically, encoder makes the framework buffer the data, till the complete data is received, to convert the byte[] into a high level object.</p>
<p>So, how do we use this Decoder</p>
<p>Extend from the class <em>CumulativeProtocolDecoder</em> and implement the <em>doDecode()</em>.</p>
<p>Conditions to take care of</p>
<ol>
<li>read the IoBuffer and decode as per yur logic</li>
<li>If the data is sufficient to create your message, return true, else return false</li>
</ol>
<div><strong><span style="text-decoration: underline;">Under the Hood</span></strong></div>
<div>The magic lies in the asbtract class CumulativeProtocolDecoder, which internally buffer the data and keep on calling our doDecoder(). Based on the return type from doDecode(), it either keeps buffering or allows the framework to call next filter in the chain.</div>
<div>Implementation of CumulativeProtocolDecoder can be seen in detail in the following post</div>
<div><a title="Permanent Link: Implementing XML Decoder for Apache MINA" rel="bookmark" href="http://www.ashishpaliwal.com/blog/2008/10/implementing-xml-decoder-for-apache-mina/">Implementing XML Decoder for Apache MINA</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.ashishpaliwal.com/blog/2008/11/apache-mina-cumulativeprotocoldecoder-explained/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
