<?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>Anand Rajasekar</title>
	<atom:link href="http://www.anandsekar.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.anandsekar.com</link>
	<description>ரெங்கசாமி ஆனந்த் சேகர் ராஜசேகர்</description>
	<lastBuildDate>Tue, 09 Feb 2010 15:37:29 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Timemachine and Psync</title>
		<link>http://www.anandsekar.com/2010/02/09/timemachine-and-psync/</link>
		<comments>http://www.anandsekar.com/2010/02/09/timemachine-and-psync/#comments</comments>
		<pubDate>Tue, 09 Feb 2010 15:36:35 +0000</pubDate>
		<dc:creator>anandsekar</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.anandsekar.com/?p=96</guid>
		<description><![CDATA[I have started using Timemachine to backup my computer. It was very simple to setup. One nice feature is that internally the incremental backups use links to refer to unchanged old files so opening the backup in finder shows the complete view.
For my secondary backup snapshot I use pync which synchronizes my data with my [...]]]></description>
			<content:encoded><![CDATA[<p>I have started using Timemachine to backup my computer. It was very simple to setup. One nice feature is that internally the incremental backups use links to refer to unchanged old files so opening the backup in finder shows the complete view.<br />
For my secondary backup snapshot I use <a href="http://www.dan.co.jp/cases/macosx/psync.html">pync</a> which synchronizes my data with my network hard drive.<br />
I had bad experiences with all the GUI frontends to psync, so I would recommend to stay away from the GUI and stick to scripts.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.anandsekar.com/2010/02/09/timemachine-and-psync/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SyncBack vs SyncToy</title>
		<link>http://www.anandsekar.com/2009/11/14/syncback-vs-synctoy/</link>
		<comments>http://www.anandsekar.com/2009/11/14/syncback-vs-synctoy/#comments</comments>
		<pubDate>Sat, 14 Nov 2009 13:24:30 +0000</pubDate>
		<dc:creator>anandsekar</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.anandsekar.com/?p=93</guid>
		<description><![CDATA[I have been using Microsoft&#8217;s synctoy a lot. After moving all my computing to a Mac, I still have been running synctoy on parallels to get my backups done. When moving from Vista to Windows 7 I found so many quirks in synctoy that I have finally settled with SyncBack. SyncToy maintains a database of [...]]]></description>
			<content:encoded><![CDATA[<p>I have been using Microsoft&#8217;s synctoy a lot. After moving all my computing to a Mac, I still have been running synctoy on parallels to get my backups done. When moving from Vista to Windows 7 I found so many quirks in synctoy that I have finally settled with SyncBack. SyncToy maintains a database of the file meta data and hence has the ability to find out which files were deleted in a synchronized folder, however since it has a database using your existing backup with a new synctoy installation just does not work. You have to redo the entire backup, which was not an option as I had about 40 GB of data. </p>
<p>I tried SyncBack and I I have been very happy. It is much much faster than sync toy, always consistent and simple. Since it does not store the file metadata, and you delete a file in the primary folder, you need to specify specify if you want to delete or copy over the file from the passive folder pair.<br />
<a href="http://www.2brightsparks.com/freeware/freeware-hub.html"></p>
]]></content:encoded>
			<wfw:commentRss>http://www.anandsekar.com/2009/11/14/syncback-vs-synctoy/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Optimizing Windows Vista for Parallels</title>
		<link>http://www.anandsekar.com/2009/11/02/optimizing-windows-vista-for-parallels/</link>
		<comments>http://www.anandsekar.com/2009/11/02/optimizing-windows-vista-for-parallels/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 03:38:06 +0000</pubDate>
		<dc:creator>anandsekar</dc:creator>
				<category><![CDATA[mac]]></category>

		<guid isPermaLink="false">http://www.anandsekar.com/?p=83</guid>
		<description><![CDATA[I have finally moved all my computing to my MacBook. I used Parallels to run Windows Vista in Mac mostly to run Quicken. It was painfully slow. To speed up Windows Vista open up the display performance settings and set it to &#8220;Adjust for Best Performance&#8221;. With this setting Windows Vista is considerably faster

]]></description>
			<content:encoded><![CDATA[<p>I have finally moved all my computing to my MacBook. I used Parallels to run Windows Vista in Mac mostly to run Quicken. It was painfully slow. To speed up Windows Vista open up the display performance settings and set it to &#8220;Adjust for Best Performance&#8221;. With this setting Windows Vista is considerably faster<br />
<a href="http://www.anandsekar.com/wp-content/uploads/2009/11/parallels-picture.png"><img src="http://www.anandsekar.com/wp-content/uploads/2009/11/parallels-picture.png" alt="" title="parallels-picture" class="aligncenter size-thumbnail wp-image-85" width="500"/></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.anandsekar.com/2009/11/02/optimizing-windows-vista-for-parallels/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Time Lapse of Sunset from Milpitas Hills</title>
		<link>http://www.anandsekar.com/2009/06/08/time-lapse-of-sunset-from-milpitas-hills/</link>
		<comments>http://www.anandsekar.com/2009/06/08/time-lapse-of-sunset-from-milpitas-hills/#comments</comments>
		<pubDate>Mon, 08 Jun 2009 08:24:50 +0000</pubDate>
		<dc:creator>anandsekar</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.anandsekar.com/?p=81</guid>
		<description><![CDATA[
Untitled from Anand Rajasekar on Vimeo.
]]></description>
			<content:encoded><![CDATA[<p><object width="400" height="300"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=5056740&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=5056740&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="300"></embed></object>
<p><a href="http://vimeo.com/5056740">Untitled</a> from <a href="http://vimeo.com/user1771101">Anand Rajasekar</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.anandsekar.com/2009/06/08/time-lapse-of-sunset-from-milpitas-hills/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Tomcat Initializing Servlet Twice</title>
		<link>http://www.anandsekar.com/2009/05/28/tomcat-initializing-servlet-twice/</link>
		<comments>http://www.anandsekar.com/2009/05/28/tomcat-initializing-servlet-twice/#comments</comments>
		<pubDate>Thu, 28 May 2009 16:44:21 +0000</pubDate>
		<dc:creator>anandsekar</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.anandsekar.com/?p=77</guid>
		<description><![CDATA[A web application is configured using tomcat&#8217;s server.xml and the context.xml. There some configurations that cause web applications to initialize twice like

Duplicate definition of context in context.xml and server.xml
Bugs in tomcat launchers for eclipse that create duplicate context definitions
Duplicate definition of contexts when defining multiple hosts

In my case I had a proper definition of the [...]]]></description>
			<content:encoded><![CDATA[<p>A web application is configured using tomcat&#8217;s server.xml and the context.xml. There some configurations that cause web applications to initialize twice like</p>
<ol>
<li>Duplicate definition of context in context.xml and server.xml</li>
<li>Bugs in tomcat launchers for eclipse that create duplicate context definitions</li>
<li>Duplicate definition of contexts when defining multiple hosts</li>
</ol>
<p>In my case I had a proper definition of the context and the problem was I was using a exploded war deployment format and my root directory was named <app>.war , This was causing tomcat to treat it as a war file and a directory and initializing it twice.</p>
<p>The problem vanished after removing the .war extension to the directory. This happened to me on tomcat 6.0.16</p>
]]></content:encoded>
			<wfw:commentRss>http://www.anandsekar.com/2009/05/28/tomcat-initializing-servlet-twice/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Three makes it perfect</title>
		<link>http://www.anandsekar.com/2009/05/18/three-makes-it-perfect/</link>
		<comments>http://www.anandsekar.com/2009/05/18/three-makes-it-perfect/#comments</comments>
		<pubDate>Mon, 18 May 2009 04:31:11 +0000</pubDate>
		<dc:creator>anandsekar</dc:creator>
				<category><![CDATA[Photography]]></category>
		<category><![CDATA[collage]]></category>

		<guid isPermaLink="false">http://www.anandsekar.com/?p=74</guid>
		<description><![CDATA[Sometimes creating a collage of similar photographs adds a stunning effect. Here are three photographs of Aradhana stacking blocks.

]]></description>
			<content:encoded><![CDATA[<p>Sometimes creating a collage of similar photographs adds a stunning effect. Here are three photographs of Aradhana stacking blocks.<br />
<a href="http://www.anandsekar.com/wp-content/uploads/2009/05/aradhana-stacking-blocks.jpg"><img src="http://www.anandsekar.com/wp-content/uploads/2009/05/aradhana-stacking-blocks-300x240.jpg" alt="" title="aradhana-stacking-blocks" width="300" height="240" class="alignnone size-medium wp-image-75" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.anandsekar.com/2009/05/18/three-makes-it-perfect/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Photographing Running Children</title>
		<link>http://www.anandsekar.com/2009/05/18/photographing-running-children/</link>
		<comments>http://www.anandsekar.com/2009/05/18/photographing-running-children/#comments</comments>
		<pubDate>Mon, 18 May 2009 04:17:16 +0000</pubDate>
		<dc:creator>anandsekar</dc:creator>
				<category><![CDATA[Photography]]></category>
		<category><![CDATA[AI Servo]]></category>

		<guid isPermaLink="false">http://www.anandsekar.com/?p=69</guid>
		<description><![CDATA[Capturing a sharp photograph of a running child can be quite a challenge. Canon has a focusing mode called AI Servo that makes focusing moving objects very easy. This mode uses the auto focus motor to continuously focus on the object in the center of the view finder. 

This photograph was taken with my Digtal [...]]]></description>
			<content:encoded><![CDATA[<p>Capturing a sharp photograph of a running child can be quite a challenge. Canon has a focusing mode called AI Servo that makes focusing moving objects very easy. This mode uses the auto focus motor to continuously focus on the object in the center of the view finder. </p>
<p><a href="http://www.anandsekar.com/wp-content/uploads/2009/05/img_3854-1.jpg"><img src="http://www.anandsekar.com/wp-content/uploads/2009/05/img_3854-1.jpg" alt="" title="img_3854-1" width="500" height="333" class="alignnone size-full wp-image-71" /></a><br />
This photograph was taken with my Digtal Rebel XT, 50mm prime lens at f/1.8  ISO 200 1/400s</p>
<p>AI Servo mode makes photographing running children much easier, especially when you are shooting with a high aperture in low light.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.anandsekar.com/2009/05/18/photographing-running-children/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Java Serialization Versioning with Externalizable</title>
		<link>http://www.anandsekar.com/2008/10/22/java-serialization-versioning-with-externalizable/</link>
		<comments>http://www.anandsekar.com/2008/10/22/java-serialization-versioning-with-externalizable/#comments</comments>
		<pubDate>Wed, 22 Oct 2008 05:39:06 +0000</pubDate>
		<dc:creator>anandsekar</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.anandsekar.com/?p=59</guid>
		<description><![CDATA[Java Serialization is a easy way to persist the state of Java Objects. However if the structure of the class changes the serialized bytes is invalidated by the changes. This article suggest how one could implement serialization with Externalizable with support for versions.
Consider a simple java class




public class SimpleObject implements Serializable &#123;


&#160; &#160; &#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>Java Serialization is a easy way to persist the state of Java Objects. However if the structure of the class changes the serialized bytes is invalidated by the changes. This article suggest how one could implement serialization with Externalizable with support for versions.</p>
<p>Consider a simple java class</p>
<div class="codesnip-container" >
<div class="codesnip">
<ol>
<li class="li1">
<div class="de1"><span class="kw2">public</span> <span class="kw2">class</span> SimpleObject <span class="kw2">implements</span> <a href="http://www.google.com/search?q=allinurl%3ASerializable+java.sun.com&#038;bntl=1"><span class="kw3">Serializable</span></a> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">private</span> <span class="kw4">int</span> field1;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">private</span> <span class="kw4">int</span> field2;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span> </div>
</li>
</ol>
</div>
</div>
<p>If the structure of the class changes, then the serialized bytes becomes incompatible and you would get the dreaded ClassCastException</p>
<div class="codesnip-container" >
<div class="codesnip">
<ol>
<li class="li1">
<div class="de1"><span class="kw2">public</span> <span class="kw2">class</span> SimpleObject <span class="kw2">implements</span> <a href="http://www.google.com/search?q=allinurl%3ASerializable+java.sun.com&#038;bntl=1"><span class="kw3">Serializable</span></a> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//private int field1; removed</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">private</span> <span class="kw4">int</span> field2;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">private</span> <span class="kw4">int</span> field3; <span class="co1">//added</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span> </div>
</li>
</ol>
</div>
</div>
<p>A good way to get complete control of the serialization and support version is by implementing Externalizable instead of Serializable.</p>
<p>Externalizable gives the programmer full control over how the class is serialized and de-serialized. It is common practice to add a version variable to support representations of the same class over time.</p>
<p>Consider first version of the same class</p>
<div class="codesnip-container" >
<div class="codesnip">
<ol>
<li class="li1">
<div class="de1"><span class="kw2">public</span> <span class="kw2">class</span> SimpleObject <span class="kw2">implements</span> <a href="http://www.google.com/search?q=allinurl%3AExternalizable+java.sun.com&#038;bntl=1"><span class="kw3">Externalizable</span></a> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">private</span> <span class="kw4">int</span> version=<span class="nu0">1</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">private</span> <span class="kw4">int</span> field1; </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">private</span> <span class="kw4">int</span> field2;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; @Override</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">public</span> <span class="kw4">void</span> readExternal<span class="br0">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AObjectInput+java.sun.com&#038;bntl=1"><span class="kw3">ObjectInput</span></a> in<span class="br0">&#41;</span> <span class="kw2">throws</span> <a href="http://www.google.com/search?q=allinurl%3AIOException+java.sun.com&#038;bntl=1"><span class="kw3">IOException</span></a>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?q=allinurl%3AClassNotFoundException+java.sun.com&#038;bntl=1"><span class="kw3">ClassNotFoundException</span></a> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; version=in.<span class="me1">readInt</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span>version==<span class="nu0">1</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; field1=in.<span class="me1">readInt</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; field2=in.<span class="me1">readInt</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">throw</span> <span class="kw2">new</span> <a href="http://www.google.com/search?q=allinurl%3AIOException+java.sun.com&#038;bntl=1"><span class="kw3">IOException</span></a><span class="br0">&#40;</span><span class="st0">&#8220;Invalid Version&#8221;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; @Override</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">public</span> <span class="kw4">void</span> writeExternal<span class="br0">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AObjectOutput+java.sun.com&#038;bntl=1"><span class="kw3">ObjectOutput</span></a> out<span class="br0">&#41;</span> <span class="kw2">throws</span> <a href="http://www.google.com/search?q=allinurl%3AIOException+java.sun.com&#038;bntl=1"><span class="kw3">IOException</span></a> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; out.<span class="me1">writeInt</span><span class="br0">&#40;</span>version<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; out.<span class="me1">writeInt</span><span class="br0">&#40;</span>field1<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; out.<span class="me1">writeInt</span><span class="br0">&#40;</span>field2<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span> </div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span> </div>
</li>
</ol>
</div>
</div>
<p>Now if the next version of the class needs to add a String and remove field2 the class would look like</p>
<div class="codesnip-container" >
<div class="codesnip">
<ol>
<li class="li1">
<div class="de1"><span class="kw2">public</span> <span class="kw2">class</span> SimpleObject <span class="kw2">implements</span> <a href="http://www.google.com/search?q=allinurl%3AExternalizable+java.sun.com&#038;bntl=1"><span class="kw3">Externalizable</span></a> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">private</span> <span class="kw4">int</span> version=<span class="nu0">2</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">private</span> <span class="kw4">int</span> field1; </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//private int field2; removed</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">private</span> <a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&#038;bntl=1"><span class="kw3">String</span></a> version2String;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; @Override</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">public</span> <span class="kw4">void</span> readExternal<span class="br0">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AObjectInput+java.sun.com&#038;bntl=1"><span class="kw3">ObjectInput</span></a> in<span class="br0">&#41;</span> <span class="kw2">throws</span> <a href="http://www.google.com/search?q=allinurl%3AIOException+java.sun.com&#038;bntl=1"><span class="kw3">IOException</span></a>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?q=allinurl%3AClassNotFoundException+java.sun.com&#038;bntl=1"><span class="kw3">ClassNotFoundException</span></a> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; version=in.<span class="me1">readInt</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span>version==<span class="nu0">1</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; field1=in.<span class="me1">readInt</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; in.<span class="me1">readInt</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<span class="co1">// ignore</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; version2String=<span class="st0">&#8220;&#8221;</span>;<span class="co1">// initialize to default</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span> <span class="kw1">else</span> <span class="kw1">if</span> <span class="br0">&#40;</span>version==<span class="nu0">2</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; field1=in.<span class="me1">readInt</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; version2String=<span class="br0">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&#038;bntl=1"><span class="kw3">String</span></a><span class="br0">&#41;</span> in.<span class="me1">readObject</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">throw</span> <span class="kw2">new</span> <a href="http://www.google.com/search?q=allinurl%3AIOException+java.sun.com&#038;bntl=1"><span class="kw3">IOException</span></a><span class="br0">&#40;</span><span class="st0">&#8220;Invalid Version&#8221;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; @Override</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">public</span> <span class="kw4">void</span> writeExternal<span class="br0">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AObjectOutput+java.sun.com&#038;bntl=1"><span class="kw3">ObjectOutput</span></a> out<span class="br0">&#41;</span> <span class="kw2">throws</span> <a href="http://www.google.com/search?q=allinurl%3AIOException+java.sun.com&#038;bntl=1"><span class="kw3">IOException</span></a> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; out.<span class="me1">writeInt</span><span class="br0">&#40;</span>version<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; out.<span class="me1">writeInt</span><span class="br0">&#40;</span>field1<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; out.<span class="me1">writeObject</span><span class="br0">&#40;</span>version2String<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span> </div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span> </div>
</li>
</ol>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.anandsekar.com/2008/10/22/java-serialization-versioning-with-externalizable/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Modifying Classpath at Runtime</title>
		<link>http://www.anandsekar.com/2008/08/27/modifying-classpath-at-runtime/</link>
		<comments>http://www.anandsekar.com/2008/08/27/modifying-classpath-at-runtime/#comments</comments>
		<pubDate>Wed, 27 Aug 2008 20:19:35 +0000</pubDate>
		<dc:creator>anandsekar</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.anandsekar.com/?p=52</guid>
		<description><![CDATA[A hackish way of modifying the classpath at runtime can be done in a way described at the java forums Modifying Classpath at Runtime
A cleaner approach is to configure your own classloader and set it as the threads context classloader




URL&#91;&#93; urls=new URL&#91;2&#93;;


URLClassLoader classLoader=new URLClassLoader&#40;urls&#41;;


Thread.currentThread&#40;&#41;.setContextClassLoader&#40;classLoader&#41;; 




This is extremely useful if your unit test cases have dependencies [...]]]></description>
			<content:encoded><![CDATA[<p>A hackish way of modifying the classpath at runtime can be done in a way described at the java forums <a href="http://forums.sun.com/thread.jspa?threadID=300557&#038;forumID=32">Modifying Classpath at Runtime</a><br />
A cleaner approach is to configure your own classloader and set it as the threads context classloader</p>
<div class="codesnip-container" >
<div class="codesnip">
<ol>
<li class="li1">
<div class="de1"><a href="http://www.google.com/search?q=allinurl%3AURL+java.sun.com&#038;bntl=1"><span class="kw3">URL</span></a><span class="br0">&#91;</span><span class="br0">&#93;</span> urls=<span class="kw2">new</span> <a href="http://www.google.com/search?q=allinurl%3AURL+java.sun.com&#038;bntl=1"><span class="kw3">URL</span></a><span class="br0">&#91;</span><span class="nu0">2</span><span class="br0">&#93;</span>;</div>
</li>
<li class="li1">
<div class="de1"><a href="http://www.google.com/search?q=allinurl%3AURLClassLoader+java.sun.com&#038;bntl=1"><span class="kw3">URLClassLoader</span></a> classLoader=<span class="kw2">new</span> <a href="http://www.google.com/search?q=allinurl%3AURLClassLoader+java.sun.com&#038;bntl=1"><span class="kw3">URLClassLoader</span></a><span class="br0">&#40;</span>urls<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><a href="http://www.google.com/search?q=allinurl%3AThread+java.sun.com&#038;bntl=1"><span class="kw3">Thread</span></a>.<span class="me1">currentThread</span><span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">setContextClassLoader</span><span class="br0">&#40;</span>classLoader<span class="br0">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
<p>This is extremely useful if your unit test cases have dependencies that you would like to load at runtime</p>
]]></content:encoded>
			<wfw:commentRss>http://www.anandsekar.com/2008/08/27/modifying-classpath-at-runtime/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>InheritableThreadLocal and Tomcat</title>
		<link>http://www.anandsekar.com/2008/05/08/inheritablethreadlocal-and-tomcat/</link>
		<comments>http://www.anandsekar.com/2008/05/08/inheritablethreadlocal-and-tomcat/#comments</comments>
		<pubDate>Thu, 08 May 2008 05:18:40 +0000</pubDate>
		<dc:creator>anandsekar</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[multithreading]]></category>
		<category><![CDATA[tomcat]]></category>

		<guid isPermaLink="false">http://www.anandsekar.com/2008/05/08/inheritablethreadlocal-and-tomcat/</guid>
		<description><![CDATA[InheritableThreadLocal does not work with tomcat as tomcat thread pool does not clear the thread local contacts after a request has been executed. This results in no good way to share information information between the parent and the child threads that are created using thread local variables. 
One way to solve this problem is to [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/InheritableThreadLocal.html">InheritableThreadLocal</a> does not work with tomcat as tomcat thread pool does not clear the thread local contacts after a request has been executed. This results in no good way to share information information between the parent and the child threads that are created using thread local variables. </p>
<p>One way to solve this problem is to maintain a reference to the parent thread by writing your own thread that is constructed by a thread factory.</p>
<div class="codesnip-container" >
<div class="codesnip">
<ol>
<li class="li1">
<div class="de1"><span class="kw2">public</span> <span class="kw2">class</span> MyThread <span class="kw2">extends</span> <a href="http://www.google.com/search?q=allinurl%3AThread+java.sun.com&#038;bntl=1"><span class="kw3">Thread</span></a> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">private</span> <a href="http://www.google.com/search?q=allinurl%3AThread+java.sun.com&#038;bntl=1"><span class="kw3">Thread</span></a> parent;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">public</span> MyThread<span class="br0">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AThread+java.sun.com&#038;bntl=1"><span class="kw3">Thread</span></a> parent<span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; super<span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">this</span>.<span class="me1">parent</span> = parent;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">public</span> <a href="http://www.google.com/search?q=allinurl%3AThread+java.sun.com&#038;bntl=1"><span class="kw3">Thread</span></a> getParent<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">return</span> parent;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span> </div>
</li>
</ol>
</div>
</div>
<div class="codesnip-container" >
<div class="codesnip">
<ol>
<li class="li1">
<div class="de1"><span class="co2">import java.util.concurrent.ThreadFactory;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">public</span> <span class="kw2">class</span> MyThreadFactory <span class="kw2">implements</span> ThreadFactory <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; @Override</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">public</span> <a href="http://www.google.com/search?q=allinurl%3AThread+java.sun.com&#038;bntl=1"><span class="kw3">Thread</span></a> newThread<span class="br0">&#40;</span><a href="http://www.google.com/search?q=allinurl%3ARunnable+java.sun.com&#038;bntl=1"><span class="kw3">Runnable</span></a> arg0<span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">return</span> <span class="kw2">new</span> MyThread<span class="br0">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AThread+java.sun.com&#038;bntl=1"><span class="kw3">Thread</span></a>.<span class="me1">currentThread</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span> </div>
</li>
</ol>
</div>
</div>
<div class="codesnip-container" >
<div class="codesnip">
<ol>
<li class="li1">
<div class="de1"><span class="co2">import java.util.HashMap;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co2">import java.util.Map;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">public</span> <span class="kw2">class</span> ClassNeedingInheritableThreadLocal <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">private</span> <a href="http://www.google.com/search?q=allinurl%3AMap+java.sun.com&#038;bntl=1"><span class="kw3">Map</span></a> inheritableThreadLocal=<span class="kw2">new</span> <a href="http://www.google.com/search?q=allinurl%3AHashMap+java.sun.com&#038;bntl=1"><span class="kw3">HashMap</span></a><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">public</span> <a href="http://www.google.com/search?q=allinurl%3AObject+java.sun.com&#038;bntl=1"><span class="kw3">Object</span></a> getInheritableThreadContext<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">return</span> inheritableThreadLocal.<span class="me1">get</span><span class="br0">&#40;</span>getThread<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">public</span> <span class="kw4">void</span> setInheritableThreadContext<span class="br0">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AObject+java.sun.com&#038;bntl=1"><span class="kw3">Object</span></a> context<span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inheritableThreadLocal.<span class="me1">put</span><span class="br0">&#40;</span>getThread<span class="br0">&#40;</span><span class="br0">&#41;</span>, context<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">private</span> <a href="http://www.google.com/search?q=allinurl%3AThread+java.sun.com&#038;bntl=1"><span class="kw3">Thread</span></a> getThread<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?q=allinurl%3AThread+java.sun.com&#038;bntl=1"><span class="kw3">Thread</span></a> currentThread=<a href="http://www.google.com/search?q=allinurl%3AThread+java.sun.com&#038;bntl=1"><span class="kw3">Thread</span></a>.<span class="me1">currentThread</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span>currentThread instanceof MyThread<span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; currentThread=getParent<span class="br0">&#40;</span><span class="br0">&#40;</span>MyThread<span class="br0">&#41;</span> currentThread<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">return</span> currentThread;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">public</span> <a href="http://www.google.com/search?q=allinurl%3AThread+java.sun.com&#038;bntl=1"><span class="kw3">Thread</span></a> getParent<span class="br0">&#40;</span>MyThread myThread<span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?q=allinurl%3AThread+java.sun.com&#038;bntl=1"><span class="kw3">Thread</span></a> parent=myThread.<span class="me1">getParent</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span>parent instanceof MyThread<span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">return</span> getParent<span class="br0">&#40;</span><span class="br0">&#40;</span>MyThread<span class="br0">&#41;</span> parent<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">return</span> parent;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span> </div>
</li>
</ol>
</div>
</div>
<p>Create a executor service by using our thread factory</p>
<div class="codesnip-container" >
<div class="codesnip">
<ol>
<li class="li1">
<div class="de1">ExecutorService service=Executors.<span class="me1">newFixedThreadPool</span><span class="br0">&#40;</span><span class="nu0">10</span>, <span class="kw2">new</span> MyThreadFactory<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
<p>Remember that you would need to clean up all the objects that were put in the thread local. This can be done with a filter or by using AOP.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.anandsekar.com/2008/05/08/inheritablethreadlocal-and-tomcat/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
