<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Javasight's Weblog</title>
	<atom:link href="http://javasight.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://javasight.wordpress.com</link>
	<description>Technology across minds.....</description>
	<lastBuildDate>Sun, 15 Jan 2012 07:24:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='javasight.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Javasight's Weblog</title>
		<link>http://javasight.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://javasight.wordpress.com/osd.xml" title="Javasight&#039;s Weblog" />
	<atom:link rel='hub' href='http://javasight.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Microsoft TECH.ED 2011 (Middle East) – DAY 1</title>
		<link>http://javasight.wordpress.com/2011/03/12/microsoft-tech-ed-2011-middle-east-%e2%80%93-day-1/</link>
		<comments>http://javasight.wordpress.com/2011/03/12/microsoft-tech-ed-2011-middle-east-%e2%80%93-day-1/#comments</comments>
		<pubDate>Sat, 12 Mar 2011 16:23:12 +0000</pubDate>
		<dc:creator>Franklin</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Day 1]]></category>
		<category><![CDATA[Dubai]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[TECH.ED]]></category>
		<category><![CDATA[TECH.ED 2011]]></category>

		<guid isPermaLink="false">http://javasight.wordpress.com/?p=331</guid>
		<description><![CDATA[Microsoft TECH.ED 2011 experiences of the First Day in Dubai<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javasight.wordpress.com&amp;blog=4467463&amp;post=331&amp;subd=javasight&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is the first time I am attending the Microsoft TECH.ED and I was really excited to know what was in stall for us. Like any company organized event (e.g.: IBM Smart SOA), it was more of a sales pitch of Microsoft’s Cloud platform – <strong>AZURE</strong> (its pronounced somewhat like ASSURE)</p>
<p>The Keynote was given<strong> </strong>by<strong> Mr. S. Somasegar</strong> and there were some interesting points that I could pick up, like <strong>ODATA</strong>. It is a new open data specification proposed and actively supported by Microsoft. It is completely based on REST. I also had the privilege to see a live demo on easily integrating a Windows 7 app with eBAY website (which exposed their data in the form of ODATA).A very good initiative but will have to wait and see how many vendors would easy support ODATA</p>
<p>An interesting announcement was that <strong>Kinect SDK</strong> will be available soon in Spring. That would be a very interesting thing to watch out for. As soon as the SDK is made available a proliferation of possibilities are going to hit the shores. The possibilities are endless and it would be the right time to think of how to leverage this technology in the business space and very likely in the medical and educational space. Kudos to Microsoft guys to bring out the Kinect SDK.</p>
<p>Also there were talks about <strong>Visual Studio 2010</strong> <strong>SP1 </strong>on what all enhancements and feature packs have been in place. Mr. S Somasegar claimed that the VS 2010 SP1 will be available to download on March 8<sup>th</sup>, if you are a MSDN subscriber. If not hard luck NON-MSDN guys, you can only download it on March 10<sup>th</sup>. Oh my goodness that is really going to pain…..Seriously.</p>
<p><strong>VS 2010 Load Testing</strong> feature pack has increased it virtual user limit from 250 to infinity. Good, but can you really spawn 250 virtual users from your developer machines? (Just a thought)</p>
<p>If that was not enough, enter <strong>VS 2010 Light Switch</strong> (Its still beta, hope it stays the same). The feature pack facilitates a developer to build applications in a jiffy and gives him the power to deploy the application on the desktop or browser, with the data-screen motto in mind.</p>
<p>This is what Jason Gander has to say about Light Switch: “At their core, most end user business applications combine two things:  <strong>data + screens</strong>.  LightSwitch is optimized around making these two things very simple.”</p>
<p>Come on MS guys, we are professional developers building serious enterprise applications. You really thing business applications are just screens and data. The real value of LightSwitch can be for hobbyist and kids to play around with technology and build prototypes, POCs etc, but building business applications, you got to be kidding me. If you don’t believe me, check out the comments by some users here (<a href="http://blogs.msdn.com/b/jasonz/archive/2010/08/03/introducing-microsoft-visual-studio-lightswitch.aspx">http://blogs.msdn.com/b/jasonz/archive/2010/08/03/introducing-microsoft-visual-studio-lightswitch.aspx</a>)</p>
<p>&nbsp;</p>
<p>Following the keynote were, 1 hour sessions by different speakers. You had to choose the session based on your preference of technology (which I figured out only on the second day)</p>
<p>Fascinated by the name of the session, “<strong>Enterprise Strategy &amp; Architecture Overview</strong>”, I had to leave Mr. Parimal Deshpande in 10 minutes although the room occupancy rate was pretty high. Not sure why, probably the strange taste of Star Bucks coffee in my mouth.</p>
<p>Next, I entered “<strong>Stepping Outside the Browser with Microsoft Silverlight 4</strong>”. The presentation was given by Mr. Daron Yondem. It was interesting with some of the new features supported by Silverlight when it runs outside the browser. Also elaborated with a demo as to how you could get the snapshot of a website and show it inside a Web Browser component. Quite a few quirky samples were also demonstrated which kept the audience attentive. Overall, was moderately worth listening too.</p>
<p>Next session was really jaw dropping and mostly mouth watering. I had been eagerly looking forward to it: “<strong>Lunch Break</strong>”. The food was good and thankfully less on variety. Sure helped me choose easily. I totally forgot about the dessert till I stepped out.</p>
<p>Evening session started with “<strong>Citrix &amp; Microsoft Virtualized and Optimized Desktops</strong>” given by Mr. Yannick Kunegel. The talk was really interesting and the occupancy was really high probably packing the room. Desktop virtualization seems to be a good option on tremendously cutting down on you Operation Costs. However, the Capex can be significantly higher as rightly questioned by a member of the audience. Fortunately, I did sit through the whole session.</p>
<p>Next session was “<strong>Using Cloud to Engage across a Diversity of Devices</strong>” by Mr. Marc Mercuri. Came to know about a couple of websites/frameworks such as TOWNHALL probably deployed on Windows Azure. Plan to check out the code base as it seems to be open source. By the way Mr. Marc , I seriously believe you need to bring down your pace a bit.</p>
<p>Finally “<strong>A Dive into Internet Explorer 9 for Designer &amp; Developers</strong>” by Ms. Asli Bilgin. The speaker kept claiming about the new tags that had been supported by IE 9. However these were mostly HTML 5 tags which have been long over due. Thanks a lot MS guys for supporting them quite quickly. A very interesting project MOSAIC 23/25 <a href="http://www.jumpman23mosaic.com/">http://www.jumpman23mosaic.com</a> was also shown. I would advice all to go check it out and it sure uses the power of Azure to do queries.</p>
<p>Disclaimer: I have been mostly working on JAVA technologies for quite sometime. However am not new to Microsoft technologies.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/javasight.wordpress.com/331/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/javasight.wordpress.com/331/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/javasight.wordpress.com/331/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/javasight.wordpress.com/331/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/javasight.wordpress.com/331/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/javasight.wordpress.com/331/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/javasight.wordpress.com/331/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/javasight.wordpress.com/331/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/javasight.wordpress.com/331/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/javasight.wordpress.com/331/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/javasight.wordpress.com/331/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/javasight.wordpress.com/331/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/javasight.wordpress.com/331/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/javasight.wordpress.com/331/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javasight.wordpress.com&amp;blog=4467463&amp;post=331&amp;subd=javasight&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://javasight.wordpress.com/2011/03/12/microsoft-tech-ed-2011-middle-east-%e2%80%93-day-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/34614a06c803826394b37239b2d3a1da?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Franklin</media:title>
		</media:content>
	</item>
		<item>
		<title>Monitoring with Spring and JAMon using JamonPerformanceMonitorInterceptor</title>
		<link>http://javasight.wordpress.com/2010/10/04/monitoring-with-spring-and-jamon-using-jamonperformancemonitorinterceptor/</link>
		<comments>http://javasight.wordpress.com/2010/10/04/monitoring-with-spring-and-jamon-using-jamonperformancemonitorinterceptor/#comments</comments>
		<pubDate>Mon, 04 Oct 2010 18:26:16 +0000</pubDate>
		<dc:creator>Franklin</dc:creator>
				<category><![CDATA[JAMon]]></category>
		<category><![CDATA[JAVA]]></category>
		<category><![CDATA[Spring]]></category>
		<category><![CDATA[aop]]></category>
		<category><![CDATA[aspect]]></category>
		<category><![CDATA[interceptor]]></category>
		<category><![CDATA[jamon]]></category>
		<category><![CDATA[JamonPerformanceMonitorInterceptor]]></category>
		<category><![CDATA[monitor]]></category>
		<category><![CDATA[monitoring]]></category>
		<category><![CDATA[profile]]></category>
		<category><![CDATA[profiling]]></category>

		<guid isPermaLink="false">http://javasight.wordpress.com/?p=310</guid>
		<description><![CDATA[  Recently I was in need to tune some of the java services which I had implemented for for an iPhone project. When integrating services with mobile and hand held devices, it is very important that the services respond in a matter of seconds. In order to tune the services and get the best UI [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javasight.wordpress.com&amp;blog=4467463&amp;post=310&amp;subd=javasight&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p> <br />
Recently I was in need to tune some of the java services which I had implemented for for an iPhone project. When integrating services with mobile and hand held devices, it is very important that the services respond in a matter of seconds. In order to tune the services and get the best UI experience, the obvious step is to find the slowest service. However the intriguing question was ….HOW?</p>
<p>Following are some of the alternates most developers do</p>
<ul>
<li>Have a System.out / Log.debug after you enter and before you exit the service, which prints the time</li>
<li>Write and aspect using AOP and log the time before and after invocation of the method</li>
</ul>
<p> </p>
<p>Serious developers choose the second approach, since monitoring is a cross cutting concern.</p>
<p>Before you fire up you IDE and start writing an Aspect and all those AOP jargon, I would like to introduce you to a class from the Spring Framework core portfolio called <strong>“JamonPerformanceMonitorInterceptor”.</strong> As the name suggests, it is an AOP interceptor that hooks into the framework called JAMon. JAMon is a java monitoring framework and it sure is sweet.</p>
<p>To know more about JAMon check it out <a href="http://jamonapi.sourceforge.net/">HERE.</a> Make sure you download the jamon-2.7.jar file and put it on your classpath</p>
<p>That’s right, no writing of interceptors and joint points and what not AOP jargon out there.</p>
<p>All you need to to do is instantiate a <strong>JamonPerformanceMonitorInterceptor </strong>bean and tell it which all Spring beans to intercept</p>
<p>Add this to instantiate the bean</p>
<p><pre class="brush: xml;">
&lt;bean id=&quot;jamonPerformanceMonitorInterceptor&quot; class=&quot;org.springframework.aop.interceptor.JamonPerformanceMonitorInterceptor&quot; &gt;
   &lt;property name=&quot;trackAllInvocations&quot; value=&quot;true&quot;&gt;&lt;/property&gt;
   &lt;property name=&quot;useDynamicLogger&quot; value=&quot;true&quot;&gt;&lt;/property&gt;
&lt;/bean&gt;
</pre></p>
<p>Next create a “BeanNameAutoProxyCreator” and hook in the interceptor.<strong></strong></p>
<p><pre class="brush: xml;">
&lt;bean id=&quot;autoProxyCreator&quot; class=&quot;org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator&quot;&gt;
	&lt;property name=&quot;interceptorNames&quot;&gt;
		&lt;list&gt;
			&lt;idref bean=&quot;jamonPerformanceMonitorInterceptor&quot;/&gt;
		&lt;/list&gt;
	&lt;/property&gt;
	&lt;property name=&quot;beanNames&quot;&gt;
		&lt;list&gt;
			&lt;value&gt;aRegularSpringBean&lt;/value&gt;
			&lt;value&gt;statisticsDao&lt;/value&gt;
			&lt;value&gt;statisticsService&lt;/value&gt;
			&lt;value&gt;paymentDao&lt;/value&gt;	
			&lt;value&gt;paymentService&lt;/value&gt;				
		&lt;/list&gt;
	&lt;/property&gt;
&lt;/bean&gt;

</pre></p>
<p>All you need to do now is, tell the BeanNameAutoProxyCreator which all Spring beans to intercept.&#8221;paymentDao&#8221;,&#8221;paymentService&#8221; etc are all classic Spring beans. Voila, your services and dao are all being monitored.</p>
<p>Oh…And one last thing.</p>
<p><strong>Make sure you set the log4 logging level to TRACE or else it will NOT work!!</strong></p>
<p>In the follow article , I shall show you have to generate reports from the JAMON framework using a simple servlet.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/javasight.wordpress.com/310/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/javasight.wordpress.com/310/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/javasight.wordpress.com/310/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/javasight.wordpress.com/310/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/javasight.wordpress.com/310/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/javasight.wordpress.com/310/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/javasight.wordpress.com/310/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/javasight.wordpress.com/310/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/javasight.wordpress.com/310/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/javasight.wordpress.com/310/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/javasight.wordpress.com/310/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/javasight.wordpress.com/310/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/javasight.wordpress.com/310/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/javasight.wordpress.com/310/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javasight.wordpress.com&amp;blog=4467463&amp;post=310&amp;subd=javasight&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://javasight.wordpress.com/2010/10/04/monitoring-with-spring-and-jamon-using-jamonperformancemonitorinterceptor/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/34614a06c803826394b37239b2d3a1da?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Franklin</media:title>
		</media:content>
	</item>
		<item>
		<title>Serial Killers</title>
		<link>http://javasight.wordpress.com/2010/08/31/serial-killers/</link>
		<comments>http://javasight.wordpress.com/2010/08/31/serial-killers/#comments</comments>
		<pubDate>Tue, 31 Aug 2010 04:53:24 +0000</pubDate>
		<dc:creator>Franklin</dc:creator>
				<category><![CDATA[Random]]></category>
		<category><![CDATA[idiot box]]></category>
		<category><![CDATA[killer]]></category>
		<category><![CDATA[serial]]></category>
		<category><![CDATA[tv series]]></category>

		<guid isPermaLink="false">http://javasight.wordpress.com/?p=299</guid>
		<description><![CDATA[Many of you are aware that laughter is one of the best medicines that can boost the state of mind. But how many of us know that worries and miseries can harm our total health. The more you become depressed and worried, the worst your health is affected and so does the interaction with your [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javasight.wordpress.com&amp;blog=4467463&amp;post=299&amp;subd=javasight&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Many of you are aware that laughter is one of the best medicines that can boost the state of mind. But how many of us know that worries and miseries can harm our total health. The more you become depressed and worried, the worst your health is affected and so does the interaction with your near and dear ones. </p>
<p>Scientific studies have proven beyond doubt that laughter and happiness have a positive effect where as sadness, worries and despair have adverse effects on the life span of any living being. Neither joy nor sorrow come from within, but is the result of external turbulence. However, some of the agonies are unprecedented like accidents and natural calamities. At the same time, there are voluntarily chosen ones like the emotional turmoil generating TV serials/series. As the saying goes, too much of anything is harmful and so are these. In another few minutes, I will try to prove, with the help of facts and figures, how these emotionally disturbing tear generators can become “serial killers”. </p>
<p>            Consider the case of an average family that views the idiot box. The bread winner is mostly busy with his day’s work and hardly put in any effort to watch it after a day’s work at office. The kids, back from school have hefty homework and are usually denied cartoons that bring in color and imagination to the mind of a growing child. The remaining members are the housewives and the old aged. Now you know why majority of the TV serials are shot with crying characters and pouring out tears. It appears that there are, at least, three channels airing such serials at a time. If the family is of a multilingual nature, then the number of serials gets multiplied by the number of languages the family can understand.</p>
<p>The calculation I have taken into consideration is trimmed down to the lowest. The peak viewing hours are often from 6pm to 9pm on weekdays and it becomes more on weekends. Taking a rough estimate, we can approximate 3 hours viewing per day (I am sure its even more than that). </p>
<p>Out of this, 1½ hours are eye rubbing (filled with tears) TV serials and 1½ hours are good entertainers which hardly any housewife cares about as they are addicted to the “family enthrallers”. </p>
<p>            From the 1½ hours, we set aside ½ an hour for advertisement. Have you ever wondered why these different ads are shown in between these serials!!!! ‘Cause various companies have sponsored the programs?????  Well, you guessed wrong. The sole intention of these properly spaced ads is to prevent the old aged from going into a stroke or coma while viewing these depressing serials. At the end, we have a total of 1hr viewing. Now for some scientific facts:</p>
<ul>
<li>If you are positive and happy then you get your life span extended by 1 day (if you do not watch such serials)</li>
<li>If you cry, get depressed or turns into a bad- mood, it shortens your life span by at least 1 hour. </li>
</ul>
<p>So a total of 1 year’s viewing gives you 365 hours of non stop worries, and mind it, they do make sure to watch the next episode even if the day’s food is not cooked (no exaggerations whatsoever).</p>
<p>One day’s viewing gives a reduction in life span = 60 minutes </p>
<p>                                        Therefore 1 year’s viewing   = 365 units (1 hr/day)</p>
<p>               Therefore 1 year’s reduction in life span = (365*60) minutes</p>
<p>                                                                                                 = 365 hrs</p>
<p>                                                                                                 = (365/24) days</p>
<p>                                                                                                 = 15.2 days</p>
<p> <a href="http://javasight.files.wordpress.com/2010/08/life.jpg"><img class="aligncenter size-full wp-image-301" title="life" src="http://javasight.files.wordpress.com/2010/08/life.jpg?w=500&#038;h=340" alt="" width="500" height="340" /></a></p>
<p>The average life expectancy of a human being is 70 years.</p>
<p>                         After 67 years, the loss of years    = (67*15.2)/365</p>
<p>                                                                                                <strong>Approx 3 years</strong></p>
<p>If loosing 3 years of your life is a luxury you can afford then you just have wasted your time.</p>
<p>Now I leave it for you to decide.</p>
<p><strong><em>Those who long to live, live longer…</em></strong></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/javasight.wordpress.com/299/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/javasight.wordpress.com/299/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/javasight.wordpress.com/299/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/javasight.wordpress.com/299/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/javasight.wordpress.com/299/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/javasight.wordpress.com/299/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/javasight.wordpress.com/299/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/javasight.wordpress.com/299/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/javasight.wordpress.com/299/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/javasight.wordpress.com/299/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/javasight.wordpress.com/299/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/javasight.wordpress.com/299/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/javasight.wordpress.com/299/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/javasight.wordpress.com/299/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javasight.wordpress.com&amp;blog=4467463&amp;post=299&amp;subd=javasight&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://javasight.wordpress.com/2010/08/31/serial-killers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/34614a06c803826394b37239b2d3a1da?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Franklin</media:title>
		</media:content>

		<media:content url="http://javasight.files.wordpress.com/2010/08/life.jpg" medium="image">
			<media:title type="html">life</media:title>
		</media:content>
	</item>
		<item>
		<title>Don’T be embarrassed: GMAIL saves the day!!</title>
		<link>http://javasight.wordpress.com/2010/06/23/dont-be-embarrassed-gmail-saves-the-day/</link>
		<comments>http://javasight.wordpress.com/2010/06/23/dont-be-embarrassed-gmail-saves-the-day/#comments</comments>
		<pubDate>Wed, 23 Jun 2010 14:52:44 +0000</pubDate>
		<dc:creator>Franklin</dc:creator>
				<category><![CDATA[Random]]></category>
		<category><![CDATA[alert]]></category>
		<category><![CDATA[attachment]]></category>
		<category><![CDATA[empty attachment]]></category>
		<category><![CDATA[forgot attachment]]></category>
		<category><![CDATA[gmail]]></category>
		<category><![CDATA[missed attachment]]></category>
		<category><![CDATA[notify]]></category>

		<guid isPermaLink="false">http://javasight.wordpress.com/?p=289</guid>
		<description><![CDATA[How many times have you sent out an email and then said !@$%#!@. I  forgot the attachment again!! Dont worry. Gmail can now save you from such embarassing moments. If you try to send an email using gmail where in which your content has something like &#8220;Kindly find attached with this mail &#8230;.&#8221; and you forget to attach [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javasight.wordpress.com&amp;blog=4467463&amp;post=289&amp;subd=javasight&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>How many times have you sent out an email and then said <strong>!@$%#!@. I  forgot the attachment again!! </strong></p>
<p>Dont worry. Gmail can now save you from such embarassing moments.</p>
<p>If you try to send an email using gmail where in which your content has something like &#8220;Kindly <strong><span style="text-decoration:underline;">find attached</span></strong> with this mail &#8230;.&#8221; and you forget to attach your document Gmail &#8220;automagically&#8221; alerts you. Check out the screenshot if you dont believe me.</p>
<div id="attachment_290" class="wp-caption aligncenter" style="width: 510px"><a href="http://javasight.files.wordpress.com/2010/06/gmail.jpg"><img class="size-full wp-image-290" title="Gmail Attachment Alert" src="http://javasight.files.wordpress.com/2010/06/gmail.jpg?w=500&#038;h=254" alt="Gmail Attachment Alert" width="500" height="254" /></a><p class="wp-caption-text">Gmail Attachment Alert</p></div>
<p>And this is called &#8220;Thinking out of the Box&#8221;. Imagine, there have been thick clients such as Outlook and their likes for so so long, but such a small ingenious thought and thats what is called creative thinking. Hats off  &#8220;Google Guys&#8221;!!</p>
<p>Enjoy,</p>
<p>Franklin</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/javasight.wordpress.com/289/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/javasight.wordpress.com/289/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/javasight.wordpress.com/289/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/javasight.wordpress.com/289/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/javasight.wordpress.com/289/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/javasight.wordpress.com/289/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/javasight.wordpress.com/289/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/javasight.wordpress.com/289/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/javasight.wordpress.com/289/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/javasight.wordpress.com/289/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/javasight.wordpress.com/289/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/javasight.wordpress.com/289/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/javasight.wordpress.com/289/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/javasight.wordpress.com/289/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javasight.wordpress.com&amp;blog=4467463&amp;post=289&amp;subd=javasight&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://javasight.wordpress.com/2010/06/23/dont-be-embarrassed-gmail-saves-the-day/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/34614a06c803826394b37239b2d3a1da?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Franklin</media:title>
		</media:content>

		<media:content url="http://javasight.files.wordpress.com/2010/06/gmail.jpg" medium="image">
			<media:title type="html">Gmail Attachment Alert</media:title>
		</media:content>
	</item>
		<item>
		<title>Apache Web Services Invocation Framework: PART &#8211; I</title>
		<link>http://javasight.wordpress.com/2010/03/07/apache-web-services-invocation-framework-part-i/</link>
		<comments>http://javasight.wordpress.com/2010/03/07/apache-web-services-invocation-framework-part-i/#comments</comments>
		<pubDate>Sun, 07 Mar 2010 12:07:44 +0000</pubDate>
		<dc:creator>Franklin</dc:creator>
				<category><![CDATA[Apache WSIF]]></category>
		<category><![CDATA[JAVA]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[web services]]></category>
		<category><![CDATA[web services invocation framework]]></category>
		<category><![CDATA[webservices]]></category>
		<category><![CDATA[wsif]]></category>

		<guid isPermaLink="false">http://javasight.wordpress.com/?p=267</guid>
		<description><![CDATA[Some time back, I was in need to invoke a simple WebService and that’s when one of my colleagues brought to my notice the simplicity of WSIF. Initially it looked to me as though it’s very simple. However I had to struggle a bit to invoke a simple WebService. I believe the reason for that [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javasight.wordpress.com&amp;blog=4467463&amp;post=267&amp;subd=javasight&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Some time back, I was in need to invoke a simple WebService and that’s when one of my colleagues brought to my notice the simplicity of WSIF. Initially it looked to me as though it’s very simple. However I had to struggle a bit to invoke a simple WebService. I believe the reason for that was their poor documentation.</p>
<p>Needless to say WSIF was the brain child of IBM folks (do correct me if I am wrong) and has been prominently used in this space.</p>
<p>This article is just to show how to invoke a simple WebService which takes a FLAT XML request object and returns a FLAT XML response.</p>
<p>Below is the WSDL of the WebService in question. All it does is spit back a concatenated string of what you spit at it.</p>
<p><pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;wsdl:definitions xmlns:wsdl=&quot;http://schemas.xmlsoap.org/wsdl/&quot; xmlns:mime=&quot;http://schemas.xmlsoap.org/wsdl/mime/&quot; xmlns:soap12=&quot;http://schemas.xmlsoap.org/wsdl/soap12/&quot; xmlns:http=&quot;http://schemas.xmlsoap.org/wsdl/http/&quot; xmlns:ns1=&quot;http://org.apache.axis2/xsd&quot; xmlns:wsaw=&quot;http://www.w3.org/2006/05/addressing/wsdl&quot; xmlns:ns=&quot;http://ws.apache.org/axis2&quot; xmlns:xs=&quot;http://www.w3.org/2001/XMLSchema&quot; xmlns:soap=&quot;http://schemas.xmlsoap.org/wsdl/soap/&quot; targetNamespace=&quot;http://ws.apache.org/axis2&quot;&gt;
    &lt;wsdl:types&gt;
        &lt;xs:schema attributeFormDefault=&quot;qualified&quot; elementFormDefault=&quot;unqualified&quot; targetNamespace=&quot;http://ws.apache.org/axis2&quot;&gt;
            &lt;xs:element name=&quot;showEcho&quot;&gt;
                &lt;xs:complexType&gt;
                    &lt;xs:sequence&gt;
                        &lt;xs:element minOccurs=&quot;0&quot; name=&quot;value&quot; nillable=&quot;true&quot; type=&quot;xs:string&quot;/&gt;
                    &lt;/xs:sequence&gt;
                &lt;/xs:complexType&gt;
            &lt;/xs:element&gt;
            &lt;xs:element name=&quot;showEchoResponse&quot;&gt;
                &lt;xs:complexType&gt;
                    &lt;xs:sequence&gt;
                        &lt;xs:element minOccurs=&quot;0&quot; name=&quot;return&quot; nillable=&quot;true&quot; type=&quot;xs:string&quot;/&gt;
                    &lt;/xs:sequence&gt;
                &lt;/xs:complexType&gt;
            &lt;/xs:element&gt;
        &lt;/xs:schema&gt;
    &lt;/wsdl:types&gt;
    &lt;wsdl:message name=&quot;showEchoRequest&quot;&gt;
        &lt;wsdl:part name=&quot;parameters&quot; element=&quot;ns:showEcho&quot;/&gt;
    &lt;/wsdl:message&gt;
    &lt;wsdl:message name=&quot;showEchoResponse&quot;&gt;
        &lt;wsdl:part name=&quot;parameters&quot; element=&quot;ns:showEchoResponse&quot;/&gt;
    &lt;/wsdl:message&gt;
    &lt;wsdl:portType name=&quot;TestPortType&quot;&gt;
        &lt;wsdl:operation name=&quot;showEcho&quot;&gt;
            &lt;wsdl:input message=&quot;ns:showEchoRequest&quot; wsaw:Action=&quot;urn:showEcho&quot;/&gt;
            &lt;wsdl:output message=&quot;ns:showEchoResponse&quot; wsaw:Action=&quot;urn:showEchoResponse&quot;/&gt;
        &lt;/wsdl:operation&gt;
    &lt;/wsdl:portType&gt;
    &lt;wsdl:binding name=&quot;TestSoap11Binding&quot; type=&quot;ns:TestPortType&quot;&gt;
        &lt;soap:binding transport=&quot;http://schemas.xmlsoap.org/soap/http&quot; style=&quot;document&quot;/&gt;
        &lt;wsdl:operation name=&quot;showEcho&quot;&gt;
            &lt;soap:operation soapAction=&quot;urn:showEcho&quot; style=&quot;document&quot;/&gt;
            &lt;wsdl:input&gt;
                &lt;soap:body use=&quot;literal&quot;/&gt;
            &lt;/wsdl:input&gt;
            &lt;wsdl:output&gt;
                &lt;soap:body use=&quot;literal&quot;/&gt;
            &lt;/wsdl:output&gt;
        &lt;/wsdl:operation&gt;
    &lt;/wsdl:binding&gt;
    &lt;wsdl:binding name=&quot;TestSoap12Binding&quot; type=&quot;ns:TestPortType&quot;&gt;
        &lt;soap12:binding transport=&quot;http://schemas.xmlsoap.org/soap/http&quot; style=&quot;document&quot;/&gt;
        &lt;wsdl:operation name=&quot;showEcho&quot;&gt;
            &lt;soap12:operation soapAction=&quot;urn:showEcho&quot; style=&quot;document&quot;/&gt;
            &lt;wsdl:input&gt;
                &lt;soap12:body use=&quot;literal&quot;/&gt;
            &lt;/wsdl:input&gt;
            &lt;wsdl:output&gt;
                &lt;soap12:body use=&quot;literal&quot;/&gt;
            &lt;/wsdl:output&gt;
        &lt;/wsdl:operation&gt;
    &lt;/wsdl:binding&gt;
    &lt;wsdl:binding name=&quot;TestHttpBinding&quot; type=&quot;ns:TestPortType&quot;&gt;
        &lt;http:binding verb=&quot;POST&quot;/&gt;
        &lt;wsdl:operation name=&quot;showEcho&quot;&gt;
            &lt;http:operation location=&quot;Test/showEcho&quot;/&gt;
            &lt;wsdl:input&gt;
                &lt;mime:content type=&quot;text/xml&quot; part=&quot;showEcho&quot;/&gt;
            &lt;/wsdl:input&gt;
            &lt;wsdl:output&gt;
                &lt;mime:content type=&quot;text/xml&quot; part=&quot;showEcho&quot;/&gt;
            &lt;/wsdl:output&gt;
        &lt;/wsdl:operation&gt;
    &lt;/wsdl:binding&gt;
    &lt;wsdl:service name=&quot;Test&quot;&gt;
        &lt;wsdl:port name=&quot;TestHttpSoap11Endpoint&quot; binding=&quot;ns:TestSoap11Binding&quot;&gt;
            &lt;soap:address location=&quot;http://10.142.20.66:8080/axis2/services/Test.TestHttpSoap11Endpoint/&quot;/&gt;
        &lt;/wsdl:port&gt;
        &lt;wsdl:port name=&quot;TestHttpSoap12Endpoint&quot; binding=&quot;ns:TestSoap12Binding&quot;&gt;
            &lt;soap12:address location=&quot;http://10.142.20.66:8080/axis2/services/Test.TestHttpSoap12Endpoint/&quot;/&gt;
        &lt;/wsdl:port&gt;
        &lt;wsdl:port name=&quot;TestHttpEndpoint&quot; binding=&quot;ns:TestHttpBinding&quot;&gt;
            &lt;http:address location=&quot;http://10.142.20.66:8080/axis2/services/Test.TestHttpEndpoint/&quot;/&gt;
        &lt;/wsdl:port&gt;
    &lt;/wsdl:service&gt;
&lt;/wsdl:definitions&gt;

</pre></p>
<p>NOTE: This WebService was developed with the help of AXIS 2 runtime. I just created a normal java class and put the complied class file (after renaming its extension from .class to .aar) into the repository folder of the AXIS 2 server.</p>
<p>Now the Class used to invoke the WebService</p>
<p><pre class="brush: java;">

package com.datel.transliterator.app;

import org.apache.log4j.Logger;
import org.apache.wsif.WSIFException;
import org.apache.wsif.WSIFMessage;
import org.apache.wsif.WSIFOperation;
import org.apache.wsif.WSIFPort;
import org.apache.wsif.WSIFService;
import org.apache.wsif.WSIFServiceFactory;
import org.apache.wsif.providers.soap.apacheaxis.WSIFDynamicProvider_ApacheAxis;
import org.apache.wsif.util.WSIFPluggableProviders;

public class WSInvoke {
	
	Logger log = Logger.getLogger(RunNow.class);
	
	public static void main(String[] args) throws Exception 
	{
		new WSInvoke().invoke();		
	}
		
    public void invoke() throws Exception
    {
		String result = null;
		
        WSIFPluggableProviders.overrideDefaultProvider(&quot;http://schemas.xmlsoap.org/wsdl/soap/&quot;,
        		new WSIFDynamicProvider_ApacheAxis()
    
        );
       
        // create a service factory
        WSIFServiceFactory factory = WSIFServiceFactory.newInstance();
        WSIFService service = factory.getService(
	                &quot;http://localhost:8080/axis2/services/Test?wsdl&quot;, //Location of the WSDL
	                null,
	                null,
	                &quot;http://ws.apache.org/axis2&quot;, //TargetNamespace as per the WSDL
	                &quot;TestPortType&quot;); //PortType as per the WSDL

	        WSIFPort port = service.getPort();
	 

	        // create the operation
	        WSIFOperation operation = port.createOperation(&quot;showEcho&quot;);
	        
      

	        // create the input, output and fault messages associated with this operation
	        WSIFMessage input = operation.createInputMessage();
	        WSIFMessage output = operation.createOutputMessage();
	        WSIFMessage fault = operation.createFaultMessage();
	        
      
	        /*VALUE : BECAUSE OF THE attribute VALUE
	          &lt;xs:element name=&quot;showEcho&quot;&gt;
				&lt;xs:complexType&gt;
					&lt;xs:sequence&gt;
						&lt;xs:element minOccurs=&quot;0&quot; name=&quot;value&quot; nillable=&quot;true&quot; type=&quot;xs:string&quot;/&gt;
					&lt;/xs:sequence&gt;
				&lt;/xs:complexType&gt;
			   &lt;/xs:element&gt;

        	  &lt;xs:element name=&quot;showEchoResponse&quot;&gt;
				&lt;xs:complexType&gt;
					&lt;xs:sequence&gt;
						&lt;xs:element minOccurs=&quot;0&quot; name=&quot;return&quot; nillable=&quot;true&quot; type=&quot;xs:string&quot;/&gt;
					&lt;/xs:sequence&gt;
				&lt;/xs:complexType&gt;
				&lt;/xs:element&gt;
        	  */	        
	        input.setObjectPart(&quot;value&quot;, &quot; Hi there&quot;);
       
	        if (operation.executeRequestResponseOperation(input, output, fault)) 
	        {

	        	result = (String) output.getObjectPart(&quot;return&quot;);
	            System.out.println(result);
	             
	        } 
	        else 
	        {
	        	System.out.println(&quot;Invocation failed&quot;);
	            // extract fault message info
	        }
             
    }

}


</pre></p>
<p>We have created an “input” request object and set it with a key value pair, where the key is “name”. This is because the XML request object takes an attribute “name”</p>
<p>We have created an “output” response object and get it with a key value pair, where the key is “return”. This is because the XML response object takes an attribute “return”</p>
<p><strong>Important:</strong><br />
<em>This example is assuming the structure of the XML request and response object. I have only been able to using this type of invocation for FLAT XML objects. For complex XML request object please wait for PART 2 to see how its invoked.</em></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/javasight.wordpress.com/267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/javasight.wordpress.com/267/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/javasight.wordpress.com/267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/javasight.wordpress.com/267/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/javasight.wordpress.com/267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/javasight.wordpress.com/267/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/javasight.wordpress.com/267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/javasight.wordpress.com/267/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/javasight.wordpress.com/267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/javasight.wordpress.com/267/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/javasight.wordpress.com/267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/javasight.wordpress.com/267/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/javasight.wordpress.com/267/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/javasight.wordpress.com/267/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javasight.wordpress.com&amp;blog=4467463&amp;post=267&amp;subd=javasight&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://javasight.wordpress.com/2010/03/07/apache-web-services-invocation-framework-part-i/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/34614a06c803826394b37239b2d3a1da?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Franklin</media:title>
		</media:content>
	</item>
		<item>
		<title>Oracle JDeveloper SUCKS!!!</title>
		<link>http://javasight.wordpress.com/2010/02/18/oracle-jdeveloper-sucks/</link>
		<comments>http://javasight.wordpress.com/2010/02/18/oracle-jdeveloper-sucks/#comments</comments>
		<pubDate>Thu, 18 Feb 2010 07:47:08 +0000</pubDate>
		<dc:creator>Franklin</dc:creator>
				<category><![CDATA[JAVA]]></category>
		<category><![CDATA[jdeveloper]]></category>
		<category><![CDATA[Oracle]]></category>

		<guid isPermaLink="false">http://javasight.wordpress.com/?p=262</guid>
		<description><![CDATA[I really couldn&#8217;t help but write this after I found out how to create a folder with JDeveloper. Do you agree or disagree?<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javasight.wordpress.com&amp;blog=4467463&amp;post=262&amp;subd=javasight&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I really couldn&#8217;t help but write this after I found out how to create a folder with JDeveloper.</p>
<p>Do you agree or disagree?</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/javasight.wordpress.com/262/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/javasight.wordpress.com/262/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/javasight.wordpress.com/262/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/javasight.wordpress.com/262/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/javasight.wordpress.com/262/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/javasight.wordpress.com/262/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/javasight.wordpress.com/262/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/javasight.wordpress.com/262/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/javasight.wordpress.com/262/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/javasight.wordpress.com/262/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/javasight.wordpress.com/262/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/javasight.wordpress.com/262/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/javasight.wordpress.com/262/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/javasight.wordpress.com/262/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javasight.wordpress.com&amp;blog=4467463&amp;post=262&amp;subd=javasight&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://javasight.wordpress.com/2010/02/18/oracle-jdeveloper-sucks/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/34614a06c803826394b37239b2d3a1da?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Franklin</media:title>
		</media:content>
	</item>
		<item>
		<title>My musings on BizTalk!!</title>
		<link>http://javasight.wordpress.com/2009/06/08/my-musings-on-biztalk/</link>
		<comments>http://javasight.wordpress.com/2009/06/08/my-musings-on-biztalk/#comments</comments>
		<pubDate>Mon, 08 Jun 2009 12:29:59 +0000</pubDate>
		<dc:creator>Franklin</dc:creator>
				<category><![CDATA[Biztalk]]></category>
		<category><![CDATA[Messaging System]]></category>
		<category><![CDATA[Random]]></category>

		<guid isPermaLink="false">http://javasight.wordpress.com/?p=254</guid>
		<description><![CDATA[  Vendor : You can use this “CANNON” to fire moving objects and its extremely powerful Customer : I only need a “STRAW” to drink juice !! Vendor : Well you can disable the features in a “CANNON” and use it as “STRAW” Customer : In that case I might as well use a “MISSLE” [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javasight.wordpress.com&amp;blog=4467463&amp;post=254&amp;subd=javasight&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p> </p>
<p><strong>Vendor :</strong> <strong><span style="color:#008000;">You can use this “CANNON” to fire moving objects and its extremely powerful</span></strong></p>
<p><strong>Customer :</strong> <strong><span style="color:#ff0000;">I only need a “STRAW” to drink juice !!</span></strong></p>
<p><strong>Vendor :</strong> <strong><span style="color:#008000;">Well you can disable the features in a “CANNON” and use it as “STRAW”</span></strong></p>
<p><strong>Customer :</strong> <strong><span style="color:#ff0000;">In that case I might as well use a “MISSLE” or a “ROCKET” !!</span></strong></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/javasight.wordpress.com/254/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/javasight.wordpress.com/254/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/javasight.wordpress.com/254/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/javasight.wordpress.com/254/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/javasight.wordpress.com/254/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/javasight.wordpress.com/254/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/javasight.wordpress.com/254/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/javasight.wordpress.com/254/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/javasight.wordpress.com/254/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/javasight.wordpress.com/254/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/javasight.wordpress.com/254/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/javasight.wordpress.com/254/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/javasight.wordpress.com/254/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/javasight.wordpress.com/254/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javasight.wordpress.com&amp;blog=4467463&amp;post=254&amp;subd=javasight&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://javasight.wordpress.com/2009/06/08/my-musings-on-biztalk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/34614a06c803826394b37239b2d3a1da?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Franklin</media:title>
		</media:content>
	</item>
		<item>
		<title>Accessing SSL enabled web site using Apache HttpClient</title>
		<link>http://javasight.wordpress.com/2009/03/06/accessing-ssl-enabled-web-site-using-apache-httpclient/</link>
		<comments>http://javasight.wordpress.com/2009/03/06/accessing-ssl-enabled-web-site-using-apache-httpclient/#comments</comments>
		<pubDate>Fri, 06 Mar 2009 13:44:16 +0000</pubDate>
		<dc:creator>Suad</dc:creator>
				<category><![CDATA[JAVA]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[HttpClient]]></category>
		<category><![CDATA[JSSE]]></category>
		<category><![CDATA[SSL]]></category>

		<guid isPermaLink="false">http://javasight.wordpress.com/?p=247</guid>
		<description><![CDATA[I was trying to access a secure web site using Apache HttpClient API. However, it was failing giving me the following exception javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target In apache HttpClient website, it states that &#8220;HttpClient provides full support for HTTP over Secure Sockets Layer [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javasight.wordpress.com&amp;blog=4467463&amp;post=247&amp;subd=javasight&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I was trying to access a secure web site using Apache HttpClient API. However, it was failing giving me the following exception</p>
<h5><span style="color:#ff0000;">javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target</span></h5>
<p>In<a title="httpClient" href="http://hc.apache.org/httpclient-3.x/sslguide.html" target="_blank"> apache HttpClient website</a>, it states that &#8220;<em>HttpClient provides full support for HTTP over Secure Sockets Layer (SSL) or IETF Transport Layer Security (TLS) protocols by leveraging the Java Secure Socket Extension (JSSE).</em>&#8220;</p>
<p>I tried their example of accessing a secure website and it worked. However the website I was trying to access is still failing.</p>
<p>After debugging the problem I came across a good <a title="No more 'unable to find valid certification path to requested target'" href="http://blogs.sun.com/andreas/entry/no_more_unable_to_find" target="_blank">article</a>. In the article, the author mentioned that the above exception comes in the following case &#8220;<em>when trying to open an SSL connection to a host using JSSE. What this usually means is that the server is using a test certificate (possibly generated using keytool) rather than a certificate from a well known commercial Certification Authority such as Verisign or GoDaddy. Web browsers display warning dialogs in this case, but since JSSE cannot assume an interactive user is present it just throws an exception by default.</em>&#8220;</p>
<p>That was not exactly my case. I was not getting a warning from the web browser. The web site I was trying to access was using a commercial certificate but it was not a very well known. It was from a regional authority and not an international authority. Any key store comes with a default set of certificates from well known authorities.</p>
<p>So, I ran the program mentioned in the <a title="No more 'unable to find valid certification path to requested target'" href="http://blogs.sun.com/andreas/entry/no_more_unable_to_find" target="_blank">article</a>. A file called <strong>jssecacerts </strong>was generated which includes the certificate. I have placed the file in the <strong>JAVA_HOME\jre\lib\security </strong>directory. Finally I was able to access the secure web site successfully.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/javasight.wordpress.com/247/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/javasight.wordpress.com/247/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/javasight.wordpress.com/247/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/javasight.wordpress.com/247/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/javasight.wordpress.com/247/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/javasight.wordpress.com/247/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/javasight.wordpress.com/247/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/javasight.wordpress.com/247/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/javasight.wordpress.com/247/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/javasight.wordpress.com/247/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/javasight.wordpress.com/247/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/javasight.wordpress.com/247/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/javasight.wordpress.com/247/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/javasight.wordpress.com/247/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javasight.wordpress.com&amp;blog=4467463&amp;post=247&amp;subd=javasight&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://javasight.wordpress.com/2009/03/06/accessing-ssl-enabled-web-site-using-apache-httpclient/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/47cf279b6eb96ddce5c85806fa2b7ddd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">S. Al Shamsi</media:title>
		</media:content>
	</item>
		<item>
		<title>Transaction optimization for Read Only Transaction: Spring ReadOnly attribute</title>
		<link>http://javasight.wordpress.com/2009/02/22/transaction-optimization-for-read-only-transaction-spring-readonly-attribute/</link>
		<comments>http://javasight.wordpress.com/2009/02/22/transaction-optimization-for-read-only-transaction-spring-readonly-attribute/#comments</comments>
		<pubDate>Sun, 22 Feb 2009 09:42:52 +0000</pubDate>
		<dc:creator>Franklin</dc:creator>
				<category><![CDATA[JDBC]]></category>
		<category><![CDATA[Spring]]></category>
		<category><![CDATA[readOnly]]></category>
		<category><![CDATA[transaction management]]></category>
		<category><![CDATA[transaction optimization]]></category>
		<category><![CDATA[transaction strategies]]></category>

		<guid isPermaLink="false">http://javasight.wordpress.com/?p=231</guid>
		<description><![CDATA[This article is a small POC on how the readOnly attribute used in Spring Transaction strategy improves database access in case of transactions that involve only READing data from datasources. First a small extract from the Spring reference documentation: The TransactionDefinition interface specifies: • Isolation: the degree of isolation this transaction has from the work [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javasight.wordpress.com&amp;blog=4467463&amp;post=231&amp;subd=javasight&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This article is a small POC on how the readOnly attribute used in Spring Transaction strategy improves database access in case of transactions that involve only READing data from datasources.</p>
<p>First a small extract from the Spring reference documentation:</p>
<blockquote>
<p>The TransactionDefinition interface specifies:<br />
•	Isolation: the degree of isolation this transaction has from the work of other transactions. For example, can this transaction see uncommitted writes from other transactions?<br />
•	Propagation: normally all code executed within a transaction scope will run in that transaction. However, there are several options specifying behavior if a transactional method is executed when a transaction context already exists: for example, simply continue running in the existing transaction (the common case); or suspending the existing transaction and creating a new transaction. Spring offers all of the transaction propagation options familiar from EJB CMT.<br />
•	Timeout: how long this transaction may run before timing out (and automatically being rolled back by the underlying transaction infrastructure).<br />
•	Read-only status: a read-only transaction does not modify any data. Read-only transactions can be a useful optimization in some cases (such as when using Hibernate).
</p></blockquote>
<p>As you can see the Read-only status seems to be silver bullet for transactions that involve only reading data. Following is a setup that I used to prove the point.</p>
<p>The setup included a Service method which in turn calls the DAO layer to access a table and ONLY retrieve records. The time required to access the data is calculated both WITH and WITHOUT the readOnly attribute. The time is calculated using Spring’s StopWatch utility class. However you can use your own timing methodologies to check out the outcome. The application is run for sometime to warm up the JVM followed by the actual estimation of the time. This is clear in the Main.java class</p>
<p>This test is run on the following configuration machine:</p>
<p>JDK: 1.5<br />
MySQL: 5.0.26<br />
Records in DB: 1,000,000 plus records<br />
RAM: 1.5 GB<br />
Processor: Pentium 1.8GHz </p>
<p><strong>DAO Class : DAOStep.java</strong></p>
<p><pre class="brush: java;">

package com.tx.app.dao;

import java.sql.Types;
import java.util.Calendar;
import java.util.List;

import org.springframework.jdbc.core.namedparam.NamedParameterJdbcDaoSupport;
import org.springframework.jdbc.core.support.JdbcDaoSupport;

public class DAOStep extends  NamedParameterJdbcDaoSupport implements IDAOStep
{
	


	public void getData(int x) 
	{

		final String insertIntoTest = &quot;insert into TEST(VAL1,VAL2) values(?,?) &quot;;

		List val=getJdbcTemplate().queryForList(&quot;select 1 from test where val1= ? order by 1 desc&quot; , new Object[]{x},new int[]{Types.INTEGER});
		
	}
	

}

</pre></p>
<p>This DAO class only queries a table name “TEST” with the following query</p>
<p><strong>SELECT 1 from TEST where val1=? ORDER BY 1 DESC</strong></p>
<p><strong>Next is the Service Class : ServiceStep.java</strong></p>
<p><pre class="brush: java;">

package com.tx.app.service;

import com.tx.app.dao.IDAOStep;
import com.tx.app.exception.MyCheckedException;
import com.tx.app.exception.MyRuntimeException;

public class ServiceStep 
{

	private IDAOStep daoStep;
	
	
	
	public void getReadOnlyData(int x) 
	{
		daoStep.getData(x);

		
	}	
	
	public void getNoReadOnlyData(int x) 
	{
		daoStep.getData(x);
		
	}	

	public IDAOStep getDaoStep() {
		return daoStep;
	}

	public void setDaoStep(IDAOStep daoStep) {
		this.daoStep = daoStep;
	}
	
	
}
</pre></p>
<p><strong>Next is the Main Class : Main.java</strong></p>
<p><pre class="brush: java;">

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.util.StopWatch;

import com.tx.app.dao.IDAOStep;
import com.tx.app.exception.MyCheckedException;
import com.tx.app.service.ServiceStep;


public class Main 

{

	
	
	public static void main(String[] args) throws MyCheckedException 
	{
	
		ApplicationContext context = new ClassPathXmlApplicationContext(new String[]{&quot;context.xml&quot;});
		ServiceStep service = (ServiceStep)context.getBean(&quot;serviceStepTX&quot;);
		
		
/*Warm Up for the application and the JVM*/
		for (int i = 0; &lt; 10; i++)
		{
			service.getNoReadOnlyData(1);
			service.getReadOnlyData(1);
		}

		
		

		long readOnlyTime =0;
		long noReadOnlyTime =0;
		int runTime =500;
		
		for (int i = 0; i &lt; runTime; i++) 
		{

		
		
		StopWatch watch = new StopWatch(&quot;Read-Only-Data&quot;);
		//watch.start(&quot;First Task&quot;);
		service.getReadOnlyData(1);
		//watch.stop();
		watch.start(&quot;Second Task&quot;);
		service.getReadOnlyData(2);
		watch.stop();
		watch.start(&quot;Third Task&quot;);		
		service.getReadOnlyData(3);
		watch.stop();
		watch.start(&quot;Four Task&quot;);		
		service.getReadOnlyData(4);
		watch.stop();
		watch.start(&quot;Five Task&quot;);		
		service.getReadOnlyData(5);
		watch.stop();		
		watch.start(&quot;Six Task&quot;);		
		service.getReadOnlyData(6);
		watch.stop();		
		//System.out.println(watch.prettyPrint());
		//System.out.println(watch.shortSummary());
		readOnlyTime = readOnlyTime+watch.getTotalTimeMillis();
		}
		

		for (int i = 0; i &lt; runTime; i++) 
		{
			
		
		StopWatch watch1 = new StopWatch(&quot;No-Read-Only-Data&quot;);
		//watch.start(&quot;First Task&quot;);
		service.getNoReadOnlyData(1);
		//watch.stop();
		watch1.start(&quot;Second Task&quot;);
		service.getNoReadOnlyData(2);
		watch1.stop();
		watch1.start(&quot;Third Task&quot;);		
		service.getNoReadOnlyData(3);
		watch1.stop();
		watch1.start(&quot;Four Task&quot;);		
		service.getNoReadOnlyData(4);
		watch1.stop();
		watch1.start(&quot;Five Task&quot;);		
		service.getNoReadOnlyData(5);
		watch1.stop();		
		watch1.start(&quot;Six Task&quot;);		
		service.getNoReadOnlyData(6);
		watch1.stop();		
		//System.out.println(watch1.prettyPrint());
		//System.out.println(watch1.shortSummary());
		noReadOnlyTime = noReadOnlyTime+watch1.getTotalTimeMillis();
		
		
		}
		
		System.out.println(&quot;Read Only : &quot;+(readOnlyTime/runTime));
		System.out.println(&quot;No Read Only : &quot;+(noReadOnlyTime/runTime));
		
	}
	
	
}
</pre></p>
<p><strong>Finally the Spring XML configuration file</strong></p>
<p><pre class="brush: xml;">

&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;beans  xmlns=&quot;http://www.springframework.org/schema/beans&quot;
		xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
		xmlns:context=&quot;http://www.springframework.org/schema/context&quot;
		xsi:schemaLocation=&quot;http://www.springframework.org/schema/beans
							http://www.springframework.org/schema/beans/spring-beans-2.5.xsd&quot;&gt;
	

   
    &lt;bean id=&quot;faceDataSource&quot; class=&quot;com.mchange.v2.c3p0.ComboPooledDataSource&quot;&gt;
   		&lt;property name=&quot;driverClass&quot; value=&quot;com.mysql.jdbc.Driver&quot;/&gt;
		&lt;property name=&quot;jdbcUrl&quot; value=&quot;jdbc:mysql://localhost:3306/facedb&quot;/&gt;
		&lt;property name=&quot;user&quot; value=&quot;root&quot;/&gt;	
		&lt;property name=&quot;password&quot; value=&quot;&quot;/&gt;	
		&lt;property name=&quot;initialPoolSize&quot;&gt;&lt;value&gt;3&lt;/value&gt;&lt;/property&gt;		
		&lt;property name=&quot;minPoolSize&quot;&gt;&lt;value&gt;5&lt;/value&gt;&lt;/property&gt;	
		&lt;property name=&quot;acquireIncrement&quot;&gt;&lt;value&gt;5&lt;/value&gt;&lt;/property&gt;		
        &lt;property name=&quot;acquireRetryAttempts&quot;&gt;&lt;value&gt;10&lt;/value&gt;&lt;/property&gt;
        &lt;property name=&quot;acquireRetryDelay&quot;&gt;&lt;value&gt;1000&lt;/value&gt;&lt;/property&gt;
        &lt;property name=&quot;checkoutTimeout&quot;&gt;&lt;value&gt;600000&lt;/value&gt;&lt;/property&gt;
        &lt;property name=&quot;maxPoolSize&quot;&gt;&lt;value&gt;25&lt;/value&gt;&lt;/property&gt;
        &lt;property name=&quot;maxStatements&quot;&gt;&lt;value&gt;200&lt;/value&gt;&lt;/property&gt;
        &lt;property name=&quot;maxStatementsPerConnection&quot;&gt;&lt;value&gt;20&lt;/value&gt;&lt;/property&gt;
        &lt;property name=&quot;maxIdleTimeExcessConnections&quot;&gt;&lt;value&gt;600&lt;/value&gt;&lt;/property&gt;
    &lt;/bean&gt;
    
	
	&lt;bean id=&quot;daoStep&quot; class=&quot;com.tx.app.dao.DAOStep&quot;&gt;
		&lt;property name=&quot;dataSource&quot; ref=&quot;faceDataSource&quot;/&gt;
	&lt;/bean&gt;
	
	&lt;bean id=&quot;serviceStep&quot; class=&quot;com.tx.app.service.ServiceStep&quot;&gt;
		&lt;property name=&quot;daoStep&quot;  ref=&quot;daoStep&quot;/&gt;
	&lt;/bean&gt;
	
	&lt;bean id=&quot;txManager&quot; class=&quot;org.springframework.jdbc.datasource.DataSourceTransactionManager&quot;&gt;
    	&lt;property name=&quot;dataSource&quot; ref=&quot;faceDataSource&quot;/&gt;
    &lt;/bean&gt;
    

	&lt;bean id=&quot;serviceStepTX&quot; class=&quot;org.springframework.transaction.interceptor.TransactionProxyFactoryBean&quot;&gt;
		&lt;property name=&quot;transactionManager&quot; ref=&quot;txManager&quot;/&gt;
		&lt;property name=&quot;target&quot; ref=&quot;serviceStep&quot;/&gt;
		&lt;property name=&quot;proxyTargetClass&quot; value=&quot;true&quot;/&gt;		
		&lt;property name=&quot;transactionAttributes&quot;&gt;
			&lt;props&gt;
				&lt;prop key=&quot;getReadOnly*&quot;&gt;PROPAGATION_REQUIRED,readOnly&lt;/prop&gt;	
				&lt;prop key=&quot;getNoReadOnly*&quot;&gt;PROPAGATION_REQUIRED&lt;/prop&gt;				
			&lt;/props&gt;
		&lt;/property&gt;
	&lt;/bean&gt;    
	
    
&lt;/beans&gt;

</pre></p>
<p>Once Now create a table in the MySQL database with the following script</p>
<p><strong>CREATE TABLE TEST<br />
(VAL1 INT,<br />
VAL2 INT) engine=innodb;</p>
<p>CREATE INDEX TEST_INDEX on TEST(VAL1);</strong></p>
<p><strong>OUTPUT<br />
&#8212;&#8212;&#8212;-</strong><br />
Once you run the Main.java class you will see an output similar to this.</p>
<p>Read Only : 15<br />
No Read Only : 30</p>
<p>The interpretation of this output is that a SELECT on the table </p>
<p><strong>With readOnly attribute took an average of 15 ms<br />
Without readOnly attribute took an average of 30 ms</strong></p>
<p>Pretty good I suppose!!!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/javasight.wordpress.com/231/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/javasight.wordpress.com/231/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/javasight.wordpress.com/231/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/javasight.wordpress.com/231/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/javasight.wordpress.com/231/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/javasight.wordpress.com/231/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/javasight.wordpress.com/231/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/javasight.wordpress.com/231/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/javasight.wordpress.com/231/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/javasight.wordpress.com/231/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/javasight.wordpress.com/231/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/javasight.wordpress.com/231/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/javasight.wordpress.com/231/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/javasight.wordpress.com/231/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javasight.wordpress.com&amp;blog=4467463&amp;post=231&amp;subd=javasight&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://javasight.wordpress.com/2009/02/22/transaction-optimization-for-read-only-transaction-spring-readonly-attribute/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/34614a06c803826394b37239b2d3a1da?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Franklin</media:title>
		</media:content>
	</item>
		<item>
		<title>Understanding Spring Transaction management with Checked and Unchecked exceptions</title>
		<link>http://javasight.wordpress.com/2009/02/17/understanding-spring-transaction-management-with-checked-and-unchecked-exceptions/</link>
		<comments>http://javasight.wordpress.com/2009/02/17/understanding-spring-transaction-management-with-checked-and-unchecked-exceptions/#comments</comments>
		<pubDate>Tue, 17 Feb 2009 12:25:34 +0000</pubDate>
		<dc:creator>Franklin</dc:creator>
				<category><![CDATA[JAVA]]></category>
		<category><![CDATA[Spring]]></category>
		<category><![CDATA[checked exception]]></category>
		<category><![CDATA[transaction management]]></category>
		<category><![CDATA[transaction strategies]]></category>
		<category><![CDATA[tx]]></category>
		<category><![CDATA[unchecked exception]]></category>

		<guid isPermaLink="false">http://javasight.wordpress.com/?p=211</guid>
		<description><![CDATA[I have been using Spring TX Management for quite sometime until I recently came upon an article describing the common pitfalls that occur in Transaction Strategies. Although many cases were covered, I would like to describe the common one that is seen in most code. I am going to explain it with the help of [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javasight.wordpress.com&amp;blog=4467463&amp;post=211&amp;subd=javasight&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I have been using Spring TX Management for quite sometime until I recently came upon an article describing the common pitfalls that occur in Transaction Strategies. Although many cases were covered, I would like to describe the common one that is seen in most code.</p>
<p>I am going to explain it with the help of a sample example. In the example we shall put together a sample Service which in turn calls a DAO. The service will call two methods from the DAO. It is only a trivial Service-DAO example.</p>
<p>First the DAO class : DAOStep.java</p>
<p><pre class="brush: java;">

package com.tx.app.dao;

import java.sql.Types;
import java.util.Calendar;

import org.springframework.jdbc.core.namedparam.NamedParameterJdbcDaoSupport;
import org.springframework.jdbc.core.support.JdbcDaoSupport;

public class DAOStep extends  NamedParameterJdbcDaoSupport implements IDAOStep
{
	

	public void updateData(int val1 , int val2) 
	{
	
		final String insertIntoTest = &quot;UPDATE TEST SET VAL1= ? where VAL2= ? &quot;;

		getJdbcTemplate().update(insertIntoTest,
				new Object[]{
							val1,
							val2
							},
				new int[]{
						 Types.INTEGER,
						 Types.INTEGER,
					});

	}
	

	public void insertData(int val1 , int val2) 
	{
		
		
		final String insertIntoTest = &quot;insert into TEST(VAL1,VAL2) values(?,?) &quot;;

		getJdbcTemplate().update(insertIntoTest,
				new Object[]{
							val1,
							val2
							},
				new int[]{
						 Types.INTEGER,
						 Types.INTEGER,
					});

	}
	

}

</pre></p>
<p>Next the Service class : ServiceStep.java</p>
<p><pre class="brush: java;">
package com.tx.app.service;

import com.tx.app.dao.IDAOStep;
import com.tx.app.exception.MyCheckedException;
import com.tx.app.exception.MyRuntimeException;

public class ServiceStep 
{

	private IDAOStep daoStep;
	
	public void doStepRuntimeException()
	{
		daoStep.insertData(2, 2);
		daoStep.updateData(-2, 2);
		throw new MyRuntimeException();

		
	}
	
	public void doStepCheckedException() throws MyCheckedException
	{
		daoStep.insertData(2, 2);
		daoStep.updateData(-2, 2);
		throw new MyCheckedException();

		
	}	

	public IDAOStep getDaoStep() {
		return daoStep;
	}

	public void setDaoStep(IDAOStep daoStep) {
		this.daoStep = daoStep;
	}

	


	
	
}
</pre></p>
<p>As you can see the service throws two exceptions, one a checked exception(MyCheckedException) and second a runtime exception (MyRuntimeException).</p>
<p>Next the Runtime Exception class : MyRuntimeException.java</p>
<p><pre class="brush: java;">
package com.tx.app.exception;

public class MyRuntimeException extends RuntimeException
{

}

</pre></p>
<p>Next the Checked Exception class: MyCheckedException.java</p>
<p><pre class="brush: java;">
package com.tx.app.exception;

public class MyCheckedException extends Exception
{

}

</pre></p>
<p>And the main class to bootstrap the application</p>
<p><pre class="brush: java;">
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.tx.app.dao.IDAOStep;
import com.tx.app.exception.MyCheckedException;
import com.tx.app.service.ServiceStep;


public class Main 

{

	
	
	public static void main(String[] args) throws MyCheckedException 
	{
	
		ApplicationContext context = new ClassPathXmlApplicationContext(new String[]{&quot;context.xml&quot;});
		ServiceStep service = (ServiceStep)context.getBean(&quot;serviceStepTX&quot;);
		/*Method One*/
		service.doStepRuntimeException();
		/*Method Two*/
		service.doStepCheckedException();
		
		
		
	}
	
	
}
</pre></p>
<p>Finally the Spring XML context file : context.xml</p>
<p><pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;beans  xmlns=&quot;http://www.springframework.org/schema/beans&quot;
		xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
		xmlns:context=&quot;http://www.springframework.org/schema/context&quot;
		xsi:schemaLocation=&quot;http://www.springframework.org/schema/beans
							http://www.springframework.org/schema/beans/spring-beans-2.5.xsd&quot;&gt;
	

   
    &lt;bean id=&quot;faceDataSource&quot; class=&quot;com.mchange.v2.c3p0.ComboPooledDataSource&quot;&gt;
   		&lt;property name=&quot;driverClass&quot; value=&quot;com.mysql.jdbc.Driver&quot;/&gt;
		&lt;property name=&quot;jdbcUrl&quot; value=&quot;jdbc:mysql://localhost:3306/facedb&quot;/&gt;
		&lt;property name=&quot;user&quot; value=&quot;root&quot;/&gt;	
		&lt;property name=&quot;password&quot; value=&quot;&quot;/&gt;	
		&lt;property name=&quot;initialPoolSize&quot;&gt;&lt;value&gt;3&lt;/value&gt;&lt;/property&gt;		
		&lt;property name=&quot;minPoolSize&quot;&gt;&lt;value&gt;5&lt;/value&gt;&lt;/property&gt;	
		&lt;property name=&quot;acquireIncrement&quot;&gt;&lt;value&gt;5&lt;/value&gt;&lt;/property&gt;		
        &lt;property name=&quot;acquireRetryAttempts&quot;&gt;&lt;value&gt;10&lt;/value&gt;&lt;/property&gt;
        &lt;property name=&quot;acquireRetryDelay&quot;&gt;&lt;value&gt;1000&lt;/value&gt;&lt;/property&gt;
        &lt;property name=&quot;checkoutTimeout&quot;&gt;&lt;value&gt;600000&lt;/value&gt;&lt;/property&gt;
        &lt;property name=&quot;maxPoolSize&quot;&gt;&lt;value&gt;25&lt;/value&gt;&lt;/property&gt;
        &lt;property name=&quot;maxStatements&quot;&gt;&lt;value&gt;200&lt;/value&gt;&lt;/property&gt;
        &lt;property name=&quot;maxStatementsPerConnection&quot;&gt;&lt;value&gt;20&lt;/value&gt;&lt;/property&gt;
        &lt;property name=&quot;maxIdleTimeExcessConnections&quot;&gt;&lt;value&gt;600&lt;/value&gt;&lt;/property&gt;
    &lt;/bean&gt;
    
	
	&lt;bean id=&quot;daoStep&quot; class=&quot;com.tx.app.dao.DAOStep&quot;&gt;
		&lt;property name=&quot;dataSource&quot; ref=&quot;faceDataSource&quot;/&gt;
	&lt;/bean&gt;
	
	&lt;bean id=&quot;serviceStep&quot; class=&quot;com.tx.app.service.ServiceStep&quot;&gt;
		&lt;property name=&quot;daoStep&quot;  ref=&quot;daoStep&quot;/&gt;
	&lt;/bean&gt;
	
	&lt;bean id=&quot;txManager&quot; class=&quot;org.springframework.jdbc.datasource.DataSourceTransactionManager&quot;&gt;
    	&lt;property name=&quot;dataSource&quot; ref=&quot;faceDataSource&quot;/&gt;
    &lt;/bean&gt;
    

	&lt;bean id=&quot;serviceStepTX&quot; class=&quot;org.springframework.transaction.interceptor.TransactionProxyFactoryBean&quot;&gt;
		&lt;property name=&quot;transactionManager&quot; ref=&quot;txManager&quot;/&gt;
		&lt;property name=&quot;target&quot; ref=&quot;serviceStep&quot;/&gt;
		&lt;property name=&quot;proxyTargetClass&quot; value=&quot;true&quot;/&gt;		
		&lt;property name=&quot;transactionAttributes&quot;&gt;
			&lt;props&gt;
				&lt;prop key=&quot;doStepRuntimeException*&quot;&gt;PROPAGATION_REQUIRED&lt;/prop&gt;
				&lt;prop key=&quot;doStepCheckedException*&quot;&gt;PROPAGATION_REQUIRED&lt;/prop&gt;				
			&lt;/props&gt;
		&lt;/property&gt;
	&lt;/bean&gt;    
	
    
&lt;/beans&gt;

</pre></p>
<p>The Table that needs to be there in some database is TEST. I am using MySQL database and following is the script used to create the TEST table</p>
<p>CREATE TABLE TEST<br />
(VAL1 INT,<br />
VAL2 INT) engine=innodb</p>
<p><strong>Question</strong></p>
<p>As you can see the Transaction attribute for the doStepRuntimeException and doStepCheckedException are both PROPAGATION_REQUIRED. What do you think would be the outcome when the Main class is executed once with Method 1 and once with Method 2? Would the records be inserted as well as updated in the database?</p>
<p><strong>Explanation</strong></p>
<p>The answer is follows.</p>
<p>Method 1)<br />
The whole transaction is rolled back as RuntimeException is thrown and the current transaction is Rolled back</p>
<p>Method 2)<br />
The whole transaction is committed as a checked exception (Exception) is thrown and the current transaction is Commited.</p>
<p>The correct way to rollback both the transactions would be to alter the XML file as follows</p>
<p><pre class="brush: xml;">
&lt;bean id=&quot;serviceStepTX&quot; class=&quot;org.springframework.transaction.interceptor.TransactionProxyFactoryBean&quot;&gt;
		&lt;property name=&quot;transactionManager&quot; ref=&quot;txManager&quot;/&gt;
		&lt;property name=&quot;target&quot; ref=&quot;serviceStep&quot;/&gt;
		&lt;property name=&quot;proxyTargetClass&quot; value=&quot;true&quot;/&gt;		
		&lt;property name=&quot;transactionAttributes&quot;&gt;
			&lt;props&gt;
				&lt;prop key=&quot;doStepRuntimeException*&quot;&gt;PROPAGATION_REQUIRED,-MyRuntimeException&lt;/prop&gt;
				&lt;prop key=&quot;doStepCheckedException*&quot;&gt;PROPAGATION_REQUIRED,-MyCheckedException&lt;/prop&gt;				
			&lt;/props&gt;
		&lt;/property&gt;
	&lt;/bean&gt;  

</pre></p>
<p>However, if you want to rollback all checked exceptions you can use -Exception instead of -MyCheckedException. The default behaviour is for Unchecked exception the current transaction is rolled back and for Checked exception the current transaction is commited.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/javasight.wordpress.com/211/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/javasight.wordpress.com/211/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/javasight.wordpress.com/211/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/javasight.wordpress.com/211/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/javasight.wordpress.com/211/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/javasight.wordpress.com/211/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/javasight.wordpress.com/211/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/javasight.wordpress.com/211/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/javasight.wordpress.com/211/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/javasight.wordpress.com/211/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/javasight.wordpress.com/211/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/javasight.wordpress.com/211/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/javasight.wordpress.com/211/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/javasight.wordpress.com/211/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=javasight.wordpress.com&amp;blog=4467463&amp;post=211&amp;subd=javasight&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://javasight.wordpress.com/2009/02/17/understanding-spring-transaction-management-with-checked-and-unchecked-exceptions/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/34614a06c803826394b37239b2d3a1da?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Franklin</media:title>
		</media:content>
	</item>
	</channel>
</rss>
