Spring Core

Using ApplicationContextAware in Spring

<p>In this chapter&comma; we will show you a short hint about how you can access your <b>Spring-ApplicationContext<&sol;b> from everywhere in your <b>Application<&sol;b>&period; We&&num;8217&semi;ll provide our beans with access to the ApplicationContext object by implementing the ApplicationContextAware interface&period; We&&num;8217&semi;ll also use BeanNameAware interface to get the name of the bean configured in the Spring XML&period;<&sol;p>&NewLine;<div dir&equals;"ltr" style&equals;"text-align&colon; justify&semi;">&NewLine;<div dir&equals;"ltr" style&equals;"text-align&colon; justify&semi;">&NewLine;<div dir&equals;"ltr" style&equals;"text-align&colon; justify&semi;">&NewLine;<div style&equals;"color&colon; &num;274e13&semi;">&NewLine;<div class&equals;"separator" style&equals;"clear&colon; both&semi; text-align&colon; center&semi;"><img src&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;wp-content&sol;uploads&sol;2012&sol;06&sol;applicationcontextaware&period;jpg" border&equals;"0" &sol;><&sol;div>&NewLine;<h2><b><br &sol;>&NewLine;<&sol;b> <b>WHY <&sol;b><i style&equals;"color&colon; blue&semi;"><b>ApplicationContextAware&quest; <&sol;b><&sol;i><&sol;h2>&NewLine;<p>Imagine we have <b>an application &lpar;e&period;g&period; a web or Swing-application&rpar;<&sol;b> which we now want to be <b>Spring-enabled<&sol;b>&period; Ok&comma; we add the <b>Spring libraries&lpar;spring&period;jar&rpar;<&sol;b> and the <b>Configuration-file&lpar;spring&period;xml&rpar;<&sol;b> and create our <b>Spring-bean<&sol;b>s&period; But there are still some <b>old class-files<&sol;b> which you can’t use in this way&period; These files still need access to the Spring-Honeypot where all the goodies exist and you don’t want to redesign your application&period;<&sol;p>&NewLine;<div style&equals;"background-color&colon; &num;f2f9fc&semi; border&colon; 1px solid &num;c9e6f2&semi; border-radius&colon; 3px&semi; padding&colon; 16px&semi; line-height&colon; 1&period;45&semi;">&NewLine;<p><span style&equals;"color&colon; red&semi; font-size&colon; x-large&semi; text-align&colon; center&semi;"><b>Popular Tutorials<&sol;b><&sol;span><&sol;p>&NewLine;<ul style&equals;"text-align&colon; left&semi;">&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-tutorial&sol;"><em><strong>Spring Tutorial<&sol;strong> <&sol;em><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-web-mvc-framework-chapter-38&sol;"><strong><em>Spring MVC Web Tutorial <&sol;em><&sol;strong><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;introduction-to-spring-boot-a-spring-boot-complete-guide&sol;"><strong>Spring Boot Tutorial<&sol;strong> <&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-security-take-baby-step-to-secure&sol;"><em>Spring Security Tutorial<&sol;em><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-aop-tutorial-with-example-aspect-advice-pointcut-joinpoint&sol;"><em>Spring AOP Tutorial<&sol;em><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;using-spring-jdbc-framework-chapter-32&sol;"><em>Spring JDBC Tutorial<&sol;em><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-hateoas-hypermedia-driven-restful-web-service&sol;"><em><strong>Spring HATEOAS <&sol;strong><&sol;em><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;microservices-with-spring-boot&sol;"><em><strong>Microservices with Spring Boot<&sol;strong><&sol;em><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;jax-rs-web-service-tutorial&sol;"><strong><em>REST Webservice<&sol;em> <&sol;strong><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;core-java-baby-step-to-be-best-java-ian&sol;"><em><strong>Core Java <&sol;strong><&sol;em><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;hibernate-3-on-baby-steps&sol;"><em><strong>Hibernate Tutorial<&sol;strong><&sol;em><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-batch-process-with-example&sol;"><strong><em>Spring Batch<&sol;em> <&sol;strong><&sol;a><&sol;b><&sol;li>&NewLine;<&sol;ul>&NewLine;<&sol;div>&NewLine;<p>First&comma; create the class &&num;8220&semi;<b>ApplicationContextProvider<&sol;b> &lpar;<b>Triangle class<&sol;b>&rpar;&&num;8221&semi;&period; This class implements the <b>ApplicationContextAware<&sol;b>&period; A bean which implements the <b>ApplicationContextAware<&sol;b>-interface and is deployed into the context will be called back on the creation of the bean&comma; using the interface’s <b>setApplicationContext&lpar;…&rpar; <&sol;b>method&comma; and provided with a reference to the context&comma; which may be stored for later interaction with the context&period;<&sol;p>&NewLine;<&sol;div>&NewLine;<p>In this tutorial&comma; you will see an example of using ApplicationContextAware&period; The ApplicationContextAware is used when an object required&period;<br &sol;>&NewLine;<b><br &sol;>&NewLine;<&sol;b> <b>Triangle&period;java<&sol;b><&sol;p>&NewLine;<pre class&equals;"highlight">package com&period;dineshonjava&period;sdnext&period;contextAware&period;tutorial&semi; &NewLine; &NewLine;import org&period;springframework&period;beans&period;BeansException&semi; &NewLine;import org&period;springframework&period;beans&period;factory&period;BeanNameAware&semi; &NewLine;import org&period;springframework&period;context&period;ApplicationContext&semi; &NewLine;import org&period;springframework&period;context&period;ApplicationContextAware&semi; &NewLine; &NewLine;public class Triangle implements ApplicationContextAware&comma; BeanNameAware &NewLine;&lbrace; &NewLine; private Point pointA&semi; &NewLine; private Point pointB&semi; &NewLine; private Point pointC&semi; &NewLine; private ApplicationContext context &equals; null&semi; &NewLine; &NewLine; &sol;&ast;&ast; &NewLine; &ast; &commat;param pointA the pointA to set &NewLine; &ast;&sol; &NewLine; public void setPointA&lpar;Point pointA&rpar; &lbrace; &NewLine; this&period;pointA &equals; pointA&semi; &NewLine; &rcub; &NewLine; &NewLine; &sol;&ast;&ast; &NewLine; &ast; &commat;param pointB the pointB to set &NewLine; &ast;&sol; &NewLine; public void setPointB&lpar;Point pointB&rpar; &lbrace; &NewLine; this&period;pointB &equals; pointB&semi; &NewLine; &rcub; &NewLine; &NewLine; &sol;&ast;&ast; &NewLine; &ast; &commat;param pointC the pointC to set &NewLine; &ast;&sol; &NewLine; public void setPointC&lpar;Point pointC&rpar; &lbrace; &NewLine; this&period;pointC &equals; pointC&semi; &NewLine; &rcub; &NewLine; &NewLine; public void draw&lpar;&rpar; &NewLine; &lbrace; &NewLine;System&period;out&period;println&lpar;"PointA is &lpar;"&plus;pointA&period;getX&lpar;&rpar;&plus;"&comma; "&plus;pointA&period;getY&lpar;&rpar;&plus;"&rpar;"&rpar;&semi; &NewLine;System&period;out&period;println&lpar;"PointB is &lpar;"&plus;pointB&period;getX&lpar;&rpar;&plus;"&comma; "&plus;pointB&period;getY&lpar;&rpar;&plus;"&rpar;"&rpar;&semi; &NewLine;System&period;out&period;println&lpar;"PointC is &lpar;"&plus;pointC&period;getX&lpar;&rpar;&plus;"&comma; "&plus;pointC&period;getY&lpar;&rpar;&plus;"&rpar;"&rpar;&semi; &NewLine; &rcub; &NewLine; &NewLine; &commat;Override &NewLine; public void setApplicationContext&lpar;ApplicationContext context&rpar; throws BeansException &NewLine; &lbrace; &NewLine; this&period;context &equals; context&semi; &NewLine; &rcub; &NewLine; &NewLine; &commat;Override &NewLine; public void setBeanName&lpar;String beanName&rpar; &NewLine; &lbrace; &NewLine; System&period;out&period;println&lpar;"Bean name is&colon; "&plus;beanName&rpar;&semi; &NewLine; &rcub; &NewLine;&rcub; &NewLine;<&sol;pre>&NewLine;<p><b>Point&period;java<&sol;b><&sol;p>&NewLine;<pre class&equals;"highlight">package com&period;dineshonjava&period;sdnext&period;contextAware&period;tutorial&semi; &NewLine; &NewLine;public class Point &NewLine;&lbrace; &NewLine; private int x&semi; &NewLine; private int y&semi; &NewLine; &sol;&ast;&ast; &NewLine; &ast; &commat;return the x &NewLine; &ast;&sol; &NewLine; public int getX&lpar;&rpar; &lbrace; &NewLine; return x&semi; &NewLine; &rcub; &NewLine; &sol;&ast;&ast; &NewLine; &ast; &commat;param x the x to set &NewLine; &ast;&sol; &NewLine; public void setX&lpar;int x&rpar; &lbrace; &NewLine; this&period;x &equals; x&semi; &NewLine; &rcub; &NewLine; &sol;&ast;&ast; &NewLine; &ast; &commat;return the y &NewLine; &ast;&sol; &NewLine; public int getY&lpar;&rpar; &lbrace; &NewLine; return y&semi; &NewLine; &rcub; &NewLine; &sol;&ast;&ast; &NewLine; &ast; &commat;param y the y to set &NewLine; &ast;&sol; &NewLine; public void setY&lpar;int y&rpar; &lbrace; &NewLine; this&period;y &equals; y&semi; &NewLine; &rcub; &NewLine;&rcub; &NewLine;<&sol;pre>&NewLine;<p><b>spring&period;xml<&sol;b><&sol;p>&NewLine;<pre class&equals;"highlight">&lt&semi;beans xmlns&colon;xsi&equals;"http&colon;&sol;&sol;www&period;w3&period;org&sol;2001&sol;XMLSchema-instance" xmlns&equals;"http&colon;&sol;&sol;www&period;springframework&period;org&sol;schema&sol;beans" xsi&colon;schemalocation&equals;"http&colon;&sol;&sol;www&period;springframework&period;org&sol;schema&sol;beans &NewLine;http&colon;&sol;&sol;www&period;springframework&period;org&sol;schema&sol;beans&sol;spring-beans-2&period;5&period;xsd"&gt&semi; &NewLine; &lt&semi;bean autowire&equals;"byName" class&equals;"com&period;dineshonjava&period;sdnext&period;contextAware&period;tutorial&period;Triangle" id&equals;"triangle"&gt&semi;&lt&semi;&sol;bean&gt&semi; &NewLine; &NewLine;&lt&semi;bean class&equals;"com&period;dineshonjava&period;sdnext&period;contextAware&period;tutorial&period;Point" id&equals;"pointA"&gt&semi; &NewLine; &lt&semi;property name&equals;"x" value&equals;"0"&gt&semi;&lt&semi;&sol;property&gt&semi; &NewLine; &lt&semi;property name&equals;"y" value&equals;"0"&gt&semi;&lt&semi;&sol;property&gt&semi; &NewLine;&lt&semi;&sol;bean&gt&semi; &NewLine; &NewLine;&lt&semi;bean class&equals;"com&period;dineshonjava&period;sdnext&period;contextAware&period;tutorial&period;Point" id&equals;"pointB"&gt&semi; &NewLine; &lt&semi;property name&equals;"x" value&equals;"-20"&gt&semi;&lt&semi;&sol;property&gt&semi; &NewLine; &lt&semi;property name&equals;"y" value&equals;"0"&gt&semi;&lt&semi;&sol;property&gt&semi; &NewLine;&lt&semi;&sol;bean&gt&semi; &NewLine; &NewLine;&lt&semi;bean class&equals;"com&period;dineshonjava&period;sdnext&period;contextAware&period;tutorial&period;Point" id&equals;"pointC"&gt&semi; &NewLine; &lt&semi;property name&equals;"x" value&equals;"20"&gt&semi;&lt&semi;&sol;property&gt&semi; &NewLine; &lt&semi;property name&equals;"y" value&equals;"0"&gt&semi;&lt&semi;&sol;property&gt&semi; &NewLine;&lt&semi;&sol;bean&gt&semi; &NewLine;&lt&semi;&sol;beans&gt&semi; &NewLine;<&sol;pre>&NewLine;<p><b>DrawingApp&period;java<&sol;b><&sol;p>&NewLine;<pre class&equals;"highlight">package com&period;sdnext&period;contextAware&period;tutorial&semi; &NewLine; &NewLine;import org&period;springframework&period;context&period;ApplicationContext&semi; &NewLine;import org&period;springframework&period;context&period;support&period;ClassPathXmlApplicationContext&semi; &NewLine; &NewLine;&sol;&ast;&ast; &NewLine; &ast; &commat;author Dinesh Rajput &NewLine; &ast; &NewLine; &ast;&sol; &NewLine;public class DrawingApp &NewLine;&lbrace; &NewLine; &sol;&ast;&ast; &NewLine; &ast; &commat;param args &NewLine; &ast;&sol; &NewLine; public static void main&lpar;String&lbrack;&rsqb; args&rpar; &NewLine; &lbrace; &NewLine;ApplicationContext context &equals; new ClassPathXmlApplicationContext&lpar;"spring&period;xml"&rpar;&semi; &NewLine;Triangle triangle &equals; &lpar;Triangle&rpar; context&period;getBean&lpar;"triangle"&rpar;&semi; &NewLine;triangle&period;draw&lpar;&rpar;&semi; &NewLine; &rcub; &NewLine;&rcub; &NewLine;<&sol;pre>&NewLine;<div style&equals;"background-color&colon; &num;ff99cc&semi; border-width&colon; thin&semi; border&colon; solid&semi;">&NewLine;<div style&equals;"color&colon; blue&semi;"><b>Output&colon;<&sol;b><&sol;div>&NewLine;<div style&equals;"color&colon; red&semi;">Jun 30&comma; 2012 3&colon;28&colon;54 PM org&period;springframework&period;context&period;support&period;AbstractApplicationContext prepareRefresh<&sol;div>&NewLine;<div style&equals;"color&colon; red&semi;">INFO&colon; Refreshing org&period;springframework&period;context&period;support&period;ClassPathXmlApplicationContext&commat;145d068&colon; startup date &lbrack;Sat Jun 30 15&colon;28&colon;54 IST 2012&rsqb;&semi; root of context hierarchy<&sol;div>&NewLine;<div style&equals;"color&colon; red&semi;">Jun 30&comma; 2012 3&colon;28&colon;55 PM org&period;springframework&period;beans&period;factory&period;xml&period;XmlBeanDefinitionReader loadBeanDefinitions<&sol;div>&NewLine;<div style&equals;"color&colon; red&semi;">INFO&colon; Loading XML bean definitions from class path resource &lbrack;spring&period;xml&rsqb;<&sol;div>&NewLine;<div style&equals;"color&colon; red&semi;">Jun 30&comma; 2012 3&colon;28&colon;55 PM org&period;springframework&period;beans&period;factory&period;support&period;DefaultListableBeanFactory preInstantiateSingletons<&sol;div>&NewLine;<div style&equals;"color&colon; red&semi;">INFO&colon; Pre-instantiating singletons in org&period;springframework&period;beans&period;factory&period;support&period;DefaultListableBeanFactory&commat;f11404&colon; defining beans &lbrack;triangle&comma;pointA&comma;pointB&comma;pointC&rsqb;&semi; root of factory hierarchy<&sol;div>&NewLine;<p><b>Bean name is&colon; triangle<&sol;b><br &sol;>&NewLine;<b>PointA is &lpar;0&comma; 0&rpar;<&sol;b><br &sol;>&NewLine;<b>PointB is &lpar;-20&comma; 0&rpar;<&sol;b><br &sol;>&NewLine;<b>PointC is &lpar;20&comma; 0&rpar;<&sol;b><&sol;p>&NewLine;<&sol;div>&NewLine;<&sol;div>&NewLine;<h3><i style&equals;"color&colon; blue&semi;"><b>What is Need for Using ApplicationContextAware<&sol;b><&sol;i><i style&equals;"color&colon; blue&semi;"> <b>in Application&quest;<&sol;b><&sol;i><&sol;h3>&NewLine;<p>In the previous chapter&comma; we have seen that we create <b>application context object <&sol;b>via using <b>a configuration file&lpar;spring&period;xml&rpar;<&sol;b> but we did this only one time of the<b> application context object<&sol;b> using <b>a configuration file &lpar;spring&period;xml&rpar;<&sol;b> for an entire application&period;<&sol;p>&NewLine;<p>If we done one time creating <b>application context <&sol;b>object and also one time creating <b>triangle <&sol;b>bean through the <b>getBean&lpar;&rpar;<&sol;b> method because its have &&num;8220&semi;<b>singleton<&sol;b>&&num;8221&semi; scope and <b>beans pointA&comma; pointB &amp&semi; pointC<&sol;b> are also populated <b>along with triangle bean<&sol;b> only one time when <b>triangle <&sol;b>bean is initialized even though <b>pointA&comma; pointB &amp&semi; pointC<&sol;b> are the <b>prototypes <&sol;b>in scope&period;<&sol;p>&NewLine;<div style&equals;"color&colon; &num;274e13&semi;">After that&comma; we can not create <b>a<&sol;b> <b>new bean pointA&comma; pointB &amp&semi; pointC<&sol;b> objects without creating <b>triangle <&sol;b>bean in the <b>Triangle<&sol;b> class or <b>anywhere else except the main app&lpar;DrawingApp&period;java&rpar;<&sol;b>&period;<&sol;div>&NewLine;<div style&equals;"color&colon; &num;274e13&semi;"><&sol;div>&NewLine;<p>And there is some situation we want to use <b>application context <&sol;b>object anywhere else like in bean class&lpar;in <b>Triangle <&sol;b>class&rpar;&period; Suppose the Triangle bean need to <b>application context <&sol;b>object for some reasons&period;<&sol;p>&NewLine;<p>Suppose If we want to create <b>new beans<&sol;b> <b>pointA&comma; pointB &amp&semi; pointC<&sol;b> in <b>triangle <&sol;b>class then we have to declare pointA<b>&comma; pointB &amp&semi; pointC<&sol;b> beans <b>as prototype bean scope<&sol;b>&period; Now we have to need to access <b>an applicationContext<&sol;b> object in the<b> triangle <&sol;b><b>bean<&sol;b><b> class<&sol;b> so because of this we are used <b>ApplicationContextAware<&sol;b> interface and this interface is implements by the <b>Triangle<&sol;b> bean class for accessing <b>application context <&sol;b>object from overriding the following method of the <b>ApplicationContextAware<&sol;b> interface&period;<&sol;p>&NewLine;<pre class&equals;"highlight">&commat;override &NewLine;public void setApplicationContext&lpar;ApplicationContext context&rpar; throws BeansException &NewLine;&lbrace; &NewLine; this&period;context &equals; context&semi; &NewLine;&rcub;<&sol;pre>&NewLine;<p><b>In <a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;bean-definition-inheritance-in-spring&sol;">Next Chapter<&sol;a>&comma; we will discuss <&sol;b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;bean-definition-inheritance-in-spring&sol;"><b>Bean Definition Inheritance in Spring<&sol;b><&sol;a><b><&sol;b><b> in Application&period;<&sol;b><&sol;p>&NewLine;<&sol;div>&NewLine;<&sol;div>&NewLine;<p>&nbsp&semi;<&sol;p>&NewLine;<div style&equals;"background-color&colon; &num;f2f9fc&semi; border-radius&colon; 3px&semi; border&colon; 1px solid &num;c9e6f2&semi; line-height&colon; 1&period;45&semi; padding&colon; 16px&semi;">&NewLine;<p><span style&equals;"color&colon; red&semi; font-size&colon; x-large&semi; text-align&colon; center&semi;"><b>Spring Related Topics you may like<&sol;b><&sol;span><&sol;p>&NewLine;<ul>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;interview-questions-on-spring&sol;"><span style&equals;"color&colon; red&semi;">Spring Interview Questions and Answers<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-aop-interview-questions-and-answers&sol;"><span style&equals;"color&colon; red&semi;">Spring AOP Interview Questions and Answers<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-mvc-interview-questions-and-answers&sol;"><span style&equals;"color&colon; red&semi;">Spring MVC Interview Questions<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-security-interview-questions-and-answers&sol;"><span style&equals;"color&colon; red&semi;">Spring Security Interview Questions and Answers<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-rest-web-services-interview-questions-and-answers&sol;"><span style&equals;"color&colon; red&semi;">Spring REST Interview Questions and Answers<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-boot-interview-questions-and-answers&sol;"><span style&equals;"color&colon; red&semi;">Spring Boot Interview Questions and Answers<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-boot-microservices-interview-questions-answers&sol;"><span style&equals;"color&colon; red&semi;">Spring Boot Microservices Interview Questions and Answers<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;dependency-injection-in-spring&sol;"><span style&equals;"color&colon; red&semi;">Dependency Injection &lpar;DI&rpar; in Spring <&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-ioc-container&sol;"><span style&equals;"color&colon; red&semi;">Spring IoC Container<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;what-is-bean-factory-in-spring&sol;"><span style&equals;"color&colon; red&semi;">What is Bean Factory in Spring<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;application-context-in-spring&sol;"><span style&equals;"color&colon; red&semi;">ApplicationContext in Spring<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;bean-autowiring-in-spring&sol;"><span style&equals;"color&colon; red&semi;">Bean Autowiring in Spring<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;understanding-bean-scopes&sol;"><span style&equals;"color&colon; red&semi;">Spring Bean Scopes<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;create-custom-bean-scope-in-spring-example&sol;"><span style&equals;"color&colon; red&semi;">Create Custom Bean Scope in Spring Example<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;using-applicationcontextaware-in-spring&sol;"><span style&equals;"color&colon; red&semi;">Using ApplicationContextAware in Spring<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;bean-lifecycle-and-callbacks&sol;"><span style&equals;"color&colon; red&semi;">Spring Bean Life Cycle and Callbacks<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;writing-beanpostprocessor-in-spring&sol;"><span style&equals;"color&colon; red&semi;">BeanPostProcessor in Spring<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;writing-beanfactorypostprocessor-in&sol;"><span style&equals;"color&colon; red&semi;">BeanFactoryPostProcessor in Spring<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;annotations-in-spring-and-based&sol;"><span style&equals;"color&colon; red&semi;"> Annotations in Spring and Based Configuration<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-jsr-250-annotations&sol;"><span style&equals;"color&colon; red&semi;">Spring JSR-250 Annotations<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;jsr-330-annotations-in-spring&sol;"><span style&equals;"color&colon; red&semi;">JSR 330 Annotations in Spring<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;stereotype-annotations-in-spring&sol;"><span style&equals;"color&colon; red&semi;">Spring &commat;Component&comma; &commat;Repository&comma; &commat;Service and &commat;Controller Stereotype Annotations<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;method-injection-with-spring-using-lookup-method-property&sol;"><span style&equals;"color&colon; red&semi;">Method injection with Spring using Lookup method property<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;introduction-to-aop-in-spring&sol;"><span style&equals;"color&colon; red&semi;">Spring AOP-Introduction to Aspect Oriented Programming<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-aspect-annotation&sol;"><span style&equals;"color&colon; red&semi;">&commat;Aspect Annotation in Spring<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-aop-aspectj-before-annotation-advice-example&sol;"><span style&equals;"color&colon; red&semi;"> Spring AOP AspectJ &commat;Before Annotation Advice Example<br &sol;>&NewLine;<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-aop-before-advice-example-using-xml-config&sol;"><span style&equals;"color&colon; red&semi;"> Spring AOP Before Advice Example using XML Config<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-aop-aspectj-after-annotation-advice-example&sol;"><span style&equals;"color&colon; red&semi;"> Spring AOP AspectJ &commat;After Annotation Advice Example<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-aop-after-advice-example-using-xml-config&sol;"><span style&equals;"color&colon; red&semi;"> Spring AOP After Advice Example using XML Config<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-aop-aspectj-after-returning-annotation-advice-example&sol;"><span style&equals;"color&colon; red&semi;"> Spring AOP AspectJ &commat;AfterReturning Annotation Advice Example<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-aop-after-returning-advice-example-using-xml-config&sol;"><span style&equals;"color&colon; red&semi;"> Spring AOP After-Returning Advice Example using XML Config<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-aop-aspectj-after-throwing-annotation-advice-example&sol;"><span style&equals;"color&colon; red&semi;"> Spring AOP AspectJ &commat;AfterThrowing Annotation Advice Example<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-aop-after-throwing-advice-example-using-xml-config&sol;"><span style&equals;"color&colon; red&semi;"> Spring AOP After Throwing Advice Example using XML Config<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-aop-aspectj-around-annotation-advice-example&sol;"><span style&equals;"color&colon; red&semi;"> Spring AOP AspectJ &commat;Around Annotation Advice Example<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-aop-around-advice-example-using-xml-config&sol;"><span style&equals;"color&colon; red&semi;"> Spring AOP Around Advice Example using XML Config<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;understanding-aop-proxies-chapter-31&sol;"><span style&equals;"color&colon; red&semi;">Spring AOP Proxies in Spring<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-aop-transaction-management-in&sol;"><span style&equals;"color&colon; red&semi;"> Spring AOP Transaction Management in Hibernate<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;transaction-management-in-spring&sol;"><span style&equals;"color&colon; red&semi;">Spring Transaction Management<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;declarative-transaction-management&sol;"><span style&equals;"color&colon; red&semi;">Spring Declarative Transaction Management Example<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-aop-ordering-of-aspects-with-example&sol;"><span style&equals;"color&colon; red&semi;">Spring AOP-Ordering of Aspects with Example<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-security-java-based-configuration-with-example&sol;"><span style&equals;"color&colon; red&semi;">Spring Security Java Based Configuration with Example<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-security-xml-namespace-configuration-example&sol;"><span style&equals;"color&colon; red&semi;">Spring Security XML Namespace Configuration Example<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<&sol;ul>&NewLine;<p>&nbsp&semi;<&sol;p>&NewLine;<&sol;div>&NewLine;<div class&equals;"wp-post-navigation"> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <div class&equals;"wp-post-navigation-pre"> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;prototype-bean-scope-with-annotation&sol;">Previous<&sol;a> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <&sol;div> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <div class&equals;"wp-post-navigation-next"> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;bean-definition-inheritance-in-spring&sol;">Next<&sol;a> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <&sol;div> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;<&sol;div>&NewLine;<script type&equals;"text&sol;javascript">&NewLine;jQuery&lpar;document&rpar;&period;ready&lpar;function&lpar;&dollar;&rpar; &lbrace;&NewLine; &dollar;&period;post&lpar;'https&colon;&sol;&sol;dineshonjava&period;com&sol;wp-admin&sol;admin-ajax&period;php'&comma; &lbrace;action&colon; 'mts&lowbar;view&lowbar;count'&comma; id&colon; '665'&rcub;&rpar;&semi;&NewLine;&rcub;&rpar;&semi;&NewLine;<&sol;script>

Dinesh Rajput

Dinesh Rajput is the chief editor of a website Dineshonjava, a technical blog dedicated to the Spring and Java technologies. It has a series of articles related to Java technologies. Dinesh has been a Spring enthusiast since 2008 and is a Pivotal Certified Spring Professional, an author of a book Spring 5 Design Pattern, and a blogger. He has more than 10 years of experience with different aspects of Spring and Java design and development. His core expertise lies in the latest version of Spring Framework, Spring Boot, Spring Security, creating REST APIs, Microservice Architecture, Reactive Pattern, Spring AOP, Design Patterns, Struts, Hibernate, Web Services, Spring Batch, Cassandra, MongoDB, and Web Application Design and Architecture. He is currently working as a technology manager at a leading product and web development company. He worked as a developer and tech lead at the Bennett, Coleman & Co. Ltd and was the first developer in his previous company, Paytm. Dinesh is passionate about the latest Java technologies and loves to write technical blogs related to it. He is a very active member of the Java and Spring community on different forums. When it comes to the Spring Framework and Java, Dinesh tops the list!

Share
Published by
Dinesh Rajput

Recent Posts

Strategy Design Patterns using Lambda

Strategy Design Patterns We can easily create a strategy design pattern using lambda. To implement…

4 years ago

Decorator Pattern using Lambda

Decorator Pattern A decorator pattern allows a user to add new functionality to an existing…

4 years ago

Delegating pattern using lambda

Delegating pattern In software engineering, the delegation pattern is an object-oriented design pattern that allows…

4 years ago

Spring Vs Django- Know The Difference Between The Two

Technology has emerged a lot in the last decade, and now we have artificial intelligence;…

4 years ago

TOP 20 MongoDB INTERVIEW QUESTIONS 2022

Managing a database is becoming increasingly complex now due to the vast amount of data…

4 years ago

Scheduler @Scheduled Annotation Spring Boot

Overview In this article, we will explore Spring Scheduler how we could use it by…

4 years ago