<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-517388772395375329</id><updated>2011-12-19T23:08:34.380-08:00</updated><category term='webservice'/><category term='IOC Example'/><category term='spring-webservice'/><category term='TRAC'/><category term='Spring-JMS Integration'/><category term='Dynamic Address Hosting website'/><category term='Captcha'/><category term='Hibernate'/><category term='ActiveMQ'/><category term='Soring-IOC'/><category term='CruiseControl'/><category term='Spring Hibernate Integration'/><category term='IOC'/><category term='JMS'/><category term='castor'/><category term='JCaptcha'/><category term='Spring'/><category term='Spring Example'/><category term='SVN'/><category term='o/x mapping spring webservice'/><category term='Dynamic IP Address'/><category term='web-service'/><category term='Website Hosting'/><title type='text'>Spring Framework</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://springkbase.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/517388772395375329/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://springkbase.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Anil Verma</name><uri>http://www.blogger.com/profile/07159037456674064065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://4.bp.blogspot.com/_7ZiCsz7bxzk/Sh6rQK6LSeI/AAAAAAAAAXs/9j_hHnOvp6E/S220/40815841.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>6</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-517388772395375329.post-3319799079881097593</id><published>2009-07-01T00:42:00.001-07:00</published><updated>2011-03-30T08:48:40.218-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Captcha'/><category scheme='http://www.blogger.com/atom/ns#' term='JCaptcha'/><category scheme='http://www.blogger.com/atom/ns#' term='Spring'/><title type='text'>Spring and JCaptcha</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;span style="font-size: 100%;" xmlns=""&gt;Recently, I have made a sample application using Spring and JCaptcha, and want to share with you all.&lt;br /&gt;&lt;br /&gt;Basically funda of Captcha is to distinguish between human or robot(basically bot written to automate to fill some  forms of your website which might be used to crash your application).&lt;br /&gt;&lt;br /&gt;In this, program will produce some image containing dictionary words or some random alphanumeric words which you have to fill up in corresponding textfield in the form.&lt;br /&gt;&lt;br /&gt;For this I am using JCaptcha and Spring. You can get more information JCaptcha from &lt;a href="http://forge.octo.com/jcaptcha/confluence/display/general/Home"&gt;http://forge.octo.com/jcaptcha/confluence/display/general/Home&lt;/a&gt; .&lt;br /&gt;&lt;br /&gt;So let start with the integration of JCaptcha and Spring.&lt;br /&gt;&lt;br /&gt;&lt;ul style="margin-left: 54pt;"&gt;&lt;li&gt;&lt;div&gt;First thing is to have one conf file, mine is applicationContext.xml file which get loaded using web.xml file.&lt;/div&gt;&lt;span style="color: red; font-family: Courier New;"&gt;&amp;lt;context-param&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="margin-left: 36pt;"&gt;&lt;span style="color: red; font-family: Courier New;"&gt;&amp;lt;param-name&amp;gt;contextConfigLocation&amp;lt;/param-name&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-left: 36pt;"&gt;&lt;span style="color: red; font-family: Courier New;"&gt;&amp;lt;param-value&amp;gt;/WEB-INF/applicationContext.xml&amp;lt;/param-value&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style="color: red; font-family: Courier New;"&gt;&amp;lt;/context-param&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-family: Courier New;"&gt;In applicationContext.xml file,put these lines for basic configuration :&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;div style="margin-left: 54pt;"&gt;&lt;span style="font-family: Courier New;"&gt;&amp;lt;bean class="com.octo.captcha.service.image.DefaultManageableImageCaptchaService" id="imageCaptchaService"/&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;div style="margin-left: 36pt;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-left: 54pt;"&gt;&lt;span style="font-family: Courier New;"&gt;But I think nobody want the basic things with your project so you need to change this configuration to :&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-left: 36pt;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-left: 54pt;"&gt;&lt;span style="color: red; font-family: Courier New;"&gt;&amp;lt;bean id="captchaService"&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-left: 90pt;"&gt;&lt;span style="color: red; font-family: Courier New;"&gt;class="com.octo.captcha.service.multitype.GenericManageableCaptchaService"&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-left: 126pt;"&gt;&lt;span style="color: red; font-family: Courier New;"&gt;&amp;lt;constructor-arg index="&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;0&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;"&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-left: 162pt;"&gt;&lt;span style="color: red; font-family: Courier New;"&gt;&amp;lt;ref bean="imageEngine" /&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-left: 126pt;"&gt;&lt;span style="color: red; font-family: Courier New;"&gt;&amp;lt;/constructor-arg&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-left: 126pt;"&gt;&lt;span style="color: red; font-family: Courier New;"&gt;&amp;lt;constructor-arg index="&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;"&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-left: 162pt;"&gt;&lt;span style="color: red; font-family: Courier New;"&gt;&amp;lt;value&amp;gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;180&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&amp;lt;/value&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-left: 126pt;"&gt;&lt;span style="color: red; font-family: Courier New;"&gt;&amp;lt;/constructor-arg&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-left: 126pt;"&gt;&lt;span style="color: red; font-family: Courier New;"&gt;&amp;lt;constructor-arg index="&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;"&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-left: 162pt;"&gt;&lt;span style="color: red; font-family: Courier New;"&gt;&amp;lt;value&amp;gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;180000&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&amp;lt;/value&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-left: 126pt;"&gt;&lt;span style="color: red; font-family: Courier New;"&gt;&amp;lt;/constructor-arg&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-left: 126pt;"&gt;&lt;span style="color: red; font-family: Courier New;"&gt;&amp;lt;constructor-arg type="int" index="&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;3&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;" value="&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;75000&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;"/&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-left: 54pt;"&gt;&lt;span style="color: red; font-family: Courier New;"&gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-left: 54pt;"&gt;&lt;span style="font-family: Courier New;"&gt;This is for customizing your JCaptcha look and feel and the words which going to come in image that will be get displayed in your application form.&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul style="margin-left: 54pt;"&gt;&lt;li&gt;Third important thing is to set up the imageEngine bean which is instance of CaptchaEngine.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;There are several Engines pre-configured, but as we want to control configuration, we have to use the GenericCaptchaEngine, which is built with a list of captcha factories&lt;br /&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;&amp;lt;bean id="imageEngine"&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        class="com.octo.captcha.engine.GenericCaptchaEngine"&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        &amp;lt;constructor-arg index="&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;0&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;"&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;            &amp;lt;list&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;                &amp;lt;ref bean="CaptchaFactory" /&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;            &amp;lt;/list&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        &amp;lt;/constructor-arg&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;    &amp;lt;/bean&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;Then, a CaptchaFactory needs:&lt;br /&gt;&lt;br /&gt;&lt;ul style="margin-left: 72pt;"&gt;&lt;li&gt;A word generator, to create the text to read.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;A wordToImage, to generate the captcha from the text.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style="color: red; font-family: Courier New;"&gt;&amp;lt;bean id="CaptchaFactory"&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        class="com.octo.captcha.image.gimpy.GimpyFactory"&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        &amp;lt;constructor-arg&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;            &amp;lt;ref bean="wordgen" /&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        &amp;lt;/constructor-arg&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        &amp;lt;constructor-arg&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;            &amp;lt;ref bean="wordtoimage" /&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        &amp;lt;/constructor-arg&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red;"&gt;&lt;span style="font-family: Courier New;"&gt;    &amp;lt;/bean&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="margin-left: 36pt;"&gt;A WordGenerator creates a text to be read, it can be random, be a common implementation take words from a list, and can make composition to create a text easier to read for a human being. In the example the WordGenerator needs a Dictionnary to get real words from.&lt;br /&gt;&lt;/div&gt;&lt;span style="color: red; font-family: Courier New;"&gt;&amp;lt;bean id="wordgen"&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        class="com.octo.captcha.component.word.wordgenerator.DictionaryWordGenerator"&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        &amp;lt;constructor-arg&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;            &amp;lt;ref bean="filedict" /&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        &amp;lt;/constructor-arg&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;    &amp;lt;/bean&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;A Dictionary provides words, this one reads words from the one provided by default, with almost &lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;6000&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; english words.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;&amp;lt;bean id="filedict"&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        class="com.octo.captcha.component.word.FileDictionary"&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        &amp;lt;constructor-arg index="&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;0&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;"&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;            &amp;lt;value&amp;gt;toddlist&amp;lt;/value&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        &amp;lt;/constructor-arg&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;    &amp;lt;/bean&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;After to other important part to create a factory, is the WordToImage component, which is mainly created with three others components:&lt;br /&gt;&lt;br /&gt;&lt;ul style="margin-left: 72pt;"&gt;&lt;li&gt;A font generator&lt;br /&gt;&lt;/li&gt;&lt;li&gt;A background generator&lt;br /&gt;&lt;/li&gt;&lt;li&gt;A Text paster&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;This example is a bit more complex one; it takes the usual main three components, but also three deformations, to increase the power of captchas. All three are set to none, a component which creates no deformation, see below, and Examples to have more examples of deformations.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;    &lt;span style="color: red;"&gt;&amp;lt;bean id="wordtoimage"&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        class="com.octo.captcha.component.image.wordtoimage.ComposedWordToImage"&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        &amp;lt;constructor-arg index="&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;0&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;"&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;            &amp;lt;ref bean="fontGenRandom" /&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        &amp;lt;/constructor-arg&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        &amp;lt;constructor-arg index="&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;"&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;            &amp;lt;ref bean="backGenUni" /&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        &amp;lt;/constructor-arg&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        &amp;lt;constructor-arg index="&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;"&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;            &amp;lt;ref bean="simpleWhitePaster" /&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        &amp;lt;/constructor-arg&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;    &amp;lt;/bean&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="margin-left: 36pt;"&gt;A FontGenerator provide Fonts to a WordToImage, differents fonts increase the difficulties for cracking software using a learning process. This one generates random fonts from a list, and the first two arguments are the minimum size and the maximum size of the font.&lt;br /&gt;&lt;/div&gt;&lt;span style="font-family: Courier New;"&gt;    &lt;span style="color: red;"&gt;&amp;lt;bean id="fontGenRandom"&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        class="com.octo.captcha.component.image.fontgenerator.RandomFontGenerator"&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        &amp;lt;constructor-arg index="&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;0&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;"&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;            &amp;lt;value&amp;gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;40&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&amp;lt;/value&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        &amp;lt;/constructor-arg&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        &amp;lt;constructor-arg index="&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;"&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;            &amp;lt;value&amp;gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;50&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&amp;lt;/value&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        &amp;lt;/constructor-arg&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        &amp;lt;constructor-arg index="&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;"&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;            &amp;lt;list&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;                &amp;lt;ref bean="fontArial" /&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;            &amp;lt;/list&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        &amp;lt;/constructor-arg&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;    &amp;lt;/bean&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;A font is declared like this :&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;    &lt;span style="color: red;"&gt;&amp;lt;bean id="fontArial" class="java.awt.Font"&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        &amp;lt;constructor-arg index="&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;0&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;"&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;            &amp;lt;value&amp;gt;Arial&amp;lt;/value&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        &amp;lt;/constructor-arg&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        &amp;lt;constructor-arg index="&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;"&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;            &amp;lt;value&amp;gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;0&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&amp;lt;/value&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        &amp;lt;/constructor-arg&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        &amp;lt;constructor-arg index="&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;"&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;            &amp;lt;value&amp;gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;10&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&amp;lt;/value&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        &amp;lt;/constructor-arg&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;    &amp;lt;/bean&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="margin-left: 36pt;"&gt;The BackgrountGenerator component can be very simple like in the example, single color, or more complex with real picture, or fancy computed shapes. The first two arguments are always, the size (length and height) of the resulting image.&lt;br /&gt;&lt;/div&gt;&lt;span style="font-family: Courier New;"&gt;    &lt;span style="color: red;"&gt;&amp;lt;bean id="backGenUni"&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        class="com.octo.captcha.component.image.backgroundgenerator.UniColorBackgroundGenerator"&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        &amp;lt;constructor-arg index="&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;0&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;"&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;            &amp;lt;value&amp;gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;300&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&amp;lt;/value&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        &amp;lt;/constructor-arg&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        &amp;lt;constructor-arg index="&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;"&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;            &amp;lt;value&amp;gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;100&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&amp;lt;/value&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        &amp;lt;/constructor-arg&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;    &amp;lt;/bean&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="margin-left: 36pt;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-left: 36pt;"&gt;The TextPaster, according to his name, pastes the text on the background. This can be done in a simple way, (see example below), or another implementation can paste each character randomly (but still readably), or can double the text to make computers more confused. TextPaster can be even decorated to put perturbations around the text, a component, TextDecorator, is designed for this purpose, see Annexes for some examples. Commons arguments for TextPaster are:&lt;br /&gt;&lt;/div&gt;&lt;ul style="margin-left: 72pt;"&gt;&lt;li&gt;Minimal length of the text&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Maximal length of the text&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;A color generator component to create the text color, see Annexes.&lt;/div&gt;&lt;span style="color: red; font-family: Courier New;"&gt;&amp;lt;bean id="simpleWhitePaster"    class="com.octo.captcha.component.image.textpaster.SimpleTextPaster"&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        &amp;lt;constructor-arg type="java.lang.Integer" index="&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;0&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;"&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;            &amp;lt;value&amp;gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;3&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&amp;lt;/value&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        &amp;lt;/constructor-arg&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        &amp;lt;constructor-arg type="java.lang.Integer" index="&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;"&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;            &amp;lt;value&amp;gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;5&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&amp;lt;/value&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        &amp;lt;/constructor-arg&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        &amp;lt;constructor-arg type="java.awt.Color" index="&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;"&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;            &amp;lt;ref bean="colorGreen" /&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        &amp;lt;/constructor-arg&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;And a color definition:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: Courier New;"&gt;    &lt;span style="color: red;"&gt;&amp;lt;bean id="colorGreen" class="java.awt.Color"&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        &amp;lt;constructor-arg index="&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;0&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;"&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;            &amp;lt;value&amp;gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;0&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&amp;lt;/value&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        &amp;lt;/constructor-arg&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        &amp;lt;constructor-arg index="&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;"&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;            &amp;lt;value&amp;gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;255&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&amp;lt;/value&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        &amp;lt;/constructor-arg&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        &amp;lt;constructor-arg index="&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;"&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;            &amp;lt;value&amp;gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;0&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&amp;lt;/value&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        &amp;lt;/constructor-arg&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;    &amp;lt;/bean&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="margin-left: 18pt;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New;"&gt;This is all about the how jCaptcha generates the captcha image,now time is to use this captcha service with some application.&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New;"&gt;I am going to use this in simple registration form.&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New;"&gt;You can go through code for more details.&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-left: 36pt;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-left: 36pt;"&gt;&lt;a href="http://3.bp.blogspot.com/_7ZiCsz7bxzk/SksWa3uO-AI/AAAAAAAAAiQ/iRFL7ZAH83g/s1600-h/untitled.bmp" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5353397232950245378" src="http://3.bp.blogspot.com/_7ZiCsz7bxzk/SksWa3uO-AI/AAAAAAAAAiQ/iRFL7ZAH83g/s320/untitled.bmp" style="cursor: pointer; display: block; height: 320px; margin: 0px auto 10px; text-align: center; width: 218px;" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style="margin-left: 36pt;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New;"&gt;This is screenshot form of my registration page. The "grow" image is generated by the JCaptcha Controller.&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-left: 36pt;"&gt;&lt;span style="font-family: Courier New;"&gt;Things to do for this are :&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-left: 36pt;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;ul style="margin-left: 72pt;"&gt;&lt;li&gt;&lt;span style="font-family: Courier New;"&gt;In your registration form ,you should have text with name "j_captcha_response" and the second thing is to have image source which will get generated using CaptchaImageGenerator class.&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-family: Courier New;"&gt;        &lt;span style="color: red;"&gt;&amp;lt;tr&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;            &amp;lt;td&amp;gt;&amp;lt;label&amp;gt;Control text&amp;lt;/label&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;input type="text" name="j_captcha_response" /&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        &amp;lt;/tr&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        &amp;lt;tr&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;            &amp;lt;td colspan="&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;"&amp;gt;&amp;lt;img src="captcha.htm" /&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="margin-left: 54pt;"&gt;&lt;span style="color: red; font-family: Courier New;"&gt;   &amp;lt;/tr&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;ul style="margin-left: 72pt;"&gt;&lt;li&gt;&lt;span style="font-family: Courier New;"&gt;There is CaptchaImageGenerator which generate a jpeg image file for capchta image using captcha service.&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-family: Courier New;"&gt;&lt;span style="color: black;"&gt;        &lt;/span&gt;&lt;span style="color: red;"&gt;&lt;b&gt;public&lt;/b&gt; ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) &lt;b&gt;throws&lt;/b&gt; Exception {&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;            &lt;b&gt;byte&lt;/b&gt;[] captchaChallengeAsJpeg = &lt;b&gt;null&lt;/b&gt;;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="margin-left: 36pt;"&gt;&lt;span style="color: red; font-family: Courier New;"&gt;      ByteArrayOutputStream jpegOutputStream = &lt;b&gt;new&lt;/b&gt; ByteArrayOutputStream();&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style="color: red; font-family: Courier New;"&gt;                  String captchaId = request.getSession().getId();&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;                 BufferedImage challenge = captchaService.getImageChallengeForID(captchaId,request.getLocale());&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;                  JPEGImageEncoder jpegEncoder =&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: red; font-family: Courier New;"&gt;                  JPEGCodec.&lt;i&gt;createJPEGEncoder&lt;/i&gt;(jpegOutputStream);&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="margin-left: 72pt;"&gt;&lt;span style="color: red; font-family: Courier New;"&gt;      jpegEncoder.encode(challenge);&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-left: 72pt;"&gt;&lt;span style="color: red; font-family: Courier New;"&gt;      captchaChallengeAsJpeg = jpegOutputStream.toByteArray();&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-left: 72pt;"&gt;&lt;span style="color: red; font-family: Courier New;"&gt;      response.setHeader("Cache-Control", "no-store");&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-left: 72pt;"&gt;&lt;span style="color: red; font-family: Courier New;"&gt;      response.setHeader("Pragma", "no-cache");&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-left: 72pt;"&gt;&lt;span style="color: red; font-family: Courier New;"&gt;      response.setDateHeader("Expires", &lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;&lt;span class="currency_converter_link" title="Convert this amount"&gt;0&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;);&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-left: 72pt;"&gt;&lt;span style="color: red; font-family: Courier New;"&gt;      response.setContentType("image/jpeg");&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-left: 72pt;"&gt;&lt;span style="color: red; font-family: Courier New;"&gt;      ServletOutputStream responseOutputStream =&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-left: 72pt;"&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        response.getOutputStream();&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-left: 72pt;"&gt;&lt;span style="color: red; font-family: Courier New;"&gt;      responseOutputStream.write(captchaChallengeAsJpeg);&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-left: 72pt;"&gt;&lt;span style="color: red; font-family: Courier New;"&gt;      responseOutputStream.flush();&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-left: 72pt;"&gt;&lt;span style="color: red; font-family: Courier New;"&gt;      responseOutputStream.close();&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-left: 72pt;"&gt;&lt;span style="color: red; font-family: Courier New;"&gt;&lt;br /&gt;&lt;b&gt;return&lt;/b&gt;&lt;br /&gt;&lt;b&gt;null&lt;/b&gt;;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-left: 54pt;"&gt;&lt;span style="color: red; font-family: Courier New;"&gt;    }&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;ul style="margin-left: 72pt;"&gt;&lt;li&gt;&lt;span style="font-family: Courier New;"&gt;&lt;span style="color: black;"&gt;There will be validator method to validate this image :&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style="color: red; font-family: Courier New;"&gt;&lt;b&gt;protected&lt;/b&gt;&lt;br /&gt;&lt;b&gt;void&lt;/b&gt; validateCaptcha(HttpServletRequest request, BindException errors){&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="margin-left: 54pt;"&gt;&lt;span style="color: red; font-family: Courier New;"&gt;    &lt;b&gt;boolean&lt;/b&gt; isResponseCorrect = &lt;b&gt;false&lt;/b&gt;;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-left: 54pt;"&gt;&lt;span style="color: red; font-family: Courier New;"&gt;   String captchaId = request.getSession().getId();&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-left: 54pt;"&gt;&lt;span style="color: red; font-family: Courier New;"&gt;   String response = request.getParameter(captchaResponseParameterName);&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-left: 54pt;"&gt;&lt;span style="color: red; font-family: Courier New;"&gt;&lt;br /&gt;&lt;b&gt;try&lt;/b&gt; {    &lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-left: 54pt;"&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        &lt;b&gt;if&lt;/b&gt;(response != &lt;b&gt;null&lt;/b&gt;){&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-left: 54pt;"&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        isResponseCorrect = captchaService.validateResponseForID(captchaId, response);&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-left: 54pt;"&gt;&lt;span style="color: red; font-family: Courier New;"&gt;            }&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-left: 54pt;"&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        } &lt;b&gt;catch&lt;/b&gt; (CaptchaServiceException e) {&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-left: 54pt;"&gt;&lt;span style="color: red; font-family: Courier New;"&gt;    &lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-left: 54pt;"&gt;&lt;span style="color: red; font-family: Courier New;"&gt;    }&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-left: 54pt;"&gt;&lt;span style="color: red; font-family: Courier New;"&gt;    &lt;b&gt;if&lt;/b&gt;(!isResponseCorrect){&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-left: 54pt;"&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        String objectName = "Captcha";&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-left: 54pt;"&gt;&lt;span style="color: red; font-family: Courier New;"&gt;        String[] codes = {"invalid"};&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-left: 54pt;"&gt;&lt;span style="color: red; font-family: Courier New;"&gt;         Object[] arguments = {};&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-left: 54pt;"&gt;&lt;span style="color: red; font-family: Courier New;"&gt;         String defaultMessage = "Invalid image test entered!";&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-left: 54pt;"&gt;&lt;span style="color: red; font-family: Courier New;"&gt;         ObjectError oe = &lt;b&gt;new&lt;/b&gt; ObjectError(objectName, codes, arguments, defaultMessage);&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-left: 54pt;"&gt;&lt;span style="color: red; font-family: Courier New;"&gt;         errors.addError(oe);&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-left: 54pt;"&gt;&lt;span style="color: red; font-family: Courier New;"&gt;    } &lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-left: 54pt;"&gt;&lt;span style="color: red; font-family: Courier New;"&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-left: 36pt;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;span style="font-family: Courier New;"&gt;That's it you are done with JCpatcha. You can download the code from &lt;a href="http://www.esnips.com/doc/271c96b3-2209-4dcd-9456-2acb302d431e/JCaptchaSpring"&gt;http://www.esnips.com/doc/271c96b3-2209-4dcd-9456-2acb302d431e/JCaptchaSpring&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/517388772395375329-3319799079881097593?l=springkbase.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://springkbase.blogspot.com/feeds/3319799079881097593/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=517388772395375329&amp;postID=3319799079881097593' title='11 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/517388772395375329/posts/default/3319799079881097593'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/517388772395375329/posts/default/3319799079881097593'/><link rel='alternate' type='text/html' href='http://springkbase.blogspot.com/2009/07/spring-and-jcaptcha.html' title='Spring and JCaptcha'/><author><name>Anil Verma</name><uri>http://www.blogger.com/profile/07159037456674064065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://4.bp.blogspot.com/_7ZiCsz7bxzk/Sh6rQK6LSeI/AAAAAAAAAXs/9j_hHnOvp6E/S220/40815841.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_7ZiCsz7bxzk/SksWa3uO-AI/AAAAAAAAAiQ/iRFL7ZAH83g/s72-c/untitled.bmp' height='72' width='72'/><thr:total>11</thr:total></entry><entry><id>tag:blogger.com,1999:blog-517388772395375329.post-3940271559508215258</id><published>2009-06-15T00:47:00.000-07:00</published><updated>2009-06-15T01:06:16.442-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JMS'/><category scheme='http://www.blogger.com/atom/ns#' term='ActiveMQ'/><category scheme='http://www.blogger.com/atom/ns#' term='o/x mapping spring webservice'/><category scheme='http://www.blogger.com/atom/ns#' term='Spring-JMS Integration'/><title type='text'>Spring + JMS</title><content type='html'>This blog is been written as part of Spring integration with other technologies. In this blog I am going to explain how to integrate JMS(Java Messaging Service) with spring and to use template mechanism of spring for easy integration of  JMS. Spring provides a template mechanism to hide the details of a typical JMS implementation so developers can concentrate on the&lt;br /&gt;actual task of processing messages instead of worrying about how to create, access, or clean up JMS resources.As like other posts on integration I am supposing that you know spring and jms as I will just taking an example which will explain a “Hello World” type example of JMS with Spring.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I will be using Apache ActiveMQ as Message Broker. Please&lt;br /&gt;download the latest one from &lt;a href="http://activemq.apache.org/activemq-520-release.html"&gt;http://activemq.apache.org/activemq-520-release.html&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;So let’s see how can we integrate JMS with Spring. You can get the source code from&lt;br /&gt;&lt;a href="http://www.mediafire.com/download.php?wmqmfcnqnjm"&gt;http://www.mediafire.com/download.php?wmqmfcnqnjm&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Step 1. Configuring the Connection Factory&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;First thing we have to do is to create connection factory instance which will provide entry point to interact with Message Broker. This is connection factory will be used for sending and receiving messages. Here is the bean definition which will get into your spring configuration file.&lt;br /&gt;&lt;br /&gt;&amp;lt;!-- JMS Queue Connection Factory--&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;bean id="activeMQConnectionFactory"&lt;br /&gt;class="org.apache.activemq.ActiveMQConnectionFactory"&amp;gt;&lt;br /&gt;&amp;lt;property name="brokerURL" value="tcp://localhost:61616" /&amp;gt;&lt;br /&gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Step2.  Configuring the Message Destination&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;You can use both queue and topic mode for sending and&lt;br /&gt;receving the messages.&lt;br /&gt;&lt;br /&gt;For queue:&lt;br /&gt;&lt;br /&gt;&amp;lt;bean id="springJmsQueue" class="org.apache.activemq.command.ActiveMQQueue"&amp;gt;&lt;br /&gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;&lt;br /&gt;And for Topic:&lt;br /&gt;&lt;br /&gt;&amp;lt;bean id="springJmsTopic" class="org.apache.activemq.command.ActiveMQTopic"&amp;gt;&lt;br /&gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Step 3. Defining the JMS Template class&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Normally we create the connection factory instance ,then we create the session and the we send the message and hell lot of try catch blocks and code for closing sessions. Spring's JMSTemplate class simplifies the life of sending the message. Here is the declaration of the JMS Template class as a Spring bean,&lt;br /&gt;&lt;br /&gt;&amp;lt;!-- JMS Queue Template --&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;bean id="jmsQueueTemplate"&lt;br /&gt;class="org.springframework.jms.core.JmsTemplate"&amp;gt;&lt;br /&gt;&lt;br /&gt;     &amp;lt;property name="connectionFactory"&amp;gt;&lt;br /&gt;           &amp;lt;ref bean="activeMQConnectionFactory"/&amp;gt;&lt;br /&gt;     &amp;lt;/property&amp;gt;&lt;br /&gt;&amp;lt;property name="defaultDestination" ref="ideekshaQueue"&amp;gt;&amp;lt;/property&amp;gt;&lt;br /&gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;&lt;br /&gt;JMS Template takes reference for the connection factory  through which it will connect to Message Broker.I have used default destination queue to sens and receive messages, you can use you own and declare them for jms receiver and jms sender.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Step 4. Sending a message&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Here is the code for sending the JMS message using&lt;br /&gt;JMSTemplate.&lt;br /&gt;&lt;br /&gt;JmsSender.java&lt;br /&gt;&lt;br /&gt;-------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;package com.ideeksha.spring.jms;&lt;br /&gt;&lt;br /&gt;import org.springframework.jms.core.JmsTemplate;&lt;br /&gt;&lt;br /&gt;public class JmsSender {&lt;br /&gt;&lt;br /&gt;     private JmsTemplate jmsTemplate;&lt;br /&gt;     public JmsTemplate getJmsTemplate() {&lt;br /&gt;             return jmsTemplate;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;     public void setJmsTemplate(JmsTemplate jmsTemplate) {&lt;br /&gt;           this.jmsTemplate = jmsTemplate;&lt;br /&gt;     }&lt;br /&gt;&lt;br /&gt;     public void sendMesage() {&lt;br /&gt;             jmsTemplate.convertAndSend("HelloWorld!!!!");&lt;br /&gt;     }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;jmsTemplate.convertAndSend() takes destination and the message, as I have use defaultDestination in template it will take that destination and if you want to override this you can pass other destination to convertAndSend().&lt;br /&gt;This is the bean definition for JmsSender.  &lt;br /&gt;&lt;br /&gt;&amp;lt;bean id="jmsSender" class="com.ideeksha.spring.jms.JmsSender"&amp;gt;&lt;br /&gt;&amp;lt;property name="jmsTemplate"&amp;gt;&lt;br /&gt;        &amp;lt;ref bean="jmsQueueTemplate"/&amp;gt;&lt;br /&gt;&amp;lt;/property&amp;gt;&lt;br /&gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Step 5. Receiving the message&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Here is the code for receiving the JMS message using JMSTemplate.&lt;br /&gt;&lt;br /&gt;JmsReceiver.java&lt;br /&gt;&lt;br /&gt;-------------------------------------------------&lt;br /&gt;&lt;br /&gt;package com.ideeksha.spring.jms;&lt;br /&gt;&lt;br /&gt;import javax.jms.Message;&lt;br /&gt;import javax.jms.TextMessage;&lt;br /&gt;&lt;br /&gt;import org.springframework.jms.core.JmsTemplate;&lt;br /&gt;&lt;br /&gt;public class JmsReceiver {&lt;br /&gt;       private JmsTemplate jmsTemplate;&lt;br /&gt;&lt;br /&gt;       public JmsTemplate getjmsTemplate() {&lt;br /&gt;&lt;br /&gt;              return jmsTemplate;&lt;br /&gt;&lt;br /&gt;       }&lt;br /&gt;       public void setjmsTemplate(JmsTemplate jmsTemplate) {&lt;br /&gt;&lt;br /&gt;              this.jmsTemplate = jmsTemplate;&lt;br /&gt;&lt;br /&gt;       }&lt;br /&gt;       public void processMessage() {&lt;br /&gt;&lt;br /&gt;              Message msg = jmsTemplate.receive();&lt;br /&gt;              try {&lt;br /&gt;                      TextMessage textMessage = (TextMessage)msg;&lt;br /&gt;                      if (msg != null) {&lt;br /&gt;                              System.out.println(" Message Received --&amp;gt;"+ textMessage.getText());&lt;br /&gt;&lt;br /&gt;                      }&lt;br /&gt;              } catch (Exception e) {&lt;br /&gt;&lt;br /&gt;                      e.printStackTrace();&lt;br /&gt;&lt;br /&gt;              }&lt;br /&gt;&lt;br /&gt;       }&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;And here is the bean definition for the message receiver class,&lt;br /&gt;&lt;br /&gt;&amp;lt;bean id="jmsReceiver" class="com.ideeksha.spring.jms.JmsReceiver"&amp;gt;&lt;br /&gt;     &amp;lt;property name="jmsTemplate"&amp;gt;&lt;br /&gt;           &amp;lt;ref bean="jmsQueueTemplate"/&amp;gt;&lt;br /&gt;     &amp;lt;/property&amp;gt;&lt;br /&gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Step 6. Running this application&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;First we can  provide this as a service by declaring a service interface.&lt;br /&gt;&lt;br /&gt;This is my service interface:&lt;br /&gt;&lt;br /&gt;JmsService.java&lt;br /&gt;&lt;br /&gt;-------------------------------------------&lt;br /&gt;&lt;br /&gt;package com.ideeksha.spring.jms;&lt;br /&gt;&lt;br /&gt;public interface JmsService {&lt;br /&gt;&lt;br /&gt;     public abstract void process();&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;And here is its implementation&lt;br /&gt;&lt;br /&gt;JmsServiceImpl.java&lt;br /&gt;------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;package com.ideeksha.spring.jms;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;public class JmsServiceImpl implements JmsService {&lt;br /&gt;&lt;br /&gt;     private JmsSender sender;&lt;br /&gt;&lt;br /&gt;     private JmsReceiver receiver;&lt;br /&gt;&lt;br /&gt;     public JmsSender getSender() {&lt;br /&gt;           return sender;&lt;br /&gt;     }&lt;br /&gt;     public void setSender(JmsSender sender) {&lt;br /&gt;           this.sender = sender;&lt;br /&gt;     }&lt;br /&gt;&lt;br /&gt;     public JmsReceiver getReceiver() {&lt;br /&gt;           return receiver;&lt;br /&gt;     }&lt;br /&gt;&lt;br /&gt;    public void setReceiver(JmsReceiver receiver) {&lt;br /&gt;           this.receiver = receiver;&lt;br /&gt;     }&lt;br /&gt;&lt;br /&gt;    public void process() {&lt;br /&gt;           sender.sendMesage();&lt;br /&gt;//          uncomment below lines for checking in active mq admin GUI&lt;br /&gt;//          try {&lt;br /&gt;//                Thread.sleep(10000);&lt;br /&gt;//          } catch(InterruptedException e) {&lt;br /&gt;//                e.printStackTrace();&lt;br /&gt;//          }&lt;br /&gt;           receiver.processMessage();&lt;br /&gt;     }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;And finally the main class which will execute this:&lt;br /&gt;&lt;br /&gt;App.java&lt;br /&gt;&lt;br /&gt;----------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;package com.ideeksha.spring.jms;&lt;br /&gt;&lt;br /&gt;import org.springframework.context.ApplicationContext;&lt;br /&gt;&lt;br /&gt;import org.springframework.context.support.ClassPathXmlApplicationContext;&lt;br /&gt;&lt;br /&gt;public class App {&lt;br /&gt;&lt;br /&gt;     public static void main(String[] args) {&lt;br /&gt;&lt;br /&gt;           ApplicationContext ctx = new                      ClassPathXmlApplicationContext("applicationContext.xml");&lt;br /&gt;  JmsServiceImpl service =(JmsServiceImpl) ctx.getBean("jmsService");&lt;br /&gt;           service.process();&lt;br /&gt;&lt;br /&gt;     }&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;And the bean definition for all of this is&lt;br /&gt;&lt;br /&gt;&amp;lt;bean id="jmsService" class="com.ideeksha.spring.jms.JmsServiceImpl"&amp;gt;&lt;br /&gt;&amp;lt;property name="sender"&amp;gt;&lt;br /&gt; &amp;lt;ref bean="jmsSender"/&amp;gt;&lt;br /&gt;&amp;lt;/property&amp;gt;&lt;br /&gt;&amp;lt;property name="receiver"&amp;gt;&lt;br /&gt; &amp;lt;ref bean="jmsReceiver"/&amp;gt;&lt;br /&gt;&amp;lt;/property&amp;gt;&lt;br /&gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;&lt;br /&gt;But this is synchronous JMS code, but we use jms for asynchronous communication.&lt;br /&gt;So for this we have to modify the Service implementaion and remove the receiver&lt;br /&gt;code.&lt;br /&gt;&lt;br /&gt;So out new implementation file will be&lt;br /&gt;&lt;br /&gt;JmsServiceImpl.java&lt;br /&gt;--------------------------------------------------------------------&lt;br /&gt;&lt;br /&gt;package com.ideeksha.spring.jms;&lt;br /&gt;&lt;br /&gt;public class JmsServiceImpl implements&lt;br /&gt;JmsService {&lt;br /&gt;&lt;br /&gt;     private JmsSender sender;&lt;br /&gt;&lt;br /&gt;     private JmsReceiver receiver;&lt;br /&gt;&lt;br /&gt;     public JmsSender getSender() {&lt;br /&gt;           return sender;&lt;br /&gt;     }&lt;br /&gt;&lt;br /&gt;     public void setSender(JmsSender sender) {&lt;br /&gt;           this.sender = sender;&lt;br /&gt;     }&lt;br /&gt;     public JmsReceiver getReceiver() {&lt;br /&gt;           return receiver;&lt;br /&gt;     }&lt;br /&gt;     public void setReceiver(JmsReceiver receiver) {&lt;br /&gt;           this.receiver = receiver;&lt;br /&gt;     }&lt;br /&gt;     public void process() {&lt;br /&gt;           sender.sendMesage();&lt;br /&gt;     }&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;And there will be Message Listener which will listen for one particular destincation queue/topic.&lt;br /&gt;So we have Listener class which will be implementing MessageListener imterface.&lt;br /&gt;&lt;br /&gt;Listener.java&lt;br /&gt;-----------------------------------------------------------&lt;br /&gt;&lt;br /&gt;package com.ideeksha.spring.jms;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;import javax.jms.JMSException;&lt;br /&gt;import javax.jms.Message;&lt;br /&gt;import javax.jms.MessageListener;&lt;br /&gt;import javax.jms.TextMessage;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;public class Listener implements MessageListener {&lt;br /&gt;&lt;br /&gt;     public void onMessage(Message msg) {&lt;br /&gt;&lt;br /&gt;           if (msg instanceof TextMessage) {&lt;br /&gt;                 try {&lt;br /&gt;                       System.out.println("Received msg asynchronously: " + ((TextMessage) msg).getText());&lt;br /&gt;&lt;br /&gt;                 } catch (JMSException e) {&lt;br /&gt;                       e.printStackTrace();&lt;br /&gt;                 }&lt;br /&gt;&lt;br /&gt;           } else {&lt;br /&gt;&lt;br /&gt;                 throw new RuntimeException("This message should be of type TextMessage");&lt;br /&gt;           }&lt;br /&gt;     }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;And the bean definition for this is&lt;br /&gt;    &amp;lt;!-- This is the Message Driven Pojo (MDP) --&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;bean id="messageListener" class="com.ideeksha.spring.jms.Listener" /&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;We have to put this Listener in jms Container. For that this is the bean definition of jms container&lt;br /&gt;&lt;br /&gt;&amp;lt;!-- This is the message listener container --&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;bean id="jmsContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer"&amp;gt;&lt;br /&gt;&amp;lt;property name="connectionFactory" ref="activeMQConnectionFactory"/&amp;gt;&lt;br /&gt;&amp;lt;property name="destination" ref="ideekshaQueue" /&amp;gt;&lt;br /&gt;&amp;lt;property name="messageListener" ref="messageListener" /&amp;gt;&lt;br /&gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;&lt;br /&gt;Which will have reference for jms queue on which it will be listening and the listener reference.&lt;br /&gt;&lt;br /&gt;In the sample code what I have attached is having synchronous functionality, if you want to do asynchronous uncomment the listener and the container definition from the configuration file.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/517388772395375329-3940271559508215258?l=springkbase.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://springkbase.blogspot.com/feeds/3940271559508215258/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=517388772395375329&amp;postID=3940271559508215258' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/517388772395375329/posts/default/3940271559508215258'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/517388772395375329/posts/default/3940271559508215258'/><link rel='alternate' type='text/html' href='http://springkbase.blogspot.com/2009/06/spring-jms.html' title='Spring + JMS'/><author><name>Anil Verma</name><uri>http://www.blogger.com/profile/07159037456674064065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://4.bp.blogspot.com/_7ZiCsz7bxzk/Sh6rQK6LSeI/AAAAAAAAAXs/9j_hHnOvp6E/S220/40815841.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-517388772395375329.post-2033361987498363195</id><published>2009-06-02T03:02:00.000-07:00</published><updated>2009-06-03T19:18:44.178-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='spring-webservice'/><category scheme='http://www.blogger.com/atom/ns#' term='webservice'/><category scheme='http://www.blogger.com/atom/ns#' term='castor'/><category scheme='http://www.blogger.com/atom/ns#' term='web-service'/><category scheme='http://www.blogger.com/atom/ns#' term='Spring'/><category scheme='http://www.blogger.com/atom/ns#' term='o/x mapping spring webservice'/><title type='text'>Spring WebService with Castor</title><content type='html'>&lt;script src="http://www.gmodules.com/ig/ifr?url=http://www.google.com/ig/modules/translatemypage.xml&amp;up_source_language=en&amp;w=160&amp;h=60&amp;title=&amp;border=&amp;output=js"&gt;&lt;/script&gt;&lt;br /&gt;&lt;div  style="font-family:courier new;"&gt;&lt;span style="font-size:130%;"&gt;This tutorial is all about Spring based contract-first based web-services.&lt;br /&gt;&lt;/span&gt;&lt;div&gt;&lt;span style="font-size:130%;"&gt;I am also demostrating how to use Castor as marshaller and unmashaller.&lt;br /&gt;The client for web-service I am using as SOAP UI which will generate the&lt;br /&gt;SOAP request for the web-service and offcourse it will also show the response&lt;br /&gt;sent by the web-service.&lt;br /&gt;&lt;br /&gt;For developing web services I will start with the XML Schema/WSDL because it is contract first web-service followed by the Java code second. Spring-WS focuses on this development style, and this tutorial will help you get started. Note that the first part of this tutorial contains almost no Spring-WS specific information: it is mostly about  XML, XSD, and WSDL. The second part focusses on implementing this contract using Spring-WS .&lt;br /&gt;&lt;br /&gt;The most important thing when doing contract-first Web service development is&lt;br /&gt;to try and think in terms of XML. This means that Java-language concepts are&lt;br /&gt;of lesser importance. It is the XML that is sent across the wire, and you&lt;br /&gt;should focus on that. The fact that Java is used to implement the Web service&lt;br /&gt;is an implementation detail. An important detail, but a detail nonetheless.&lt;br /&gt;&lt;br /&gt;In this tutorial, we will define a Web service that is created by a Store&lt;br /&gt;department. Clients can send order request to this service to add a order.&lt;br /&gt;&lt;br /&gt;1.2. Messages&lt;br /&gt;In this section, we will focus on the actual XML messages that are sent to&lt;br /&gt;and from the Web service. We will start out by determining what these messages&lt;br /&gt;look like.&lt;br /&gt;&lt;br /&gt;1.2.1. Order&lt;br /&gt;In the scenario, we have to deal with Order requests, so it makes sense&lt;br /&gt;to determine what a Order looks like in XML:&lt;br /&gt;&lt;br /&gt;&amp;lt;OrderRequest&amp;gt;&lt;br /&gt;&amp;lt;item&amp;gt;&lt;br /&gt;&amp;lt;id&amp;gt;13245&amp;lt;/id&amp;gt;&lt;br /&gt;&amp;lt;itemName&amp;gt;Keyboard&amp;lt;/itemName&amp;gt;&lt;br /&gt;&amp;lt;quantity&amp;gt;10&amp;lt;/quantity&amp;gt;&lt;br /&gt;&amp;lt;discount&amp;gt;0&amp;lt;/discount&amp;gt;&lt;br /&gt;&amp;lt;sellingprice&amp;gt;3000&amp;lt;/sellingprice&amp;gt;&lt;br /&gt;&amp;lt;/item&amp;gt;&lt;br /&gt;&amp;lt;item&amp;gt;&lt;br /&gt;&amp;lt;id&amp;gt;13247&amp;lt;/id&amp;gt;&lt;br /&gt;&amp;lt;itemName&amp;gt;Monitor&amp;lt;/itemName&amp;gt;&lt;br /&gt;&amp;lt;quantity&amp;gt;10&amp;lt;/quantity&amp;gt;&lt;br /&gt;&amp;lt;discount&amp;gt;0&amp;lt;/discount&amp;gt;&lt;br /&gt;&amp;lt;sellingprice&amp;gt;90000&amp;lt;/sellingprice&amp;gt;&lt;br /&gt;&amp;lt;/item&amp;gt;&lt;br /&gt;&amp;lt;customerID&amp;gt;898798&amp;lt;/customerID&amp;gt;&lt;br /&gt;&amp;lt;orderID&amp;gt;8797&amp;lt;/orderID&amp;gt;&lt;br /&gt;&amp;lt;/OrderRequest&amp;gt;&lt;br /&gt;&lt;br /&gt;A OrderRequest consists of customer id ,order id and the list of items that are in order. We have also decided to use the "string" elements, because that will save a lot of parsing hassle.&lt;br /&gt;&lt;br /&gt;1.3. Data Contract&lt;br /&gt;Now that we have seen some examples of the XML data that we will use,&lt;br /&gt;it makes sense to formalize this into a schema. This data contract&lt;br /&gt;defines the message format we accept. There are four different ways&lt;br /&gt;of defining such a contract for XML:&lt;br /&gt;DTDsXML&lt;br /&gt;Schema (XSD)&lt;br /&gt;RELAX&lt;br /&gt;NGSchematron&lt;br /&gt;&lt;br /&gt;DTDs have limited namespace support, so they are not suitable for Web&lt;br /&gt;services. Relax NG and Schematron certainly are easier than XML Schema.&lt;br /&gt;Unfortunately, they are not so widely supported across platforms. We&lt;br /&gt;will use XML Schema.&lt;br /&gt;&lt;br /&gt;By far the easiest way to create an XSD is to infer it from sample&lt;br /&gt;documents. Any good XML editor or Java IDE offers this functionality.&lt;br /&gt;Basically, these tools use some sample XML documents, and generate a&lt;br /&gt;schema from it that validates them all. The end result certainly needs&lt;br /&gt;to be polished up, but it's a great starting point.&lt;br /&gt;&lt;br /&gt;This is our final xsd:&lt;br /&gt;orderService.xsd&lt;br /&gt;---------------------------------&lt;br /&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;&lt;br /&gt;&amp;lt;schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:ideeksha-spring-ws="http://ideeksha.gotdns.com/order" targetNamespace="http://ideeksha.gotdns.com/order" elementFormDefault="qualified"&amp;gt;&lt;br /&gt;&amp;lt;complexType name="item"&amp;gt;&lt;br /&gt;&amp;lt;sequence&amp;gt;&lt;br /&gt;&amp;lt;element name="id" type="string" minOccurs="1"/&amp;gt;&lt;br /&gt;&amp;lt;element name="itemName" type="string" minOccurs="1"/&amp;gt;&lt;br /&gt;&amp;lt;element name="quantity" type="string" minOccurs="1"/&amp;gt;&lt;br /&gt;&amp;lt;element name="discount" type="string" minOccurs="1"/&amp;gt;&lt;br /&gt;&amp;lt;element name="sellingprice" type="string" minOccurs="1"/&amp;gt;&lt;br /&gt;&amp;lt;/sequence&amp;gt;&lt;br /&gt;&amp;lt;/complexType&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;complexType name="order-response"&amp;gt;&lt;br /&gt;&amp;lt;sequence&amp;gt;&lt;br /&gt;&amp;lt;element name="code" type="string" minOccurs="1"/&amp;gt;&lt;br /&gt;&amp;lt;/sequence&amp;gt;&lt;br /&gt;&amp;lt;/complexType&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;complexType name="order-request"&amp;gt;&lt;br /&gt;&amp;lt;sequence&amp;gt;&lt;br /&gt;&amp;lt;element name="item" type="ideeksha-spring-ws:item" minOccurs="1" maxOccurs="unbounded"/&amp;gt;&lt;br /&gt;&amp;lt;element name="customerID" type="string" minOccurs="1"/&amp;gt;&lt;br /&gt;&amp;lt;element name="orderID" type="string" minOccurs="1"/&amp;gt;&lt;br /&gt;&amp;lt;/sequence&amp;gt;&lt;br /&gt;&amp;lt;/complexType&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;element name="OrderRequest" type="ideeksha-spring-ws:order-request"/&amp;gt;&lt;br /&gt;&amp;lt;element name="OrderResponse" type="ideeksha-spring-ws:order-response"/&amp;gt;&lt;br /&gt;&amp;lt;/schema&amp;gt;&lt;br /&gt;&lt;br /&gt;1.4. Service contract&lt;br /&gt;A service contract is generally expressed as a WSDL file.&lt;br /&gt;Note that in Spring-WS, writing the WSDL by hand is not required. Based on the XSD and some conventions, Spring-WS can create the WSDL for you, as explained in the section entitled Section 3.6, “Implementing the Endpoint”.&lt;br /&gt;This is our final wsdl file generated by Spring :&lt;br /&gt;&lt;br /&gt;http://localhost:8080/SpringWebService/order-ws/orderWebService.wsdl&lt;br /&gt;---------------------------------------------------------------------------&lt;br /&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;&amp;lt;wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:sch="http://ideeksha.gotdns.com/order" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://ideeksha.gotdns.com/order" targetNamespace="http://ideeksha.gotdns.com/order"&amp;gt;&lt;br /&gt;&amp;lt;wsdl:types&amp;gt;&lt;br /&gt;&amp;lt;schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:ideeksha-spring-ws="http://ideeksha.gotdns.com/order" elementFormDefault="qualified" targetNamespace="http://ideeksha.gotdns.com/order"&amp;gt;&lt;br /&gt;&amp;lt;complexType name="item"&amp;gt;&lt;br /&gt;&amp;lt;sequence&amp;gt;&lt;br /&gt;&amp;lt;element minOccurs="1" name="id" type="string"/&amp;gt;&lt;br /&gt;&amp;lt;element minOccurs="1" name="itemName" type="string"/&amp;gt;&lt;br /&gt;&amp;lt;element minOccurs="1" name="quantity" type="string"/&amp;gt;&lt;br /&gt;&amp;lt;element minOccurs="1" name="discount" type="string"/&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;element minOccurs="1" name="sellingprice" type="string"/&amp;gt;&lt;br /&gt;&amp;lt;/sequence&amp;gt;&lt;br /&gt;&amp;lt;/complexType&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;complexType name="order-response"&amp;gt;&lt;br /&gt;&amp;lt;sequence&amp;gt;&lt;br /&gt;&amp;lt;element minOccurs="1" name="code" type="string"/&amp;gt;&lt;br /&gt;&amp;lt;/sequence&amp;gt;&lt;br /&gt;&amp;lt;/complexType&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;complexType name="order-request"&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;sequence&amp;gt;&lt;br /&gt;&amp;lt;element maxOccurs="unbounded" minOccurs="1" name="item" type="ideeksha-spring-ws:item"/&amp;gt;&lt;br /&gt;&amp;lt;element minOccurs="1" name="customerID" type="string"/&amp;gt;&lt;br /&gt;&amp;lt;element minOccurs="1" name="orderID" type="string"/&amp;gt;&lt;br /&gt;&amp;lt;/sequence&amp;gt;&lt;br /&gt;&amp;lt;/complexType&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;element name="OrderRequest" type="ideeksha-spring-ws:order-request"/&amp;gt;&lt;br /&gt;&amp;lt;element name="OrderResponse" type="ideeksha-spring-ws:order-response"/&amp;gt;&lt;br /&gt;&amp;lt;/schema&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/wsdl:types&amp;gt;&lt;br /&gt;&amp;lt;wsdl:message name="OrderResponse"&amp;gt;&lt;br /&gt;&amp;lt;wsdl:part element="tns:OrderResponse" name="OrderResponse"&amp;gt;&lt;br /&gt;&amp;lt;/wsdl:part&amp;gt;&lt;br /&gt;&amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;&amp;lt;wsdl:message name="OrderRequest"&amp;gt;&lt;br /&gt;&amp;lt;wsdl:part element="tns:OrderRequest" name="OrderRequest"&amp;gt;&lt;br /&gt;&amp;lt;/wsdl:part&amp;gt;&lt;br /&gt;&amp;lt;/wsdl:message&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;wsdl:portType name="OrderResource"&amp;gt;&lt;br /&gt;&amp;lt;wsdl:operation name="Order"&amp;gt;&lt;br /&gt;&amp;lt;wsdl:input message="tns:OrderRequest" name="OrderRequest"&amp;gt;&lt;br /&gt;&amp;lt;/wsdl:input&amp;gt;&lt;br /&gt;&amp;lt;wsdl:output message="tns:OrderResponse" name="OrderResponse"&amp;gt;&lt;br /&gt;&amp;lt;/wsdl:output&amp;gt;&lt;br /&gt;&amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;&amp;lt;/wsdl:portType&amp;gt;&lt;br /&gt;&amp;lt;wsdl:binding name="OrderResourceSoap11" type="tns:OrderResource"&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/&amp;gt;&lt;br /&gt;&amp;lt;wsdl:operation name="Order"&amp;gt;&lt;br /&gt;&amp;lt;soap:operation soapAction=""/&amp;gt;&lt;br /&gt;&amp;lt;wsdl:input name="OrderRequest"&amp;gt;&lt;br /&gt;&amp;lt;soap:body use="literal"/&amp;gt;&lt;br /&gt;&amp;lt;/wsdl:input&amp;gt;&lt;br /&gt;&amp;lt;wsdl:output name="OrderResponse"&amp;gt;&lt;br /&gt;&amp;lt;soap:body use="literal"/&amp;gt;&lt;br /&gt;&amp;lt;/wsdl:output&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/wsdl:operation&amp;gt;&lt;br /&gt;&amp;lt;/wsdl:binding&amp;gt;&lt;br /&gt;&amp;lt;wsdl:service name="OrderResourceService"&amp;gt;&lt;br /&gt;&amp;lt;wsdl:port binding="tns:OrderResourceSoap11" name="OrderResourceSoap11"&amp;gt;&lt;br /&gt;&amp;lt;soap:address location="http://localhost:8080/SpringWebService/order-ws/orderWebService"/&amp;gt;&lt;br /&gt;&amp;lt;/wsdl:port&amp;gt;&lt;br /&gt;&amp;lt;/wsdl:service&amp;gt;&lt;br /&gt;&amp;lt;/wsdl:definitions&amp;gt;&lt;br /&gt;&lt;br /&gt;I define the OrderRequest message, which gets used in the&lt;br /&gt;portType.&lt;br /&gt;&lt;br /&gt;The OrderRequest type is defined in the schema.&lt;br /&gt;&lt;br /&gt;I define the OrderResource port type, which gets used in the&lt;br /&gt;binding.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I use a document/literal style.&lt;br /&gt;&lt;br /&gt;The literal http://schemas.xmlsoap.org/soap/http signifies a&lt;br /&gt;HTTP transport.&lt;br /&gt;&lt;br /&gt;The soapAction attribute signifies the SOAPAction HTTP&lt;br /&gt;header that will be sent with every request.&lt;br /&gt;&lt;br /&gt;The http://localhost:8080/SpringWebService/order-ws/SpringWebService address is the URL where the web-service can be invoked.&lt;br /&gt;&lt;br /&gt;This is the final WSDL. We will describe how to implement the resulting schema and WSDL in the next section.&lt;br /&gt;&lt;br /&gt;1.5. Creating the project&lt;br /&gt;In this section, we will be using Maven2 to create the&lt;br /&gt;initial project structure for us. Doing so is not required, but greatly reduces the amount of code we have to write to setup our HolidayService.&lt;br /&gt;&lt;br /&gt;The following command creates a Maven2 web application project for us, using the Spring-WS archetype (that is, project template)&lt;br /&gt;mvn archetype:create -DarchetypeGroupId=org.springframework.ws \&lt;br /&gt;-DarchetypeArtifactId=spring-ws-archetype \&lt;br /&gt;-DarchetypeVersion=1.5.7 \&lt;br /&gt;-DgroupId=com.ideeksha.spring.ws \&lt;br /&gt;-DartifactId=SpringWebService&lt;br /&gt;&lt;br /&gt;This command will create a new directory called SpringWebService. In this directory,&lt;br /&gt;there is a 'src/main/webapp' directory, which will contain the root of the WAR file.&lt;br /&gt;You will find the standard web application deployment descriptor 'WEB-INF/web.xml'  here, which defines a Spring-WS MessageDispatcherServlet and maps all incoming requests to this servlet:&lt;br /&gt;&lt;br /&gt;&amp;lt;web-app xmlns="http://java.sun.com/xml/ns/j2ee"&lt;br /&gt;xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&lt;br /&gt;xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee&lt;br /&gt;http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"&lt;br /&gt;version="2.4"&amp;gt;&lt;br /&gt;&amp;lt;display-name&amp;gt;Store Department Order Service&amp;lt;/display-name&amp;gt;&lt;br /&gt;&amp;lt;servlet&amp;gt;&lt;br /&gt;&amp;lt;servlet-name&amp;gt;order-ws&amp;lt;/servlet-name&amp;gt;&lt;br /&gt;&amp;lt;servlet-class&amp;gt;org.springframework.ws.transport.http.MessageDispatcherServlet&amp;lt;/servlet-class&amp;gt;&lt;br /&gt;&amp;lt;/servlet&amp;gt;&lt;br /&gt;&amp;lt;servlet-mapping&amp;gt;&lt;br /&gt;&amp;lt;servlet-name&amp;gt;order-ws&amp;lt;/servlet-name&amp;gt;&lt;br /&gt;&amp;lt;url-pattern&amp;gt;/order-ws/*&amp;lt;/url-pattern&amp;gt;&lt;br /&gt;&amp;lt;/servlet-mapping&amp;gt;&lt;br /&gt;&amp;lt;/web-app&amp;gt;&lt;br /&gt;&lt;br /&gt;In addition to the above 'WEB-INF/web.xml' file, you will also need another,&lt;br /&gt;Spring-WS-specific configuration file, named 'WEB-INF/order-ws-servlet.xml'.&lt;br /&gt;This file contains all of the Spring-WS-specific beans such as EndPoints,&lt;br /&gt;WebServiceMessageReceivers, and such like, and is used to create a new Spring container.&lt;br /&gt;The name of this file is derived from the name of the attendant servlet (in this case&lt;br /&gt;'order-ws') with '-servlet.xml' appended to it.&lt;br /&gt;&lt;br /&gt;1.6. Implementing the Endpoint&lt;br /&gt;In Spring-WS, you will implement Endpoints to handle incoming XML messages.&lt;br /&gt;There are two flavors of endpoints: message endpoints and&lt;br /&gt;payload endpoints. Message endpoints give access to the entire XML message, including SOAP headers. Typically, the endpoint will only be interested in the payload of the message, that is the contents of the SOAP body.&lt;br /&gt;In that case, creating a payload endpoint makes more sense.&lt;br /&gt;&lt;br /&gt;1.6.1. Handling the XML Message&lt;br /&gt;In this sample application, we are going to use Castor to handle&lt;br /&gt;the XML message.&lt;br /&gt;&lt;br /&gt;OrderWSEndpoint.java&lt;br /&gt;------------------------------&lt;br /&gt;package com.ideeksha.order.ws;&lt;br /&gt;&lt;br /&gt;import java.util.Iterator;&lt;br /&gt;import java.util.List;&lt;br /&gt;&lt;br /&gt;import org.apache.commons.logging.Log;&lt;br /&gt;import org.apache.commons.logging.LogFactory;&lt;br /&gt;import org.springframework.ws.server.endpoint.annotation.Endpoint;&lt;br /&gt;import org.springframework.ws.server.endpoint.annotation.PayloadRoot;&lt;br /&gt;&lt;br /&gt;@Endpoint&lt;br /&gt;public class OrderWSEndpoint {&lt;br /&gt;&lt;br /&gt;private static final Log LOG = LogFactory.getLog(OrderWSEndpoint.class);&lt;br /&gt;&lt;br /&gt;@PayloadRoot(localPart = "OrderRequest", namespace = "http://ideeksha.gotdns.com/order")&lt;br /&gt;public OrderResponse receiveOrder(&lt;br /&gt;OrderRequest orderRequest) {&lt;br /&gt;&lt;br /&gt;try {&lt;br /&gt;List&amp;lt;Item&amp;gt; itemList = orderRequest.getItemList();&lt;br /&gt;&lt;br /&gt;Iterator&amp;lt;Item&amp;gt; iterator = itemList.iterator();&lt;br /&gt;while (iterator.hasNext()) {&lt;br /&gt;Item item = iterator.next();&lt;br /&gt;System.out.println(item);&lt;br /&gt;}&lt;br /&gt;} catch (Exception e) {&lt;br /&gt;LOG.error("", e);&lt;br /&gt;}&lt;br /&gt;OrderResponse orderResponse = new OrderResponse();&lt;br /&gt;orderResponse.setCode("SUCCESS");&lt;br /&gt;&lt;br /&gt;return orderResponse;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;We are using annoation to mark a class as Endpoint and the method which is to be executed for the particular type of request is denoted by&lt;br /&gt;"@PayloadRoot(localPart = "OrderRequest", namespace = "http://ideeksha.gotdns.com/order")" anotaion.&lt;br /&gt;So "receiveOrder" ,method will get executed if any OrderRequest is come for this EndPoint.&lt;br /&gt;&lt;br /&gt;Because we use Castor, we must add some dependencies to the Maven pom.xml, which is in the root of our project directory. Here is the part of POM file:&lt;br /&gt;&lt;br /&gt;&amp;lt;dependency&amp;gt;&lt;br /&gt;&amp;lt;groupId&amp;gt;org.springframework.ws&amp;lt;/groupId&amp;gt;&lt;br /&gt;&amp;lt;artifactId&amp;gt;spring-ws-core-tiger&amp;lt;/artifactId&amp;gt;&lt;br /&gt;&amp;lt;version&amp;gt;1.5.6&amp;lt;/version&amp;gt;&lt;br /&gt;&amp;lt;exclusions&amp;gt;&lt;br /&gt;&amp;lt;exclusion&amp;gt;&lt;br /&gt;&amp;lt;groupId&amp;gt;log4j&amp;lt;/groupId&amp;gt;&lt;br /&gt;&amp;lt;artifactId&amp;gt;log4j&amp;lt;/artifactId&amp;gt;&lt;br /&gt;&amp;lt;/exclusion&amp;gt;&lt;br /&gt;&amp;lt;/exclusions&amp;gt;&lt;br /&gt;&amp;lt;/dependency&amp;gt;&lt;br /&gt;&amp;lt;dependency&amp;gt;&lt;br /&gt;&amp;lt;groupId&amp;gt;jdom&amp;lt;/groupId&amp;gt;&lt;br /&gt;&amp;lt;artifactId&amp;gt;jdom&amp;lt;/artifactId&amp;gt;&lt;br /&gt;&amp;lt;version&amp;gt;1.0&amp;lt;/version&amp;gt;&lt;br /&gt;&amp;lt;exclusions&amp;gt;&lt;br /&gt;&amp;lt;exclusion&amp;gt;&lt;br /&gt;&amp;lt;groupId&amp;gt;log4j&amp;lt;/groupId&amp;gt;&lt;br /&gt;&amp;lt;artifactId&amp;gt;log4j&amp;lt;/artifactId&amp;gt;&lt;br /&gt;&amp;lt;/exclusion&amp;gt;&lt;br /&gt;&amp;lt;/exclusions&amp;gt;&lt;br /&gt;&amp;lt;/dependency&amp;gt;&lt;br /&gt;&amp;lt;dependency&amp;gt;&lt;br /&gt;&amp;lt;groupId&amp;gt;jaxen&amp;lt;/groupId&amp;gt;&lt;br /&gt;&amp;lt;artifactId&amp;gt;jaxen&amp;lt;/artifactId&amp;gt;&lt;br /&gt;&amp;lt;version&amp;gt;1.1&amp;lt;/version&amp;gt;&lt;br /&gt;&amp;lt;exclusions&amp;gt;&lt;br /&gt;&amp;lt;exclusion&amp;gt;&lt;br /&gt;&amp;lt;groupId&amp;gt;log4j&amp;lt;/groupId&amp;gt;&lt;br /&gt;&amp;lt;artifactId&amp;gt;log4j&amp;lt;/artifactId&amp;gt;&lt;br /&gt;&amp;lt;/exclusion&amp;gt;&lt;br /&gt;&amp;lt;/exclusions&amp;gt;&lt;br /&gt;&amp;lt;/dependency&amp;gt;&lt;br /&gt;&amp;lt;dependency&amp;gt;&lt;br /&gt;&amp;lt;groupId&amp;gt;javax.xml.soap&amp;lt;/groupId&amp;gt;&lt;br /&gt;&amp;lt;artifactId&amp;gt;saaj-api&amp;lt;/artifactId&amp;gt;&lt;br /&gt;&amp;lt;version&amp;gt;1.3&amp;lt;/version&amp;gt;&lt;br /&gt;&amp;lt;scope&amp;gt;runtime&amp;lt;/scope&amp;gt;&lt;br /&gt;&amp;lt;exclusions&amp;gt;&lt;br /&gt;&amp;lt;exclusion&amp;gt;&lt;br /&gt;&amp;lt;groupId&amp;gt;log4j&amp;lt;/groupId&amp;gt;&lt;br /&gt;&amp;lt;artifactId&amp;gt;log4j&amp;lt;/artifactId&amp;gt;&lt;br /&gt;&amp;lt;/exclusion&amp;gt;&lt;br /&gt;&amp;lt;/exclusions&amp;gt;&lt;br /&gt;&amp;lt;/dependency&amp;gt;&lt;br /&gt;&amp;lt;dependency&amp;gt;&lt;br /&gt;&amp;lt;groupId&amp;gt;com.sun.xml.messaging.saaj&amp;lt;/groupId&amp;gt;&lt;br /&gt;&amp;lt;artifactId&amp;gt;saaj-impl&amp;lt;/artifactId&amp;gt;&lt;br /&gt;&amp;lt;version&amp;gt;1.3&amp;lt;/version&amp;gt;&lt;br /&gt;&amp;lt;scope&amp;gt;runtime&amp;lt;/scope&amp;gt;&lt;br /&gt;&amp;lt;exclusions&amp;gt;&lt;br /&gt;&amp;lt;exclusion&amp;gt;&lt;br /&gt;&amp;lt;groupId&amp;gt;log4j&amp;lt;/groupId&amp;gt;&lt;br /&gt;&amp;lt;artifactId&amp;gt;log4j&amp;lt;/artifactId&amp;gt;&lt;br /&gt;&amp;lt;/exclusion&amp;gt;&lt;br /&gt;&amp;lt;/exclusions&amp;gt;&lt;br /&gt;&amp;lt;/dependency&amp;gt;&lt;br /&gt;&amp;lt;dependency&amp;gt;&lt;br /&gt;&amp;lt;groupId&amp;gt;org.codehaus.castor&amp;lt;/groupId&amp;gt;&lt;br /&gt;&amp;lt;artifactId&amp;gt;castor&amp;lt;/artifactId&amp;gt;&lt;br /&gt;&amp;lt;version&amp;gt;1.2&amp;lt;/version&amp;gt;&lt;br /&gt;&amp;lt;exclusions&amp;gt;&lt;br /&gt;&amp;lt;exclusion&amp;gt;&lt;br /&gt;&amp;lt;groupId&amp;gt;log4j&amp;lt;/groupId&amp;gt;&lt;br /&gt;&amp;lt;artifactId&amp;gt;log4j&amp;lt;/artifactId&amp;gt;&lt;br /&gt;&amp;lt;/exclusion&amp;gt;&lt;br /&gt;&amp;lt;/exclusions&amp;gt;&lt;br /&gt;&amp;lt;/dependency&amp;gt;&lt;br /&gt;&amp;lt;dependency&amp;gt;&lt;br /&gt;&amp;lt;groupId&amp;gt;javax.annotation&amp;lt;/groupId&amp;gt;&lt;br /&gt;&amp;lt;artifactId&amp;gt;jsr250-api&amp;lt;/artifactId&amp;gt;&lt;br /&gt;&amp;lt;version&amp;gt;1.0&amp;lt;/version&amp;gt;&lt;br /&gt;&amp;lt;/dependency&amp;gt;&lt;br /&gt;&amp;lt;/dependencies&amp;gt;&lt;br /&gt;&lt;br /&gt;Here is how we would configure these classes in our order-ws-servlet.xml&lt;br /&gt;&lt;br /&gt;Spring XML configuration file:&lt;br /&gt;&lt;br /&gt;&amp;lt;beans xmlns="http://www.springframework.org/schema/beans"&amp;gt;&lt;br /&gt;&amp;lt;bean id="orderWSEndpoint" class="com.ideeksha.order.ws.OrderWSEndpoint" autowire="byName"/&amp;gt;&lt;br /&gt;&amp;lt;/beans&amp;gt;&lt;br /&gt;&lt;br /&gt;1.6.2. Routing the Message to the Endpoint&lt;br /&gt;&lt;br /&gt;Now that we have written an endpoint that handles the message, we must define how incoming messages are routed to that endpoint. In Spring-WS, this is the responsibility of an EndpointMapping. In this tutorial, we will route messages based on their content, by using a PayloadRootAnnotationMethodEndpointMapping. Here is how we configure a PayloadRootAnnotationMethodEndpointMapping in order-ws-servlet.xml:&lt;br /&gt;&lt;br /&gt;&amp;lt;bean id="loggingInterceptor"&lt;br /&gt;class="org.springframework.ws.server.endpoint.interceptor.PayloadLoggingInterceptor"/&amp;gt;&lt;br /&gt;&amp;lt;bean&lt;br /&gt;class="org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping"&amp;gt;&lt;br /&gt;&amp;lt;property name="interceptors"&amp;gt;&lt;br /&gt;&amp;lt;list&amp;gt;&lt;br /&gt;&amp;lt;ref local="loggingInterceptor"/&amp;gt;&lt;br /&gt;&amp;lt;/list&amp;gt;&lt;br /&gt;&amp;lt;/property&amp;gt;&lt;br /&gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;&lt;br /&gt;This means that whenever an XML message is received it will check all the annonated EndPoint Class and check for the method which will serve the request with that particular namespace and local name.(It also adds a PayloadLoggingInterceptor,that dumps incoming and outgoing messages to the log.)&lt;br /&gt;&lt;br /&gt;1.7. Publishing the WSDL&lt;br /&gt;Finally, we need to publish the WSDL. As stated in Section 3.4, “Service contract”, we don't need to write a WSDL ourselves; Spring-WS can generate one for us based on some conventions.&lt;br /&gt;Here is how we define the generation:&lt;br /&gt;&lt;br /&gt;&amp;lt;bean id="orderWebService" class="org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition"&amp;gt;&lt;br /&gt;&amp;lt;property name="schema" ref="orderSchema"/&amp;gt;&lt;br /&gt;&amp;lt;property name="portTypeName" value="OrderResource"/&amp;gt;&lt;br /&gt;&amp;lt;property name="locationUri" value="/order-ws/orderWebService"/&amp;gt;&lt;br /&gt;&amp;lt;property name="targetNamespace" value="http://ideeksha.gotdns.com/order"/&amp;gt;&lt;br /&gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;&amp;lt;bean id="orderSchema" class="org.springframework.xml.xsd.SimpleXsdSchema"&amp;gt;&lt;br /&gt;&amp;lt;property name="xsd" value="/WEB-INF/orderService.xsd"/&amp;gt;&lt;br /&gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;&lt;br /&gt;The bean id determines the URL where the WSDL can be retrieved. In this case, the bean id is holiday, which means that the WSDL can be retrieved as holiday.wsdl in the servlet context. The full URL will typically be&lt;br /&gt;&lt;br /&gt;http://localhost:8080/SpringWebService/order-ws/orderWebService.wsdl.&lt;br /&gt;&lt;br /&gt;The schema property refers to the human resource schema we defined in Section 3.3, “Data Contract”, wrapped in a SimpleXsdSchema. We simply placed the schema in the WEB-INF directory of the application.&lt;br /&gt;&lt;br /&gt;Next, we define the WSDL port type to be OrderResource.&lt;br /&gt;&lt;br /&gt;We set the location where the service can be reached:&lt;br /&gt;/order-ws/orderWebService/. We use a a relative URI and we instruct the framework to transform it dynamically to an absolute URI. Hence, if the service is deployed to different contexts we don't have to change the URI manually.&lt;br /&gt;Finally, we define the target namespace for the WSDL definition itself. Setting these&lt;br /&gt;is not required. If not set, we give the WSDL the same namespace as the schema.&lt;br /&gt;&lt;br /&gt;1.8. Doing the Castor Mapping&lt;br /&gt;We have to define the marshaller and unmashller for the XML messages.We define them in order-ws-servlet.xml file.&lt;br /&gt;&lt;br /&gt;&amp;lt;bean id="marshaller" class="org.springframework.oxm.castor.CastorMarshaller"&amp;gt;&lt;br /&gt;&amp;lt;property name="mappingLocation" value="classpath:WEB-INF/castor-mapping.xml"/&amp;gt;&lt;br /&gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;&amp;lt;bean&lt;br /&gt;class="org.springframework.ws.server.endpoint.adapter.GenericMarshallingMethodEndpointAdapter"&amp;gt;&lt;br /&gt;&amp;lt;constructor-arg ref="marshaller"/&amp;gt;&lt;br /&gt;&amp;lt;constructor-arg ref="marshaller"/&amp;gt;&lt;br /&gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;&lt;br /&gt;O/X mapping is done using castor so you can assess the xml as object.Below is the OrderRequest and OrderResponse with its corresponding castor mapping:&lt;br /&gt;&lt;br /&gt;OrderRequest.java:&lt;br /&gt;-------------------&lt;br /&gt;package com.ideeksha.order.ws;&lt;br /&gt;&lt;br /&gt;import java.util.List;&lt;br /&gt;&lt;br /&gt;public class OrderRequest {&lt;br /&gt;private List&amp;lt;Item&amp;gt; itemList = null;&lt;br /&gt;private String customerID;&lt;br /&gt;private String orderID;&lt;br /&gt;&lt;br /&gt;public List&amp;lt;Item&amp;gt; getItemList() {&lt;br /&gt;return itemList;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public void setItemList(&lt;br /&gt;List&amp;lt;Item&amp;gt; itemList) {&lt;br /&gt;this.itemList = itemList;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public String getCustomerID() {&lt;br /&gt;return customerID;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public void setCustomerID(String customerID) {&lt;br /&gt;this.customerID = customerID;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public String getOrderID() {&lt;br /&gt;return orderID;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public void setOrderID(String orderID) {&lt;br /&gt;this.orderID = orderID;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;OrderResponse.java&lt;br /&gt;-----------------------&lt;br /&gt;&lt;br /&gt;package com.ideeksha.order.ws;&lt;br /&gt;&lt;br /&gt;public class OrderResponse {&lt;br /&gt;&lt;br /&gt;private String code;&lt;br /&gt;&lt;br /&gt;public String getCode() {&lt;br /&gt;return code;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public void setCode(String code) {&lt;br /&gt;this.code = code;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Item.java&lt;br /&gt;--------------------&lt;br /&gt;package com.ideeksha.order.ws;&lt;br /&gt;&lt;br /&gt;public class Item {&lt;br /&gt;private String id = null;&lt;br /&gt;private String itemName = null;&lt;br /&gt;private String sellingprice = null;&lt;br /&gt;private String quantity = null;&lt;br /&gt;private String discount = null;&lt;br /&gt;&lt;br /&gt;public String getId() {&lt;br /&gt;return id;&lt;br /&gt;}&lt;br /&gt;public void setId(String id) {&lt;br /&gt;this.id = id;&lt;br /&gt;}&lt;br /&gt;public String getItemName() {&lt;br /&gt;return itemName;&lt;br /&gt;}&lt;br /&gt;public void setItemName(String itemName) {&lt;br /&gt;this.itemName = itemName;&lt;br /&gt;}&lt;br /&gt;public String getSellingprice() {&lt;br /&gt;return sellingprice;&lt;br /&gt;}&lt;br /&gt;public void setSellingprice(String sellingprice) {&lt;br /&gt;this.sellingprice = sellingprice;&lt;br /&gt;}&lt;br /&gt;public String getQuantity() {&lt;br /&gt;return quantity;&lt;br /&gt;}&lt;br /&gt;public void setQuantity(String quantity) {&lt;br /&gt;this.quantity = quantity;&lt;br /&gt;}&lt;br /&gt;public String getDiscount() {&lt;br /&gt;return discount;&lt;br /&gt;}&lt;br /&gt;public void setDiscount(String discount) {&lt;br /&gt;this.discount = discount;&lt;br /&gt;}&lt;br /&gt;@Override&lt;br /&gt;public String toString() {&lt;br /&gt;return id+ " " + itemName + " " + sellingprice + " " +quantity + " " + discount;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;castor-mapping.xml&lt;br /&gt;--------------------------------&lt;br /&gt;&lt;br /&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Mapping DTD Version 1.0//EN"&lt;br /&gt;"http://castor.org/mapping.dtd"&amp;gt;&lt;br /&gt;&amp;lt;mapping&amp;gt;&lt;br /&gt;&amp;lt;description&amp;gt;Description of the mapping&amp;lt;/description&amp;gt;&lt;br /&gt;&amp;lt;class name="com.ideeksha.order.ws.OrderResponse"&amp;gt;&lt;br /&gt;&amp;lt;map-to xml="OrderResponse" ns-uri="http://ideeksha.gotdns.com/order" /&amp;gt;&lt;br /&gt;&amp;lt;field name="code"&amp;gt;&lt;br /&gt;&amp;lt;bind-xml name="code" node="element" type="string"/&amp;gt;&lt;br /&gt;&amp;lt;/field&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/class&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;class name="com.ideeksha.order.ws.Item"&amp;gt;&lt;br /&gt;&amp;lt;map-to xml="item" ns-uri="http://ideeksha.gotdns.com/order" /&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;field name="id"&amp;gt;&lt;br /&gt;&amp;lt;bind-xml name="id" node="element" type="string"/&amp;gt;&lt;br /&gt;&amp;lt;/field&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;field name="itemName"&amp;gt;&lt;br /&gt;&amp;lt;bind-xml name="itemName" node="element" type="itemName"/&amp;gt;&lt;br /&gt;&amp;lt;/field&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;field name="quantity"&amp;gt;&lt;br /&gt;&amp;lt;bind-xml name="quantity" node="element" type="string"/&amp;gt;&lt;br /&gt;&amp;lt;/field&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;field name="discount"&amp;gt;&lt;br /&gt;&amp;lt;bind-xml name="discount" node="element" type="itemName"/&amp;gt;&lt;br /&gt;&amp;lt;/field&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;field name="sellingprice"&amp;gt;&lt;br /&gt;&amp;lt;bind-xml name="sellingprice" node="element" type="itemName"/&amp;gt;&lt;br /&gt;&amp;lt;/field&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/class&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;class name="com.ideeksha.order.ws.OrderRequest"&amp;gt;&lt;br /&gt;&amp;lt;map-to xml="OrderRequest" ns-uri="http://ideeksha.gotdns.com/order" /&amp;gt;&lt;br /&gt;&amp;lt;field name="customerID"&amp;gt;&lt;br /&gt;&amp;lt;bind-xml name="customerID" node="element" type="itemName"/&amp;gt;&lt;br /&gt;&amp;lt;/field&amp;gt;&lt;br /&gt;&amp;lt;field name="orderID"&amp;gt;&lt;br /&gt;&amp;lt;bind-xml name="orderID" node="element" type="itemName"/&amp;gt;&lt;br /&gt;&amp;lt;/field&amp;gt;&lt;br /&gt;&amp;lt;field name="itemList" type="com.ideeksha.order.ws.Item" collection="arraylist"&amp;gt;&lt;br /&gt;&amp;lt;bind-xml name="item" node="element" type="ideeksha-spring-ws:item"/&amp;gt;&lt;br /&gt;&amp;lt;/field&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/class&amp;gt;&lt;br /&gt;&amp;lt;/mapping&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;You can create a WAR file using mvn install.&lt;br /&gt;If you deploy the application (to Tomcat, Jetty, etc.), and point your browser at&lt;br /&gt;this location, you will see the generated WSDL. This WSDL is ready to be used by clients, such as soapUI, or other SOAP frameworks.&lt;br /&gt;&lt;br /&gt;I will explain how to create project in SOAPUI and send a order request to our webservice.&lt;br /&gt;Create new Project in SOAP UI and give the project name and the wsdl file path.In my case the Project name is SpringWebSerice and the wsdl path will be&lt;br /&gt;"http://localhost:8080/SpringWebService/order-ws/orderWebService.wsdl"&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The click on "Order" and then to "request1" under the SpringWebService Project menu.&lt;br /&gt;Edit the default values of this request.Now send this request be clicking on run button(green arrowhead) on the top of the request message window. And the you will get "SUCCESSFUL" as response as we are sending as Order response.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div&gt;&lt;span style="font-size:130%;"&gt;&lt;a href="http://2.bp.blogspot.com/_7ZiCsz7bxzk/SiUBb6DjunI/AAAAAAAAAaE/m9D6s-ClJaM/s1600-h/1.bmp"&gt;&lt;img id="BLOGGER_PHOTO_ID_5342678111897238130" style="margin: 0px auto 10px; display: block; width: 320px; height: 199px; text-align: center;" alt="" src="http://2.bp.blogspot.com/_7ZiCsz7bxzk/SiUBb6DjunI/AAAAAAAAAaE/m9D6s-ClJaM/s320/1.bmp" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;div&gt;&lt;span style="font-size:130%;"&gt;&lt;a href="http://4.bp.blogspot.com/_7ZiCsz7bxzk/SiUBcNtQYAI/AAAAAAAAAaM/ZUbnoaRhCgU/s1600-h/4.bmp"&gt;&lt;img id="BLOGGER_PHOTO_ID_5342678117172404226" style="margin: 0px auto 10px; display: block; width: 320px; height: 179px; text-align: center;" alt="" src="http://4.bp.blogspot.com/_7ZiCsz7bxzk/SiUBcNtQYAI/AAAAAAAAAaM/ZUbnoaRhCgU/s320/4.bmp" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;&lt;br /&gt;This conclude spring webservice turorial. You can download the source code for this article from &lt;a href="http://www.mediafire.com/download.php?zxlmjmnuiei"&gt;http://www.mediafire.com/download.php?zxlmjmnuiei&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/517388772395375329-2033361987498363195?l=springkbase.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://springkbase.blogspot.com/feeds/2033361987498363195/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=517388772395375329&amp;postID=2033361987498363195' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/517388772395375329/posts/default/2033361987498363195'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/517388772395375329/posts/default/2033361987498363195'/><link rel='alternate' type='text/html' href='http://springkbase.blogspot.com/2009/06/spring-webservice-with-castor.html' title='Spring WebService with Castor'/><author><name>Anil Verma</name><uri>http://www.blogger.com/profile/07159037456674064065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://4.bp.blogspot.com/_7ZiCsz7bxzk/Sh6rQK6LSeI/AAAAAAAAAXs/9j_hHnOvp6E/S220/40815841.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_7ZiCsz7bxzk/SiUBb6DjunI/AAAAAAAAAaE/m9D6s-ClJaM/s72-c/1.bmp' height='72' width='72'/><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-517388772395375329.post-1168103784965608860</id><published>2009-05-30T22:45:00.000-07:00</published><updated>2009-06-03T19:23:22.762-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='CruiseControl'/><category scheme='http://www.blogger.com/atom/ns#' term='Dynamic Address Hosting website'/><category scheme='http://www.blogger.com/atom/ns#' term='TRAC'/><category scheme='http://www.blogger.com/atom/ns#' term='Dynamic IP Address'/><category scheme='http://www.blogger.com/atom/ns#' term='Website Hosting'/><category scheme='http://www.blogger.com/atom/ns#' term='SVN'/><title type='text'>Host Your Own Website on Dynamic IP Address</title><content type='html'>&lt;script src="http://www.gmodules.com/ig/ifr?url=http://www.google.com/ig/modules/translatemypage.xml&amp;up_source_language=en&amp;w=160&amp;h=60&amp;title=&amp;border=&amp;output=js"&gt;&lt;/script&gt;&lt;br /&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;Now you can host your website on own local machine with a &lt;b&gt;&lt;i&gt;Dynamic IP Address&lt;/i&gt;&lt;/b&gt;. I have hosted on my local machine and yes you can do too!!! &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;I am not just writing this blog for hosting your websites on your local machine with dynamic ip address but also you can configure your machine to host repositories of your code and other software’s like Trac, CruiseControl, Svn, etc. I Hope you know about these software’s... :) &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;This is helpful for those guys who want to start with small team working in different places …&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;span style="font-size:100%;"&gt;First of all the required things you have to have are:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-size:100%;"&gt;1.Desktop or Laptop where you want to host the applications with good configuration.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-size:100%;"&gt;   2.Broadband Connection … it will be work with your dial up too...for that god only can help you ;) &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;span style="font-size:100%;"&gt;&lt;p class="MsoNormal"&gt; 3.Off-course software’s that to be installed. I am demonstrating with &lt;b&gt;Apache 2.2&lt;/b&gt; to host your static web application, &lt;b&gt;Svn&lt;/b&gt; for code repository, &lt;b&gt;Cruise-Control&lt;/b&gt; for automating build process of your code base and &lt;b&gt;Trac&lt;/b&gt; for code browse and bug management.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;span style="font-size:100%;"&gt;&lt;p class="MsoNormal"&gt; 4.And for hosting then website you need to register yourself on &lt;/p&gt;&lt;/span&gt;&lt;p class="MsoNormal"&gt;&lt;a href="http://www.dyndns.com/"&gt;&lt;span style="font-family:courier new;"&gt;http://www.dyndns.com&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:courier new;"&gt;&lt;p class="MsoNormal"&gt; (Just for connecting to your machine to DNS server).&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoListParagraphCxSpMiddle"&gt;&lt;o:p&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;p class="MsoListParagraphCxSpMiddle"&gt;&lt;o:p&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;p class="MsoListParagraphCxSpMiddle"&gt;&lt;span style="font-family:courier new;"&gt;&lt;p class="MsoNormal"&gt;First let see how to get the domain name registered on DynDns.com.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoListParagraphCxSpMiddle"&gt;&lt;o:p&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;p class="MsoListParagraphCxSpMiddle"&gt;&lt;span style="font-family:courier new;"&gt;&lt;p class="MsoNormal"&gt;After registeration on DydnDNS ,follow these steps:&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="text-indent: -0.25in; margin-left: 60pt;" class="MsoListParagraphCxSpLast"&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;span style="font-size:100%;"&gt;&lt;p class="MsoNormal"&gt;1. Login to website and go My Services.&lt;/p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span style="line-height: 115%;"&gt;&lt;/span&gt;&lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;span style="font-size:100%;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;p style="margin-left: 60pt;" class="MsoListParagraphCxSpFirst"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_7ZiCsz7bxzk/SiIektLF2ZI/AAAAAAAAAYU/ijeNRQZNznY/s1600-h/1.bmp"&gt;&lt;span style="font-family:courier new;"&gt;&lt;img style="margin: 0px auto 10px; text-align: center; width: 320px; display: block; height: 200px; cursor: pointer;" id="BLOGGER_PHOTO_ID_5341865723965069714" alt="" src="http://4.bp.blogspot.com/_7ZiCsz7bxzk/SiIektLF2ZI/AAAAAAAAAYU/ijeNRQZNznY/s320/1.bmp" border="0" /&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="text-indent: -0.25in; margin-left: 60pt;" class="MsoListParagraphCxSpMiddle"&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;span style="font-size:100%;"&gt;&lt;p class="MsoNormal"&gt;2. And from there you click on "Add Hostname".&lt;/p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="text-indent: -0.25in; margin-left: 60pt;" class="MsoListParagraphCxSpMiddle"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_7ZiCsz7bxzk/SiIfskLPexI/AAAAAAAAAYk/rpGWZonikuQ/s1600-h/3.bmp"&gt;&lt;span style="font-family:courier new;"&gt;&lt;img style="margin: 0px auto 10px; text-align: center; width: 320px; display: block; height: 200px; cursor: pointer;" id="BLOGGER_PHOTO_ID_5341866958500363026" alt="" src="http://2.bp.blogspot.com/_7ZiCsz7bxzk/SiIfskLPexI/AAAAAAAAAYk/rpGWZonikuQ/s320/3.bmp" border="0" /&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoListParagraphCxSpMiddle"&gt;&lt;o:p&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;p class="MsoListParagraphCxSpMiddle"&gt;&lt;o:p&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;p class="MsoListParagraphCxSpMiddle"&gt;&lt;o:p&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;p class="MsoListParagraphCxSpMiddle"&gt;&lt;o:p&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;p class="MsoListParagraphCxSpMiddle"&gt;&lt;br /&gt;&lt;o:p&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;p style="text-indent: -0.25in; margin-left: 60pt;" class="MsoListParagraphCxSpMiddle"&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;span style="font-size:100%;"&gt;&lt;p class="MsoNormal"&gt;3. Add the hostname and the choose the domain name which will get suffix to your hostname.Like I choose hostname as “&lt;b&gt;ideeksha&lt;/b&gt;” and the domain as “&lt;b&gt;gotdns.com&lt;/b&gt;”.So you access your website as &lt;/p&gt;&lt;/span&gt;&lt;a href="http://ideeksha.gotdns.com/"&gt;&lt;span style="font-family:courier new;"&gt;http://ideeksha.gotdns.com/&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:courier new;"&gt; .&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="text-indent: -0.25in; margin-left: 60pt;" class="MsoListParagraphCxSpMiddle"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_7ZiCsz7bxzk/SiIe0MyUC6I/AAAAAAAAAYc/gi7FReryYVI/s1600-h/2.bmp"&gt;&lt;span style="font-family:courier new;"&gt;&lt;img style="margin: 0px auto 10px; text-align: center; width: 320px; display: block; height: 200px; cursor: pointer;" id="BLOGGER_PHOTO_ID_5341865990149114786" alt="" src="http://1.bp.blogspot.com/_7ZiCsz7bxzk/SiIe0MyUC6I/AAAAAAAAAYc/gi7FReryYVI/s320/2.bmp" border="0" /&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoListParagraphCxSpMiddle"&gt;&lt;o:p&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;p style="text-indent: -0.25in; margin-left: 60pt;" class="MsoListParagraphCxSpMiddle"&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;span style="font-size:100%;"&gt;&lt;p class="MsoNormal"&gt;4. DynDNS will detect your ip address ,so click on autp detect link which will fill your ip address field. Finally click on “Create Host ” button. This will lead you towards checkout of this service and as it is free service you will be charged “Zero” dollars. Happily do the checkout and activate the service. &lt;/p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="text-align: center;" class="MsoListParagraphCxSpMiddle"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_7ZiCsz7bxzk/SiIftNMBQMI/AAAAAAAAAY0/kw5H4GgjceI/s1600-h/5.bmp"&gt;&lt;span style="font-family:courier new;"&gt;&lt;img style="margin: 0px auto 10px; text-align: center; width: 320px; display: block; height: 200px; cursor: pointer;" id="BLOGGER_PHOTO_ID_5341866965863441298" alt="" src="http://3.bp.blogspot.com/_7ZiCsz7bxzk/SiIfs_mvI5I/AAAAAAAAAYs/_h29WuAtp6M/s320/4.bmp" border="0" /&gt;&lt;img style="margin: 0px auto 10px; text-align: center; width: 320px; display: block; height: 200px; cursor: pointer;" id="BLOGGER_PHOTO_ID_5341866969509478594" alt="" src="http://2.bp.blogspot.com/_7ZiCsz7bxzk/SiIftNMBQMI/AAAAAAAAAY0/kw5H4GgjceI/s320/5.bmp" border="0" /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;p class="MsoListParagraphCxSpMiddle"&gt;&lt;o:p&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;p class="MsoListParagraphCxSpMiddle"&gt;&lt;o:p&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;p class="MsoListParagraphCxSpMiddle"&gt;&lt;o:p&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;p class="MsoListParagraphCxSpMiddle"&gt;&lt;o:p&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;p class="MsoListParagraphCxSpLast"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_7ZiCsz7bxzk/SiIgIrx6K_I/AAAAAAAAAZM/4UoAX3NaaAM/s1600-h/8.bmp"&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;/a&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;span style="font-size:100%;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;span style="font-size:100%;"&gt;5. After this you have to edit your host file. As I am on Windows XP machine ,you will find your host file in “C:\WINDOW\system32\drivers\etc” directory. Open your hosts file and add the highlighted entry and save the file.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_7ZiCsz7bxzk/SiIftRXwtSI/AAAAAAAAAY8/FrxbQh-Sbyc/s1600-h/6.bmp"&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;span style="font-size:100%;"&gt;&lt;img style="margin: 0px auto 10px; text-align: center; width: 320px; display: block; height: 200px; cursor: pointer;" id="BLOGGER_PHOTO_ID_5341866970632467746" alt="" src="http://2.bp.blogspot.com/_7ZiCsz7bxzk/SiIftRXwtSI/AAAAAAAAAY8/FrxbQh-Sbyc/s320/6.bmp" border="0" /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;192.168.1.2 is the ip address assigned to my machine by the router ,as the router is connected to my modem. So the ip address that you entered on DynDNS is modem ip address and to route the request from modem to your machine ,this is entry is needed.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;span style="font-size:100%;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;span style="font-size:100%;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;Now time is come when you can install Apache or tomcat on your machine and hosts the application there. So install the Apache and put the application under your apache htdocs folder and mine is here “C:\Program Files\Apache Software Foundation\Apache2.2\htdocs”.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;span style="font-size:100%;"&gt;Start your apache and excess the website as &lt;/span&gt;&lt;a href="http://ideeksha.gotdns.com/"&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;span style="font-size:100%;"&gt;http://ideeksha.gotdns.com/&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;span style="font-size:100%;"&gt;. And you can see your website hosted on your local machine with dynamic ip address.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_7ZiCsz7bxzk/SiIftnyUCwI/AAAAAAAAAZE/-Zzl-c-6GI0/s1600-h/7.bmp"&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;span style="font-size:100%;"&gt;&lt;img style="margin: 0px auto 10px; text-align: center; width: 320px; display: block; height: 200px; cursor: pointer;" id="BLOGGER_PHOTO_ID_5341866976649415426" alt="" src="http://3.bp.blogspot.com/_7ZiCsz7bxzk/SiIftnyUCwI/AAAAAAAAAZE/-Zzl-c-6GI0/s320/7.bmp" border="0" /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;o:p&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;span style="font-size:100%;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;span style="font-size:100%;"&gt;And there is one mystery about who will update the ip address on DynDns for you updated ip address when you get new ipaddress from your ISP. This can be solved by two means ,you can install the DynDns Auto Update Client which automatically update your dns entry in DynDNS or yor modem may have the facilty to do the same. You can see both settings images below.&lt;v:shape id="Picture_x0020_34" type="#_x0000_t75" spid="_x0000_i1027"&gt; &lt;v:imagedata title="" src="file:///C:%5CDOCUME%7E1%5CANIL%7E1.ANI%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_image015.png"&gt;&lt;/v:imagedata&gt;&lt;!--[if !vml]--&gt;&lt;/v:shape&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_7ZiCsz7bxzk/SiIfs_mvI5I/AAAAAAAAAYs/_h29WuAtp6M/s1600-h/4.bmp"&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;span style="font-size:100%;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_7ZiCsz7bxzk/SiIgIzYuW0I/AAAAAAAAAZU/NqdWDpP7HzQ/s1600-h/9.bmp"&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;span style="font-size:100%;"&gt;&lt;img style="margin: 0px auto 10px; text-align: center; width: 320px; display: block; height: 200px; cursor: pointer;" id="BLOGGER_PHOTO_ID_5341867443619781442" alt="" src="http://2.bp.blogspot.com/_7ZiCsz7bxzk/SiIgIzYuW0I/AAAAAAAAAZU/NqdWDpP7HzQ/s320/9.bmp" border="0" /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_7ZiCsz7bxzk/SiIgIrx6K_I/AAAAAAAAAZM/4UoAX3NaaAM/s1600-h/8.bmp"&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;span style="font-size:100%;"&gt;&lt;img style="margin: 0px auto 10px; text-align: center; width: 320px; display: block; height: 214px; cursor: pointer;" id="BLOGGER_PHOTO_ID_5341867441577929714" alt="" src="http://1.bp.blogspot.com/_7ZiCsz7bxzk/SiIgIrx6K_I/AAAAAAAAAZM/4UoAX3NaaAM/s320/8.bmp" border="0" /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;Last thing which is remaining is to integrate svn and trac with your apache so you can access them.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;Install svn and trac with their default settings and change the httpd.conf file of apache with these settings:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;span style="font-size:100%;"&gt;&amp;lt;Location /svn/iDeekshaMailClient&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;DAV svn&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;SVNPath C:/SVNREPO/iDeekshaMailClient&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;AuthType Basic&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;AuthName "Subversion iDeekshaMailClient repository"&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;AuthUserFile c:/etc/svn-auth-file&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;Require valid-user&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&amp;lt;/Location&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;span style="font-size:100%;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&amp;lt;LocationMatch "/Trac/[^/]+/login"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;AuthType Basic&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;AuthName "Trac"&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;AuthUserFile C:/etc/svn-auth-file&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;Require valid-user&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&amp;lt;/LocationMatch&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;span style="font-size:100%;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&amp;lt;Location /Trac&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;SetHandler mod_python&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;PythonInterpreter main_interpreter&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;PythonHandler trac.web.modpython_frontend &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;PythonOption TracEnvParentDir C:/TRACREPO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;PythonOption TracUriRoot /Trac&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt;&amp;lt;/Location&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;span style="font-size:100%;"&gt;Now you can access your svn as &lt;/span&gt;&lt;a href="http://ideeksha.gotdns.com/svn/iDeekshaMailClient"&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;span style="font-size:100%;"&gt;http://ideeksha.gotdns.com/svn/iDeekshaMailClient&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;span style="font-size:100%;"&gt; and trac as &lt;/span&gt;&lt;a href="http://ideeksha.gotdns.com/Trac/iDeekshaMailClient"&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;span style="font-size:100%;"&gt;http://ideeksha.gotdns.com/Trac/iDeekshaMailClient&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-size:100%;"&gt; Integration of svn and trac in detail you get from googling :) &lt;style&gt; &lt;!--  /* Font Definitions */  @font-face  {font-family:"Cambria Math";  panose-1:2 4 5 3 5 4 6 3 2 4;  mso-font-charset:1;  mso-generic-font-family:roman;  mso-font-format:other;  mso-font-pitch:variable;  mso-font-signature:0 0 0 0 0 0;} @font-face  {font-family:Calibri;  panose-1:2 15 5 2 2 2 4 3 2 4;  mso-font-charset:0;  mso-generic-font-family:swiss;  mso-font-pitch:variable;  mso-font-signature:-1610611985 1073750139 0 0 159 0;}  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal  {mso-style-unhide:no;  mso-style-qformat:yes;  mso-style-parent:"";  margin-top:0in;  margin-right:0in;  margin-bottom:10.0pt;  margin-left:0in;  line-height:115%;  mso-pagination:widow-orphan;  font-size:11.0pt;  font-family:"Calibri","sans-serif";  mso-ascii-font-family:Calibri;  mso-ascii-theme-font:minor-latin;  mso-fareast-font-family:Calibri;  mso-fareast-theme-font:minor-latin;  mso-hansi-font-family:Calibri;  mso-hansi-theme-font:minor-latin;  mso-bidi-font-family:"Times New Roman";  mso-bidi-theme-font:minor-bidi;} a:link, span.MsoHyperlink  {mso-style-priority:99;  color:blue;  mso-themecolor:hyperlink;  text-decoration:underline;  text-underline:single;} a:visited, span.MsoHyperlinkFollowed  {mso-style-noshow:yes;  mso-style-priority:99;  color:purple;  mso-themecolor:followedhyperlink;  text-decoration:underline;  text-underline:single;} .MsoChpDefault  {mso-style-type:export-only;  mso-default-props:yes;  mso-ascii-font-family:Calibri;  mso-ascii-theme-font:minor-latin;  mso-fareast-font-family:Calibri;  mso-fareast-theme-font:minor-latin;  mso-hansi-font-family:Calibri;  mso-hansi-theme-font:minor-latin;  mso-bidi-font-family:"Times New Roman";  mso-bidi-theme-font:minor-bidi;} .MsoPapDefault  {mso-style-type:export-only;  margin-bottom:10.0pt;  line-height:115%;} @page Section1  {size:8.5in 11.0in;  margin:1.0in 1.0in 1.0in 1.0in;  mso-header-margin:.5in;  mso-footer-margin:.5in;  mso-paper-source:0;} div.Section1  {page:Section1;} --&gt; &lt;/style&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;span style="font-size:100%;"&gt;For svn installation and integration with apache (&lt;/span&gt;&lt;a href="http://www.trajiklyhip.com/blog/index.cfm/2007/3/13/Part-2-Installing-Subversion-142-and-Integrating-Subversion-With-Apache"&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;span style="font-size:100%;"&gt;http://www.trajiklyhip.com/blog/index.cfm/2007/3/13/Part-2-Installing-Subversion-142-and-Integrating-Subversion-With-Apache&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;span style="font-size:100%;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;span style="font-size:100%;"&gt;For your cruise-control you have install Cruise-Control first and for that you have to register for different domain name like I have done .You have to do redirect as apache is running on 80 port and cruise control is running on 7070 port , so have to do port forwarding on your modem for 7070 for cruise control application. &lt;v:shape id="Picture_x0020_43" type="#_x0000_t75" spid="_x0000_i1025"&gt;&lt;v:imagedata title="" src="file:///C:%5CDOCUME%7E1%5CANIL%7E1.ANI%5CLOCALS%7E1%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_image019.png"&gt;&lt;/v:imagedata&gt;&lt;!--[if !vml]--&gt;&lt;/v:shape&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_7ZiCsz7bxzk/SiIgJLqEOKI/AAAAAAAAAZc/Z7kMQhp5T3k/s1600-h/10.bmp"&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;span style="font-size:100%;"&gt;&lt;img style="margin: 0px auto 10px; text-align: center; width: 320px; display: block; height: 200px; cursor: pointer;" id="BLOGGER_PHOTO_ID_5341867450134968482" alt="" src="http://1.bp.blogspot.com/_7ZiCsz7bxzk/SiIgJLqEOKI/AAAAAAAAAZc/Z7kMQhp5T3k/s320/10.bmp" border="0" /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;span style="font-size:100%;"&gt;So, this concludes with our integration of trac and svn with apache and running the cruise-control build on your code base .So now from any member of your team can take check out of your code and do code browsing using trac and off-course do the build on code base using cruise-control.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;span style="font-size:100%;"&gt;Happy Coding!!!&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;span style="font-size:100%;"&gt;Cheers!&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;span style="font-size:100%;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;span style="font-size:100%;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;span style=";font-family:courier new;font-size:100%;"  &gt;&lt;span style="font-size:100%;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/517388772395375329-1168103784965608860?l=springkbase.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://springkbase.blogspot.com/feeds/1168103784965608860/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=517388772395375329&amp;postID=1168103784965608860' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/517388772395375329/posts/default/1168103784965608860'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/517388772395375329/posts/default/1168103784965608860'/><link rel='alternate' type='text/html' href='http://springkbase.blogspot.com/2009/05/host-your-own-website-on-dynamic-ip.html' title='Host Your Own Website on Dynamic IP Address'/><author><name>Anil Verma</name><uri>http://www.blogger.com/profile/07159037456674064065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://4.bp.blogspot.com/_7ZiCsz7bxzk/Sh6rQK6LSeI/AAAAAAAAAXs/9j_hHnOvp6E/S220/40815841.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_7ZiCsz7bxzk/SiIektLF2ZI/AAAAAAAAAYU/ijeNRQZNznY/s72-c/1.bmp' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-517388772395375329.post-2619935173811348185</id><published>2009-05-28T02:07:00.000-07:00</published><updated>2009-06-03T19:23:43.457-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Spring Hibernate Integration'/><category scheme='http://www.blogger.com/atom/ns#' term='Spring'/><category scheme='http://www.blogger.com/atom/ns#' term='Hibernate'/><title type='text'>Spring + Hibernate</title><content type='html'>&lt;script src="http://www.gmodules.com/ig/ifr?url=http://www.google.com/ig/modules/translatemypage.xml&amp;up_source_language=en&amp;w=160&amp;h=60&amp;title=&amp;border=&amp;output=js"&gt;&lt;/script&gt;&lt;br /&gt;Spring + Hibernate&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;This article is for those who know spring and hibernate but never integrated or run them together. I hope you know both of these technologies as I am not going in detail of these  :)&lt;br /&gt;&lt;br /&gt;Steps to integrate hibernate and spring are as follows:&lt;br /&gt;1. Jars for hibernate, spring and the dependencies (Use maven for this, I will be adding pom.xml file for your reference).&lt;br /&gt;2. Mapping and Configuration files of hibernate.&lt;br /&gt;3. And off-course you have to have the spring bean xml file.&lt;br /&gt;&lt;br /&gt;I will split this tutorial into three parts:&lt;br /&gt;1. Develop Hibernate Application&lt;br /&gt;2. Using hibernate with Spring Framework.&lt;br /&gt;3. Running the Example Application.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Developing Hibernate Application:&lt;br /&gt;We will have employee as entity with which we are going play with.&lt;br /&gt;&lt;br /&gt;First will look into how we do this in traditional way means with standalone client:&lt;br /&gt;1. Will have Employee POJO class&lt;br /&gt;Employee.java&lt;br /&gt;---------------------------------------------&lt;br /&gt;package com.ideeksha;&lt;br /&gt;&lt;br /&gt;public class Employee {&lt;br /&gt;&lt;br /&gt;private Long employeeCode;&lt;br /&gt;private String employeeName;&lt;br /&gt;private int employeesalary;&lt;br /&gt;&lt;br /&gt;public Long getEmployeeCode() {&lt;br /&gt;return employeeCode;&lt;br /&gt;}&lt;br /&gt;public void setEmployeeCode(Long employeeCode) {&lt;br /&gt;this.employeeCode = employeeCode;&lt;br /&gt;}&lt;br /&gt;public String getEmployeeName() {&lt;br /&gt;return employeeName;&lt;br /&gt;}&lt;br /&gt;public void setEmployeeName(String employeeName) {&lt;br /&gt;this.employeeName = employeeName;&lt;br /&gt;}&lt;br /&gt;public int getEmployeesalary() {&lt;br /&gt;return employeesalary;&lt;br /&gt;}&lt;br /&gt;public void setEmployeesalary(int employeesalary) {&lt;br /&gt;this.employeesalary = employeesalary;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;2. Then will have the mapping file&lt;br /&gt;&lt;br /&gt;Employee.hbm.xml&lt;br /&gt;---------------------------------------------&lt;br /&gt;&lt;br /&gt;&amp;lt;?xml version="1.0"?&amp;gt;&lt;br /&gt;&amp;lt;!DOCTYPE hibernate-mapping PUBLIC&lt;br /&gt;"-//Hibernate/Hibernate Mapping DTD 3.0//EN"&lt;br /&gt;"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"&amp;gt;&lt;br /&gt;&amp;lt;hibernate-mapping package="com.ideeksha"&amp;gt;&lt;br /&gt;&amp;lt;class name="Employee" table="EMP"&amp;gt;&lt;br /&gt;&amp;lt;id name="employeeCode" column="EMP_CODE" type="long"&amp;gt;&lt;br /&gt;&amp;lt;generator class="increment"&amp;gt;&amp;lt;/generator&amp;gt;&lt;br /&gt;&amp;lt;/id&amp;gt;&lt;br /&gt;&amp;lt;property name="employeeName" column="NAME" type="string"&amp;gt;&amp;lt;/property&amp;gt;&lt;br /&gt;&amp;lt;property name="employeesalary"&amp;gt;&amp;lt;/property&amp;gt;&lt;br /&gt;&amp;lt;/class&amp;gt;&lt;br /&gt;&amp;lt;/hibernate-mapping&amp;gt;&lt;br /&gt;&lt;br /&gt;3. And the configuration file :&lt;br /&gt;&lt;br /&gt;Hibernate.cfg.xml&lt;br /&gt;---------------------------------------------------&lt;br /&gt;&lt;br /&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;&lt;br /&gt;&amp;lt;!DOCTYPE hibernate-configuration PUBLIC&lt;br /&gt;"-//Hibernate/Hibernate Configuration DTD 3.0//EN"&lt;br /&gt;"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"&amp;gt;&lt;br /&gt;&amp;lt;hibernate-configuration&amp;gt;&lt;br /&gt;&amp;lt;session-factory&amp;gt;&lt;br /&gt; &amp;lt;property name="hibernate.connection.driver_class"&amp;gt;oracle.jdbc.driver.OracleDriver&amp;lt;/property&amp;gt;&lt;br /&gt; &amp;lt;property name="hibernate.connection.password"&amp;gt;tiger&amp;lt;/property&amp;gt;&lt;br /&gt; &amp;lt;property name="hibernate.connection.url"&amp;gt;jdbc:oracle:thin:@localhost:1521:machinename&amp;lt;/property&amp;gt;&lt;br /&gt; &amp;lt;property name="hibernate.connection.username"&amp;gt;scott&amp;lt;/property&amp;gt;&lt;br /&gt; &amp;lt;property name="hibernate.dialect"&amp;gt;org.hibernate.dialect.Oracle9iDialect&amp;lt;/property&amp;gt;&lt;br /&gt;&lt;br /&gt; &amp;lt;property name="hibernate.hbm2ddl.auto"&amp;gt;create&amp;lt;/property&amp;gt;&lt;br /&gt; &amp;lt;property name="hibernate.show_sql"&amp;gt;true&amp;lt;/property&amp;gt;&lt;br /&gt;&lt;br /&gt; &amp;lt;mapping resource="Employee.hbm.xml"/&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/session-factory&amp;gt;&lt;br /&gt;&amp;lt;/hibernate-configuration&amp;gt;&lt;br /&gt;4. Offcourse the main class to run this :&lt;br /&gt;&lt;br /&gt;PersistEmployee.java&lt;br /&gt;--------------------------------------------------------&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;package com.ideeksha;&lt;br /&gt;&lt;br /&gt;import org.hibernate.Session;&lt;br /&gt;import org.hibernate.SessionFactory;&lt;br /&gt;import org.hibernate.Transaction;&lt;br /&gt;import org.hibernate.cfg.Configuration;&lt;br /&gt;&lt;br /&gt;public class PersistEmp {&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;* @param args&lt;br /&gt;*/&lt;br /&gt;public static void main(String[] args) {&lt;br /&gt;SessionFactory factory=null;&lt;br /&gt;Session session = null;&lt;br /&gt;Transaction tx = null;&lt;br /&gt;&lt;br /&gt;try&lt;br /&gt;{&lt;br /&gt;factory = new Configuration().configure().buildSessionFactory();&lt;br /&gt;session = factory.openSession();&lt;br /&gt;tx = session.beginTransaction();&lt;br /&gt;&lt;br /&gt;Employee emp = new Employee();&lt;br /&gt;emp.setEmployeeName("Anil Verma");&lt;br /&gt;&lt;br /&gt;session.save(emp);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;tx.commit();&lt;br /&gt;&lt;br /&gt;}catch (Exception e) {&lt;br /&gt;tx.rollback();&lt;br /&gt;e.printStackTrace();&lt;br /&gt;}finally&lt;br /&gt;{&lt;br /&gt;session.close();&lt;br /&gt;factory.close();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Yes!! you have developed your simple hibernate application.&lt;br /&gt;&lt;br /&gt;2. Using hibernate with Spring Framework.&lt;br /&gt;&lt;br /&gt;And now time is come to integrate this to Spring.Configuring the Hibernate SessionFactory in Spring.Here is an example Hibernate SessionFactory configured in Spring. You will be using this instead of the typical hibernate-config.xml. All we are doing here is telling Hibernate/Spring what our Hibernate mapping files are:&lt;br /&gt;&lt;br /&gt;&amp;lt;bean id="sessionFactory"&lt;br /&gt;class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"&amp;gt;&lt;br /&gt;&amp;lt;property name="mappingResources"&amp;gt;&lt;br /&gt;&amp;lt;list&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;value&amp;gt;Employee.hbm.xml&amp;lt;/value&amp;gt;&lt;br /&gt;&amp;lt;/list&amp;gt;&lt;br /&gt;&amp;lt;/property&amp;gt;&lt;br /&gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;&lt;br /&gt;If you have a hibernate.properties in your classpath, the Spring LocalSessionFactoryBean will use that file to configure the database connections, dialect and pooling. Alternatively, you can define a DataSource in Spring (any class that implements javax.sql.DataSource) and explicity set all of your Hibernate properties in the LocalSessionFactoryBean:&lt;br /&gt;&lt;br /&gt;&amp;lt;bean id="sessionFactory"&lt;br /&gt;class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"&amp;gt;&lt;br /&gt;&amp;lt;property name="mappingResources"&amp;gt;&lt;br /&gt;&amp;lt;list&amp;gt;&lt;br /&gt;&amp;lt;value&amp;gt;Employee.hbm.xml&amp;lt;/value&amp;gt;&lt;br /&gt;&amp;lt;/list&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/property&amp;gt;&lt;br /&gt;&amp;lt;property name="hibernateProperties"&amp;gt;&lt;br /&gt;&amp;lt;props&amp;gt;&lt;br /&gt;&amp;lt;prop key="hibernate.dialect"&amp;gt;&lt;br /&gt;    org.hibernate.dialect.Oracle9iDialect&lt;br /&gt;&amp;lt;/prop&amp;gt;&lt;br /&gt;&amp;lt;/props&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/property&amp;gt;&lt;br /&gt;&amp;lt;property name="dataSource"&amp;gt;&lt;br /&gt;&amp;lt;ref bean="dataSource"/&amp;gt;&lt;br /&gt;&amp;lt;/property&amp;gt;&lt;br /&gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;bean id="dataSource"&lt;br /&gt;class="org.springframework.jdbc.datasource.DriverManagerDataSource"&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;property name="driverClassName"&amp;gt;&lt;br /&gt;&amp;lt;value&amp;gt; oracle.jdbc.driver.OracleDriver&amp;lt;/value&amp;gt;&lt;br /&gt;&amp;lt;/property&amp;gt;&lt;br /&gt;&amp;lt;property name="url"&amp;gt;&lt;br /&gt;&amp;lt;value&amp;gt; jdbc:oracle:thin:@localhost:1521:machinename&amp;lt;/value&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/property&amp;gt;&lt;br /&gt;&amp;lt;property name="username"&amp;gt;&amp;lt;value&amp;gt;scott&amp;lt;/value&amp;gt;&amp;lt;/property&amp;gt;&lt;br /&gt;&amp;lt;property name="password"&amp;gt;&amp;lt;value&amp;gt;tiger&amp;lt;/value&amp;gt;&amp;lt;/property&amp;gt;&lt;br /&gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Extending HibernateDaoSupport for the Actual DAO Implementation&lt;br /&gt;The Spring HibernateDaoSupport class provides all kinds of convenience methods for working with Hibernate. Most of these are accessible via the HibernateTemplate object that this class exposes.&lt;br /&gt;Anyway, here is our EmployeeDAO implemented by extending HibernateDaoSupport:&lt;br /&gt;&lt;br /&gt;EmployeeDAOImpl.java&lt;br /&gt;-----------------------------------------&lt;br /&gt;package  com.ideeksha;&lt;br /&gt;public class EmployeeDAOImpl&lt;br /&gt;       extends HibernateDaoSupport&lt;br /&gt;       implements EmployeeDAO&lt;br /&gt;{&lt;br /&gt;/**&lt;br /&gt;* Returns a java.util.List of all Employees in the system.&lt;br /&gt;* @return&lt;br /&gt;*/&lt;br /&gt;public Collection getEmployees()&lt;br /&gt;{&lt;br /&gt;return getHibernateTemplate().loadAll(Employee.class);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;* Get a Employee Object given the id&lt;br /&gt;* @param id&lt;br /&gt;* @return&lt;br /&gt;*/&lt;br /&gt;public Employee getEmployeeById(Long id)&lt;br /&gt;{&lt;br /&gt;return (Employee)&lt;br /&gt;     getHibernateTemplate().load(Employee.class, id);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/**&lt;br /&gt;* Save a Employee Object, if the given Employee&lt;br /&gt;* is not in the data store,it should insert it,&lt;br /&gt;* if it is in the data store, it should update it.&lt;br /&gt;* @param employee&lt;br /&gt;*/&lt;br /&gt;public Employee saveEmployee(Employee employee)&lt;br /&gt;{&lt;br /&gt;getHibernateTemplate().saveOrUpdate(employee);&lt;br /&gt;return employee;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;3. Running the Example Application.&lt;br /&gt;&lt;br /&gt;Now we are done with the spring configuration. We will write a client for Spring DAO now.&lt;br /&gt;PersistEmp.java&lt;br /&gt;--------------------------------&lt;br /&gt;&lt;br /&gt;package com.ideeksha;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;import org.springframework.context.ApplicationContext;&lt;br /&gt;import org.springframework.context.support.ClassPathXmlApplicationContext;&lt;br /&gt;&lt;br /&gt;public class PersistEmp {&lt;br /&gt;&lt;br /&gt;public static void main(String[] args) {&lt;br /&gt;ApplicationContext context=new ClassPathXmlApplicationContext("spring2beans.xml");&lt;br /&gt;EmployeeDAO dao=( EmployeeDAO)context.getBean("employeeDAO");&lt;br /&gt;Employee emp = new Employee();&lt;br /&gt;emp.setEmployeeName("Anil Verma");&lt;br /&gt;dao.save(group);&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Now we can run this client application directly. This will be the final spring conf file :&lt;br /&gt;spring2beans.xml&lt;br /&gt;-------------------------------&lt;br /&gt;&amp;lt;!-- from the file 'context.xml' --&amp;gt;&lt;br /&gt;&amp;lt;beans xmlns="http://www.springframework.org/schema/beans"&lt;br /&gt;xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&lt;br /&gt;xmlns:aop="http://www.springframework.org/schema/aop"&lt;br /&gt;xmlns:tx="http://www.springframework.org/schema/tx"&lt;br /&gt;xsi:schemaLocation="&lt;br /&gt;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd&lt;br /&gt;http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd&lt;br /&gt;http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;bean id="employeeDAO" class="com.ideeksha.EmployeeDAOImpl"&amp;gt;&lt;br /&gt;&amp;lt;property name="sessionFactory" ref="mySessionFactory" /&amp;gt;&lt;br /&gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"&amp;gt;&lt;br /&gt;&amp;lt;property name="driverClassName" value="com.mysql.jdbc.Driver"/&amp;gt;&lt;br /&gt; &amp;lt;property name="url" value="jdbc:mysql://localhost:3306/hibernate"/&amp;gt;&lt;br /&gt; &amp;lt;property name="username" value="root"/&amp;gt;&lt;br /&gt; &amp;lt;property name="password" value="root"/&amp;gt;&lt;br /&gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;&amp;lt;bean id="mySessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"&amp;gt;&lt;br /&gt;&amp;lt;property name="dataSource" ref="dataSource"/&amp;gt;&lt;br /&gt;&amp;lt;property name="mappingResources"&amp;gt;&lt;br /&gt;&amp;lt;list&amp;gt;&lt;br /&gt; &amp;lt;value&amp;gt;com/ideeksha/Employee.hbm.xml&amp;lt;/value&amp;gt;&lt;br /&gt;&amp;lt;/list&amp;gt;&lt;br /&gt;&amp;lt;/property&amp;gt;&lt;br /&gt;&amp;lt;property name="hibernateProperties"&amp;gt;&lt;br /&gt;&amp;lt;value&amp;gt;&lt;br /&gt; hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect&lt;br /&gt; hibernate.hbm2ddl.auto=update&lt;br /&gt; hibernate.show_sql=true&lt;br /&gt;&amp;lt;/value&amp;gt;&lt;br /&gt;&amp;lt;/property&amp;gt;&lt;br /&gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;&amp;lt;/beans&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;And yes the last part remaining is the pom.xml file :&lt;br /&gt;&lt;br /&gt;&amp;lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;&lt;br /&gt;&amp;lt;modelVersion&gt;4.0.0&amp;lt;/modelVersion&gt;&lt;br /&gt;&amp;lt;groupId&gt;com.ideeksha&amp;lt;/groupId&gt;&lt;br /&gt;&amp;lt;artifactId&gt;SpringHibernate&amp;lt;/artifactId&gt;&lt;br /&gt;&amp;lt;name&gt;SpringHibernate&amp;lt;/name&gt;&lt;br /&gt;&amp;lt;version&gt;0.0.1-SNAPSHOT&amp;lt;/version&gt;&lt;br /&gt;&amp;lt;description/&gt;&lt;br /&gt;&amp;lt;dependencies&gt;&lt;br /&gt;&amp;lt;dependency&gt;&lt;br /&gt;&amp;lt;groupId&gt;junit&amp;lt;/groupId&gt;&lt;br /&gt;&amp;lt;artifactId&gt;junit&amp;lt;/artifactId&gt;&lt;br /&gt;&amp;lt;version&gt;3.8.1&amp;lt;/version&gt;&lt;br /&gt;&amp;lt;scope&gt;test&amp;lt;/scope&gt;&lt;br /&gt;&amp;lt;/dependency&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;dependency&gt;&lt;br /&gt;&amp;lt;groupId&gt;org.hibernate&amp;lt;/groupId&gt;&lt;br /&gt;&amp;lt;artifactId&gt;hibernate&amp;lt;/artifactId&gt;&lt;br /&gt;&amp;lt;version&gt;3.2.5.ga&amp;lt;/version&gt;&lt;br /&gt;&amp;lt;/dependency&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;dependency&gt;&lt;br /&gt;&amp;lt;groupId&gt;mysql&amp;lt;/groupId&gt;&lt;br /&gt;&amp;lt;artifactId&gt;mysql-connector-java&amp;lt;/artifactId&gt;&lt;br /&gt;&amp;lt;version&gt;5.1.6&amp;lt;/version&gt;&lt;br /&gt;&amp;lt;/dependency&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;dependency&gt;&lt;br /&gt;&amp;lt;groupId&gt;org.springframework&amp;lt;/groupId&gt;&lt;br /&gt;&amp;lt;artifactId&gt;spring&amp;lt;/artifactId&gt;&lt;br /&gt;&amp;lt;version&gt;2.0.6&amp;lt;/version&gt;&lt;br /&gt;&amp;lt;/dependency&gt;&lt;br /&gt;&amp;lt;dependency&gt;&lt;br /&gt;&amp;lt;groupId&gt;commons-dbcp&amp;lt;/groupId&gt;&lt;br /&gt;&amp;lt;artifactId&gt;commons-dbcp&amp;lt;/artifactId&gt;&lt;br /&gt;&amp;lt;version&gt;1.2.2&amp;lt;/version&gt;&lt;br /&gt;&amp;lt;/dependency&gt;&lt;br /&gt;&amp;lt;/dependencies&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/project&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Check the database table, is your employee is been persisted or not ...If Yes ..I can say now you have successfully integrated hibernate and spring. If "No" ...Its time to go to bed ...try next morning :)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;And off-course if you feel lazy to do the coding ...this is the link were you will get the code ..&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.mediafire.com/download.php?jydgwgmhynw"&gt;http://www.mediafire.com/download.php?jydgwgmhynw&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Cheers!!!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/517388772395375329-2619935173811348185?l=springkbase.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://springkbase.blogspot.com/feeds/2619935173811348185/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=517388772395375329&amp;postID=2619935173811348185' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/517388772395375329/posts/default/2619935173811348185'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/517388772395375329/posts/default/2619935173811348185'/><link rel='alternate' type='text/html' href='http://springkbase.blogspot.com/2009/05/spring-hibernate.html' title='Spring + Hibernate'/><author><name>Anil Verma</name><uri>http://www.blogger.com/profile/07159037456674064065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://4.bp.blogspot.com/_7ZiCsz7bxzk/Sh6rQK6LSeI/AAAAAAAAAXs/9j_hHnOvp6E/S220/40815841.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-517388772395375329.post-3974228173240573932</id><published>2009-05-27T02:08:00.001-07:00</published><updated>2009-06-03T19:24:30.058-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Soring-IOC'/><category scheme='http://www.blogger.com/atom/ns#' term='IOC'/><category scheme='http://www.blogger.com/atom/ns#' term='Spring Example'/><category scheme='http://www.blogger.com/atom/ns#' term='IOC Example'/><category scheme='http://www.blogger.com/atom/ns#' term='Spring'/><title type='text'></title><content type='html'>&lt;script src="http://www.gmodules.com/ig/ifr?url=http://www.google.com/ig/modules/translatemypage.xml&amp;up_source_language=en&amp;w=160&amp;h=60&amp;title=&amp;border=&amp;output=js"&gt;&lt;/script&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-weight: bold;"&gt;The Spring Framework: Understanding IoC&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;In Spring, the Inversion of Control (IoC) principle is implemented using the Dependency Injection (DI) design pattern. IoC or Inversion of Control is one of the core features of Spring. It helps in simplifying the implementation of business logic. To use the Spring Framework to its full potential, understanding the IoC container of the framework is essential.&lt;br /&gt;&lt;br /&gt;Let's understand dependency injection with the help of an example. First we will see a java version of the example and later we will add spring functionalities to it. As far as the example go, its pretty simple. The Quiz interface exposes the getQuestion() method. To keep things simple, our Quiz will generate only one question.&lt;br /&gt;&lt;br /&gt;Quiz.java&lt;br /&gt;----------------&lt;br /&gt;package com.ideeksha;&lt;br /&gt;&lt;br /&gt;public interface Quiz {&lt;br /&gt;&lt;br /&gt;public String getQuestion();&lt;br /&gt;}&lt;br /&gt;                                              &lt;br /&gt;The StrutsQuiz and the SpringQuiz class implements Quiz interface and they generate questions related to struts and spring respectively.&lt;br /&gt;&lt;br /&gt;StrutsQuiz.java&lt;br /&gt;----------------------&lt;br /&gt;package com.ideeksha;&lt;br /&gt;&lt;br /&gt;public class StrutsQuiz implements Quiz {&lt;br /&gt;&lt;br /&gt;@Override&lt;br /&gt;public String getQuestion() {&lt;br /&gt;return "Are you new to Struts?";&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;                                              &lt;br /&gt;SpringQuiz.java&lt;br /&gt;----------------------&lt;br /&gt;package com.ideeksha;&lt;br /&gt;&lt;br /&gt;public class SpringQuiz implements Quiz {&lt;br /&gt;&lt;br /&gt;@Override&lt;br /&gt;public String getQuestion() {&lt;br /&gt;return "Are you new to Spring?";&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;                                              &lt;br /&gt;We have a QuizService class that displays the question to the user. The QuizService class holds reference to the Quiz.&lt;br /&gt;&lt;br /&gt;QuizService.java&lt;br /&gt;-----------------------&lt;br /&gt;package com.ideeksha;&lt;br /&gt;&lt;br /&gt;public class QuizService {&lt;br /&gt;&lt;br /&gt;private Quiz quiz = new SpringQuiz ();&lt;br /&gt;&lt;br /&gt;public void askQuestion()&lt;br /&gt;{&lt;br /&gt;System.out.println(quiz.getQuestion());&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;                                              &lt;br /&gt;Finally we create the QuizProgram class to conduct quiz.&lt;br /&gt;QuizProgram.java&lt;br /&gt;----------------&lt;br /&gt;package com.ideeksha;&lt;br /&gt;&lt;br /&gt;public class QuizProgram {&lt;br /&gt;&lt;br /&gt;public static void main(String[] args) {&lt;br /&gt;QuizService quizService = new QuizService();&lt;br /&gt;quizService.askQuestion();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;                                              &lt;br /&gt;As you can see it is pretty simple, here we create an instance of the QuizService class and call the askQuestion() method. When you run the program as expected "Are you new to Spring?" gets printed in the console.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Spring Dependency Injection&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Let's have a look at the class diagram of this example. The green arrows indicate generalization and the blue arrows indicates association.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_7ZiCsz7bxzk/Sh0DuUnbjvI/AAAAAAAAAWU/mXMqbTtP-io/s1600-h/QuizWithoutSpring.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 157px;" src="http://4.bp.blogspot.com/_7ZiCsz7bxzk/Sh0DuUnbjvI/AAAAAAAAAWU/mXMqbTtP-io/s320/QuizWithoutSpring.bmp" alt="" id="BLOGGER_PHOTO_ID_5340428827474235122" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;As you can see this architecture is tightly coupled. We create an instance of the Quiz in the QuizService class in the following way.&lt;br /&gt;private Quiz quiz = new SpringQuiz();&lt;br /&gt;                                              &lt;br /&gt;To make our quiz master Struts genius we need to make modifications to the QuizService class like this.&lt;br /&gt;private Quiz quiz = new StrutsQuiz();&lt;br /&gt;                                              &lt;br /&gt;So it is tightly coupled. Now lets see how we can avoid this by using the Dependency Injection design pattern. The Spring framework provides prowerful container to manage the components. The container is based on the Inversion of Control (IoC) principle and can be implemented by using the Dependency Injection (DI) design pattern. Here the component only needs to choose a way to accept the resources and the container will deliver the resource to the components.&lt;br /&gt;In this example instead of we, directly creating an object of the Quiz bean in the QuizService class, we make use of the container to do this job for us. Instead of hard coding any values we will allow the container to inject the required dependancies.&lt;br /&gt;We can inject the dependancies using the setter or constructor injection. Here we will see how we can do this using the setter injection.&lt;br /&gt;QuizService.java&lt;br /&gt;-----------------------&lt;br /&gt;package com.ideeksha;&lt;br /&gt;&lt;br /&gt;public class QuizService {&lt;br /&gt;&lt;br /&gt;Quiz quiz;&lt;br /&gt;&lt;br /&gt;public void setQuiz(Quiz quiz) {&lt;br /&gt;this.quiz = quiz;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public void askQuestion()&lt;br /&gt;{&lt;br /&gt;System.out.println(quiz.getQuestion());&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;                                              &lt;br /&gt;The value for the Quiz will be set using the setQuiz () method. The Quiz object is never instantiated in the QuizService class, but still we access it. Usually this will throw a NullPointerException, but here the container will instantiate the object for us, so it works fine.&lt;br /&gt;&lt;br /&gt;After making all the changes, the class diagram of the example look like this.&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_7ZiCsz7bxzk/Sh0Ei3wny_I/AAAAAAAAAWc/doQykuEqTzE/s1600-h/QuizWithSpring.bmp"&gt;&lt;img style="cursor: pointer; width: 320px; height: 207px;" src="http://2.bp.blogspot.com/_7ZiCsz7bxzk/Sh0Ei3wny_I/AAAAAAAAAWc/doQykuEqTzE/s320/QuizWithSpring.bmp" alt="" id="BLOGGER_PHOTO_ID_5340429730261224434" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;The container comes into picture and it helps in injecting the dependancies.&lt;br /&gt;The bean configuration is done in the beans.xml file.&lt;br /&gt;&lt;br /&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;&lt;br /&gt;&amp;lt;beans xmlns="http://www.springframework.org/schema/beans"&lt;br /&gt;xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&lt;br /&gt;xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"&amp;gt;&lt;br /&gt;&amp;lt;bean id="springQuiz" class="com.ideeksha.SpringQuiz"&amp;gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;&amp;lt;bean id="strutsQuiz" class="com.ideeksha.StrutsQuiz"&amp;gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;&amp;lt;bean id="quizService" class="com.ideeksha.QuizService"&amp;gt;&lt;br /&gt; &amp;lt;property name="quiz"&amp;gt;&lt;br /&gt;  &amp;lt;ref local="springQuiz"/&amp;gt;&lt;br /&gt; &amp;lt;/property&amp;gt;&lt;br /&gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;&amp;lt;/beans&amp;gt;&lt;br /&gt;&lt;br /&gt;We define each bean using the bean tag. The id attribute of the bean tag gives a logical name to the bean and the class attribute represents the actual bean class. The property tag is used to refer the property of the bean. To inject a bean using the setter injection you need to use the ref tag.&lt;br /&gt;&lt;br /&gt;Here a reference of SpringQuiz is injected to the Quiz bean. When we execute this example, "Are you new to Spring?" gets printed in the console.&lt;br /&gt;To make our Quiz ask questions related to Struts, the only change we need to do is, to change the bean reference in the ref tag.&lt;br /&gt;&lt;br /&gt;&amp;lt;bean id="quizService" class="com.ideeksha.QuizService"&amp;gt;&lt;br /&gt;   &amp;lt;property name="quiz"&amp;gt;&lt;br /&gt;       &amp;lt;ref local="strutsQuiz"/&amp;gt;&lt;br /&gt;   &amp;lt;/property&amp;gt;&lt;br /&gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;&lt;br /&gt;In this way the Dependency Injection helps in reducing the coupling between the components. And yes it says “NO” to ‘new’ operator!!!&lt;br /&gt;&lt;p&gt;To Run This example&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;QuizExample.java&lt;br /&gt;&lt;br /&gt;---------------------------&lt;br /&gt;package com.ideeksha;&lt;br /&gt;&lt;br /&gt;import org.springframework.context.ApplicationContext;&lt;br /&gt;import org.springframework.context.support.ClassPathXmlApplicationContext;&lt;br /&gt;&lt;br /&gt;public class QuizProgram {&lt;br /&gt;&lt;br /&gt;public static void main(String[] args) {&lt;br /&gt; ApplicationContext context = new ClassPathXmlApplicationContext("beans.xml");&lt;br /&gt; QuizService quizService = (QuizService) context.getBean("quizService");&lt;br /&gt; quizService.askQuestion();&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;!-- google_ad_client = "pub-4029248803193693"; /* 728x15, created 5/27/09 */ google_ad_slot = "0072141329"; google_ad_width = 728; google_ad_height = 15; //--&gt;&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;More things on Spring IOC --Ways to do Spring dependency Injection !!!&lt;/span&gt;&lt;br /&gt;Inversion of Control or IoC is one of the techniques used to wire services or components to an application program. By definition, IoC is “A software design  pattern and set of associated programming techniques in which the flow of control of a system is inverted in comparison to the traditional interaction mode.” Simply stated, in IoC, instead of an application calling the framework, it is the framework that calls the components specified by the application.&lt;br /&gt;This approach is similar to the one that Hollywood agents adopt with their clients. It is sometimes known as “Don’t call me, I will call you.” This is why IoC is also known as the Hollywood approach.&lt;br /&gt;However, IoC is a broad and generic term. The aspect of IoC that the Spring Framework uses is "Injection of required resources or dependency at Run-time into the dependent resource," which is also known as Dependency Injection. Hence, the service provided by the IoC container of Spring is Dependency Injection. Therefore, I will be using the terms IoC and Dependency Injection in a lax way.&lt;br /&gt;There are three forms or styles of Dependency Injection. They are:&lt;br /&gt;1. Constructor Injection&lt;br /&gt;2. Setter Injection&lt;br /&gt;3. Interface Injection&lt;br /&gt;&lt;br /&gt;Of these, the Spring Framework directly supports the first and second forms whereas the third form is supported indirectly. Between the first and the second, the Spring Framework prefers the use of second rather than the first. Here are the details.&lt;br /&gt;1. Constructor Injection: In Constructor Injection, an IoC container uses the constructor to inject the dependency. All the dependencies, whether they are simple values or references to other objects, are declared in the constructor. One of the advantages of Constructor Injection is that all the dependencies are declared in one go. This also helps in understanding whether the class depends on too many services.&lt;br /&gt;2. Setter Injection: This form of Dependency Injection uses Setters, also known as mutators (because they change the value of the corresponding instance variables), to inject the required resources or dependencies. In other words, each of the objects that the class depends upon will have a setter and the IoC container will use the setters to provide the resource at run-time.&lt;br /&gt;&lt;br /&gt;The main difference between Constructor Injection and Setter Injection is that in Constructor Injection, the handing over of the dependencies takes place during instantiation of the dependent object, whereas with Setter Injection, it takes place after the dependent object is instantiated. The Spring Framework favors Setter Injection over Constructor Injection.&lt;br /&gt;3. Interface Injection: Interface Injection provides the concrete implementations of an interface to the dependent object according to the configuration. The main difference between Interface Injection and the previous two is that in Interface Injection, any of the implementations of the interface can be injected, whereas with the other two, the object of the class specified is injected. Spring does not provide direct support for Interface Injection.&lt;br /&gt;&lt;br /&gt;That completes the overview of IoC.&lt;br /&gt;&lt;br /&gt;To execute this example add the following jar files to the classpath.&lt;br /&gt;&lt;br /&gt;antlr-runtime-3.0&lt;br /&gt;commons-logging-1.0.4&lt;br /&gt;org.springframework.asm-3.0.0.M3&lt;br /&gt;org.springframework.beans-3.0.0.M3&lt;br /&gt;org.springframework.context-3.0.0.M3&lt;br /&gt;org.springframework.context.support-3.0.0.M3&lt;br /&gt;org.springframework.core-3.0.0.M3&lt;br /&gt;org.springframework.expression-3.0.0.M3&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/517388772395375329-3974228173240573932?l=springkbase.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://springkbase.blogspot.com/feeds/3974228173240573932/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=517388772395375329&amp;postID=3974228173240573932' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/517388772395375329/posts/default/3974228173240573932'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/517388772395375329/posts/default/3974228173240573932'/><link rel='alternate' type='text/html' href='http://springkbase.blogspot.com/2009/05/spring-framework-understanding-ioc-in.html' title=''/><author><name>Anil Verma</name><uri>http://www.blogger.com/profile/07159037456674064065</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='31' height='32' src='http://4.bp.blogspot.com/_7ZiCsz7bxzk/Sh6rQK6LSeI/AAAAAAAAAXs/9j_hHnOvp6E/S220/40815841.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_7ZiCsz7bxzk/Sh0DuUnbjvI/AAAAAAAAAWU/mXMqbTtP-io/s72-c/QuizWithoutSpring.bmp' height='72' width='72'/><thr:total>2</thr:total></entry></feed>
