<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Implementing XML Decoder for Apache MINA</title>
	<atom:link href="http://www.ashishpaliwal.com/blog/2008/10/implementing-xml-decoder-for-apache-mina/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ashishpaliwal.com/blog/2008/10/implementing-xml-decoder-for-apache-mina/</link>
	<description>From Programmer, For Programmers</description>
	<lastBuildDate>Mon, 09 Jan 2012 04:02:36 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: deepti</title>
		<link>http://www.ashishpaliwal.com/blog/2008/10/implementing-xml-decoder-for-apache-mina/comment-page-1/#comment-47053</link>
		<dc:creator>deepti</dc:creator>
		<pubDate>Wed, 28 Sep 2011 09:50:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.ashishpaliwal.com/blog/?p=187#comment-47053</guid>
		<description>can you send me code how can i use CumulativeProtocolDecoder in my previous code whatever i posted</description>
		<content:encoded><![CDATA[<p>can you send me code how can i use CumulativeProtocolDecoder in my previous code whatever i posted</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ashish</title>
		<link>http://www.ashishpaliwal.com/blog/2008/10/implementing-xml-decoder-for-apache-mina/comment-page-1/#comment-47052</link>
		<dc:creator>ashish</dc:creator>
		<pubDate>Wed, 28 Sep 2011 09:37:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.ashishpaliwal.com/blog/?p=187#comment-47052</guid>
		<description>That&#039;s why you need CumulativeProctocolDecoder, which accumulates data till complete data is received.</description>
		<content:encoded><![CDATA[<p>That&#8217;s why you need CumulativeProctocolDecoder, which accumulates data till complete data is received.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: deepti</title>
		<link>http://www.ashishpaliwal.com/blog/2008/10/implementing-xml-decoder-for-apache-mina/comment-page-1/#comment-47048</link>
		<dc:creator>deepti</dc:creator>
		<pubDate>Wed, 28 Sep 2011 09:00:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.ashishpaliwal.com/blog/?p=187#comment-47048</guid>
		<description>Thanks ashish for quick reply for new beginners.
In the post it is extending cumulativeprotocolcodec factory.but i am implementing prtotocoldecoder in my case.
here is the complete code.Plz help me out how can i get the full xml file on file endpoint.

Groovy class:
class SampleRouteBuilder extends SpringRouteBuilder {

    void configure() {
		     from(&quot;mina:tcp://localhost:6000sync=true&amp;codec=#XMLCodec&quot;)
.to(&quot;file:data/outbox&quot;)
}
}

public class XMLCodec implements ProtocolCodecFactory {

	@Override
	public ProtocolDecoder getDecoder() throws Exception {
		System.out.println(&quot;inside getDecoder&quot;);
		return new XMLDecoder();
	}

	@Override
	public ProtocolEncoder getEncoder() throws Exception {
		System.out.println(&quot;Inside getencoder&quot;);
		return new XMLEncoder();
	}
}

XMLDecoder:

public class XMLDecoder implements ProtocolDecoder {

	public void dispose(IoSession arg0) throws Exception {

	}

	public void finishDecode(IoSession session, ProtocolDecoderOutput output)
			throws Exception {

	}

	public void decode(IoSession session, ByteBuffer buffer,
			ProtocolDecoderOutput output) throws Exception {
		String buf = null;

		if (buffer.remaining() &gt; 0) {

			buf = IOUtils.toString(MinaConverter.toInputStream(buffer));
			System.out.println(&quot;Buffer&quot; + buf);
		}
		output.write(buf);
	}
}
XMLEncoder:

public class XMLEncoder implements ProtocolEncoder {

	public void dispose(IoSession arg0) throws Exception {

	}

	public void encode(IoSession arg0, Object arg1, ProtocolEncoderOutput arg2)
			throws Exception {

	}
}

decode method of XMLDecoder will be called for 4 to 5 times.In the outbox folder,uploaded xml file is getting splitted into 4/5 file.
tell me how to receive uploaded file into outbox folder as a single file.Please tell me where am i doing mistake</description>
		<content:encoded><![CDATA[<p>Thanks ashish for quick reply for new beginners.<br />
In the post it is extending cumulativeprotocolcodec factory.but i am implementing prtotocoldecoder in my case.<br />
here is the complete code.Plz help me out how can i get the full xml file on file endpoint.</p>
<p>Groovy class:<br />
class SampleRouteBuilder extends SpringRouteBuilder {</p>
<p>    void configure() {<br />
		     from(&#8220;mina:tcp://localhost:6000sync=true&amp;codec=#XMLCodec&#8221;)<br />
.to(&#8220;file:data/outbox&#8221;)<br />
}<br />
}</p>
<p>public class XMLCodec implements ProtocolCodecFactory {</p>
<p>	@Override<br />
	public ProtocolDecoder getDecoder() throws Exception {<br />
		System.out.println(&#8220;inside getDecoder&#8221;);<br />
		return new XMLDecoder();<br />
	}</p>
<p>	@Override<br />
	public ProtocolEncoder getEncoder() throws Exception {<br />
		System.out.println(&#8220;Inside getencoder&#8221;);<br />
		return new XMLEncoder();<br />
	}<br />
}</p>
<p>XMLDecoder:</p>
<p>public class XMLDecoder implements ProtocolDecoder {</p>
<p>	public void dispose(IoSession arg0) throws Exception {</p>
<p>	}</p>
<p>	public void finishDecode(IoSession session, ProtocolDecoderOutput output)<br />
			throws Exception {</p>
<p>	}</p>
<p>	public void decode(IoSession session, ByteBuffer buffer,<br />
			ProtocolDecoderOutput output) throws Exception {<br />
		String buf = null;</p>
<p>		if (buffer.remaining() &gt; 0) {</p>
<p>			buf = IOUtils.toString(MinaConverter.toInputStream(buffer));<br />
			System.out.println(&#8220;Buffer&#8221; + buf);<br />
		}<br />
		output.write(buf);<br />
	}<br />
}<br />
XMLEncoder:</p>
<p>public class XMLEncoder implements ProtocolEncoder {</p>
<p>	public void dispose(IoSession arg0) throws Exception {</p>
<p>	}</p>
<p>	public void encode(IoSession arg0, Object arg1, ProtocolEncoderOutput arg2)<br />
			throws Exception {</p>
<p>	}<br />
}</p>
<p>decode method of XMLDecoder will be called for 4 to 5 times.In the outbox folder,uploaded xml file is getting splitted into 4/5 file.<br />
tell me how to receive uploaded file into outbox folder as a single file.Please tell me where am i doing mistake</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ashish</title>
		<link>http://www.ashishpaliwal.com/blog/2008/10/implementing-xml-decoder-for-apache-mina/comment-page-1/#comment-47037</link>
		<dc:creator>ashish</dc:creator>
		<pubDate>Wed, 28 Sep 2011 06:15:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.ashishpaliwal.com/blog/?p=187#comment-47037</guid>
		<description>decode() shall be called each time a message is received. Its the logic in decoder to decide if the XML is complete or not. The code is in the post itself.</description>
		<content:encoded><![CDATA[<p>decode() shall be called each time a message is received. Its the logic in decoder to decide if the XML is complete or not. The code is in the post itself.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: deepthi</title>
		<link>http://www.ashishpaliwal.com/blog/2008/10/implementing-xml-decoder-for-apache-mina/comment-page-1/#comment-47036</link>
		<dc:creator>deepthi</dc:creator>
		<pubDate>Wed, 28 Sep 2011 06:12:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.ashishpaliwal.com/blog/?p=187#comment-47036</guid>
		<description>thanks avinash.But i don&#039;t have any decoding logic in decode method of ProtocolDecoder.My requirement is to receive complete xml file as one file into file endpoint.My decode method is keep on calling until buffer gets empty.but i want decode method to be called once only. Can you send me sample code to do that?</description>
		<content:encoded><![CDATA[<p>thanks avinash.But i don&#8217;t have any decoding logic in decode method of ProtocolDecoder.My requirement is to receive complete xml file as one file into file endpoint.My decode method is keep on calling until buffer gets empty.but i want decode method to be called once only. Can you send me sample code to do that?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ashish</title>
		<link>http://www.ashishpaliwal.com/blog/2008/10/implementing-xml-decoder-for-apache-mina/comment-page-1/#comment-46974</link>
		<dc:creator>ashish</dc:creator>
		<pubDate>Tue, 27 Sep 2011 12:29:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.ashishpaliwal.com/blog/?p=187#comment-46974</guid>
		<description>This is how NIO works, you get packets as and when received. So you need to ensure that you have complete data before decoding.</description>
		<content:encoded><![CDATA[<p>This is how NIO works, you get packets as and when received. So you need to ensure that you have complete data before decoding.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Deepthi</title>
		<link>http://www.ashishpaliwal.com/blog/2008/10/implementing-xml-decoder-for-apache-mina/comment-page-1/#comment-46973</link>
		<dc:creator>Deepthi</dc:creator>
		<pubDate>Tue, 27 Sep 2011 12:21:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.ashishpaliwal.com/blog/?p=187#comment-46973</guid>
		<description>Hi,
I want to use tcp mina endpoint to read XML file.I have written custom XML codec by implementing Protocolcodecfactory interface.And it got two unimplemented methods protocoldecoder and protocolencoder.I just implemented these interfaces.When i try to get entire XML,i am not able to get.It is getting broken into 4 to 5 pieces.I am receiving in file endpoint as 4 to 5 files.what could be the problem?</description>
		<content:encoded><![CDATA[<p>Hi,<br />
I want to use tcp mina endpoint to read XML file.I have written custom XML codec by implementing Protocolcodecfactory interface.And it got two unimplemented methods protocoldecoder and protocolencoder.I just implemented these interfaces.When i try to get entire XML,i am not able to get.It is getting broken into 4 to 5 pieces.I am receiving in file endpoint as 4 to 5 files.what could be the problem?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ashish</title>
		<link>http://www.ashishpaliwal.com/blog/2008/10/implementing-xml-decoder-for-apache-mina/comment-page-1/#comment-463</link>
		<dc:creator>ashish</dc:creator>
		<pubDate>Tue, 02 Dec 2008 08:47:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.ashishpaliwal.com/blog/?p=187#comment-463</guid>
		<description>Nope you don&#039;t have to return true, just write the XML to protocoldecoder output and continue to create the XML structure. Though I am not sure about the memory implication of the same</description>
		<content:encoded><![CDATA[<p>Nope you don&#8217;t have to return true, just write the XML to protocoldecoder output and continue to create the XML structure. Though I am not sure about the memory implication of the same</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: newToMina</title>
		<link>http://www.ashishpaliwal.com/blog/2008/10/implementing-xml-decoder-for-apache-mina/comment-page-1/#comment-461</link>
		<dc:creator>newToMina</dc:creator>
		<pubDate>Mon, 01 Dec 2008 14:11:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.ashishpaliwal.com/blog/?p=187#comment-461</guid>
		<description>Once I get a complete XML document (could be the first one out of many that the client wrote to the socket in a single write operation) my question is:

If I return true from doDecode and process the first assembled xml document, will I be able to read the subsequent xml documents from that session again?

It would be a great help if you could refine and post your example here at the earliest possible. Once again I truly appreciate you taking the time to help new programmers.</description>
		<content:encoded><![CDATA[<p>Once I get a complete XML document (could be the first one out of many that the client wrote to the socket in a single write operation) my question is:</p>
<p>If I return true from doDecode and process the first assembled xml document, will I be able to read the subsequent xml documents from that session again?</p>
<p>It would be a great help if you could refine and post your example here at the earliest possible. Once again I truly appreciate you taking the time to help new programmers.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ashish</title>
		<link>http://www.ashishpaliwal.com/blog/2008/10/implementing-xml-decoder-for-apache-mina/comment-page-1/#comment-459</link>
		<dc:creator>ashish</dc:creator>
		<pubDate>Sun, 30 Nov 2008 06:34:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.ashishpaliwal.com/blog/?p=187#comment-459</guid>
		<description>Well I did tried for multiple xml documents and then realized its one of the exceptional scenarios, hence haven&#039;t worked on it much.

On point 1, I would say as soon as the XML document is complete, process it and write response back onto the session

Well you can use Executors for threading.

Let me refine my program, before I post it here. Will be a while before I can do it.</description>
		<content:encoded><![CDATA[<p>Well I did tried for multiple xml documents and then realized its one of the exceptional scenarios, hence haven&#8217;t worked on it much.</p>
<p>On point 1, I would say as soon as the XML document is complete, process it and write response back onto the session</p>
<p>Well you can use Executors for threading.</p>
<p>Let me refine my program, before I post it here. Will be a while before I can do it.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

