<?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>Tue, 17 Aug 2010 12:04:21 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<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>
	<item>
		<title>By: newToMina</title>
		<link>http://www.ashishpaliwal.com/blog/2008/10/implementing-xml-decoder-for-apache-mina/comment-page-1/#comment-452</link>
		<dc:creator>newToMina</dc:creator>
		<pubDate>Wed, 26 Nov 2008 21:39:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.ashishpaliwal.com/blog/?p=187#comment-452</guid>
		<description>Ashish,

First of all thanks a lot for this example.

I am one who started the thread &quot;http://www.nabble.com/MINA---design-guidelines-td20077627.html#a20095703&quot;

Do you have any updates on how to handle clients sending very long xml documents? Also any thoughts on how to process mutiple xml documents came as part of single read. 

What are your thoughts on the following ideas?
1) Keep reading the data until all the xml documents are read and constructed and then process the xml documents one at a time and write the result back to client session.

2) Create a new thread as soon as an xml document is read and process the constructed xml document using the new thread. 

Could you please post the complete code (server &amp; client implementation including the encoders &amp; decoders) for testing the XMLDecoder program in the blog.

Any suggestions would be greatly appreciated.</description>
		<content:encoded><![CDATA[<p>Ashish,</p>
<p>First of all thanks a lot for this example.</p>
<p>I am one who started the thread &#8220;http://www.nabble.com/MINA&#8212;design-guidelines-td20077627.html#a20095703&#8243;</p>
<p>Do you have any updates on how to handle clients sending very long xml documents? Also any thoughts on how to process mutiple xml documents came as part of single read. </p>
<p>What are your thoughts on the following ideas?<br />
1) Keep reading the data until all the xml documents are read and constructed and then process the xml documents one at a time and write the result back to client session.</p>
<p>2) Create a new thread as soon as an xml document is read and process the constructed xml document using the new thread. </p>
<p>Could you please post the complete code (server &amp; client implementation including the encoders &amp; decoders) for testing the XMLDecoder program in the blog.</p>
<p>Any suggestions would be greatly appreciated.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Apache MINA - CumulativeProtocolDecoder Explained &#124; Ashish's Tech Blog</title>
		<link>http://www.ashishpaliwal.com/blog/2008/10/implementing-xml-decoder-for-apache-mina/comment-page-1/#comment-48</link>
		<dc:creator>Apache MINA - CumulativeProtocolDecoder Explained &#124; Ashish's Tech Blog</dc:creator>
		<pubDate>Sat, 08 Nov 2008 15:37:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.ashishpaliwal.com/blog/?p=187#comment-48</guid>
		<description>[...] the chain. Implementation of CumulativeProtocolDecoder can be seen in detail in the following post Implementing XML Decoder for Apache MINA  /* &quot;, &quot; &#187;&quot;); /* ]]&gt; */SHARETHIS.addEntry({ title: &quot;Apache MINA - [...]</description>
		<content:encoded><![CDATA[<p>[...] the chain. Implementation of CumulativeProtocolDecoder can be seen in detail in the following post Implementing XML Decoder for Apache MINA  /* &#8220;, &#8221; &raquo;&#8221;); /* ]]&gt; */SHARETHIS.addEntry({ title: &#8220;Apache MINA &#8211; [...]</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-42</link>
		<dc:creator>ashish</dc:creator>
		<pubDate>Thu, 06 Nov 2008 05:00:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.ashishpaliwal.com/blog/?p=187#comment-42</guid>
		<description>Yup this is a problem and unfortunately I don&#039;t have a solution as of now. My thought process on handling this is to keep a tab on xml size and disconnect violating clients. Also, since we know the type of xml we are handling, it shall be easy. There should be a way around this. Let me check async web implementation for this. It will be a good idea to post this query in MINA forum as well.</description>
		<content:encoded><![CDATA[<p>Yup this is a problem and unfortunately I don&#8217;t have a solution as of now. My thought process on handling this is to keep a tab on xml size and disconnect violating clients. Also, since we know the type of xml we are handling, it shall be easy. There should be a way around this. Let me check async web implementation for this. It will be a good idea to post this query in MINA forum as well.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: TheSorrow</title>
		<link>http://www.ashishpaliwal.com/blog/2008/10/implementing-xml-decoder-for-apache-mina/comment-page-1/#comment-41</link>
		<dc:creator>TheSorrow</dc:creator>
		<pubDate>Wed, 05 Nov 2008 21:13:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.ashishpaliwal.com/blog/?p=187#comment-41</guid>
		<description>Thank you ! It helped me a lot !

I was wondering about your decoder , if someone connect to the server and sends data like &quot;foobarfoobarfoobar.....&quot; etc , the bytebuffer will &quot;explode&quot; (OutOfMemoryError) ?</description>
		<content:encoded><![CDATA[<p>Thank you ! It helped me a lot !</p>
<p>I was wondering about your decoder , if someone connect to the server and sends data like &#8220;foobarfoobarfoobar&#8230;..&#8221; etc , the bytebuffer will &#8220;explode&#8221; (OutOfMemoryError) ?</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-28</link>
		<dc:creator>ashish</dc:creator>
		<pubDate>Mon, 03 Nov 2008 04:59:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.ashishpaliwal.com/blog/?p=187#comment-28</guid>
		<description>I tested it in almost real environment. Had a TCP client that sent the request. The xml file was pom.xml from MINA project.

Here is the code

public void connect(String host, int port) {
		NioSocketConnector connector = new NioSocketConnector();
		connector.getFilterChain().addLast(&quot;Logger&quot;, new LoggingFilter());
		connector.setHandler(new XMLHandler());
		
		ConnectFuture future = connector.connect(new InetSocketAddress(
				host, port));
		
		future.addListener(new IoFutureListener&lt;ConnectFuture&gt;() {

			@Override
			public void operationComplete(ConnectFuture connectFuture) {
				if (connectFuture.isConnected()) {
					session = connectFuture.getSession();
				}
			}
		});
	}
	
	public void send(String xmlData, String ip, int port) throws IOException {
		if(xmlData == null) {
			logger.error(&quot;Data is null&quot;);
			return;
		}
		
		// Connect
		connect(ip, port);
		
		byte[] data = xmlData.getBytes();
		
		IoBuffer buffer = IoBuffer.allocate(data.length);
		buffer.put(data);
		buffer.flip();
		// write to the session
		
		logger.debug(&quot;Writing to Session&quot;);
		while(session == null) {
			continue;
		}	
		session.write(buffer);
		session.close();
	}
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		XMLClient client = new XMLClient();
		
		try {
			File f = new File(&quot;pom.xml&quot;);
			
			BufferedReader reader = new BufferedReader(new FileReader(f));
			
			StringBuffer buffer = new StringBuffer();
			
			String line;
			
			while((line = reader.readLine()) != null) {
				buffer.append(line);
			}
			
			client.send(buffer.toString(), &quot;localhost&quot;, 8081);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

Hope it helps :-)</description>
		<content:encoded><![CDATA[<p>I tested it in almost real environment. Had a TCP client that sent the request. The xml file was pom.xml from MINA project.</p>
<p>Here is the code</p>
<p>public void connect(String host, int port) {<br />
		NioSocketConnector connector = new NioSocketConnector();<br />
		connector.getFilterChain().addLast(&#8220;Logger&#8221;, new LoggingFilter());<br />
		connector.setHandler(new XMLHandler());</p>
<p>		ConnectFuture future = connector.connect(new InetSocketAddress(<br />
				host, port));</p>
<p>		future.addListener(new IoFutureListener<connectfuture>() {</p>
<p>			@Override<br />
			public void operationComplete(ConnectFuture connectFuture) {<br />
				if (connectFuture.isConnected()) {<br />
					session = connectFuture.getSession();<br />
				}<br />
			}<br />
		});<br />
	}</p>
<p>	public void send(String xmlData, String ip, int port) throws IOException {<br />
		if(xmlData == null) {<br />
			logger.error(&#8220;Data is null&#8221;);<br />
			return;<br />
		}</p>
<p>		// Connect<br />
		connect(ip, port);</p>
<p>		byte[] data = xmlData.getBytes();</p>
<p>		IoBuffer buffer = IoBuffer.allocate(data.length);<br />
		buffer.put(data);<br />
		buffer.flip();<br />
		// write to the session</p>
<p>		logger.debug(&#8220;Writing to Session&#8221;);<br />
		while(session == null) {<br />
			continue;<br />
		}<br />
		session.write(buffer);<br />
		session.close();<br />
	}</p>
<p>	/**<br />
	 * @param args<br />
	 */<br />
	public static void main(String[] args) {<br />
		XMLClient client = new XMLClient();</p>
<p>		try {<br />
			File f = new File(&#8220;pom.xml&#8221;);</p>
<p>			BufferedReader reader = new BufferedReader(new FileReader(f));</p>
<p>			StringBuffer buffer = new StringBuffer();</p>
<p>			String line;</p>
<p>			while((line = reader.readLine()) != null) {<br />
				buffer.append(line);<br />
			}</p>
<p>			client.send(buffer.toString(), &#8220;localhost&#8221;, 8081);<br />
		} catch (Exception e) {<br />
			e.printStackTrace();<br />
		}<br />
	}</p>
<p>Hope it helps <img src='http://www.ashishpaliwal.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </connectfuture></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: TheSorrow</title>
		<link>http://www.ashishpaliwal.com/blog/2008/10/implementing-xml-decoder-for-apache-mina/comment-page-1/#comment-25</link>
		<dc:creator>TheSorrow</dc:creator>
		<pubDate>Sun, 02 Nov 2008 16:34:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.ashishpaliwal.com/blog/?p=187#comment-25</guid>
		<description>My unit test might be wrong...
Can you post the unit test you use to test this decoder ? 
I think that it can be very usefull :)

Thanks</description>
		<content:encoded><![CDATA[<p>My unit test might be wrong&#8230;<br />
Can you post the unit test you use to test this decoder ?<br />
I think that it can be very usefull <img src='http://www.ashishpaliwal.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Thanks</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-24</link>
		<dc:creator>ashish</dc:creator>
		<pubDate>Sun, 02 Nov 2008 14:34:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.ashishpaliwal.com/blog/?p=187#comment-24</guid>
		<description>Nope ioBuffer is not cleared after false. returning false is an indicator to keep buffering till we receive complete payload. I tested the code above with 4 fragmented packets and it worked fine.  If you can send the code, I can give it a try.</description>
		<content:encoded><![CDATA[<p>Nope ioBuffer is not cleared after false. returning false is an indicator to keep buffering till we receive complete payload. I tested the code above with 4 fragmented packets and it worked fine.  If you can send the code, I can give it a try.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
