<?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>Thu, 03 Jun 2010 05:30:03 +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>Awaken the Giant Within</title>
		<link>http://www.anandsekar.com/2010/06/03/awaken-the-giant-within/</link>
		<comments>http://www.anandsekar.com/2010/06/03/awaken-the-giant-within/#comments</comments>
		<pubDate>Thu, 03 Jun 2010 05:03:44 +0000</pubDate>
		<dc:creator>anandsekar</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Book Review]]></category>

		<guid isPermaLink="false">http://www.anandsekar.com/2010/06/03/awaken-the-giant-within/</guid>
		<description><![CDATA[
The main theme of the book is to how to identify goals and stay committed to them. The author asserts that decisions are to be made based on the long term and once decided one should stay committed to them and constantly take actions to reach ones goals. Again an instance of the author stressing [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://ecx.images-amazon.com/images/I/51WdpQEx9mL._SS500_.jpg" alt="" /><br />
The main theme of the book is to how to identify goals and stay committed to them. The author asserts that decisions are to be made based on the long term and once decided one should stay committed to them and constantly take actions to reach ones goals. Again an instance of the author stressing the need to stay committed and not merely interested in your goals. The author goes on to summarize how we as human beings react to pain and pleasure, and how one could leverage this small fact to stay committed. The author also acknowledges the role mental models and beliefs play in our decision making and how important it is to revaluate our beliefs so that we make sound commitments. Finally the author encourages one to write down their goals so that it forms a strong cognitive purpose in our daily lives.</p>
<p>After listening to this book I decided to write down my goals. I will also be soul searching to “why” I pursue the journey of success. The latter is influenced by the book “Three Feet From Gold”.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.anandsekar.com/2010/06/03/awaken-the-giant-within/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Self Esteem</title>
		<link>http://www.anandsekar.com/2010/06/03/self-esteem/</link>
		<comments>http://www.anandsekar.com/2010/06/03/self-esteem/#comments</comments>
		<pubDate>Thu, 03 Jun 2010 04:04:58 +0000</pubDate>
		<dc:creator>anandsekar</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.anandsekar.com/2010/06/03/self-esteem/</guid>
		<description><![CDATA[I was listening to the audio book “How to Raise Happy, Healthy, Self-Confident Children” by Brian Tracy, and the primary theme in the first chapter is to raise your child with high sense of self esteem. It got me thinking about my childhood where Ayya and Amma at every instance expressed how special and capable [...]]]></description>
			<content:encoded><![CDATA[<p>I was listening to the audio book “How to Raise Happy, Healthy, Self-Confident Children” by Brian Tracy, and the primary theme in the first chapter is to raise your child with high sense of self esteem. It got me thinking about my childhood where Ayya and Amma at every instance expressed how special and capable I was, and till date I carry a good sense of self esteem that helps me with every moment of life. I feel so thankful and hopefully myself and Priya will be able to do the same for Aradhana.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.anandsekar.com/2010/06/03/self-esteem/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<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>3</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>1</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>
	</channel>
</rss>
