<?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:blogger='http://schemas.google.com/blogger/2008' 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-7715544799292814842</id><updated>2024-12-18T19:33:04.253-08:00</updated><category term="General"/><category term="Java"/><category term="spring"/><category term="How To"/><category term="Networking"/><category term="Technology"/><category term="Hibernate"/><category term="Miscellaneous"/><category term="Tech News"/><category term="Tips and Tricks"/><category term="jsp"/><category term="Linux"/><category term="Software and Apps"/><category term="Windows"/><category term="xml"/><category term="Reviews"/><title type='text'>TechnicalToday</title><subtitle type='html'>Java programming ,Spring Framework, Hibernate, MVC, XML, JSP, JavaFx, Networking Concepts and other Technical Stuff</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://navin-bansal.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7715544799292814842/posts/default'/><link rel='alternate' type='text/html' href='http://navin-bansal.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/7715544799292814842/posts/default?start-index=26&amp;max-results=25'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06685256351965309878</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>76</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7715544799292814842.post-8910173176976461848</id><published>2013-03-27T01:48:00.002-07:00</published><updated>2013-03-27T01:48:21.277-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="General"/><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><category scheme="http://www.blogger.com/atom/ns#" term="spring"/><title type='text'>Spring Framework - MethodReplacer Example in spring</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Spring framework with AOP show many magic.One of them is Method Replacer .In this activity the called method is replaced by another method. To understand clearly have a good example-&lt;br /&gt;
Directory Structure-&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTAb8dQjQi24_Ppn0JjEAi6r3E6Z-2F08kQvoQr2GUgJFdYnJb_iTx1Ir3AvhJbViAVRgUPugSNSp5gC78wDWcxxmypsD5pgAFO_9Zga72b0YSjCm2I-KwHt-x-lmtl07FWZfvK1HsGTu0/s1600/method.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTAb8dQjQi24_Ppn0JjEAi6r3E6Z-2F08kQvoQr2GUgJFdYnJb_iTx1Ir3AvhJbViAVRgUPugSNSp5gC78wDWcxxmypsD5pgAFO_9Zga72b0YSjCm2I-KwHt-x-lmtl07FWZfvK1HsGTu0/s1600/method.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Class Ract.java-&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;div class=&quot;codeview&quot;&gt;
&lt;br /&gt;
package com.test;&lt;br /&gt;
&lt;br /&gt;
public class Ract {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;String name;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public String getName() {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return name;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public void setName(String name) {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;this.name = name;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public String getContent()&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return &quot;hello methd&quot;;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;br /&gt;
}&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;class Triangle.java-&lt;/b&gt;
&lt;br /&gt;
&lt;div class=&quot;codeview&quot;&gt;
&lt;br /&gt;
package com.test;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
public class Triangle {&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private String type;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private int height;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private Ract ract;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public Ract getRact() {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return ract;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public void setRact(Ract ract) {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;this.ract = ract;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public int getHeight() {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return height;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public void setHeight(int height) {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;this.height = height;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public String getContent()&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return &quot;pre method&quot;;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public String getType() {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return type;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public void setType(String type) {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;this.type = type;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public void draw()&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.out.println( getType()+&quot;Triangle.\n The height is=&quot;+getHeight() );&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.out.println(&quot;ractangle is=&quot;+ract.getName());&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.out.println(&quot;getcontent method=&quot;+getContent());&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;br /&gt;
}&lt;/div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt; Class MethodReplace.java-&lt;/b&gt;
&lt;br /&gt;
&lt;div class=&quot;codeview&quot;&gt;
&lt;br /&gt;
package com.test;&lt;br /&gt;
&lt;br /&gt;
import java.lang.reflect.Method;&lt;br /&gt;
&lt;br /&gt;
import org.springframework.beans.factory.support.MethodReplacer;&lt;br /&gt;
&lt;br /&gt;
public class MethodReplace implements MethodReplacer {&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;@Override&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public Object reimplement(Object arg0, Method arg1, Object[] arg2)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;throws Throwable {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;// TODO Auto-generated method stub&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return &quot;huree!!!!I m Replaced&quot;;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;br /&gt;
}&lt;/div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt; class DrawApp.java-&lt;/b&gt;
&lt;br /&gt;
&lt;div class=&quot;codeview&quot;&gt;
&lt;br /&gt;
package com.test;&lt;br /&gt;
&lt;br /&gt;
import org.springframework.context.support.AbstractApplicationContext;&lt;br /&gt;
import org.springframework.context.support.ClassPathXmlApplicationContext;&lt;br /&gt;
&lt;br /&gt;
public class DrawApp {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
public static void main(String a[])&lt;br /&gt;
{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;AbstractApplicationContext context=new ClassPathXmlApplicationContext(&quot;spring.xml&quot;);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;context.registerShutdownHook();//callsdestroy method dow the rsorce&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Triangle tri= (Triangle) context.getBean(&quot;triangle&quot;);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;tri.draw();&lt;br /&gt;
}&lt;br /&gt;
}&lt;/div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;spring.xml&lt;/b&gt;
-&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!DOCTYPE beans PUBLIC &quot;-//SPRING//DTD BEAN 2.0//EN&quot; &quot;http://www.springframework.org/dtd/spring-beans-2.0.dtd&quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;beans&amp;gt;&lt;br /&gt;
&amp;lt;bean id=&quot;ract&quot; class=&quot;com.test.Ract&quot;&amp;gt;&lt;br /&gt;
&amp;lt;property name=&quot;name&quot; value=&quot;navin&#39;s&quot;&amp;gt;&amp;lt;/property&amp;gt;&lt;br /&gt;
&amp;lt;/bean&amp;gt;&lt;br /&gt;
&amp;lt;bean id=&quot;mrp&quot; class=&quot;com.test.MethodReplace&quot;&amp;gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;lt;bean id=&quot;triangle&quot; class=&quot;com.test.Triangle&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;lt;property name=&quot;type&quot; value=&quot;test&quot;&amp;gt;&amp;lt;/property&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;lt;property name=&quot;height&quot; value=&quot;2&quot;&amp;gt;&amp;lt;/property&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;lt;property name=&quot;ract&quot; ref=&quot;ract&quot;&amp;gt;&amp;lt;/property&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;replaced-method name=&quot;getContent&quot; replacer=&quot;mrp&quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/bean&amp;gt;&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;lt;/beans&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Output-&lt;/b&gt;
&lt;br /&gt;
&lt;div class=&quot;codeview&quot;&gt;
&lt;br /&gt;
testTriangle.&lt;br /&gt;
The height is=2&lt;br /&gt;
ractangle is=navin&#39;s&lt;br /&gt;
getcontent method=huree!!!!I m Replaced&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://navin-bansal.blogspot.com/feeds/8910173176976461848/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://navin-bansal.blogspot.com/2013/03/spring-framework-methodreplacer-example.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7715544799292814842/posts/default/8910173176976461848'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7715544799292814842/posts/default/8910173176976461848'/><link rel='alternate' type='text/html' href='http://navin-bansal.blogspot.com/2013/03/spring-framework-methodreplacer-example.html' title='Spring Framework - MethodReplacer Example in spring'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06685256351965309878</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTAb8dQjQi24_Ppn0JjEAi6r3E6Z-2F08kQvoQr2GUgJFdYnJb_iTx1Ir3AvhJbViAVRgUPugSNSp5gC78wDWcxxmypsD5pgAFO_9Zga72b0YSjCm2I-KwHt-x-lmtl07FWZfvK1HsGTu0/s72-c/method.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7715544799292814842.post-690412067634603478</id><published>2013-03-26T22:09:00.000-07:00</published><updated>2013-03-26T22:09:01.149-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="General"/><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><category scheme="http://www.blogger.com/atom/ns#" term="spring"/><title type='text'>Spring Framework - Example of Database Connectivity with DataSource</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
After lot of basic tutorials and topics now we start database connectivity .In spring framework DataSource in used to define the database configuration.In XML configuration file use&amp;nbsp;&lt;b style=&quot;font-style: italic;&quot;&gt;DriverManagerDataSource &lt;/b&gt;class is used to set the database configuration like driver,pool,username and password.so understand clearly here below is a simple example-&lt;br /&gt;
&lt;div&gt;
Directory Structure-&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2CNwboBh0NTima0lEaPCaV3HQxMPomv62AEAUBU5upfSnS9gyX4WBXMWPcMAdwaFFyqWF2KLjpLHNbGOCF_7IhEM8sxbYG13Vxc4yJPiwCp6dsv35kXiWUEPsO0hngkrixv1VE0IHqXPG/s1600/data.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2CNwboBh0NTima0lEaPCaV3HQxMPomv62AEAUBU5upfSnS9gyX4WBXMWPcMAdwaFFyqWF2KLjpLHNbGOCF_7IhEM8sxbYG13Vxc4yJPiwCp6dsv35kXiWUEPsO0hngkrixv1VE0IHqXPG/s1600/data.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;class Student.java-&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;codeview&quot;&gt;
package com.test.student;&lt;br /&gt;
&lt;br /&gt;
public class Student {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int id;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;String name;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public int getId() {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return id;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public Student(int id, String name) {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;super();&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;setId(id);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;setName(name);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public void setId(int id) {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;this.id = id;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public String getName() {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return name;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public void setName(String name) {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;this.name = name;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;b&gt;Class DaoImpl.java&lt;/b&gt;
&lt;br /&gt;
&lt;div class=&quot;codeview&quot;&gt;
&lt;br /&gt;
package com.test.daoimp;&lt;br /&gt;
&lt;br /&gt;
import java.sql.Connection;&lt;br /&gt;
/*import java.sql.DriverManager;*/&lt;br /&gt;
import java.sql.PreparedStatement;&lt;br /&gt;
import java.sql.ResultSet;&lt;br /&gt;
&lt;br /&gt;
import javax.annotation.PostConstruct;&lt;br /&gt;
import javax.annotation.PreDestroy;&lt;br /&gt;
import javax.sql.DataSource;&lt;br /&gt;
&lt;br /&gt;
import org.springframework.beans.factory.annotation.Autowired;&lt;br /&gt;
import org.springframework.stereotype.Component;&lt;br /&gt;
&lt;br /&gt;
import com.test.student.Student;&lt;br /&gt;
@Component&lt;br /&gt;
public class DaoImpl {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Student stu=null;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private DataSource dataSource;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public DataSource getDataSource() {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return dataSource;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;@Autowired&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public void setDataSource(DataSource dataSource) {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;this.dataSource = dataSource;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public Student getStu(int id)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;try {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt; &amp;nbsp; Connection con=dataSource.getConnection();&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp; PreparedStatement st=con.prepareStatement(&quot;select * from stu where id=?&quot;);&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp; st.setInt(1, id);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp; ResultSet rs=st.executeQuery();&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp;if( rs.next())&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp; {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt; &amp;nbsp; stu=new Student(id,rs.getString(&quot;name&quot;));&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp; }&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp; con.close();&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp; st.close();&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp; rs.close();&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;} catch (Exception e) {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;// TODO Auto-generated catch block&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;e.printStackTrace();&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return stu;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;@PostConstruct&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public void initialmethod()&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.out.println(&quot;Welcome to database&quot;);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;@PreDestroy&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public void destroymethod()&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.out.println(&quot;!!!!!!!!!!!GooD Bye!!!!!!!!&quot;);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;br /&gt;
}&lt;/div&gt;
&lt;br /&gt;
@PostConstruct annotation used method call after the constructor is initialized and @Predestroy annotate method is calls when the scope or datasoure object scope is finished ,to call the predestory need to call the method registerShutdownHook by the AbstractApplicationContext object which is define as in &lt;b&gt;&lt;i&gt;main.java&lt;/i&gt;&lt;/b&gt; class.
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Class Main.java-&lt;/b&gt;
&lt;br /&gt;
&lt;div class=&quot;codeview&quot;&gt;
&lt;br /&gt;
package com.test.Dao;&lt;br /&gt;
&lt;br /&gt;
/*import java.io.DataInputStream;*/&lt;br /&gt;
import org.springframework.context.support.AbstractApplicationContext;&lt;br /&gt;
import org.springframework.context.support.ClassPathXmlApplicationContext;&lt;br /&gt;
&lt;br /&gt;
import com.test.daoimp.DaoImpl;&lt;br /&gt;
&lt;br /&gt;
public class Main {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public static void main(String args[])&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;AbstractApplicationContext ctx=new ClassPathXmlApplicationContext(&quot;spring.xml&quot;);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;ctx.registerShutdownHook();&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp; DaoImpl di=ctx.getBean(&quot;daoImpl&quot;,DaoImpl.class);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp; System.out.println(&quot;Student name is=&quot;+di.getStu(1).getName());&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;br /&gt;
}&lt;/div&gt;
&lt;b&gt; spring.xml-&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;&lt;br /&gt;
&amp;lt;beans xmlns=&quot;http://www.springframework.org/schema/beans&quot;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;xmlns:aop=&quot;http://www.springframework.org/schema/aop&quot;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;xsi:schemaLocation=&quot;http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd&quot;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;xmlns:context=&quot;http://www.springframework.org/schema/context&quot;&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;context:annotation-config&amp;gt;&amp;lt;/context:annotation-config&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;context:component-scan base-package=&quot;com.test&quot;&amp;gt;&amp;lt;/context:component-scan&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;bean id=&quot;dataSource&quot; class=&quot;org.springframework.jdbc.datasource.DriverManagerDataSource&quot;&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;lt;property name=&quot;driverClassName&quot; value=&quot;com.mysql.jdbc.Driver&quot;&amp;gt;&amp;lt;/property&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;lt;property name=&quot;url&quot; value=&quot;jdbc:mysql://localhost:3306/Student&quot;&amp;gt;&amp;lt;/property&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;lt;property name=&quot;username&quot; value=&quot;root&quot;&amp;gt;&amp;lt;/property&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;lt;property name=&quot;password&quot; value=&quot;root&quot;&amp;gt;&amp;lt;/property&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;lt;!-- &amp;lt;property name=&quot;initalSize&quot; value=&quot;2&quot;&amp;gt;&amp;lt;/property&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;lt;property name=&quot;maxActive&quot; value=&quot;5&quot;&amp;gt;&amp;lt;/property&amp;gt; --&amp;gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/bean&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;/beans&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;b&gt;Output-&lt;/b&gt;
&lt;br /&gt;
&lt;div class=&quot;codeview&quot;&gt;
&lt;br /&gt;
Welcome to database&lt;br /&gt;
Student name is=navin&lt;br /&gt;
!!!!!!!!!!!GooD Bye!!!!!!!!&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://navin-bansal.blogspot.com/feeds/690412067634603478/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://navin-bansal.blogspot.com/2013/03/spring-framework-example-of-database.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7715544799292814842/posts/default/690412067634603478'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7715544799292814842/posts/default/690412067634603478'/><link rel='alternate' type='text/html' href='http://navin-bansal.blogspot.com/2013/03/spring-framework-example-of-database.html' title='Spring Framework - Example of Database Connectivity with DataSource'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06685256351965309878</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2CNwboBh0NTima0lEaPCaV3HQxMPomv62AEAUBU5upfSnS9gyX4WBXMWPcMAdwaFFyqWF2KLjpLHNbGOCF_7IhEM8sxbYG13Vxc4yJPiwCp6dsv35kXiWUEPsO0hngkrixv1VE0IHqXPG/s72-c/data.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7715544799292814842.post-7633824800951261680</id><published>2013-03-25T11:18:00.001-07:00</published><updated>2013-03-25T11:18:09.809-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="General"/><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><category scheme="http://www.blogger.com/atom/ns#" term="spring"/><title type='text'>Spring Framework- Execption handling in AOP </title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Hureeeee!!!!! &amp;nbsp;Today in spring framework we learn some intresting with AOP, so today topic is Execption handling. AOP contain a method &lt;b style=&quot;font-style: italic;&quot;&gt;proceed() . &lt;/b&gt;If this method is proceed with exception then it pass the controll of the program to the catch block, In That type examples we can also used&amp;nbsp;@AfterThrowing , @AfterReturning ,@Around . here we use&amp;nbsp;@Around annotation to follow the AOP. So here below is the example --&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmzkXW5SsYq5ccXw8dpjZFsMbdfYZ9ZcrZnipsY9tDAlLTzir63SQ0tVFf_vuIClzfJVEO6wv3RMTOTyUW5zBiFv5N5ViIz0i6wjcNrVU1lpSEStX4UavEQo2D_FyxlorvE7VF754poNN8/s1600/image1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmzkXW5SsYq5ccXw8dpjZFsMbdfYZ9ZcrZnipsY9tDAlLTzir63SQ0tVFf_vuIClzfJVEO6wv3RMTOTyUW5zBiFv5N5ViIz0i6wjcNrVU1lpSEStX4UavEQo2D_FyxlorvE7VF754poNN8/s320/image1.png&quot; width=&quot;201&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;b&gt;Class circle.java-&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;codeview&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
package com.test.App;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
public class Circle {&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;String name;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public String getName() {&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return name;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public void setName(String name) {&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;this.name = name;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
}&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;font-weight: bold;&quot;&gt;
Class Triangle.java-&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;codeview&quot;&gt;
package com.test.App;&lt;br /&gt;
&lt;br /&gt;
public class Triangle {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;String name;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public String getName() {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return name;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public void setName(String name) {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;this.name = name;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;br /&gt;
}&lt;/div&gt;
&lt;div style=&quot;font-weight: bold;&quot;&gt;
Class Shape.java-&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;codeview&quot;&gt;
package com.test.service;&lt;br /&gt;
&lt;br /&gt;
import com.test.App.Circle;&lt;br /&gt;
import com.test.App.Triangle;&lt;br /&gt;
&lt;br /&gt;
public class Shape {&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Circle circle;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Triangle triangle;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public Circle getCircle() {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;throw (new RuntimeException());&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public void setCircle(Circle circle) {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;this.circle = circle;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public Triangle getTriangle() {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return triangle;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public void setTriangle(Triangle triangle) {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;this.triangle = triangle;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
}&lt;/div&gt;
&lt;div style=&quot;font-weight: bold;&quot;&gt;
Class LogAspect.java-&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;codeview&quot;&gt;
&lt;br /&gt;
package com.test.aspect;&lt;br /&gt;
&lt;br /&gt;
import org.aspectj.lang.JoinPoint;&lt;br /&gt;
import org.aspectj.lang.ProceedingJoinPoint;&lt;br /&gt;
import org.aspectj.lang.annotation.AfterReturning;&lt;br /&gt;
import org.aspectj.lang.annotation.AfterThrowing;&lt;br /&gt;
import org.aspectj.lang.annotation.Around;&lt;br /&gt;
import org.aspectj.lang.annotation.Aspect;&lt;br /&gt;
import org.aspectj.lang.annotation.Before;&lt;br /&gt;
import org.aspectj.lang.annotation.Pointcut;&lt;br /&gt;
&lt;br /&gt;
@Aspect&lt;br /&gt;
public class LogAspect {&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;@Before(&quot;allcircle()&quot;)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public void loggingAdvice(JoinPoint joinpoint)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; System.out.println(&quot;advice&quot;);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp;@Pointcut(&quot;execution(* get*())&quot;)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public void allGetters()&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.out.println(&quot;Wel Come With....allgetters&quot;);&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp;@Pointcut(&quot;within(com.test.App.Circle)&quot;)&lt;br /&gt;
&amp;nbsp; &amp;nbsp;public void allcircle()&lt;br /&gt;
&amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.out.println(&quot;Wel Come With....circle&quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;@AfterReturning(pointcut=&quot;args(name)&quot;,returning=&quot;returnstring&quot;)&lt;br /&gt;
&amp;nbsp; &amp;nbsp;public void strigArgs(String name,Object returnstring)&lt;br /&gt;
&amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; System.out.println(&quot;string args is used&quot;+name+&quot;return string is=&quot;+returnstring);&lt;br /&gt;
&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp;@AfterThrowing(pointcut=&quot;args(name)&quot;,throwing=&quot;ex&quot;)&lt;br /&gt;
&amp;nbsp;public void throwEX(String name,RuntimeException ex)&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; System.out.println(&quot;exception is call &quot;+ex);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;@Around(&quot;allGetters()&quot;)&lt;br /&gt;
&amp;nbsp;public Object aroundProcess(ProceedingJoinPoint process)&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; try {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; System.out.println(&quot;before advice&quot;);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;process.proceed();&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.out.println(&quot;atfer advice&quot;);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;} catch (Throwable e) {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;// TODO Auto-generated catch block&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.out.println(&quot;After throw&quot;);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; System.out.println(&quot;After finally&quot;);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; return null;&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
}&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Class Main.java&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;codeview&quot;&gt;
package com.test.aop;&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;
import com.test.service.Shape;&lt;br /&gt;
&lt;br /&gt;
public class Main {&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public static void main(String[] args) {&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;ApplicationContext context=new ClassPathXmlApplicationContext(&quot;spring.xml&quot;);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Shape sh=context.getBean(&quot;shape&quot;, Shape.class);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;sh.getCircle();&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;br /&gt;
}
&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;b&gt;Spring.xml-&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;&lt;br /&gt;
&amp;lt;beans xmlns=&quot;http://www.springframework.org/schema/beans&quot;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;xmlns:aop=&quot;http://www.springframework.org/schema/aop&quot;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;xsi:schemaLocation=&quot;http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd&quot;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;xmlns:context=&quot;http://www.springframework.org/schema/context&quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;lt;aop:aspectj-autoproxy/&amp;gt;&lt;br /&gt;
&amp;lt;bean id=&quot;triangle&quot; class=&quot;com.test.App.Triangle&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;lt;property name=&quot;name&quot; value=&quot;triangle drawn&quot;&amp;gt;&amp;lt;/property&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;lt;/bean&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;lt;bean id=&quot;circle&quot; class=&quot;com.test.App.Circle&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;property name=&quot;name&quot; value=&quot;circle drawn&quot;&amp;gt;&amp;lt;/property&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;lt;/bean&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;bean id=&quot;shape&quot; class=&quot;com.test.service.Shape&quot; autowire=&quot;byName&quot;&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;bean id=&quot;log&quot; class=&quot;com.test.aspect.LogAspect&quot;&amp;gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;/beans&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Output-&lt;/b&gt;
&lt;br /&gt;
&lt;div class=&quot;codeview&quot;&gt;
before advice&lt;br /&gt;
After throw&lt;br /&gt;
After finally&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://navin-bansal.blogspot.com/feeds/7633824800951261680/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://navin-bansal.blogspot.com/2013/03/spring-framework-execption-handling-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7715544799292814842/posts/default/7633824800951261680'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7715544799292814842/posts/default/7633824800951261680'/><link rel='alternate' type='text/html' href='http://navin-bansal.blogspot.com/2013/03/spring-framework-execption-handling-in.html' title='Spring Framework- Execption handling in AOP '/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06685256351965309878</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmzkXW5SsYq5ccXw8dpjZFsMbdfYZ9ZcrZnipsY9tDAlLTzir63SQ0tVFf_vuIClzfJVEO6wv3RMTOTyUW5zBiFv5N5ViIz0i6wjcNrVU1lpSEStX4UavEQo2D_FyxlorvE7VF754poNN8/s72-c/image1.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7715544799292814842.post-406212021357252740</id><published>2013-03-25T10:56:00.001-07:00</published><updated>2013-03-25T11:03:04.551-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="General"/><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><category scheme="http://www.blogger.com/atom/ns#" term="spring"/><title type='text'>Spring Framework - Example to use @Before annotation with args() in AOP</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Here In AOP, we discuss that how use&amp;nbsp;@Before(args()).Here args() is contain the name of arguments with pass to the function and also can use that argument.Now see a example to understand that-&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiS3ejqS-ajKVAfARvO4CoqI1r-WqgkFkEGtREuaK4CvU0e5RO1CYELcBtbBJ7wL_US-lNNgA6QqirWPEZVw1Wtxm8BGrTO_rOCCOKVIILZRqxdtd0qia-GD8Swxs-zfmYH1yn5_u5cUTD3/s1600/image1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiS3ejqS-ajKVAfARvO4CoqI1r-WqgkFkEGtREuaK4CvU0e5RO1CYELcBtbBJ7wL_US-lNNgA6QqirWPEZVw1Wtxm8BGrTO_rOCCOKVIILZRqxdtd0qia-GD8Swxs-zfmYH1yn5_u5cUTD3/s320/image1.png&quot; width=&quot;201&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;b&gt;Class circle.java-&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;codeview&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
package com.test.App;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
public class Circle {&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;String name;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public String getName() {&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return name;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public void setName(String name) {&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;this.name = name;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
}&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;font-weight: bold;&quot;&gt;
Class Triangle.java-&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;codeview&quot;&gt;
package com.test.App;&lt;br /&gt;
&lt;br /&gt;
public class Triangle {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;String name;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public String getName() {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return name;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public void setName(String name) {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;this.name = name;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;br /&gt;
}&lt;/div&gt;
&lt;div style=&quot;font-weight: bold;&quot;&gt;
Class Shape.java-&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;codeview&quot;&gt;
package com.test.service;&lt;br /&gt;
&lt;br /&gt;
import com.test.App.Circle;&lt;br /&gt;
import com.test.App.Triangle;&lt;br /&gt;
&lt;br /&gt;
public class Shape {&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Circle circle;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Triangle triangle;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public Circle getCircle() {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return circle;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public void setCircle(Circle circle) {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;this.circle = circle;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public Triangle getTriangle() {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return triangle;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public void setTriangle(Triangle triangle) {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;this.triangle = triangle;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
}&lt;/div&gt;
&lt;div style=&quot;font-weight: bold;&quot;&gt;
Class LogAspect.java-&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;codeview&quot;&gt;
package com.test.aspect;&lt;br /&gt;
&lt;br /&gt;
import org.aspectj.lang.JoinPoint;&lt;br /&gt;
import org.aspectj.lang.annotation.Aspect;&lt;br /&gt;
import org.aspectj.lang.annotation.Before;&lt;br /&gt;
import org.aspectj.lang.annotation.Pointcut;&lt;br /&gt;
&lt;br /&gt;
@Aspect&lt;br /&gt;
public class LogAspect {&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;@Before(&quot;allGetters() &amp;amp;&amp;amp; allcircle()&quot;)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public void loggingAdvice(JoinPoint joinpoint)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.out.println(&quot;joinpoint calls&quot;);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.out.println(joinpoint.toString());&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.out.println(joinpoint.getTarget());&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp;@Pointcut(&quot;execution(* get*())&quot;)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public void allGetters()&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.out.println(&quot;Wel Come With....allgetters&quot;);&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp;@Pointcut(&quot;within(com.test.App.Circle)&quot;)&lt;br /&gt;
&amp;nbsp; &amp;nbsp;public void allcircle()&lt;br /&gt;
&amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.out.println(&quot;Wel Come With....circle&quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;@Before(&quot;args(name)&quot;)&lt;br /&gt;
&amp;nbsp; &amp;nbsp;public void strigArgs(String name)&lt;br /&gt;
&amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; System.out.println(&quot;string args is used&quot;+name);&lt;br /&gt;
&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Here is necessary that String(&lt;u&gt;&lt;b&gt;name&lt;/b&gt;&lt;/u&gt;) and args (&lt;b&gt;&lt;u&gt;name&lt;/u&gt;&lt;/b&gt;) . Both underline parameter name is same.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Class Main.java&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;codeview&quot;&gt;
package com.test.aop;&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;
import com.test.service.Shape;&lt;br /&gt;
&lt;br /&gt;
public class Main {&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public static void main(String[] args) {&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;ApplicationContext context=new ClassPathXmlApplicationContext(&quot;spring.xml&quot;);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Shape sh=context.getBean(&quot;shape&quot;, Shape.class);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.out.println(sh.getTriangle().getName());&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;sh.getCircle().setName(&quot;navin&#39;s&quot;);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.out.println(sh.getCircle().getName());&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;br /&gt;
}
&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;b&gt;Spring.xml-&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;&lt;br /&gt;
&amp;lt;beans xmlns=&quot;http://www.springframework.org/schema/beans&quot;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;xmlns:aop=&quot;http://www.springframework.org/schema/aop&quot;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;xsi:schemaLocation=&quot;http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd&quot;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;xmlns:context=&quot;http://www.springframework.org/schema/context&quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;lt;aop:aspectj-autoproxy/&amp;gt;&lt;br /&gt;
&amp;lt;bean id=&quot;triangle&quot; class=&quot;com.test.App.Triangle&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;lt;property name=&quot;name&quot; value=&quot;triangle drawn&quot;&amp;gt;&amp;lt;/property&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;lt;/bean&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;lt;bean id=&quot;circle&quot; class=&quot;com.test.App.Circle&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;property name=&quot;name&quot; value=&quot;circle drawn&quot;&amp;gt;&amp;lt;/property&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;lt;/bean&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;bean id=&quot;shape&quot; class=&quot;com.test.service.Shape&quot; autowire=&quot;byName&quot;&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;bean id=&quot;log&quot; class=&quot;com.test.aspect.LogAspect&quot;&amp;gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;/beans&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Output-&lt;/b&gt;
&lt;br /&gt;
&lt;div class=&quot;codeview&quot;&gt;
triangle drawn&lt;br /&gt;
string args is usednavin&#39;s&lt;br /&gt;
joinpoint calls&lt;br /&gt;
execution(String com.test.App.Circle.getName())&lt;br /&gt;
com.test.App.Circle@b1074a&lt;br /&gt;
navin&#39;s&lt;/div&gt;
Here define that how can use pointcuts ans joinpoint also,and how we can access the argument using annotations.
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://navin-bansal.blogspot.com/feeds/406212021357252740/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://navin-bansal.blogspot.com/2013/03/spring-framework-example-to-use-before.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7715544799292814842/posts/default/406212021357252740'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7715544799292814842/posts/default/406212021357252740'/><link rel='alternate' type='text/html' href='http://navin-bansal.blogspot.com/2013/03/spring-framework-example-to-use-before.html' title='Spring Framework - Example to use @Before annotation with args() in AOP'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06685256351965309878</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiS3ejqS-ajKVAfARvO4CoqI1r-WqgkFkEGtREuaK4CvU0e5RO1CYELcBtbBJ7wL_US-lNNgA6QqirWPEZVw1Wtxm8BGrTO_rOCCOKVIILZRqxdtd0qia-GD8Swxs-zfmYH1yn5_u5cUTD3/s72-c/image1.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7715544799292814842.post-7806886121108463701</id><published>2013-03-18T11:25:00.001-07:00</published><updated>2013-03-18T11:26:25.350-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="General"/><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><category scheme="http://www.blogger.com/atom/ns#" term="spring"/><title type='text'>Spring Framework-Example to use JoinPoint in AOP</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Hello Friends, After discussing the &lt;a href=&quot;http://www.technicaltoday.com/2013/03/spring-framework-example-to-use.html&quot;&gt;pointcuts in last post&lt;/a&gt;&amp;nbsp;Now discuss on Joinpoint&amp;nbsp;. A Joinpoint is a point in the execution of the application where an aspect can be plugged in. this point could be a method being called Here is a example to understands the use of pointcuts-&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgH5MnDt-KW9xbzyrBCdcJDmkgeymdoYA9EcSIz7kmrmtxJH-Y_h2CTmBmRFElEQHvrozHlmC56hZZFLVLI74l7b0TLGYOCapfZAopvs6e3aztaFCHZZoUpbgaJSFbrlV71VM_YsdKCt3xc/s1600/image1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgH5MnDt-KW9xbzyrBCdcJDmkgeymdoYA9EcSIz7kmrmtxJH-Y_h2CTmBmRFElEQHvrozHlmC56hZZFLVLI74l7b0TLGYOCapfZAopvs6e3aztaFCHZZoUpbgaJSFbrlV71VM_YsdKCt3xc/s320/image1.png&quot; width=&quot;201&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;/div&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;b&gt;Circle.java-&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;codeview&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&amp;nbsp;package com.test.App;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
public class Circle {&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;String name;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public String getName() {&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return name;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public void setName(String name) {&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;this.name = name;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
}&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Triangle.java&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;codeview&quot;&gt;
&lt;div&gt;
package com.test.App;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
public class Triangle {&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;String name;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public String getName() {&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return name;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public void setName(String name) {&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;this.name = name;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;LogAspect.java&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;codeview&quot;&gt;
&lt;div&gt;
package com.test.aspect;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
import org.aspectj.lang.JoinPoint;&lt;/div&gt;
&lt;div&gt;
//import org.aspectj.lang.annotation.After;&lt;/div&gt;
&lt;div&gt;
import org.aspectj.lang.annotation.Aspect;&lt;/div&gt;
&lt;div&gt;
import org.aspectj.lang.annotation.Before;&lt;/div&gt;
&lt;div&gt;
import org.aspectj.lang.annotation.Pointcut;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
@Aspect&lt;/div&gt;
&lt;div&gt;
public class LogAspect {&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; @Before(&quot;allGetters()&quot;)&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;public void loggingAd(JoinPoint jp)&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;System.out.println(jp.toString());&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;@Before(&quot;allcircle()&quot;)&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public void loggingAdvice(JoinPoint jp)&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.out.println(jp.toString());&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;@Pointcut(&quot;execution(* get*())&quot;)&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public void allGetters()&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.out.println(&quot;Wel Come With....allgetters&quot;);&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;@Pointcut(&quot;within(com.test.App.Circle)&quot;)&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;public void allcircle()&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;{&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.out.println(&quot;Wel Come With....circle&quot;);&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;}&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Shape.java&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;codeview&quot;&gt;
&lt;div&gt;
package com.test.service;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
import com.test.App.Circle;&lt;/div&gt;
&lt;div&gt;
import com.test.App.Triangle;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
public class Shape {&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Circle circle;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Triangle triangle;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public Circle getCircle() {&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return circle;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public void setCircle(Circle circle) {&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;this.circle = circle;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public Triangle getTriangle() {&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return triangle;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public void setTriangle(Triangle triangle) {&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;this.triangle = triangle;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div style=&quot;font-weight: bold;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;font-weight: bold;&quot;&gt;
Main.java-&lt;/div&gt;
&lt;div style=&quot;font-weight: bold;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;codeview&quot;&gt;
&lt;div&gt;
package com.test.aop;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
import org.springframework.context.ApplicationContext;&lt;/div&gt;
&lt;div&gt;
import org.springframework.context.support.ClassPathXmlApplicationContext;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
import com.test.service.Shape;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
public class Main {&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public static void main(String[] args) {&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;ApplicationContext context=new ClassPathXmlApplicationContext(&quot;spring.xml&quot;);&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Shape sh=context.getBean(&quot;shape&quot;, Shape.class);&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.out.println(sh.getTriangle().getName());&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.out.println(sh.getCircle().getName());&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div style=&quot;font-weight: bold;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;font-weight: bold;&quot;&gt;
Spring.xml&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;beans xmlns=&quot;http://www.springframework.org/schema/beans&quot;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;xmlns:aop=&quot;http://www.springframework.org/schema/aop&quot;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;xsi:schemaLocation=&quot;http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd&quot;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;xmlns:context=&quot;http://www.springframework.org/schema/context&quot;&amp;gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;lt;aop:aspectj-autoproxy/&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;bean id=&quot;triangle&quot; class=&quot;com.test.App.Triangle&quot;&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;property name=&quot;name&quot; value=&quot;triangle drawn&quot;&amp;gt;&amp;lt;/property&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;/bean&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;bean id=&quot;circle&quot; class=&quot;com.test.App.Circle&quot;&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;lt;property name=&quot;name&quot; value=&quot;circle drawn&quot;&amp;gt;&amp;lt;/property&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;/bean&amp;gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;bean id=&quot;shape&quot; class=&quot;com.test.service.Shape&quot; autowire=&quot;byName&quot;&amp;gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;/bean&amp;gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;bean id=&quot;log&quot; class=&quot;com.test.aspect.LogAspect&quot;&amp;gt;&amp;lt;/bean&amp;gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;/beans&amp;gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: bold;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;Output&lt;/b&gt;
&lt;br /&gt;
&lt;div class=&quot;codeview&quot;&gt;
execution(Triangle com.test.service.Shape.getTriangle())&lt;br /&gt;
execution(String com.test.App.Triangle.getName())&lt;br /&gt;
triangle drawn&lt;br /&gt;
execution(Circle com.test.service.Shape.getCircle())&lt;br /&gt;
execution(String com.test.App.Circle.getName())&lt;br /&gt;
execution(String com.test.App.Circle.getName())&lt;br /&gt;
circle drawn
&lt;/div&gt;
JoinPoint class contain the information related to the object which pass by pointcut.
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://navin-bansal.blogspot.com/feeds/7806886121108463701/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://navin-bansal.blogspot.com/2013/03/spring-framework-example-to-use_18.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7715544799292814842/posts/default/7806886121108463701'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7715544799292814842/posts/default/7806886121108463701'/><link rel='alternate' type='text/html' href='http://navin-bansal.blogspot.com/2013/03/spring-framework-example-to-use_18.html' title='Spring Framework-Example to use JoinPoint in AOP'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06685256351965309878</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgH5MnDt-KW9xbzyrBCdcJDmkgeymdoYA9EcSIz7kmrmtxJH-Y_h2CTmBmRFElEQHvrozHlmC56hZZFLVLI74l7b0TLGYOCapfZAopvs6e3aztaFCHZZoUpbgaJSFbrlV71VM_YsdKCt3xc/s72-c/image1.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7715544799292814842.post-7623141556332053098</id><published>2013-03-17T12:43:00.000-07:00</published><updated>2013-03-17T12:43:01.844-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="General"/><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><category scheme="http://www.blogger.com/atom/ns#" term="spring"/><title type='text'>Spring Framework- Example to Use Pointcuts in AOP</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
In Aspect Oriented Programming (AOP) Advice define the what and when we call . The Pointcuts define where.A pointcut definition matches one or more jointpoints .Here discuss a simple example to use pointcut -&lt;br /&gt;
&lt;br /&gt;
Directory Structure-&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_OcV3Uy58g0_L0zMOj7f0xQkJyDKfKqcklKoJSauwQsOZTJVGyaxg_2o7gCmz1XWpU7QYKwO7scFHDhTMFkWJ9NkpZRlFaHA6vmYltgybfJhtxhwzKBoDRo-d_ZzBYpsb_puur_nL0Cn3/s1600/image1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_OcV3Uy58g0_L0zMOj7f0xQkJyDKfKqcklKoJSauwQsOZTJVGyaxg_2o7gCmz1XWpU7QYKwO7scFHDhTMFkWJ9NkpZRlFaHA6vmYltgybfJhtxhwzKBoDRo-d_ZzBYpsb_puur_nL0Cn3/s320/image1.png&quot; width=&quot;201&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;&lt;/b&gt;&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;b&gt;Circle Class-&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;div class=&quot;codeview&quot;&gt;
package com.test.App;&lt;br /&gt;
&lt;br /&gt;
public class Circle {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;String name;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public String getName() {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return name;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public void setName(String name) {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;this.name = name;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;br /&gt;
}&lt;/div&gt;
&lt;b&gt;Triangle Class-&lt;/b&gt;

&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;codeview&quot;&gt;
package com.test.App;&lt;br /&gt;
&lt;br /&gt;
public class Triangle {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;String name;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public String getName() {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return name;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public void setName(String name) {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;this.name = name;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;br /&gt;
}&lt;/div&gt;
&lt;b&gt;Class shape-&lt;/b&gt;

&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;codeview&quot;&gt;
package com.test.service;&lt;br /&gt;
&lt;br /&gt;
import com.test.App.Circle;&lt;br /&gt;
import com.test.App.Triangle;&lt;br /&gt;
&lt;br /&gt;
public class Shape {&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Circle circle;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Triangle triangle;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public Circle getCircle() {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return circle;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public void setCircle(Circle circle) {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;this.circle = circle;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public Triangle getTriangle() {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return triangle;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public void setTriangle(Triangle triangle) {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;this.triangle = triangle;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;b&gt;Class LogAspect-&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;codeview&quot;&gt;
package com.test.aspect;&lt;br /&gt;
&lt;br /&gt;
//import org.aspectj.lang.annotation.After;&lt;br /&gt;
import org.aspectj.lang.annotation.Aspect;&lt;br /&gt;
import org.aspectj.lang.annotation.Before;&lt;br /&gt;
import org.aspectj.lang.annotation.Pointcut;&lt;br /&gt;
&lt;br /&gt;
@Aspect&lt;br /&gt;
public class LogAspect {&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;@Before(&quot;allGetters() &amp;amp;&amp;amp; allcircle()&quot;)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public void loggingAdvice()&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.out.println(&quot;Wel Come With....logging advice&quot;);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp;@Pointcut(&quot;execution(* get*())&quot;)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public void allGetters()&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.out.println(&quot;Wel Come With....allgetters&quot;);&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp;@Pointcut(&quot;within(com.test.App.Circle)&quot;)&lt;br /&gt;
&amp;nbsp; &amp;nbsp;public void allcircle()&lt;br /&gt;
&amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.out.println(&quot;Wel Come With....circle&quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
}&lt;/div&gt;
&lt;b&gt;Class Main-&lt;/b&gt;

&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;codeview&quot;&gt;
package com.test.aop;&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;
import com.test.service.Shape;&lt;br /&gt;
&lt;br /&gt;
public class Main {&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public static void main(String[] args) {&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;ApplicationContext context=new ClassPathXmlApplicationContext(&quot;spring.xml&quot;);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Shape sh=context.getBean(&quot;shape&quot;, Shape.class);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.out.println(sh.getTriangle().getName());&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;System.out.println(sh.getCircle().getName());&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;br /&gt;
}&lt;/div&gt;
&lt;b&gt;Spring.XML&lt;/b&gt;

&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;&lt;br /&gt;
&amp;lt;beans xmlns=&quot;http://www.springframework.org/schema/beans&quot;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;xmlns:aop=&quot;http://www.springframework.org/schema/aop&quot;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;xsi:schemaLocation=&quot;http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd&quot;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;xmlns:context=&quot;http://www.springframework.org/schema/context&quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;lt;aop:aspectj-autoproxy/&amp;gt;&lt;br /&gt;
&amp;lt;bean id=&quot;triangle&quot; class=&quot;com.test.App.Triangle&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;lt;property name=&quot;name&quot; value=&quot;triangle drawn&quot;&amp;gt;&amp;lt;/property&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;lt;/bean&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;lt;bean id=&quot;circle&quot; class=&quot;com.test.App.Circle&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;property name=&quot;name&quot; value=&quot;circle drawn&quot;&amp;gt;&amp;lt;/property&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;lt;/bean&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;bean id=&quot;shape&quot; class=&quot;com.test.service.Shape&quot; autowire=&quot;byName&quot;&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;bean id=&quot;log&quot; class=&quot;com.test.aspect.LogAspect&quot;&amp;gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;/beans&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Output&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;codeview&quot;&gt;
triangle drawn&lt;br /&gt;
Wel Come With....logging advice&lt;br /&gt;
circle drawn
&lt;/div&gt;
Here logginAdvice() combind all type of getter and setter method and call the function.Method allCircle() call when Circle class&#39;s methods calls.so all other methods indirectly pass to logginAdvice().
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://navin-bansal.blogspot.com/feeds/7623141556332053098/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://navin-bansal.blogspot.com/2013/03/spring-framework-example-to-use.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7715544799292814842/posts/default/7623141556332053098'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7715544799292814842/posts/default/7623141556332053098'/><link rel='alternate' type='text/html' href='http://navin-bansal.blogspot.com/2013/03/spring-framework-example-to-use.html' title='Spring Framework- Example to Use Pointcuts in AOP'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06685256351965309878</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_OcV3Uy58g0_L0zMOj7f0xQkJyDKfKqcklKoJSauwQsOZTJVGyaxg_2o7gCmz1XWpU7QYKwO7scFHDhTMFkWJ9NkpZRlFaHA6vmYltgybfJhtxhwzKBoDRo-d_ZzBYpsb_puur_nL0Cn3/s72-c/image1.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7715544799292814842.post-1027354946589543268</id><published>2013-03-16T13:17:00.002-07:00</published><updated>2013-03-16T13:20:54.766-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="General"/><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><category scheme="http://www.blogger.com/atom/ns#" term="spring"/><title type='text'>Spring Framework- Simple Aspect Oriented Programming Example</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Aspect Oriented Programming basically provide alternative way to achive the inheritance and the delegation.In AOP define the comman fuctionality in one place,but you can define where and how this functionlity is applied. &amp;nbsp;The basic example of the aspect oriented programming is describe here-&lt;br /&gt;
&lt;br /&gt;
Directory Structure-&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirpkIvtZfoEiTmsDY8L4EvX1MS0w8pJlOX-QpD0ARXzAJ7XhG6P3YxIqkBmDWmhHC7HadKfgyiKVK3tjeu1qg-ZdvWU2su3yb5yPTma9jZDFydwxckIH5MFEP0OOEw623fsN6wR99RL-_L/s1600/image1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirpkIvtZfoEiTmsDY8L4EvX1MS0w8pJlOX-QpD0ARXzAJ7XhG6P3YxIqkBmDWmhHC7HadKfgyiKVK3tjeu1qg-ZdvWU2su3yb5yPTma9jZDFydwxckIH5MFEP0OOEw623fsN6wR99RL-_L/s320/image1.png&quot; width=&quot;201&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;b&gt;Circle.java-&lt;/b&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;codeview&quot;&gt;
package com.test.App;&lt;br /&gt;
&amp;nbsp;public class Circle&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;String name;&lt;br /&gt;
&amp;nbsp;public String getName()&lt;br /&gt;
{
  return name;
 }&lt;br /&gt;
&amp;nbsp;public void setName(String name)&lt;br /&gt;
&amp;nbsp;{
  this.name = name;
 }&lt;br /&gt;
&amp;nbsp;}&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt; Triangle.java-&lt;/b&gt;
&lt;br /&gt;
&lt;div class=&quot;codeview&quot;&gt;
package com.test.App;&lt;br /&gt;
&amp;nbsp;public class Triangle&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;String name;&lt;br /&gt;
&amp;nbsp;public String getName()&lt;br /&gt;
&amp;nbsp;{
  return name;
 }&lt;br /&gt;
&amp;nbsp;public void setName(String name)&lt;br /&gt;
&amp;nbsp;{
  this.name = name;
 }&lt;br /&gt;
&amp;nbsp;}&lt;/div&gt;
&lt;b&gt; LogAspect.java &lt;/b&gt;
&lt;br /&gt;
&lt;div class=&quot;codeview&quot;&gt;
package com.test.aspect;&lt;br /&gt;
&amp;nbsp;import org.aspectj.lang.annotation.Before;&lt;br /&gt;
&amp;nbsp;import org.aspectj.lang.annotation.Aspect;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;@Aspect&lt;br /&gt;
&amp;nbsp;public class LogAspect {&lt;br /&gt;
&amp;nbsp;@Before(&quot;execution(public String getName())&quot;)&lt;br /&gt;
&amp;nbsp;public void loggingAdvice()&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp;System.out.println(&quot;Wel Come With....&quot;);&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;}&lt;/div&gt;
&lt;b&gt;Shape.java&lt;/b&gt;
&lt;br /&gt;
&lt;div class=&quot;codeview&quot;&gt;
package com.test.service;&lt;br /&gt;
&amp;nbsp;import com.test.App.Circle;&lt;br /&gt;
&amp;nbsp;import com.test.App.Triangle;&lt;br /&gt;
&amp;nbsp;public class Shape&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp;Circle circle;&lt;br /&gt;
&amp;nbsp;Triangle triangle;&lt;br /&gt;
&amp;nbsp;public Circle getCircle()&lt;br /&gt;
&amp;nbsp;{
  return circle;
 }&lt;br /&gt;
&amp;nbsp;public void setCircle(Circle circle)&lt;br /&gt;
{
  this.circle = circle;
 }&lt;br /&gt;
&amp;nbsp;public Triangle getTriangle()&lt;br /&gt;
&amp;nbsp;{
  return triangle;
 }&lt;br /&gt;
&amp;nbsp;public void setTriangle(Triangle triangle)&lt;br /&gt;
&amp;nbsp;{
  this.triangle = triangle;
 }&lt;br /&gt;
&amp;nbsp;}&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;Main.java&lt;/b&gt;
&lt;br /&gt;
&lt;div class=&quot;codeview&quot;&gt;
package com.test.aop;&lt;br /&gt;
&amp;nbsp;import org.springframework.context.ApplicationContext;&lt;br /&gt;
&amp;nbsp;import org.springframework.context.support.ClassPathXmlApplicationContext;&lt;br /&gt;
&amp;nbsp;import com.test.service.Shape;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;public class Main&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;public static void main(String[] args)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;ApplicationContext context=new ClassPathXmlApplicationContext(&quot;spring.xml&quot;);&lt;br /&gt;
&amp;nbsp;Shape sh=context.getBean(&quot;shape&quot;, Shape.class);&lt;br /&gt;
&amp;nbsp;System.out.println(sh.getTriangle().getName());&lt;br /&gt;
&amp;nbsp;System.out.println(sh.getCircle().getName());&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;}&lt;/div&gt;
&lt;b&gt; spring.xml&lt;/b&gt;
&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;br /&gt;
&amp;lt;beans xmlns:aop=&quot;http://www.springframework.org/schema/aop&quot; xmlns:context=&quot;http://www.springframework.org/schema/context&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns=&quot;http://www.springframework.org/schema/beans&quot; xsi:schemalocation=&quot;http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd&quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;lt;aop:aspectj-autoproxy&amp;gt;&lt;br /&gt;
&amp;lt;bean class=&quot;com.test.App.Triangle&quot; id=&quot;triangle&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;lt;property name=&quot;name&quot; value=&quot;triangle drawn&quot;&amp;gt;&amp;lt;/property&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;lt;/bean&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;lt;bean class=&quot;com.test.App.Circle&quot; id=&quot;circle&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;property name=&quot;name&quot; value=&quot;circle drawn&quot;&amp;gt;&amp;lt;/property&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;lt;/bean&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;bean autowire=&quot;byName&quot; class=&quot;com.test.service.Shape&quot; id=&quot;shape&quot;&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;bean class=&quot;com.test.aspect.LogAspect&quot; id=&quot;log&quot;&amp;gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;/aop:aspectj-autoproxy&amp;gt;&amp;lt;/beans&amp;gt;&lt;br /&gt;
&lt;div&gt;
&lt;div style=&quot;font-weight: bold;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
In this example LogAspect is advice class which contain the&lt;b&gt;&lt;i&gt; jointpoint&lt;/i&gt;&lt;/b&gt; method-loggingAdvice().This method execute Before all method which contain the prototype -public String getName().the code&amp;nbsp;&amp;lt;aop:aspectj-autoproxy/&amp;gt; which written in xml create proxy(or aop objects).&lt;br /&gt;
The process of AOP is also called &lt;b&gt;&lt;i&gt;Weaving&lt;/i&gt;&lt;/b&gt;.The LogAspect class is also called &lt;b&gt;&lt;i&gt;Advice Class&lt;/i&gt;&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;b&gt;Output&lt;/b&gt;
&lt;br /&gt;
&lt;div class=&quot;codeview&quot;&gt;
Wel Come With....&lt;br /&gt;
&amp;nbsp;triangle drawn&lt;br /&gt;
Wel Come With....&lt;br /&gt;
&amp;nbsp;circle drawn
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://navin-bansal.blogspot.com/feeds/1027354946589543268/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://navin-bansal.blogspot.com/2013/03/spring-framework-simple-aspect-oriented.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7715544799292814842/posts/default/1027354946589543268'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7715544799292814842/posts/default/1027354946589543268'/><link rel='alternate' type='text/html' href='http://navin-bansal.blogspot.com/2013/03/spring-framework-simple-aspect-oriented.html' title='Spring Framework- Simple Aspect Oriented Programming Example'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06685256351965309878</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirpkIvtZfoEiTmsDY8L4EvX1MS0w8pJlOX-QpD0ARXzAJ7XhG6P3YxIqkBmDWmhHC7HadKfgyiKVK3tjeu1qg-ZdvWU2su3yb5yPTma9jZDFydwxckIH5MFEP0OOEw623fsN6wR99RL-_L/s72-c/image1.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7715544799292814842.post-2592967823777629950</id><published>2012-11-06T04:32:00.001-08:00</published><updated>2012-11-06T04:35:50.428-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="General"/><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><category scheme="http://www.blogger.com/atom/ns#" term="jsp"/><title type='text'>JSP Tutorials</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Lets learn JSP step by step with easy tutorials and examples. To get all tutorials click on below link-&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.technicaltoday.com/p/jsp.html&quot;&gt;Click to get JSP tutorials.&lt;/a&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://navin-bansal.blogspot.com/feeds/2592967823777629950/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://navin-bansal.blogspot.com/2012/11/lets-learn-jsp-step-by-step-with-easy.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7715544799292814842/posts/default/2592967823777629950'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7715544799292814842/posts/default/2592967823777629950'/><link rel='alternate' type='text/html' href='http://navin-bansal.blogspot.com/2012/11/lets-learn-jsp-step-by-step-with-easy.html' title='JSP Tutorials'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06685256351965309878</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7715544799292814842.post-5763307064717015544</id><published>2012-11-06T03:03:00.004-08:00</published><updated>2012-11-06T03:35:56.714-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="General"/><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><category scheme="http://www.blogger.com/atom/ns#" term="jsp"/><title type='text'>How to jsp is process in web application ?</title><content type='html'>&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcsUGdisJ785WwkvX3v_Oa4q5OvbfV2hUES3Xpsc3Fa4BcSlovoeZ2HXNayO45YBxH93dgLIx_klgjubDyOaGEKlVs_zk3fOlGDitTBuxRX3dUek2HXukqxGnD_Jj5VKgCZMMoM8QwvoZ6/s1600/Untitledn.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;/a&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcsUGdisJ785WwkvX3v_Oa4q5OvbfV2hUES3Xpsc3Fa4BcSlovoeZ2HXNayO45YBxH93dgLIx_klgjubDyOaGEKlVs_zk3fOlGDitTBuxRX3dUek2HXukqxGnD_Jj5VKgCZMMoM8QwvoZ6/s1600/Untitledn.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;/a&gt;Here we discuss how a jsp page is processed in web application when it is requested by the users-&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZuF_YRkKFFI0HvAzx-boP397Vst2-M9EoRCW744PYbmP8xyLIGWRnL25_OP5m-zbyqASE-SHakGI-Cdh1tXe2-SuYKPreNW0s26-ByBsMfrNeVIJ8x1-tnYWEQ1Vayv105ODMFLjYdc7R/s1600/jsplifecycle.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;217&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZuF_YRkKFFI0HvAzx-boP397Vst2-M9EoRCW744PYbmP8xyLIGWRnL25_OP5m-zbyqASE-SHakGI-Cdh1tXe2-SuYKPreNW0s26-ByBsMfrNeVIJ8x1-tnYWEQ1Vayv105ODMFLjYdc7R/s1600/jsplifecycle.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
1. First time JSP page is loaded by the JSP container which is also called jsp engine(Where the JSPs complied) .Here the Jsp generated and complied java code which is called&amp;nbsp; servlet code . This code is loaded in servlet engine. &lt;i&gt;This process is occurs on translation time&lt;/i&gt; . It is important to note that this occurs only the first time when jsp is requested.&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; By this process there will be slow response time for first page.&lt;br /&gt;
2. When the page is modified, is automatically reloaded and recompiled&amp;nbsp; by the container when the page request is occurs.&amp;nbsp; &lt;i&gt;This process is occurs on run time&lt;/i&gt;.&lt;br /&gt;
&lt;br /&gt;
There are three major life event methods -&lt;br /&gt;
&amp;nbsp;jspInit().&lt;br /&gt;
&amp;nbsp;jspService(request,response).&lt;br /&gt;
jspDestroy().&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcsUGdisJ785WwkvX3v_Oa4q5OvbfV2hUES3Xpsc3Fa4BcSlovoeZ2HXNayO45YBxH93dgLIx_klgjubDyOaGEKlVs_zk3fOlGDitTBuxRX3dUek2HXukqxGnD_Jj5VKgCZMMoM8QwvoZ6/s1600/Untitledn.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;61&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcsUGdisJ785WwkvX3v_Oa4q5OvbfV2hUES3Xpsc3Fa4BcSlovoeZ2HXNayO45YBxH93dgLIx_klgjubDyOaGEKlVs_zk3fOlGDitTBuxRX3dUek2HXukqxGnD_Jj5VKgCZMMoM8QwvoZ6/s1600/Untitledn.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
In most cases the jspInit() and jspDestroy() methods don&#39;t need to be provide developer. </content><link rel='replies' type='application/atom+xml' href='http://navin-bansal.blogspot.com/feeds/5763307064717015544/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://navin-bansal.blogspot.com/2012/11/how-to-jsp-is-process-in-web-application.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7715544799292814842/posts/default/5763307064717015544'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7715544799292814842/posts/default/5763307064717015544'/><link rel='alternate' type='text/html' href='http://navin-bansal.blogspot.com/2012/11/how-to-jsp-is-process-in-web-application.html' title='How to jsp is process in web application ?'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06685256351965309878</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZuF_YRkKFFI0HvAzx-boP397Vst2-M9EoRCW744PYbmP8xyLIGWRnL25_OP5m-zbyqASE-SHakGI-Cdh1tXe2-SuYKPreNW0s26-ByBsMfrNeVIJ8x1-tnYWEQ1Vayv105ODMFLjYdc7R/s72-c/jsplifecycle.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7715544799292814842.post-3787149011858067519</id><published>2012-11-06T02:39:00.000-08:00</published><updated>2012-11-06T03:36:20.534-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="General"/><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><category scheme="http://www.blogger.com/atom/ns#" term="jsp"/><title type='text'>What are the differences between jsp and servlet ?</title><content type='html'>&amp;nbsp;Both techniques are used to handle the web request in java or creating dynamic content with web pages-&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;&lt;b&gt;Servlets-&lt;/b&gt;&lt;/u&gt; servlets executed on server and acting as a middle layer between clients and lower level applications.servlets contain the html code in java program. servlets are well suited to deciding how to handle client requests and invoke them but are not well suited for generating contents.Here markup code is harder to implement or maintain in web application. Developers need more experience of java to written servlets.&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;&lt;b&gt;JSP-&lt;/b&gt;&lt;/u&gt; Jsp designed and developed less like programs and more like web pages.Generating html is much easier than servlets. Java code is written in html program or in html code.Jsp can use java bean with specified scope(Session,Request).</content><link rel='replies' type='application/atom+xml' href='http://navin-bansal.blogspot.com/feeds/3787149011858067519/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://navin-bansal.blogspot.com/2012/11/what-are-diffrences-between-jsp-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7715544799292814842/posts/default/3787149011858067519'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7715544799292814842/posts/default/3787149011858067519'/><link rel='alternate' type='text/html' href='http://navin-bansal.blogspot.com/2012/11/what-are-diffrences-between-jsp-and.html' title='What are the differences between jsp and servlet ?'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06685256351965309878</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7715544799292814842.post-2032749488508842680</id><published>2012-11-06T02:25:00.001-08:00</published><updated>2012-11-06T02:25:32.301-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="General"/><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><category scheme="http://www.blogger.com/atom/ns#" term="jsp"/><title type='text'>What is JSP ?</title><content type='html'>JSP stands for java server pages. JSP is server sided language which execute only server .The goal of the JSP specification is , creation and management of dynamic web pages. it provide more convenient way than servlets.JSP pages combine static markup like HTML,XML with scripting tags. &lt;b&gt;&lt;i&gt;The main thing is that each server page is translated into servlet the first time invoked&lt;/i&gt;.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Version of JSP 1.0&amp;nbsp; released in September 1999 and JSP 1.2 released in December 1999.</content><link rel='replies' type='application/atom+xml' href='http://navin-bansal.blogspot.com/feeds/2032749488508842680/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://navin-bansal.blogspot.com/2012/11/what-is-jsp.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7715544799292814842/posts/default/2032749488508842680'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7715544799292814842/posts/default/2032749488508842680'/><link rel='alternate' type='text/html' href='http://navin-bansal.blogspot.com/2012/11/what-is-jsp.html' title='What is JSP ?'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06685256351965309878</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7715544799292814842.post-5160179813590472496</id><published>2012-11-05T03:23:00.002-08:00</published><updated>2012-11-05T03:23:23.992-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="General"/><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><category scheme="http://www.blogger.com/atom/ns#" term="xml"/><title type='text'>XML parsing in java </title><content type='html'>XML is a good thing to cntaint database and other information. Java use parsers to read and write the xml data so here we learn how we can use xml in our java application.Here provided step by step tutorials with example to understand the functionality of XML with java.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.technicaltoday.com/p/xml.html&quot;&gt;Lets click here to learn XML and XML parsing in java.&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://navin-bansal.blogspot.com/feeds/5160179813590472496/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://navin-bansal.blogspot.com/2012/11/xml-parsing-in-java.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7715544799292814842/posts/default/5160179813590472496'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7715544799292814842/posts/default/5160179813590472496'/><link rel='alternate' type='text/html' href='http://navin-bansal.blogspot.com/2012/11/xml-parsing-in-java.html' title='XML parsing in java '/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06685256351965309878</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7715544799292814842.post-9201689181645695682</id><published>2012-11-04T22:12:00.001-08:00</published><updated>2012-11-04T22:16:51.001-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="General"/><category scheme="http://www.blogger.com/atom/ns#" term="How To"/><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><category scheme="http://www.blogger.com/atom/ns#" term="xml"/><title type='text'>What is XML ?</title><content type='html'>Markup language that define a set of rules for encoding documents in a form that is both human-readable and machine-readable.&lt;br /&gt;
• It is defined in the XML 1.0 Specification produced by the W3C, and several other related specifications.&lt;br /&gt;
&amp;nbsp;• Can be embedded with all types of oop language with parsing.&lt;br /&gt;
&amp;nbsp;Benefits-&lt;br /&gt;
&amp;nbsp;1. Simple&lt;br /&gt;
&amp;nbsp;2. Self description&lt;br /&gt;
3. Contains machine readable context information&lt;br /&gt;
&amp;nbsp;4. Facilitates the aggregation of data&lt;br /&gt;
5. Can embed multiple datatypes and existing data. 
</content><link rel='replies' type='application/atom+xml' href='http://navin-bansal.blogspot.com/feeds/9201689181645695682/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://navin-bansal.blogspot.com/2012/11/markup-language-that-define-set-of_4.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7715544799292814842/posts/default/9201689181645695682'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7715544799292814842/posts/default/9201689181645695682'/><link rel='alternate' type='text/html' href='http://navin-bansal.blogspot.com/2012/11/markup-language-that-define-set-of_4.html' title='What is XML ?'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06685256351965309878</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7715544799292814842.post-4840152275475997470</id><published>2012-11-04T21:22:00.001-08:00</published><updated>2012-11-04T21:22:13.838-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="General"/><category scheme="http://www.blogger.com/atom/ns#" term="Hibernate"/><category scheme="http://www.blogger.com/atom/ns#" term="How To"/><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><title type='text'>How to insert a record in table using hibernate.</title><content type='html'>Hibernate is a ORM.To insert the record in table basically a object is inserted which contain the all attribute of that record field. for insertion create a bean class of that types variable and apply getter and setter property.now initialize a object of that class inject the values and save the object after it the table is updated and record is inserted.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.technicaltoday.com/2012/11/how-to-write-hibernate.html&quot;&gt;To see the code click here.&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://navin-bansal.blogspot.com/feeds/4840152275475997470/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://navin-bansal.blogspot.com/2012/11/how-to-insert-record-in-table-using.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7715544799292814842/posts/default/4840152275475997470'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7715544799292814842/posts/default/4840152275475997470'/><link rel='alternate' type='text/html' href='http://navin-bansal.blogspot.com/2012/11/how-to-insert-record-in-table-using.html' title='How to insert a record in table using hibernate.'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06685256351965309878</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7715544799292814842.post-1506380235542459354</id><published>2012-11-03T23:07:00.000-07:00</published><updated>2012-11-03T23:12:46.583-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="General"/><category scheme="http://www.blogger.com/atom/ns#" term="Hibernate"/><category scheme="http://www.blogger.com/atom/ns#" term="How To"/><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><title type='text'> How to write hibernate code in java application</title><content type='html'>To use hibernate first &lt;a href=&quot;http://www.technicaltoday.com/2012/11/how-to-set-hibernate-environment-in.html&quot;&gt;setup the environment of hibernate&lt;/a&gt;&amp;nbsp;.After that need to create some files in application as-&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;1. Hibernate.cfg.xml &lt;/b&gt;file contain database configuration,connection pool,user,username,password and other sql information. the main thing is that we can not change file name the name always as it is.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hibernate-configuration&amp;gt;&lt;br /&gt;
&amp;lt;session-factory&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;property name=&quot;hibernate.connection.driver_class&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;com.mysql.jdbc.Driver&amp;lt;/property&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;property name=&quot;hibernate.connection.url&quot;&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;jdbc:mysql://localhost:3306/hibern&amp;lt;/property&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;property name=&quot;hibernate.connection.username&quot;&amp;gt;root&amp;lt;/property&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;property name=&quot;hibernate.connection.password&quot;&amp;gt;root&amp;lt;/property&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;property name=&quot;hibernate.connection.pool_size&quot;&amp;gt;10&amp;lt;/property&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;property name=&quot;show_sql&quot;&amp;gt;true&amp;lt;/property&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;property name=&quot;dialect&quot;&amp;gt;org.hibernate.dialect.MySQLDialect&amp;lt;/property&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;property name=&quot;hibernate.hbm2ddl.auto&quot;&amp;gt;update&amp;lt;/property&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;!-- Mapping files --&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;mapping resource=&quot;createtable.hbm.xml&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;lt;/mapping&amp;gt;&amp;lt;/session-factory&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/hibernate-configuration&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
Here property &amp;nbsp;&amp;nbsp;&amp;lt;property name=&quot;hibernate.connection.driver_class&quot;&amp;gt; &amp;nbsp; is use to load the driver of&amp;nbsp;particular &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; database and &amp;nbsp; &amp;nbsp;&amp;lt;mapping resource=&quot;createtable.hbm.xml&quot;/&amp;gt; &amp;nbsp; &amp;nbsp;property define the mapping file which contain the mapping with database table.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;2.Mapping file (Create.hbm.xml) &lt;/b&gt;file contain the mapping of the table as-&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;hibernate-mapping&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;class name=&quot;com.test.CreateTable&quot; table=&quot;CONTACT&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;id column=&quot;ID&quot; name=&quot;id&quot; type=&quot;long&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;generator class=&quot;increment&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/generator&amp;gt;&amp;lt;/id&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;property name=&quot;firstName&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;column name=&quot;FIRSTNAME&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/column&amp;gt;&amp;lt;/property&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;property name=&quot;lastName&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;column name=&quot;LASTNAME&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/column&amp;gt;&amp;lt;/property&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;property name=&quot;email&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;column name=&quot;EMAIL&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/column&amp;gt;&amp;lt;/property&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/class&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/hibernate-mapping&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here class name define the java file which contain the bean file who have id,firstname,lastname,email variables with getter and setter properties and these&amp;nbsp;properties&amp;nbsp;is mapped with database table here no need to create database table when code is execute automatically create a table with that&amp;nbsp;fields.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;3. bean file is use to inject the object values-&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;codeview&quot;&gt;
&lt;br /&gt;
package com.test;&lt;br /&gt;
&lt;br /&gt;
import java.io.Serializable;&lt;br /&gt;
&lt;br /&gt;
public class CreateTable &amp;nbsp;implements Serializable{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; private String firstName;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp;private String lastName;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp;private String email;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp;private long id;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp;public String getFirstName() {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return firstName;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public void setFirstName(String firstName) {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;this.firstName = firstName;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public String getLastName() {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return lastName;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public void setLastName(String lastName) {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;this.lastName = lastName;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public String getEmail() {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return email;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public void setEmail(String email) {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;this.email = email;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public long getId() {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return id;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public void setId(long id) {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;this.id = id;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;4. Main Class to do the transaction with the database -&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
package com.test;&lt;br /&gt;
&lt;div class=&quot;codeview&quot;&gt;
&lt;br /&gt;
import org.hibernate.Session;&lt;br /&gt;
import org.hibernate.SessionFactory;&lt;br /&gt;
import org.hibernate.cfg.Configuration;&lt;br /&gt;
public class Main {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public static void main(String[] args) throws Exception{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp;Session session = null;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;SessionFactory &amp;nbsp;sessionfactory;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;sessionfactory = new Configuration().configure(&quot;hibernate.cfg.xml&quot;).buildSessionFactory();&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; session =sessionfactory.openSession();&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp;//Create new instance of CreateTable and set&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;session.beginTransaction();&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; System.out.println(&quot;Inserting Record&quot;);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp;CreateTable createTable = new CreateTable();&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&amp;nbsp;createTable.setFirstName(&quot;navin&quot;);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp;createTable.setLastName(&quot;bansal&quot;);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp;createTable.setEmail(&quot;nav@gmail.com&quot;);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp;session.save(createTable);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;session.getTransaction().commit();&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp;System.out.println(&quot;Done&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; session.flush();&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp;session.close();&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;}&lt;br /&gt;
}&lt;/div&gt;
&lt;br /&gt;
now execute this file and a record is automatically inserted is your database table.
&lt;br /&gt;
Output-
&lt;br /&gt;
&lt;div class=&quot;codeview&quot;&gt;
Inserting Record&lt;br /&gt;
Hibernate: select max(ID) from CONTACT&lt;br /&gt;
Hibernate: insert into CONTACT (FIRSTNAME, LASTNAME, EMAIL, ID) values (?, ?, ?, ?)&lt;br /&gt;
Done&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
yupee!!!!!!!!! &amp;nbsp;the code is executed.now see the table-&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimxozNpCW3Kh-ux_7NnGmmGSZPvIprO0bEf9p-2fMF5RR9mic_zYmetAJrtybSh7ptpcDw49p5te-SFD_7j3c6LU-VnlAofums2M8Puy4jfNsgUA4pj8pUD-xc9mxr8bQCvpsnlbf_6Rbf/s1600/Untitled.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;74&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimxozNpCW3Kh-ux_7NnGmmGSZPvIprO0bEf9p-2fMF5RR9mic_zYmetAJrtybSh7ptpcDw49p5te-SFD_7j3c6LU-VnlAofums2M8Puy4jfNsgUA4pj8pUD-xc9mxr8bQCvpsnlbf_6Rbf/s1600/Untitled.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://navin-bansal.blogspot.com/feeds/1506380235542459354/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://navin-bansal.blogspot.com/2012/11/how-to-write-hibernate.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7715544799292814842/posts/default/1506380235542459354'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7715544799292814842/posts/default/1506380235542459354'/><link rel='alternate' type='text/html' href='http://navin-bansal.blogspot.com/2012/11/how-to-write-hibernate.html' title=' How to write hibernate code in java application'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06685256351965309878</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimxozNpCW3Kh-ux_7NnGmmGSZPvIprO0bEf9p-2fMF5RR9mic_zYmetAJrtybSh7ptpcDw49p5te-SFD_7j3c6LU-VnlAofums2M8Puy4jfNsgUA4pj8pUD-xc9mxr8bQCvpsnlbf_6Rbf/s72-c/Untitled.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7715544799292814842.post-3564727443260470426</id><published>2012-11-03T22:09:00.000-07:00</published><updated>2012-11-03T22:09:14.198-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="General"/><category scheme="http://www.blogger.com/atom/ns#" term="Hibernate"/><category scheme="http://www.blogger.com/atom/ns#" term="How To"/><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><title type='text'>How to set Hibernate environment in java application</title><content type='html'>To provide the ORM in java application need to implement the hibernate. To implement the hibernate need the jars or&amp;nbsp;libraries&amp;nbsp;which is provided by hibernate download these jar and add these jar in application and use the&amp;nbsp;benefits&amp;nbsp;of&amp;nbsp;hibernate.&lt;br /&gt;
&lt;br /&gt;
To download the Hibernate jars click on below link-&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://sourceforge.net/projects/hibernate/files/hibernate3/3.6.10.Final/hibernate-distribution-3.6.10.Final-dist.tar.gz/download&quot;&gt;http://sourceforge.net/projects/hibernate/files/hibernate3/3.6.10.Final/hibernate-distribution-3.6.10.Final-dist.tar.gz/download&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
After download that&amp;nbsp;library. add these jars in project. now application is ready to use hibernate.</content><link rel='replies' type='application/atom+xml' href='http://navin-bansal.blogspot.com/feeds/3564727443260470426/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://navin-bansal.blogspot.com/2012/11/how-to-set-hibernate-environment-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7715544799292814842/posts/default/3564727443260470426'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7715544799292814842/posts/default/3564727443260470426'/><link rel='alternate' type='text/html' href='http://navin-bansal.blogspot.com/2012/11/how-to-set-hibernate-environment-in.html' title='How to set Hibernate environment in java application'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06685256351965309878</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7715544799292814842.post-5479591690596658166</id><published>2012-11-02T09:14:00.002-07:00</published><updated>2012-11-02T09:19:06.906-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="General"/><category scheme="http://www.blogger.com/atom/ns#" term="Hibernate"/><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><title type='text'>What is Hibernate ?</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;font-family: &#39;Times New Roman&#39;, serif; font-size: 12pt; line-height: 115%;&quot;&gt;Hibernate is an object-relational mapping (ORM)
library for the Java language, providing a framework for mapping an
object-oriented domain model to a traditional relational database. Hibernate
solves object-relational impedance mismatch problems by replacing direct
persistence-related database accesses with high-level object handling
functions.&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12.0pt; line-height: 115%;&quot;&gt;Hibernate is free software that is distributed under
the GNU Lesser General Public License. Hibernate&#39;s primary feature is mapping
from Java classes to database tables (and from Java data types to SQL data
types). Hibernate also provides data query and retrieval facilities. It also
generates the SQL calls and attempts to relieve the developer from manual
result set handling and object conversion and keep the application portable to
all supported SQL databases with little performance overhead&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12.0pt; line-height: 115%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZQcCb6vfH4tfDFM_T2FluubDecyOaztVMmjutk-kdnHRRZr4CTOApUO-MLAHvrSgBsbk_Lr4psgPF18-stVfMvSEAz5ZxKB0kC8TaNVowF_gQPWuQT7tzP8NpRhlHbZ3CsO8W5eofyGVd/s1600/Untitled.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;75&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZQcCb6vfH4tfDFM_T2FluubDecyOaztVMmjutk-kdnHRRZr4CTOApUO-MLAHvrSgBsbk_Lr4psgPF18-stVfMvSEAz5ZxKB0kC8TaNVowF_gQPWuQT7tzP8NpRhlHbZ3CsO8W5eofyGVd/s320/Untitled.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12.0pt; line-height: 115%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12.0pt; line-height: 115%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
Mapping Java classes to database tables is accomplished through the
configuration of an XML file or by using Java Annotations. When using an XML
file, Hibernate can generate skeletal source code for the persistence classes.
This is unnecessary when annotations are used. Hibernate can use the XML file
or the annotations to maintain the database schema. Facilities to arrange
one-to-many and many-to-many relationships between classes are provided. In
addition to managing associations between objects, Hibernate can also manage
reflexive associations where an object has a one-to-many relationship with
other instances of its own type.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12.0pt; line-height: 115%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Hibernate supports the
mapping of custom value types. This makes the following scenarios possible:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpFirst&quot; style=&quot;mso-list: l0 level1 lfo1; text-indent: -.25in;&quot;&gt;
&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12.0pt; line-height: 115%; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;1.&lt;span style=&quot;font-family: &#39;Times New Roman&#39;; font-size: 7pt; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12.0pt; line-height: 115%;&quot;&gt;Overriding
the default SQL type that Hibernate chooses when mapping a column to a&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; property.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;mso-list: l0 level1 lfo1; text-indent: -.25in;&quot;&gt;
&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12.0pt; line-height: 115%; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;2.&lt;span style=&quot;font-family: &#39;Times New Roman&#39;; font-size: 7pt; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12.0pt; line-height: 115%;&quot;&gt;Mapping
Java bean to columns as if they were regular properties.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;mso-list: l0 level1 lfo1; text-indent: -.25in;&quot;&gt;
&lt;!--[if !supportLists]--&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12.0pt; line-height: 115%; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;3.&lt;span style=&quot;font-family: &#39;Times New Roman&#39;; font-size: 7pt; line-height: normal;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12.0pt; line-height: 115%;&quot;&gt;Mapping
a single property to multiple columns.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;mso-list: l0 level1 lfo1; text-indent: -.25in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12.0pt; line-height: 115%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgn5i5jSihny1TW-tTic5440WrjNIq4BaRKLCXr-2T-X4bieLA4gsWNDGAEphxIAcguN0Dgd8lexhp61oTIJlsgWUKjBfUrjkDh7q_ANJEZqYMFGaPaE30nXBBo2gulGnJCyW6LS7QX9eW0/s1600/Untitled.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgn5i5jSihny1TW-tTic5440WrjNIq4BaRKLCXr-2T-X4bieLA4gsWNDGAEphxIAcguN0Dgd8lexhp61oTIJlsgWUKjBfUrjkDh7q_ANJEZqYMFGaPaE30nXBBo2gulGnJCyW6LS7QX9eW0/s320/Untitled.png&quot; width=&quot;277&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;mso-list: l0 level1 lfo1; text-indent: -.25in;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12.0pt; line-height: 115%;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Times New Roman&#39;, serif; font-size: 12pt; line-height: 115%;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Times New Roman&#39;, serif; font-size: 12pt; line-height: 115%;&quot;&gt;Hibernate
provides an SQL inspired language called Hibernate Query Language (HQL) which
allows SQL-like queries to be written against Hibernate&#39;s data objects.
Criteria Queries are provided as an object-oriented alternative to HQL .Hibernate
can be used both in standalone Java applications and in Java EE applications
using servlets, EJB session beans, and JBI service components. It can also be
included as a feature in other programming languages.&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Times New Roman&#39;, serif; font-size: 12pt; line-height: 115%;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12.0pt; line-height: 115%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
Hibernate was started in 2001 by Gavin King as an alternative to using
EJB2-style entity beans. Its mission back then was to simply offer better
persistence capabilities than offered by EJB2 by simplifying the complexities
and allowing for missing features.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12.0pt; line-height: 115%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Early in 2003, the Hibernate
development team began Hibernate2 releases which offered many significant
improvements over the first release. JBoss, Inc. (now part of Red Hat) later
hired the lead Hibernate developers and worked with them in supporting
Hibernate.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12.0pt; line-height: 115%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
In 2010, Hibernate version 3.x was released with the features like: a
new Interceptor/Callback architecture, user defined filters, and JDK 5.0
Annotations (Java&#39;s metadata feature). As of 2010 Hibernate 3 (version 3.5.0
and up) was a certified implementation of the Java Persistence API 2.0
specification via a wrapper for the Core module which provides conformity with
the JSR 317 standard.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12.0pt; line-height: 115%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
In Dec 2011, Hibernate Core 4.0.0 Final was released. This includes new
features like: Initial multi-tenancy support, Introduction of ServiceRegistry
(which is a major change in how Hibernate builds and manages
&quot;services&quot;), Clean up of Session opening from SessionFactory,
Improved integration via org.hibernate.integrator.spi.Integrator and auto
discovery, Improved logging with i18n support and message codes, Initial work
on more clear split between API, SPI and implementation classes, Clean up of
deprecated methods, classes.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12.0pt; line-height: 115%;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://navin-bansal.blogspot.com/feeds/5479591690596658166/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://navin-bansal.blogspot.com/2012/11/what-is-hibernate.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7715544799292814842/posts/default/5479591690596658166'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7715544799292814842/posts/default/5479591690596658166'/><link rel='alternate' type='text/html' href='http://navin-bansal.blogspot.com/2012/11/what-is-hibernate.html' title='What is Hibernate ?'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06685256351965309878</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZQcCb6vfH4tfDFM_T2FluubDecyOaztVMmjutk-kdnHRRZr4CTOApUO-MLAHvrSgBsbk_Lr4psgPF18-stVfMvSEAz5ZxKB0kC8TaNVowF_gQPWuQT7tzP8NpRhlHbZ3CsO8W5eofyGVd/s72-c/Untitled.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7715544799292814842.post-8819917077106041566</id><published>2012-07-26T10:31:00.000-07:00</published><updated>2012-07-26T10:31:17.110-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="General"/><category scheme="http://www.blogger.com/atom/ns#" term="Hibernate"/><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><category scheme="http://www.blogger.com/atom/ns#" term="Technology"/><title type='text'>Hibernate Tutorials</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Georgia, &#39;Times New Roman&#39;, Times, serif; font-size: 14px; line-height: 21px;&quot;&gt;Lets learn Hibernate with fun. Here provide step by step tutorials to learn Core Hibernate or Hibernate+Spring ,with simple &amp;nbsp;and easily&amp;nbsp;understandable example&amp;nbsp;.&lt;/span&gt; &lt;div&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: #333333; font-family: Georgia, &#39;Times New Roman&#39;, Times, serif;&quot;&gt;&lt;span style=&quot;font-size: 14px; line-height: 21px;&quot;&gt;visit to see&amp;nbsp;contains&amp;nbsp;of&amp;nbsp;Hibernate-&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;a href=&quot;http://www.technicaltoday.com/p/hibernate.html&quot;&gt;http://www.technicaltoday.com/p/hibernate.html&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://navin-bansal.blogspot.com/feeds/8819917077106041566/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://navin-bansal.blogspot.com/2012/07/hibernate-tutorials.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7715544799292814842/posts/default/8819917077106041566'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7715544799292814842/posts/default/8819917077106041566'/><link rel='alternate' type='text/html' href='http://navin-bansal.blogspot.com/2012/07/hibernate-tutorials.html' title='Hibernate Tutorials'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06685256351965309878</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7715544799292814842.post-3999561565135157994</id><published>2012-07-26T09:46:00.001-07:00</published><updated>2012-07-26T10:07:40.785-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="General"/><category scheme="http://www.blogger.com/atom/ns#" term="Hibernate"/><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><title type='text'>What is ORM ?</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;ORM stands for Object Relation Mapping.The term Object Relation Mapping refers the technique to map the data from an object model representation to a relation data model.ORM provide the mapping for java classes with hibernate and it also provides data query and&amp;nbsp;retrieval facilities.It remove the overhead of&amp;nbsp;manually data handling in SQL and JDBC.&lt;br /&gt;
&lt;br /&gt;
Now days Hibernate which is provided for java classes use that&amp;nbsp;technique. &amp;nbsp;&amp;nbsp;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://navin-bansal.blogspot.com/feeds/3999561565135157994/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://navin-bansal.blogspot.com/2012/07/1what-is-orm.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7715544799292814842/posts/default/3999561565135157994'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7715544799292814842/posts/default/3999561565135157994'/><link rel='alternate' type='text/html' href='http://navin-bansal.blogspot.com/2012/07/1what-is-orm.html' title='What is ORM ?'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06685256351965309878</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7715544799292814842.post-2797444058113751979</id><published>2012-06-25T11:49:00.001-07:00</published><updated>2012-06-25T11:53:15.061-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="General"/><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><category scheme="http://www.blogger.com/atom/ns#" term="spring"/><title type='text'>Spring Framework Tutorials</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Lets learn spring framework with fun. Here provide step by step tutorials to learn spring framework,with simple &amp;nbsp;and easily&amp;nbsp;understandable example&amp;nbsp;.&lt;br /&gt;
visit to see&amp;nbsp;contain of spring framework&amp;nbsp;&amp;nbsp;-&lt;a href=&quot;http://www.technicaltoday.com/p/spring.html&quot;&gt;http://www.technicaltoday.com/p/spring.html&lt;/a&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://navin-bansal.blogspot.com/feeds/2797444058113751979/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://navin-bansal.blogspot.com/2012/06/spring-framework-tutorials.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7715544799292814842/posts/default/2797444058113751979'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7715544799292814842/posts/default/2797444058113751979'/><link rel='alternate' type='text/html' href='http://navin-bansal.blogspot.com/2012/06/spring-framework-tutorials.html' title='Spring Framework Tutorials'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06685256351965309878</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7715544799292814842.post-6959333388347169976</id><published>2012-06-24T22:15:00.000-07:00</published><updated>2012-06-24T22:15:49.265-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="General"/><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><category scheme="http://www.blogger.com/atom/ns#" term="spring"/><title type='text'>BeanNameAware and ApplicationContextAware in spring</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Spring offer&amp;nbsp;awareness&amp;nbsp;with beans and Applicationcontext.&lt;br /&gt;
BeanNameAware interface provide to know &amp;nbsp;bean information like name aware(know who you are).&lt;br /&gt;
ApplicationContextAware interface provide to know context information like context aware(Know where you live).&lt;br /&gt;
public setBeanName(String bean);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this method contain the name of the bean which is implement the interface BeanNameAware&lt;br /&gt;
public void setApplicationContext(ApplicationContext context)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this contain the container of context&amp;nbsp;information where that bean exist.necessary to implement that class with&amp;nbsp;ApplicationContextAware&amp;nbsp;interface.&lt;br /&gt;
&amp;nbsp;let illustrate example-&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKE8XhhjWHMyy9g0dns2gZ0hY6cZSR0WdJxzjPTfPbBJVZFPc8HFJdtDSpeKng9aMRiVuiuJHONdh3cUlP52wlGuH0By2Ov_nFb3up9nkOW-pIGZo6ea0-_xPdg-YpW4_MPatA0KeQGfma/s1600/Untitled.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKE8XhhjWHMyy9g0dns2gZ0hY6cZSR0WdJxzjPTfPbBJVZFPc8HFJdtDSpeKng9aMRiVuiuJHONdh3cUlP52wlGuH0By2Ov_nFb3up9nkOW-pIGZo6ea0-_xPdg-YpW4_MPatA0KeQGfma/s1600/Untitled.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;b&gt;class Point.java&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;codeview&quot;&gt;package com.test;&lt;br /&gt;
&lt;br /&gt;
public class Point {&lt;br /&gt;
private int x,y;&lt;br /&gt;
&lt;br /&gt;
public int getX() {&lt;br /&gt;
return x;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public void setX(int x) {&lt;br /&gt;
this.x = x;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public int getY() {&lt;br /&gt;
return y;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public void setY(int y) {&lt;br /&gt;
this.y = y;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;b&gt;class Triangle.java&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;codeview&quot;&gt;package com.test;&lt;br /&gt;
&lt;br /&gt;
import org.springframework.beans.BeansException;&lt;br /&gt;
import org.springframework.beans.factory.BeanNameAware;&lt;br /&gt;
import org.springframework.context.ApplicationContext;&lt;br /&gt;
import org.springframework.context.ApplicationContextAware;&lt;br /&gt;
&lt;br /&gt;
public class Triangle implements ApplicationContextAware,BeanNameAware{&lt;br /&gt;
&lt;br /&gt;
private Point point1;&lt;br /&gt;
private Draw dr;&lt;br /&gt;
&lt;br /&gt;
public Point getPoint1() {&lt;br /&gt;
return point1;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public void setPoint1(Point point1) {&lt;br /&gt;
this.point1 = point1;&lt;br /&gt;
}&lt;br /&gt;
public void show()&lt;br /&gt;
{&lt;br /&gt;
System.out.println(&quot;Ponit1 x=&quot;+point1.getX()+&quot;y=&quot;+point1.getY());&lt;br /&gt;
dr.draw();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public Draw getDr() {&lt;br /&gt;
return dr;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public void setDr(Draw dr) {&lt;br /&gt;
this.dr = dr;&lt;br /&gt;
}&lt;br /&gt;
@Override&lt;br /&gt;
public void setApplicationContext(ApplicationContext context)&lt;br /&gt;
throws BeansException {&lt;br /&gt;
System.out.println(&quot;context is=&quot;+context.toString());&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
@Override&lt;br /&gt;
public void setBeanName(String bean) {&lt;br /&gt;
System.out.println(&quot;bean name is=&quot;+bean);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;b&gt;class Draw.java&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;codeview&quot;&gt;package com.test;&lt;br /&gt;
&lt;br /&gt;
public class Draw {&lt;br /&gt;
&lt;br /&gt;
public void draw()&lt;br /&gt;
{&lt;br /&gt;
System.out.println(&quot;Triangle Drawn&quot;);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;b&gt;class Main.java&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;codeview&quot;&gt;package com.test;&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 Main {&lt;br /&gt;
&lt;br /&gt;
public static void main(String[] args) {&lt;br /&gt;
&lt;br /&gt;
ApplicationContext context=new ClassPathXmlApplicationContext(&quot;spring.xml&quot;);&lt;br /&gt;
Triangle tri=(Triangle) context.getBean(&quot;triangle&quot;);&lt;br /&gt;
tri.show();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;/div&gt;&lt;b&gt;Spring.xml&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;&lt;br /&gt;
&amp;lt;!DOCTYPE beans PUBLIC &quot;-//SPRING//DTD BEAN 2.0//EN&quot; &quot;http://www.springframework.org/dtd/spring-beans-2.0.dtd&quot;&amp;gt;&lt;br /&gt;
&amp;lt;beans&amp;gt;&lt;br /&gt;
&amp;lt;bean id=&quot;point1&quot; class=&quot;com.test.Point&quot;&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;property name=&quot;x&quot; value=&quot;10&quot;&amp;gt;&amp;lt;/property&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;property name=&quot;y&quot; value=&quot;20&quot;&amp;gt;&amp;lt;/property&amp;gt;&lt;br /&gt;
&amp;lt;/bean&amp;gt;&lt;br /&gt;
&amp;lt;bean id=&quot;draw&quot; class=&quot;com.test.Draw&quot;&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;
&amp;lt;bean id=&quot;triangle&quot; class=&quot;com.test.Triangle&quot; autowire=&quot;autodetect&quot;&amp;gt;&lt;br /&gt;
&amp;lt;/bean&amp;gt;&lt;br /&gt;
&amp;lt;/beans&amp;gt;&lt;br /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;b&gt;Output is=&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;codeview&quot;&gt;bean name is=triangle&lt;br /&gt;
context is=org.springframework.context.support.ClassPathXmlApplicationContext@1d6096: startup date [Mon Jun 25 10:38:24 IST 2012]; root of context hierarchy&lt;br /&gt;
Ponit1 x=10y=20&lt;br /&gt;
Triangle Drawn&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://navin-bansal.blogspot.com/feeds/6959333388347169976/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://navin-bansal.blogspot.com/2012/06/beannameaware-and-applicationcontextawa.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7715544799292814842/posts/default/6959333388347169976'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7715544799292814842/posts/default/6959333388347169976'/><link rel='alternate' type='text/html' href='http://navin-bansal.blogspot.com/2012/06/beannameaware-and-applicationcontextawa.html' title='BeanNameAware and ApplicationContextAware in spring'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06685256351965309878</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKE8XhhjWHMyy9g0dns2gZ0hY6cZSR0WdJxzjPTfPbBJVZFPc8HFJdtDSpeKng9aMRiVuiuJHONdh3cUlP52wlGuH0By2Ov_nFb3up9nkOW-pIGZo6ea0-_xPdg-YpW4_MPatA0KeQGfma/s72-c/Untitled.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7715544799292814842.post-6655241138845747851</id><published>2012-06-24T21:37:00.000-07:00</published><updated>2012-06-24T21:37:14.869-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="General"/><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><category scheme="http://www.blogger.com/atom/ns#" term="spring"/><title type='text'>Bean postprocessing in spring</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Spring provide two opportunities or us to cut into a bean&#39;s lifecycle and review or alter its configuration. this is called &#39;&lt;i&gt;post processing&lt;/i&gt;&#39;.The BeanPostProcessor interface gives two opportunities to alter a bean after it has been &amp;nbsp; &amp;nbsp; &lt;br /&gt;
created or wired.&lt;br /&gt;
public interface &lt;b&gt;BeanPostProcessor&lt;/b&gt;&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp;Object postProcessBeforeInitialization (Object bean,String name)&amp;nbsp;throw BeanException;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;Object postProcessAfterInitialization (Object bean,String name)&amp;nbsp;throw BeanException;&lt;br /&gt;
}&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; The&amp;nbsp;postProcessBeforeInitialization() method called before the bean initialization.likewise&amp;nbsp;postProcessAfterInitialization () method called immediately after initialization.&lt;br /&gt;
&lt;br /&gt;
Let see a example to understand -&lt;br /&gt;
Directory Structure-&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6MoRgEeMo66y4-J9_CQPt_xG4J66xOHERIEZufCgaiNJJsbUDA-pAx9ZHaRUjowNzdY1vrggq6rH9ww7IC7X3CLpcmxR__7Qdi0vk2zh2vF5N_WrSFynx1We8bCCEtMRKReQyJpmauYJA/s1600/Untitled.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6MoRgEeMo66y4-J9_CQPt_xG4J66xOHERIEZufCgaiNJJsbUDA-pAx9ZHaRUjowNzdY1vrggq6rH9ww7IC7X3CLpcmxR__7Qdi0vk2zh2vF5N_WrSFynx1We8bCCEtMRKReQyJpmauYJA/s1600/Untitled.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;b&gt;Class Point.java&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;codeview&quot;&gt;package com.test;&lt;br /&gt;
&lt;br /&gt;
public class Point {&lt;br /&gt;
private int x,y;&lt;br /&gt;
&lt;br /&gt;
public int getX() {&lt;br /&gt;
return x;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public void setX(int x) {&lt;br /&gt;
this.x = x;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public int getY() {&lt;br /&gt;
return y;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public void setY(int y) {&lt;br /&gt;
this.y = y;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;b&gt;Class Triangle.java&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;codeview&quot;&gt;package com.test;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
public class Triangle {&lt;br /&gt;
&lt;br /&gt;
private Point point1;&lt;br /&gt;
private Draw dr;&lt;br /&gt;
&lt;br /&gt;
public Point getPoint1() {&lt;br /&gt;
return point1;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public void setPoint1(Point point1) {&lt;br /&gt;
this.point1 = point1;&lt;br /&gt;
}&lt;br /&gt;
public void show()&lt;br /&gt;
{&lt;br /&gt;
System.out.println(&quot;Ponit1 x=&quot;+point1.getX()+&quot;y=&quot;+point1.getY());&lt;br /&gt;
dr.draw();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public Draw getDr() {&lt;br /&gt;
return dr;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public void setDr(Draw dr) {&lt;br /&gt;
this.dr = dr;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;b&gt;Class Draw.java&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;codeview&quot;&gt;&lt;br /&gt;
package com.test;&lt;br /&gt;
&lt;br /&gt;
public class Draw {&lt;br /&gt;
&lt;br /&gt;
public void draw()&lt;br /&gt;
{&lt;br /&gt;
System.out.println(&quot;Triangle Drawn&quot;);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;/div&gt;&lt;b&gt;Class BeanPostDisplay.java&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;codeview&quot;&gt;package com.test;&lt;br /&gt;
&lt;br /&gt;
import org.springframework.beans.BeansException;&lt;br /&gt;
import org.springframework.beans.factory.config.BeanPostProcessor;&lt;br /&gt;
&lt;br /&gt;
public class BeanPostDisplay implements BeanPostProcessor {&lt;br /&gt;
&lt;br /&gt;
@Override&lt;br /&gt;
public Object postProcessAfterInitialization(Object obj, String bean)&lt;br /&gt;
throws BeansException {&lt;br /&gt;
System.out.println(&quot;Initialization is complete of &quot;+bean);&lt;br /&gt;
return obj;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
@Override&lt;br /&gt;
public Object postProcessBeforeInitialization(Object obj, String bean)&lt;br /&gt;
throws BeansException {&lt;br /&gt;
System.out.println(&quot;Initialization is Started of &quot;+bean);&lt;br /&gt;
return obj;&lt;br /&gt;
}&lt;br /&gt;
}&lt;/div&gt;&lt;b&gt;Class Main.java&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;codeview&quot;&gt;package com.test;&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 Main {&lt;br /&gt;
&lt;br /&gt;
public static void main(String[] args) {&lt;br /&gt;
&lt;br /&gt;
ApplicationContext context=new ClassPathXmlApplicationContext(&quot;spring.xml&quot;);&lt;br /&gt;
Triangle tri=(Triangle) context.getBean(&quot;triangle&quot;);&lt;br /&gt;
tri.show();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;b&gt;Spring.xml&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;&lt;br /&gt;
&amp;lt;!DOCTYPE beans PUBLIC &quot;-//SPRING//DTD BEAN 2.0//EN&quot; &quot;http://www.springframework.org/dtd/spring-beans-2.0.dtd&quot;&amp;gt;&lt;br /&gt;
&amp;lt;beans&amp;gt;&lt;br /&gt;
&amp;lt;bean id=&quot;point1&quot; class=&quot;com.test.Point&quot;&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;property name=&quot;x&quot; value=&quot;10&quot;&amp;gt;&amp;lt;/property&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;property name=&quot;y&quot; value=&quot;20&quot;&amp;gt;&amp;lt;/property&amp;gt;&lt;br /&gt;
&amp;lt;/bean&amp;gt;&lt;br /&gt;
&amp;lt;bean id=&quot;draw&quot; class=&quot;com.test.Draw&quot;&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;
&amp;lt;bean id=&quot;triangle&quot; class=&quot;com.test.Triangle&quot; autowire=&quot;autodetect&quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/bean&amp;gt;&lt;br /&gt;
&amp;lt;bean class=&quot;com.test.BeanPostDisplay&quot;&amp;gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;
&amp;lt;/beans&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Output is=&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;codeview&quot;&gt;Initialization is Started of point1&lt;br /&gt;
Initialization is complete of point1&lt;br /&gt;
Initialization is Started of draw&lt;br /&gt;
Initialization is complete of draw&lt;br /&gt;
Initialization is Started of triangle&lt;br /&gt;
Initialization is complete of triangle&lt;br /&gt;
Ponit1 x=10y=20&lt;br /&gt;
Triangle Drawn&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://navin-bansal.blogspot.com/feeds/6655241138845747851/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://navin-bansal.blogspot.com/2012/06/bean-postprocessing-in-spring.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7715544799292814842/posts/default/6655241138845747851'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7715544799292814842/posts/default/6655241138845747851'/><link rel='alternate' type='text/html' href='http://navin-bansal.blogspot.com/2012/06/bean-postprocessing-in-spring.html' title='Bean postprocessing in spring'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06685256351965309878</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6MoRgEeMo66y4-J9_CQPt_xG4J66xOHERIEZufCgaiNJJsbUDA-pAx9ZHaRUjowNzdY1vrggq6rH9ww7IC7X3CLpcmxR__7Qdi0vk2zh2vF5N_WrSFynx1We8bCCEtMRKReQyJpmauYJA/s72-c/Untitled.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7715544799292814842.post-2738601564559561545</id><published>2012-06-18T12:05:00.000-07:00</published><updated>2012-06-18T12:05:06.251-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="General"/><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><category scheme="http://www.blogger.com/atom/ns#" term="spring"/><title type='text'>Create beans with factory method (singleton class) in spring</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Mostly the beans that are configure in the spring application context will be created by calling one of the class&#39;s constructor.&lt;br /&gt;
In the case of configuring&amp;nbsp;singleton class(class that only create one instance) or bean&amp;nbsp;&amp;nbsp;allowing throw factory method.&lt;br /&gt;
Here illustrate a example to understand it-&lt;br /&gt;
Directory Structure-&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnieNkMmG8wbTNR6-T-K4P9JCu7CuAqTeSZ47eKyIZNs4qT0DEuAuaIId5knmnssCigegMq26p-0-GfBOvjhnMrEl-5Q6uAGIe0YUpVUcqxWWFq3ndAy1BUqtcO1CFxa_qSs9FkR8z0l2g/s1600/Untitled.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnieNkMmG8wbTNR6-T-K4P9JCu7CuAqTeSZ47eKyIZNs4qT0DEuAuaIId5knmnssCigegMq26p-0-GfBOvjhnMrEl-5Q6uAGIe0YUpVUcqxWWFq3ndAy1BUqtcO1CFxa_qSs9FkR8z0l2g/s1600/Untitled.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;b&gt;Class FactoryBean.java&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;codeview&quot;&gt;package com.test;&lt;br /&gt;
&lt;br /&gt;
public class FactoryBean {&lt;br /&gt;
private String name;&lt;br /&gt;
&lt;br /&gt;
public String getName() {&lt;br /&gt;
return name;&lt;br /&gt;
}&lt;br /&gt;
public void setName(String name) {&lt;br /&gt;
this.name = name;&lt;br /&gt;
}&lt;br /&gt;
private FactoryBean(){}&lt;br /&gt;
&lt;br /&gt;
private static class SingaltonClass &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// inner class who create only single instance&lt;br /&gt;
{&lt;br /&gt;
static FactoryBean instance=new FactoryBean();&lt;br /&gt;
}&lt;br /&gt;
public static FactoryBean getInstance() &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// factory method to create instance&lt;br /&gt;
{&lt;br /&gt;
return SingaltonClass.instance;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
public void show()&lt;br /&gt;
{&lt;br /&gt;
System.out.println(&quot;Name is=&quot;+name);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;b&gt;class Main.java&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;codeview&quot;&gt;package com.test;&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 Main {&lt;br /&gt;
&lt;br /&gt;
public static void main(String args[])&lt;br /&gt;
{&lt;br /&gt;
ApplicationContext ctx=new ClassPathXmlApplicationContext(&quot;spring.xml&quot;);&lt;br /&gt;
FactoryBean fact=ctx.getBean(&quot;factoryBean&quot;, FactoryBean.class);&lt;br /&gt;
fact.show();&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/div&gt;&lt;b&gt;spring.xml&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;&lt;br /&gt;
&amp;lt;!DOCTYPE beans PUBLIC &quot;-//SPRING//DTD BEAN 2.0//EN&quot; &quot;http://www.springframework.org/dtd/spring-beans-2.0.dtd&quot;&amp;gt;&lt;br /&gt;
&amp;lt;beans&amp;gt;&lt;br /&gt;
&amp;lt;bean id=&quot;factoryBean&quot; class=&quot;com.test.FactoryBean&quot; factory-method=&quot;getInstance&quot;&amp;gt;&lt;br /&gt;
&amp;lt;property name=&quot;name&quot; value=&quot;Factory Beans&quot;&amp;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;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;Output is=&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;codeview&quot;&gt;Name is=Factory Beans&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://navin-bansal.blogspot.com/feeds/2738601564559561545/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://navin-bansal.blogspot.com/2012/06/create-beans-with-factory-method.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7715544799292814842/posts/default/2738601564559561545'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7715544799292814842/posts/default/2738601564559561545'/><link rel='alternate' type='text/html' href='http://navin-bansal.blogspot.com/2012/06/create-beans-with-factory-method.html' title='Create beans with factory method (singleton class) in spring'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06685256351965309878</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnieNkMmG8wbTNR6-T-K4P9JCu7CuAqTeSZ47eKyIZNs4qT0DEuAuaIId5knmnssCigegMq26p-0-GfBOvjhnMrEl-5Q6uAGIe0YUpVUcqxWWFq3ndAy1BUqtcO1CFxa_qSs9FkR8z0l2g/s72-c/Untitled.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7715544799292814842.post-2754219723615346001</id><published>2012-06-17T10:34:00.001-07:00</published><updated>2012-06-17T10:36:39.400-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="General"/><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><category scheme="http://www.blogger.com/atom/ns#" term="spring"/><title type='text'>Spring Framework- Event Handling</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Spring Framework also provide an another feature to promote loose coupling ,which is Application Event handling. Using Events, an Event publisher object can communicate with other objects without even &amp;nbsp;knowing which object is listen.and event listener can work to event without knowing which object publish the events. Publisher Object that object ,who publish the event or call the event and Listener always listen the events that are&amp;nbsp;occurs.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; To make a custom event extends the class with &lt;b&gt;&lt;i&gt;ApplicationEvent&lt;/i&gt;&lt;/b&gt; class.The&amp;nbsp;&lt;i&gt;&lt;b&gt;ApplicationEventPublisher&lt;/b&gt;&lt;/i&gt;&lt;b&gt; &lt;/b&gt;has contain &lt;b&gt;&lt;i&gt;publishEvent()&lt;/i&gt;&lt;/b&gt; method that enable to publish ApplicationEvents (Custom Events).Any &lt;b&gt;&lt;i&gt;ApplicationListener&lt;/i&gt;&lt;/b&gt; that is registered with the &lt;b&gt;&lt;i&gt;onApplicationEvent()&lt;/i&gt;&lt;/b&gt; method in application,listen the events.&lt;br /&gt;
To understand The Event handling Lets illustrate a simple example-&lt;br /&gt;
Directory Structure- &lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGILwZuVVwYzU8VxjcjSZx0Y8KCILbWs-Pya3KOdssXNgFpF6raslKCWB06MCRA_0fbNnRA6D8aZGhyphenhyphenDixAV1Ftp0f1hIn5ToVOjt022C93lkfJ5BRZkLqdyMVP5NAL25w3wTa_gAwBcWV/s1600/Untitled.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGILwZuVVwYzU8VxjcjSZx0Y8KCILbWs-Pya3KOdssXNgFpF6raslKCWB06MCRA_0fbNnRA6D8aZGhyphenhyphenDixAV1Ftp0f1hIn5ToVOjt022C93lkfJ5BRZkLqdyMVP5NAL25w3wTa_gAwBcWV/s1600/Untitled.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;b&gt;&lt;/b&gt;&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;b&gt;Class Point.java&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;codeview&quot;&gt;package com.test;&lt;br /&gt;
&lt;br /&gt;
public class Point {&lt;br /&gt;
int x,y;&lt;br /&gt;
public int getX() {&lt;br /&gt;
return x;&lt;br /&gt;
}&lt;br /&gt;
public void setX(int x) {&lt;br /&gt;
this.x = x;&lt;br /&gt;
}&lt;br /&gt;
public int getY() {&lt;br /&gt;
return y;&lt;br /&gt;
}&lt;br /&gt;
public void setY(int y) {&lt;br /&gt;
this.y = y;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;b&gt;Class Tri.java&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;codeview&quot;&gt;package com.test;&lt;br /&gt;
&lt;br /&gt;
import org.springframework.beans.factory.annotation.Autowired;&lt;br /&gt;
import org.springframework.context.ApplicationEventPublisher;&lt;br /&gt;
import org.springframework.context.ApplicationEventPublisherAware;&lt;br /&gt;
&lt;br /&gt;
public class Tri implements ApplicationEventPublisherAware{&lt;br /&gt;
ApplicationEventPublisher Ae;&lt;br /&gt;
Point p;&lt;br /&gt;
&lt;br /&gt;
public Point getP() {&lt;br /&gt;
return p;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
@Autowired&lt;br /&gt;
public void setP(Point p) {&lt;br /&gt;
this.p = p;&lt;br /&gt;
}&lt;br /&gt;
public void show()&lt;br /&gt;
{&lt;br /&gt;
System.out.println(&quot;x=&quot;+p.getX());&lt;br /&gt;
System.out.println(&quot;y=&quot;+p.getY());&lt;br /&gt;
Ae.publishEvent(new ShowEvent(this)); // &amp;nbsp;&lt;i&gt; Publish the event with publishEvent()&lt;/i&gt;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
@Override&lt;br /&gt;
public void setApplicationEventPublisher(ApplicationEventPublisher Ae) {&lt;br /&gt;
this.Ae=Ae;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;b&gt;Class MyListener.java&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;codeview&quot;&gt;package com.test;&lt;br /&gt;
&lt;br /&gt;
import org.springframework.context.ApplicationEvent;&lt;br /&gt;
import org.springframework.context.ApplicationListener;&lt;br /&gt;
import org.springframework.stereotype.Component;&lt;br /&gt;
@SuppressWarnings(&quot;rawtypes&quot;)&lt;br /&gt;
@Component&lt;br /&gt;
public class MyListener implements ApplicationListener{ &amp;nbsp;// &lt;i&gt;define Listener&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
@Override&lt;br /&gt;
public void onApplicationEvent(ApplicationEvent e) {&lt;br /&gt;
System.out.println(e.toString());&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;b&gt;Class ShowEvent.java&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;codeview&quot;&gt;package com.test;&lt;br /&gt;
&lt;br /&gt;
import org.springframework.context.ApplicationEvent;&lt;br /&gt;
public class ShowEvent extends ApplicationEvent {// &lt;i&gt;Craete Event with event clas&lt;/i&gt;s&lt;br /&gt;
&lt;br /&gt;
private static final long serialVersionUID = 1L;&lt;br /&gt;
public ShowEvent(Object source) {&lt;br /&gt;
super(source);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
public String toString()&lt;br /&gt;
{&lt;br /&gt;
return(&quot;Hurry!!!!!Show Event occurs &quot;);&lt;br /&gt;
}&lt;br /&gt;
}&lt;/div&gt;&lt;b&gt;Class Draw.java&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;codeview&quot;&gt;package com.test;&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 Draw {&lt;br /&gt;
&lt;br /&gt;
public static void main(String[] args) {&lt;br /&gt;
ApplicationContext context=new ClassPathXmlApplicationContext(&quot;spring.xml&quot;);&lt;br /&gt;
Tri t=(Tri) context.getBean(&quot;tri&quot;);&lt;br /&gt;
t.show();&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;b&gt;Spring.xml&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;&lt;br /&gt;
&amp;lt;beans xmlns=&quot;http://www.springframework.org/schema/beans&quot;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;xsi:schemaLocation=&quot;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd&quot;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;xmlns:context=&quot;http://www.springframework.org/schema/context&quot;&amp;gt;&lt;br /&gt;
&amp;lt;context:annotation-config/&amp;gt;&lt;br /&gt;
&amp;lt;bean id=&quot;p&quot; class=&quot;com.test.Point&quot;&amp;gt;&lt;br /&gt;
&amp;lt;property name=&quot;x&quot; value=&quot;10&quot;&amp;gt;&amp;lt;/property&amp;gt;&lt;br /&gt;
&amp;lt;property name=&quot;y&quot; value=&quot;20&quot;&amp;gt;&amp;lt;/property&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;lt;/bean&amp;gt;&lt;br /&gt;
&amp;lt;bean id=&quot;tri&quot; class=&quot;com.test.Tri&quot;&amp;gt;&lt;br /&gt;
&amp;lt;/bean&amp;gt;&lt;br /&gt;
&amp;lt;context:component-scan base-package=&quot;com.test&quot;&amp;gt;&amp;lt;/context:component-scan&amp;gt;&lt;br /&gt;
&amp;lt;/beans&amp;gt;&lt;br /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;b&gt;Output is=&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;codeview&quot;&gt;x=10&lt;br /&gt;
y=20&lt;br /&gt;
Hurry!!!!!Show Event occurs &lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://navin-bansal.blogspot.com/feeds/2754219723615346001/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://navin-bansal.blogspot.com/2012/06/spring-framework-event-handling.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7715544799292814842/posts/default/2754219723615346001'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7715544799292814842/posts/default/2754219723615346001'/><link rel='alternate' type='text/html' href='http://navin-bansal.blogspot.com/2012/06/spring-framework-event-handling.html' title='Spring Framework- Event Handling'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06685256351965309878</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGILwZuVVwYzU8VxjcjSZx0Y8KCILbWs-Pya3KOdssXNgFpF6raslKCWB06MCRA_0fbNnRA6D8aZGhyphenhyphenDixAV1Ftp0f1hIn5ToVOjt022C93lkfJ5BRZkLqdyMVP5NAL25w3wTa_gAwBcWV/s72-c/Untitled.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7715544799292814842.post-1526604029374487801</id><published>2012-06-16T00:33:00.000-07:00</published><updated>2012-06-16T00:33:09.788-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="General"/><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><category scheme="http://www.blogger.com/atom/ns#" term="spring"/><category scheme="http://www.blogger.com/atom/ns#" term="Technology"/><title type='text'>What is difference between id and name of bean?</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;id of bean is a&amp;nbsp;unique&amp;nbsp;in&amp;nbsp;container&amp;nbsp; for each bean . id is basically used to access the bean anywhere. but it not accept the url matching like in spring framework. name is partially work like id but it can accept url matching.&lt;br /&gt;
example-&lt;br /&gt;
&amp;lt;bean name=&lt;b&gt;&quot;/*.html&quot;&lt;/b&gt; class=&quot;com.test.handler&quot;&amp;gt;&lt;br /&gt;
In web application when url contain this pattern it call that class. The id is not preferred for that feature. It caught a exception at the run time.&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://navin-bansal.blogspot.com/feeds/1526604029374487801/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://navin-bansal.blogspot.com/2012/06/what-is-difference-between-id-and-name.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7715544799292814842/posts/default/1526604029374487801'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7715544799292814842/posts/default/1526604029374487801'/><link rel='alternate' type='text/html' href='http://navin-bansal.blogspot.com/2012/06/what-is-difference-between-id-and-name.html' title='What is difference between id and name of bean?'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/06685256351965309878</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>