<?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>Thread.currentThread().join() &#187; Java</title>
	<atom:link href="http://www.ashishpaliwal.com/blog/tag/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ashishpaliwal.com/blog</link>
	<description>From Programmer, For Programmers</description>
	<lastBuildDate>Tue, 23 Aug 2011 03:53:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Hunting down CPU hogging Java Thread</title>
		<link>http://www.ashishpaliwal.com/blog/2011/08/finding-java-thread-consuming-high-cpu/</link>
		<comments>http://www.ashishpaliwal.com/blog/2011/08/finding-java-thread-consuming-high-cpu/#comments</comments>
		<pubDate>Tue, 09 Aug 2011 21:48:21 +0000</pubDate>
		<dc:creator>ashish</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[CPU]]></category>
		<category><![CDATA[Thread]]></category>

		<guid isPermaLink="false">http://www.ashishpaliwal.com/blog/?p=632</guid>
		<description><![CDATA[Most of us have encountered a situation to find cause of high CPU usage in Java application. Profiling is the best way, but at times running Profiler in production is not an option. Fortunately, there is a simple way, if you are running your app on *nix. Lets explore how to find this. Find the [...]]]></description>
			<content:encoded><![CDATA[<p>Most of us have encountered a situation to find cause of high CPU usage in Java application. Profiling is the best way, but at times running Profiler in production is not an option. Fortunately, there is a simple way, if you are running your app on *nix.</p>
<p>Lets explore how to find this.</p>
<ul>
<li>Find the pid of the application, using <em>top</em> or <em>jps</em> command</li>
<li>Once you get the pid, run following command<br />
   <strong><strong>$ ps -L pid</strong></strong>
</li>
<p>We get an output as shown in the figure<br />
<div id="attachment_635" class="wp-caption aligncenter" style="width: 410px"><a href="http://www.ashishpaliwal.com/blog/wp-content/uploads/2011/08/Screen-shot-2011-08-10-at-2.39.54-AM1.png"><img src="http://www.ashishpaliwal.com/blog/wp-content/uploads/2011/08/Screen-shot-2011-08-10-at-2.39.54-AM1.png" alt="" title="ps output" width="400" height="216" class="size-full wp-image-635" /></a><p class="wp-caption-text">ps output</p></div></p>
<p>The output displays all the Threads in the application along with the time spent. Find the Thread that has spent highest time in execution (Entry circled on right). Once we identify this, get the LWP ID of the Thread (Entry circled on left).</p>
<li>Using <em>jstack</em> or <em>visualvm</em>, take a Thread dump.</li>
<li>Convert LWP ID to Hex and search for the ID in Thread dump. </li>
</ul>
<p>Then you can narrow down the thread which is consuming max CPU and investigate further.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ashishpaliwal.com/blog/2011/08/finding-java-thread-consuming-high-cpu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Implementing Trap Receiver in 30 minutes using Apache MINA</title>
		<link>http://www.ashishpaliwal.com/blog/2008/10/implementing-trap-receiver-in-30-minutes-using-apache-mina/</link>
		<comments>http://www.ashishpaliwal.com/blog/2008/10/implementing-trap-receiver-in-30-minutes-using-apache-mina/#comments</comments>
		<pubDate>Wed, 22 Oct 2008 10:24:26 +0000</pubDate>
		<dc:creator>ashish</dc:creator>
				<category><![CDATA[Apache MINA]]></category>
		<category><![CDATA[Network Programming]]></category>
		<category><![CDATA[How-to]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Trap Receiver]]></category>

		<guid isPermaLink="false">http://www.ashishpaliwal.com/blog/?p=157</guid>
		<description><![CDATA[Will continues to post articles about MINA, to be updated,  Subscribe in a reader Yes, we are going to implement a SNMP trap receiver in less than 30 minutes. If you have been following my post on Apache MINA, this would be a natural extension to it. In this article, we shall bring together all [...]]]></description>
			<content:encoded><![CDATA[<p><script type="text/javascript"><!--
google_ad_client = "pub-6961884887741817";
/* 468x15LinkUnit */
google_ad_slot = "4400881690";
google_ad_width = 468;
google_ad_height = 15;
// --></script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script></p>
<p>Will continues to post articles about MINA, to be updated, <a rel="alternate" type="application/rss+xml" href="http://feedproxy.google.com/AshishsTechBlog"><img style="vertical-align:middle;border:0" src="http://www.feedburner.com/fb/images/pub/feed-icon16x16.png" alt="" /></a> <a rel="alternate" type="application/rss+xml" href="http://feedproxy.google.com/AshishsTechBlog">Subscribe in a reader</a></p>
<p>Yes, we are going to implement a SNMP trap receiver in less than 30 minutes. If you have been following my post on Apache MINA, this would be a natural extension to it. In this article, we shall bring together all our components to build the system.</p>
<p> <strong>Pre-requisites:</strong></p>
<p><strong> <span style="font-weight: normal;">Please read through these articles. You can find all these posts on <a href="http://www.ashishpaliwal.com/blog/apache-mina/">Apache MINA</a></span></strong></p>
<ul type="disc">
<li>What is Apache MINA</li>
<li>Apache MINA based Server Application Architecture</li>
<li>Implementing UDP Server using Apache MINA</li>
<li>Implementing SNMP4J Decoder for Apache MINA</li>
</ul>
<p> To execute the code, you need following jars</p>
<ul type="disc">
<li>mina-core-2.0.0-M1.jar</li>
<li>slf4j-api-1.5.0.jar</li>
<li>slf4j-log4j12-1.5.0.jar</li>
<li>log4j-1.2.15.jar</li>
<li>SNMP4J.jar</li>
</ul>
<p> I am assuming that you have read my previous posts and jumping straight to the implementations. The high level architecture is explained in the post Apache MINA based Server Application Architecture</p>
<p><strong>Architecture</strong> </p>
<p><a href="http://www.ashishpaliwal.com/blog/wp-content/uploads/2008/10/traprcvrarchitecture1.png"><img class="aligncenter size-full wp-image-164" title="traprcvrarchitecture1" src="http://www.ashishpaliwal.com/blog/wp-content/uploads/2008/10/traprcvrarchitecture1.png" alt="" width="500" height="238" /></a></p>
<p>Let’s understand the flow here and see what all we need to do to process a trap</p>
<ul type="disc">
<li class="MsoNormal">Receive      the trap over UDP</li>
<li class="MsoNormal">Decode      the Trap</li>
<li class="MsoNormal">Dump      the Trap</li>
</ul>
<p>Lets see how each of the these maps to the code we have already written</p>
<p><a style="text-decoration: none;" href="http://www.ashishpaliwal.com/blog/wp-content/uploads/2008/10/traprcvrcomponents1.png"><span style="color: #000000;"><br />
 </span><img class="aligncenter size-full wp-image-160" style="text-decoration: underline;" title="traprcvrcomponents1" src="http://www.ashishpaliwal.com/blog/wp-content/uploads/2008/10/traprcvrcomponents1.png" alt="" width="500" height="248" /></a></p>
<p>It's a now simple to understand that we have reused all the components to create the Server. Let me not write too much, and jump straight to the code <span><span>J</span></span></p>
<p><strong> The Server Code</strong></p>
<p><a href="http://www.ashishpaliwal.com/blog/wp-content/uploads/2008/10/trapserver.png"><img class="aligncenter size-full wp-image-161" title="trapserver" src="http://www.ashishpaliwal.com/blog/wp-content/uploads/2008/10/trapserver.png" alt="" width="500" height="339" /></a></p>
<p>The only change that we did to the UDP Server code was to add a Protocol Codec. At line 36, we added our custom ProtocolCodecFiler. The SNMPCodecFactory return the instance of our SNMP4J codec. There is not much code and this construct is fairly simple, and explained very well in MINA’s documentation. From the main method, we just need to call the method initialize() and our trap receiver starts.</p>
<p> </p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-6961884887741817";
/* 468x15LinkUnit */
google_ad_slot = "4400881690";
google_ad_width = 468;
google_ad_height = 15;
// --></script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script><br />
 <strong>References</strong></p>
<ul type="disc">
<li><a href="http://mina.apache.org/">http://mina.apache.org/</a></li>
<li><a href="http://www.snmp4j.org/">http://www.snmp4j.org/</a></li>
</ul>
<p><script type="text/javascript"><!--
google_ad_client = "pub-6961884887741817";
/* 468x60ImageOnly */
google_ad_slot = "0221726572";
google_ad_width = 468;
google_ad_height = 60;
// --></script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ashishpaliwal.com/blog/2008/10/implementing-trap-receiver-in-30-minutes-using-apache-mina/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Implementing UDP Server using Apache MINA</title>
		<link>http://www.ashishpaliwal.com/blog/2008/10/implementing-udp-server-using-apache-mina/</link>
		<comments>http://www.ashishpaliwal.com/blog/2008/10/implementing-udp-server-using-apache-mina/#comments</comments>
		<pubDate>Tue, 21 Oct 2008 07:07:28 +0000</pubDate>
		<dc:creator>ashish</dc:creator>
				<category><![CDATA[Network Programming]]></category>
		<category><![CDATA[Apache MINA]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[UDP]]></category>

		<guid isPermaLink="false">http://www.ashishpaliwal.com/blog/?p=151</guid>
		<description><![CDATA[In my last post we created a UDP client using Apache MINA. Lets turn the table and implement the Server side. Let's see how using Apache MINA reduces the effort to create a UDP Server. Steps to create a UDP Server using java.net API's Create a Socket and listen for incoming connection Process each packet [...]]]></description>
			<content:encoded><![CDATA[<p>In my last post we created a UDP client using Apache MINA. Lets turn the table and implement the Server side. Let's see how using Apache MINA reduces the effort to create a UDP Server.</p>
<p>Steps to create a UDP Server using java.net API's</p>
<ol>
<li>Create a Socket and listen for incoming connection</li>
<li>Process each packet in a separate thread <img src='http://www.ashishpaliwal.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  (I hate this, unfortunately need this to have high processing rate)</li>
<li>Parse and process the request and optionally send response (Lets omit this to keep things simple)</li>
</ol>
<div>Lets see how to achieve the same using Apache MINA</div>
<div>
<ol>
<li>Create a NioDatagramAcceptor</li>
<li>Add an IoHandler</li>
<li>Bind and make application ready to receive</li>
</ol>
</div>
<div>That's it <img src='http://www.ashishpaliwal.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </div>
<div>Before we dive into the code, lets see some assumption made to run this</div>
<div>
<ul>
<li>Our protocol is carrying Strings in UDP packet</li>
<li>We shall not do any transformation on the packets received. We shall just dump the content</li>
</ul>
<div><strong>The Handler</strong></div>
<p> </p>
<div><a href="http://www.ashishpaliwal.com/blog/wp-content/uploads/2008/10/udpsrvhandler.png"><img class="aligncenter size-full wp-image-142" title="udpsrvhandler" src="http://www.ashishpaliwal.com/blog/wp-content/uploads/2008/10/udpsrvhandler.png" alt="" width="500" height="192" /></a></div>
<p><script type="text/javascript"><!--
google_ad_client = "pub-6961884887741817";
/* 468x15LinkUnit */
google_ad_slot = "4400881690";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p>The Handler is in its basic form. Our only method of interest is messageReceived. Since we know that we are getting "String" message without any transformation, we could easily create a new string from the bytes received. A wonderful thing to note about this API is the parameter "<em>message</em>". This makes the API generic enough to cater to any kind of objects. If we had used a ProtocolCodec in the chain and had transformed the byte[] into a custom Object, we would have type-casted <em>message </em>to that object.</p>
<div>That's all in the handler.</div>
<p> </p>
<div><strong>The Server</strong></div>
<div>Lets see the main Server code</div>
<p> </p>
<div><a href="http://www.ashishpaliwal.com/blog/wp-content/uploads/2008/10/minaudpsrv.png"><img class="aligncenter size-full wp-image-143" title="minaudpsrv" src="http://www.ashishpaliwal.com/blog/wp-content/uploads/2008/10/minaudpsrv.png" alt="" width="500" height="379" /></a></div>
<p> <script type="text/javascript"><!--
google_ad_client = "pub-6961884887741817";
/* 468x15LinkUnit */
google_ad_slot = "4400881690";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<div>The Server is even simpler than client <img src='http://www.ashishpaliwal.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </div>
<div>We create an instance of NioDatagramAcceptor and add our custom handler to it. We then bind to the port desired. Here I have made it bind to the default port, code can be customized to bind to any port desired.</div>
<p>So what does 31 does. There is wonderful description of this option at <a href="http://www.unixguide.net/network/socketfaq/4.5.shtml">http://www.unixguide.net/network/socketfaq/4.5.shtml</a><br />
The main function is pretty simple. The Server is ready. You can run it, using the Client from the post <a href="http://www.ashishpaliwal.com/blog/2008/10/implementing-udp-client-using-apache-mina/">Implementing UDP Client using Apache MINA</a></p>
<p><strong>References</strong></p>
<div>
<ul>
<li><a href="http://mina.apache.org/udp-tutorial.html">http://mina.apache.org/udp-tutorial.html</a></li>
</ul>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.ashishpaliwal.com/blog/2008/10/implementing-udp-server-using-apache-mina/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Updating Google Calendar with MS Project Tasks</title>
		<link>http://www.ashishpaliwal.com/blog/2008/10/updating-google-calendar-with-ms-project-tasks/</link>
		<comments>http://www.ashishpaliwal.com/blog/2008/10/updating-google-calendar-with-ms-project-tasks/#comments</comments>
		<pubDate>Mon, 13 Oct 2008 13:52:19 +0000</pubDate>
		<dc:creator>ashish</dc:creator>
				<category><![CDATA[Application Programming]]></category>
		<category><![CDATA[Apache POI]]></category>
		<category><![CDATA[GData API]]></category>
		<category><![CDATA[Google Calendar]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Microsoft Project]]></category>
		<category><![CDATA[MPXJ]]></category>
		<category><![CDATA[Project Management]]></category>
		<category><![CDATA[Task Tracking]]></category>

		<guid isPermaLink="false">http://www.ashishpaliwal.com/blog/?p=67</guid>
		<description><![CDATA[UPDATE Have an updated version of this writeup at http://www.ashishpaliwal.com/blog/2011/07/updating-google-calendar-with-ms-project-revisited/ I am back, as promised. Please read my earlier post Processing Microsoft Project File in Java using MPXJ. In this post we shall take an mpp and update the Google Calendar with the task details. The question is why would anyone do that?  Lets cook the [...]]]></description>
			<content:encoded><![CDATA[<p>UPDATE</p>
<p>Have an updated version of this writeup at <a href="http://www.ashishpaliwal.com/blog/2011/07/updating-google-calendar-with-ms-project-revisited/">http://www.ashishpaliwal.com/blog/2011/07/updating-google-calendar-with-ms-project-revisited/</a></p>
<hr>
<p>I am back, as promised. Please read my earlier post <a rel="bookmark" href="http://www.ashishpaliwal.com/blog/?p=58" target="_blank">Processing Microsoft Project File in Java using MPXJ</a>.</p>
<p>In this post we shall take an mpp and update the Google Calendar with the task details. The question is why would anyone do that? </p>
<p>Lets cook the story. A small team is working and the poor Project Manager share the Schedule with the team. The team is so busy coding that they forget to look at the dates, and the tasks they must be starting on. The poor Project Manager himself loose track unless he keeps MS Project Open on his desktop :-( A pretty common situation <img src='http://www.ashishpaliwal.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  </p>
<p>Have faced this situation and decided to organize myself and this post is outcome of that. The driving force was "Out of sight, is out of mind". So my assumption was if the team has a visual of the task dates, the chances of task slippage shall reduce a lot. </p>
<p>In this post, have built upon the my previous post to create an MPP parsing function. Have tried to keep the code in simplest form, so that it can customized later to specific needs. Have created a sample Schedule for this activity and used it for the implementation. Here is how it looks.</p>
<p> </p>
<div id="attachment_68" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.ashishpaliwal.com/blog/wp-content/uploads/2008/10/mpp.png"><img class="size-medium wp-image-68" title="mpp" src="http://www.ashishpaliwal.com/blog/wp-content/uploads/2008/10/mpp-300x39.png" alt="Google Calendar updater Project Schedule" width="300" height="39" /></a><p class="wp-caption-text">Google Calendar updater Project Schedule</p></div>
<p>The schdule is simple, some date, and tasks with dependencies. The concept shall work for any number of tasks.</p>
<p>Following are the steps that we need to perform:</p>
<ol>
<li>Parse the mpp file</li>
<li>Create a Calendar Service (Lets assume that the Calendar is already there, though it is possible to <span><span>programmatically</span></span> create the same)</li>
<li>Get All tasks from MPP, and create Calendar Entries in Google Calendar</li>
</ol>
<div><strong>The Code</strong></div>
<div>
<div id="attachment_69" class="wp-caption aligncenter" style="width: 510px"><a href="http://www.ashishpaliwal.com/blog/wp-content/uploads/2008/10/gcalupdatecode.png"><img class="size-full wp-image-69" title="Google Calendar Entry Creation Code" src="http://www.ashishpaliwal.com/blog/wp-content/uploads/2008/10/gcalupdatecode.png" alt="Google Calendar Entry Creation Code" width="500" height="480" /></a><p class="wp-caption-text">Google Calendar Entry Creation Code</p></div>
<p><script type="text/javascript"><!--
google_ad_client = "ca-pub-6961884887741817";
/* 468x60ImageOnly */
google_ad_slot = "0221726572";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p>The implementation is fairly simple. We have 3 functions:</p>
<ul>
<li>translateTaskToCalendarEventEntry() - Converts an Task into CalendarEventEntry, which can be added to Google Calendar</li>
<li>updateCalendar() - Takes input of all the Tasks from MPP, translates into CalendarEventEntry (using function translateTaskToCalendarEventEntry) and update the Calendar</li>
<li>updateGoogleCalendarWithMPP() - Parses the MPP using the util function from my previous post, and calls the API above to update the Calendar.</li>
</ul>
<p>Google Calendar API usage is described in details on Google's pages, hence won't discuss here.<br />
To use it for yourself, replace User Name and Password at line#70, with your User <span><span>Credentials</span></span>. Repace the URL at Line# 71 to point to your calendar.<br />
After running the program, this is how my Calendar looked like </p>
<dl id="attachment_72" class="wp-caption aligncenter" style="width: 510px;">
<dt class="wp-caption-dt"><a href="http://www.ashishpaliwal.com/blog/wp-content/uploads/2008/10/gcalview.png"><img class="size-full wp-image-72" title="Google Calendar View" src="http://www.ashishpaliwal.com/blog/wp-content/uploads/2008/10/gcalview.png" alt="Google Calendar View" width="500" height="232" /></a></dt>
<dd class="wp-caption-dd">Google Calendar View</dd>
</dl>
<p>A simple way to keep track of Tasks.<br />
 </p></div>
<p><script type="text/javascript"><!--
google_ad_client = "ca-pub-6961884887741817";
/* 468x60ImageOnly */
google_ad_slot = "0221726572";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ashishpaliwal.com/blog/2008/10/updating-google-calendar-with-ms-project-tasks/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Processing Microsoft Project File in Java using MPXJ</title>
		<link>http://www.ashishpaliwal.com/blog/2008/10/processing-microsoft-project-file-in-java-using-mpxj/</link>
		<comments>http://www.ashishpaliwal.com/blog/2008/10/processing-microsoft-project-file-in-java-using-mpxj/#comments</comments>
		<pubDate>Mon, 13 Oct 2008 08:46:32 +0000</pubDate>
		<dc:creator>ashish</dc:creator>
				<category><![CDATA[Application Programming]]></category>
		<category><![CDATA[Apache POI]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[MPXJ]]></category>

		<guid isPermaLink="false">http://www.ashishpaliwal.com/blog/?p=58</guid>
		<description><![CDATA[Many a time, I wished I had a utility that would read my projects mpp File and automatically alerted me about my tasks. Had created such a utilitly and this post desribes the process of reading MS Project Files in Java using MPXJ and Apache POI library. MPXJ - MPXJ is the java library used [...]]]></description>
			<content:encoded><![CDATA[<p>Many a time, I wished I had a utility that would read my projects mpp File and automatically alerted me about my tasks. Had created such a utilitly and this post desribes the process of reading MS Project Files in Java using MPXJ and Apache POI library.</p>
<p><strong><em>MPXJ</em></strong> - MPXJ is the java library used for parsing MS Project files. The lib depends upon Apache POI package for providing the functionality. MPXJ supports all the three formats for MS Project. The details can be found at the Home Page for MPXJ provided in references section</p>
<p>Let's start implementing. The code to read the File is fairly simple.</p>
<div id="attachment_60" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.ashishpaliwal.com/blog/wp-content/uploads/2008/10/codesnippets.png"><img class="size-medium wp-image-60" title="codesnippets" src="http://www.ashishpaliwal.com/blog/wp-content/uploads/2008/10/codesnippets-300x116.png" alt="Reading MS Project File in Java (Using MPXJ)" width="300" height="116" /></a><p class="wp-caption-text">Reading MS Project File in Java (Using MPXJ)</p></div>
<p> To read an MS Project file, we use projectReaderUtility class to get the instance of a ProjectReader, based on the extension. ProjectReader is the interface implemented by the classes that can read an MS Project file in mpxj library. Once we get the instance of ProjectReader, we need to invoke read API, passing the file name to be read. The API returns an instance of ProjectFile, containing all the details in the MS Project File. </p>
<p><strong><em>More about ProjectFile</em></strong> - ProjectFile is the class in mpxj, which contains all the information about an MS Project file. It has API's to access all Task details, as well other API's to extract and manipulate other metadata.</p>
<p>Is that it? The basic objective of reading is done. Now we can use the provided API to iterate and create applications to suite our needs. For example, to list all the tasks, use getAllTasks(), it returns a List of Tasks. Custom logic can be applied to manipulate this list as desired, like filtering the tasks based on resources or date.</p>
<p>What's next?</p>
<p>I am working on the prototype to read the MS Project File and update the Google Calendar with Task details, based on Start Date.</p>
<p>References</p>
<ul>
<li><a href="http://mpxj.sourceforge.net/index.html">http://mpxj.sourceforge.net/index.html</a></li>
<li><a href="http://poi.apache.org/index.html">http://poi.apache.org/index.html</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.ashishpaliwal.com/blog/2008/10/processing-microsoft-project-file-in-java-using-mpxj/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>(N)IO Frameworks in Java</title>
		<link>http://www.ashishpaliwal.com/blog/2008/10/nio-frameworks-in-java/</link>
		<comments>http://www.ashishpaliwal.com/blog/2008/10/nio-frameworks-in-java/#comments</comments>
		<pubDate>Mon, 13 Oct 2008 04:55:11 +0000</pubDate>
		<dc:creator>ashish</dc:creator>
				<category><![CDATA[Network Programming]]></category>
		<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Java IO frameworks]]></category>
		<category><![CDATA[Networking]]></category>

		<guid isPermaLink="false">http://www.ashishpaliwal.com/blog/?p=47</guid>
		<description><![CDATA[In this post, I have tried to briefly capture list of available Java IO application frameworks. IO Frameworks reduces the development time by providing additional features over the bare-bone IO API's provided with Java. Here is the definition I have used for the Framework "An (N)IO Framework is a library, that provides easy to use [...]]]></description>
			<content:encoded><![CDATA[<p>In this post, I have tried to briefly capture list of available Java IO application frameworks. IO Frameworks reduces the development time by providing additional features over the bare-bone IO API's provided with Java.</p>
<p>Here is the definition I have used for the Framework</p>
<p>"<em>An (N)IO Framework is a library, that provides easy to use API by shielding low level complexity of IO and provides rich and reusable API's to create robust and scalable Networking Applications</em>".</p>
<p>A key point here is, only complexity is reduced, the power of low level API's is still available.</p>
<p>Have been using Apache MINA for a while, and found some similar and powerful frameworks. The idea is to share the result of searches. I don't intent to compare them on their performances or features. The text for the frameworks have been picked from the respective websites.</p>
<ul>
<li><a href="http://mina.apache.org/" target="_blank">Apache MINA</a>   - MINA (Multipurpose Infrastructure for Network Applications) is a network application framework which helps users develop high performance and high scalability network applications easily.</li>
<li><a href="http://sourceforge.net/projects/xsocket" target="_blank">xSockets</a> - xSocket is a lightweight java nio-based server framework to build high performance, high scalable, multithreaded servers. It supports writing synchronous and asynchronous client-side applications as well as server-side applications in a very intuitive way  </li>
<li><a href="https://grizzly.dev.java.net/" target="_blank">Grizzly</a> - The Grizzly framework has been designed to help developers to take         advantage of the Java™ NIO API. Grizzly goals is to help developers         to build scalable and robust servers using NIO.</li>
<li><a href="https://www.jboss.org/netty/" target="_blank">Netty</a> - Netty is a NIO client server framework which enables quick and easy development of network applications such as protocol servers and clients. It greatly simplifies and streamlines network programming such as TCP/IP socket server</li>
</ul>
<div>There are a few others, have picked up the popular ones. </div>
<div><strong>References</strong></div>
<div>
<ul>
<li><a href="http://java-source.net/open-source/network-servers">http://java-source.net/open-source/network-servers</a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.ashishpaliwal.com/blog/2008/10/nio-frameworks-in-java/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Implementing SNMP4J Decoder for Apache MINA</title>
		<link>http://www.ashishpaliwal.com/blog/2008/10/implementing-snmp4j-decoder-for-apache-mina/</link>
		<comments>http://www.ashishpaliwal.com/blog/2008/10/implementing-snmp4j-decoder-for-apache-mina/#comments</comments>
		<pubDate>Sat, 11 Oct 2008 14:01:40 +0000</pubDate>
		<dc:creator>ashish</dc:creator>
				<category><![CDATA[Apache MINA]]></category>
		<category><![CDATA[Application Programming]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Network Management]]></category>
		<category><![CDATA[SNMP]]></category>
		<category><![CDATA[SNMP4J]]></category>

		<guid isPermaLink="false">http://www.ashishpaliwal.com/blog/?p=10</guid>
		<description><![CDATA[Recently started evaluating Apache MINA. So thought about building a Trap Receiver using Apache MINA. Refer to one of my posting on What is Apache MINA? Design In this post we shall concentrate on just writing the ProtocolDecoder The code snippet using SNMP4J library is public class SNMP4JCodec extends ProtocolDecoderAdapter { static Logger logger = LoggerFactory.getLogger(SNMP4JCodec.class); [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">Recently started evaluating Apache MINA. So thought about building a Trap Receiver using Apache MINA. Refer to one of my posting on <a href="http://www.ashishpaliwal.com/blog/2008/09/11/what-is-apache-mina/">What is Apache MINA?</a></p>
<div><span><strong>Design</strong></span></div>
<div><a href="http://3.bp.blogspot.com/_1X9TSfIQfXM/SMkET4LY59I/AAAAAAAAAC8/CbVNzkPENvo/s1600-h/snmp4jcodec.JPG" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img id="BLOGGER_PHOTO_ID_5244727980593833938" class="aligncenter" src="http://3.bp.blogspot.com/_1X9TSfIQfXM/SMkET4LY59I/AAAAAAAAAC8/CbVNzkPENvo/s320/snmp4jcodec.JPG" border="0" alt="" /></a></div>
<div>In this post we shall concentrate on just writing the ProtocolDecoder</div>
<div>The code snippet using SNMP4J library is</div>
<div>
<pre class="brush: java">
public class SNMP4JCodec extends ProtocolDecoderAdapter {

 static Logger logger = LoggerFactory.getLogger(SNMP4JCodec.class);

 public void decode(IoSession ioSession, IoBuffer ioBuffer,
                    ProtocolDecoderOutput protocolDecoderOutput) throws Exception {
     ByteBuffer pduBuffer = ioBuffer.buf();
     // Decode the bytes using SNMP4J API&#039;s
     PDU pdu = new PDU();
     try {
         BERInputStream berStream = new BERInputStream(pduBuffer);
         BER.MutableByte mutableByte = new BER.MutableByte();
         int length = BER.decodeHeader(berStream, mutableByte);
         int startPos = (int)berStream.getPosition();

         if (mutableByte.getValue() != BER.SEQUENCE) {
           String txt = &quot;SNMPv2c PDU must start with a SEQUENCE&quot;;
           throw new IOException(txt);
         }
         Integer32 version = new Integer32();
         version.decodeBER(berStream);

         // decode community string
         OctetString securityName = new OctetString();
         securityName.decodeBER(berStream);

         // decode the remaining PDU
         pdu.decodeBER(berStream);
         logger.debug(&quot;PDU - &quot;+pdu);
     } catch (Exception ex) {
         ex.printStackTrace();
     }
     protocolDecoderOutput.write(pdu);
 }
}
</pre>
<p>The code converts ByteBuffer into an SNMP PDU using SNMP4J  library. Similarly, we can use Adventnet or joesnmp to convert the byte stream into SNMP PDU's</p>
<p>NOTE: Custome Error handling need to be implemented, as per the strategy</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.ashishpaliwal.com/blog/2008/10/implementing-snmp4j-decoder-for-apache-mina/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

