Spring AOP

2,676
-1

Published on

Basics of Spring AOP for spring learners

Published in: Technology
0 Comments
7 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,676
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
253
Comments
0
Likes
7
Embeds 0
No embeds

No notes for slide

Spring AOP

  1. 1. Adlux Consultancy Services Pvt Ltd
  2. 2. AGENDA <ul><li>Introduction To AOP </li></ul><ul><li>AOP Concepts </li></ul><ul><ul><ul><li>Aspect </li></ul></ul></ul><ul><ul><ul><li>Joinpoint </li></ul></ul></ul><ul><ul><ul><li>Advice </li></ul></ul></ul><ul><ul><ul><li>Pointcuts </li></ul></ul></ul><ul><ul><ul><li>Target Object </li></ul></ul></ul><ul><ul><ul><li>Weaving </li></ul></ul></ul>Adlux Consultancy Services Pvt Ltd
  3. 3. What Is AOP <ul><li>Aspect-oriented programming, or AOP, is a programming technique that allows programmers to modularize crosscutting concerns </li></ul><ul><li>It is often defined as a programming technique that promotes separation of crosscutting concerns with in a software system. </li></ul><ul><li>concerns : </li></ul><ul><li>A concern is a particular issue, concept, or area of interest for an application: typically, a goal the application must meet. </li></ul>Adlux Consultancy Services Pvt Ltd
  4. 4. Cross-cutting concerns <ul><li>The systems or concerns that tend to cut across multiple components in a system are referred as Cross-cutting concerns </li></ul><ul><li>System wide concerns that span multiple modules. </li></ul><ul><li>Cuts across the typical division of responsibility. </li></ul><ul><li>Examples such as </li></ul><ul><ul><li>Transaction Management </li></ul></ul><ul><ul><li>Security </li></ul></ul><ul><ul><li>Logging </li></ul></ul>Adlux Consultancy Services Pvt Ltd
  5. 5. Cross Cutting Concerns in OOP Approach <ul><ul><li>OOP creates a coupling between core and crosscutting concerns. This causes </li></ul></ul><ul><ul><ul><li>Leads to duplicated code. </li></ul></ul></ul><ul><ul><ul><li>Hard to maintain code. </li></ul></ul></ul><ul><ul><ul><li>Hard to use code. </li></ul></ul></ul>Adlux Consultancy Services Pvt Ltd <ul><li>Transaction Management </li></ul><ul><li>Logging </li></ul><ul><li>Checking for the Privileged User </li></ul><ul><li>Actual Withdraw Logic </li></ul><ul><li>comes here </li></ul><ul><li>Transaction Management </li></ul><ul><li>Logging </li></ul><ul><li>Checking for the Privileged User </li></ul><ul><li>Actual Deposit Logic </li></ul><ul><li>comes here </li></ul>Withdraw method Deposit method Cross cutting concerns
  6. 6. <ul><li>Public class Account </li></ul><ul><li>{ </li></ul><ul><li>public void deposit() { </li></ul><ul><li>// Transaction Management </li></ul><ul><li>// Logging </li></ul><ul><li>// Checking for the Privileged User </li></ul><ul><li>// Actual Deposit Logic comes here </li></ul><ul><li>} </li></ul><ul><li>public void withdraw() { </li></ul><ul><li>// Transaction Management </li></ul><ul><li>// Logging </li></ul><ul><li>// Checking for the Privileged User </li></ul><ul><li>// Actual Withdraw Logic comes here </li></ul><ul><li>} </li></ul><ul><li>} </li></ul><ul><li>AOP calls this kind of logic that cross-cuts the existing business logic as Cross-Cutting Concerns . </li></ul>Adlux Consultancy Services Pvt Ltd
  7. 7. <ul><ul><li>Results in code permeating though the system at various places – hard to maintain </li></ul></ul><ul><ul><li>Harder to express concerns this way </li></ul></ul><ul><ul><li>You have to modify your code to invoke these concerns </li></ul></ul><ul><ul><ul><li>requires understanding at each level </li></ul></ul></ul>Could we not write these cross cutting concerns as functions and call? Adlux Consultancy Services Pvt Ltd
  8. 8. If we use AOP <ul><ul><ul><li>Spring AOP will take care of calling concerns, we just need to declare about concerns once in configuration file. </li></ul></ul></ul><ul><ul><ul><ul><li>You can focus on the concerns at one place </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Easier to add and remove concerns </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Easier to modify or fine tune concerns </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Easier to understand </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Efficient to implement </li></ul></ul></ul></ul><ul><ul><ul><ul><li>More efficient </li></ul></ul></ul></ul>Adlux Consultancy Services Pvt Ltd
  9. 9. AOP Terminology <ul><li>Joinpoint </li></ul><ul><li>A point during the execution of a program, such as the execution </li></ul><ul><li>of a method or the handling of an exception. </li></ul><ul><li>We can insert additional logic at Joinpoint's. </li></ul><ul><li>In Spring AOP, a join point always represents a method execution. </li></ul><ul><li>Advice </li></ul><ul><li>Action taken at a particular joinpoint is called Advice. </li></ul><ul><li>PointCut </li></ul><ul><li>A declarative condition that identifies for which joinpoint, the advices should fire. </li></ul><ul><li>Aspect: </li></ul><ul><li>An aspect is a modularization of a crosscutting concern; the gathering together of code that might otherwise have been scattered. It is termed as the combination of the point-cut and the advice . </li></ul>Adlux Consultancy Services Pvt Ltd
  10. 10. AOP vs OOP Adlux Consultancy Services Pvt Ltd Object Oriented Aspect Oriented Class – code unit that encapsulates methods and attributes. Aspect – code unit that encapsulates pointcuts, advice, and attributes. Method signatures – define the entry points for the execution of method bodies. Pointcut – define the set of entry points (triggers) in which advice is executed. Method bodies – implementations of the primary concerns. Advice – implementations of the cross cutting concerns. Compiler – converts source code into object code. Weaver – instruments code (source or object) with advice.
  11. 11. AOP History <ul><li>Spring implements the AOP Alliance interception interfaces . </li></ul><ul><li>Emerged about 10 years ago from different research efforts studying the separation of concerns in software </li></ul><ul><li>Supported in industry today by IBM, BEA, </li></ul><ul><li>AOP support is available for Java, C++, C, PHP, </li></ul><ul><li>AspectJ, AspectC++, AspectC, AOPHP, </li></ul>Adlux Consultancy Services Pvt Ltd
  12. 12. Advice Adlux Consultancy Services Pvt Ltd
  13. 13. Advice Adlux Consultancy Services Pvt Ltd
  14. 14. Advice <ul><li>Before Advice : </li></ul><ul><li>It is used to intercept before the method execution starts. </li></ul><ul><li>public class Authentication extends BeforeAdvice </li></ul><ul><li>{ </li></ul><ul><li>public void before(Method method, Object[] args, Object target) throws Throwable </li></ul><ul><li>{ </li></ul><ul><li> if (args[0] instanceof User) </li></ul><ul><li>{ </li></ul><ul><li>User user = (User)args[0]; </li></ul><ul><li>// Authenticate if he/she is the right user </li></ul><ul><li>}  </li></ul><ul><li>}  </li></ul><ul><li> } </li></ul>Adlux Consultancy Services Pvt Ltd
  15. 15. Advice <ul><li>From the above code </li></ul><ul><li>before() method will be called before the execution of method call. </li></ul><ul><li>method object represents target method to be invoked. </li></ul><ul><li>Object[] args refers to the various arguments that are passed on to the method. </li></ul>Adlux Consultancy Services Pvt Ltd
  16. 16. Advice <ul><li>After Advice </li></ul><ul><li>It will be useful if some logic has to be executed before Returning the Control within a method execution. </li></ul><ul><li>public class CleanUpOperation implements AfterReturningAdvice </li></ul><ul><li>{  </li></ul><ul><li>public void afterReturning(Object returnValue, Method method, Object[] args, Object target) throws Throwable </li></ul><ul><li>{ </li></ul><ul><li>// Clean up session and user information. </li></ul><ul><li>} </li></ul><ul><li>} </li></ul>Adlux Consultancy Services Pvt Ltd
  17. 17. Advice <ul><li>From the above code </li></ul><ul><li>afterReturning() will be called once the method returns normal execution. </li></ul><ul><li>If some exception happens in the method execution the afterReturning() method will never be called. </li></ul><ul><li>Throws Advice : </li></ul><ul><li>some kind of exception happens during the execution of a method, then to handle the exception properly. </li></ul>Adlux Consultancy Services Pvt Ltd
  18. 18. Advice <ul><li>public class DeleteFile implements ThrowsAdvice </li></ul><ul><li>{ </li></ul><ul><li>public void afterThrowing(Method method, Object[] args, Object target, IOException exception) </li></ul><ul><li>{ </li></ul><ul><li>String targetFileName = (String)args[2]; </li></ul><ul><li>// Code to delete the target file. </li></ul><ul><li>} </li></ul><ul><li>} </li></ul><ul><li>From the above code </li></ul><ul><li>afterThrowing() method will be called when an Exception, that too of type IOException is thrown </li></ul>Adlux Consultancy Services Pvt Ltd
  19. 19. Advice <ul><li>Around Advice : </li></ul><ul><li>Advice that surrounds a joinpoint such as a method invocation. </li></ul><ul><li>They are responsible for choosing whether to proceed to the joinpoint executing by returning their own return value or throwing an exception. </li></ul><ul><li>Intercepts the calls to the target method. </li></ul><ul><li>this Advice provides finer control whether the target method has to be called or not. </li></ul>Adlux Consultancy Services Pvt Ltd
  20. 20. Advice <ul><li>public class ValidateArguments implements MethodInterceptor </li></ul><ul><li>{  </li></ul><ul><li>public Object invoke(MethodInvocation invocation) throws Throwable </li></ul><ul><li>{  </li></ul><ul><li>Object arguments [] = invocation.getArguments(); </li></ul><ul><li>if ((arguments[0] instanceof Parent) && (arguments[1] instanceof Child) ) </li></ul><ul><li>{ </li></ul><ul><li>Object returnValue = invocation.proceed(); </li></ul><ul><li>return returnValue; </li></ul><ul><li>} </li></ul><ul><li>throw new Exception (&quot;Arguments are of wrong type&quot;);  </li></ul><ul><li>} </li></ul><ul><li>} </li></ul>Adlux Consultancy Services Pvt Ltd
  21. 21. Advice <ul><li>From the above code </li></ul><ul><li>It is important to make a call to MethodInvocation.proceed(), if we are happy with the arguments validation, else the target method will never gets invoked. </li></ul>Adlux Consultancy Services Pvt Ltd
  22. 22. Adlux Consultancy Services Pvt Ltd
  23. 23. Pointcuts <ul><li>Point Cuts define where exactly the Advices have to be applied in various Join Points i.e Set of Joinpoints specifying when an advice should fire. </li></ul><ul><li>Generally they act as Filters for the application of various Advices into the real implementation. </li></ul><ul><li>Each built-in Pointcuts has an advisor </li></ul><ul><li>PointcutAdvisor=Pointcut + Advice </li></ul>Adlux Consultancy Services Pvt Ltd
  24. 24. Adlux Consultancy Services Pvt Ltd
  25. 25. Pointcuts <ul><li>public interface Pointcut </li></ul><ul><li>{ </li></ul><ul><li>ClassFilter getClassFilter(); </li></ul><ul><li>MethodMatcher getMethodMatcher(); </li></ul><ul><li>} </li></ul><ul><li>public interface ClassFilter </li></ul><ul><li>{ </li></ul><ul><li>boolean matches(Class clazz); </li></ul><ul><li>} </li></ul><ul><li>public interface MethodMatcher </li></ul><ul><li>{ </li></ul><ul><li>boolean matches(Method m,Class targetClass); </li></ul><ul><li>boolean isRuntime(); </li></ul><ul><li>boolean matches(Method m,Class targetClass,Object[] args); </li></ul><ul><li>} </li></ul>Adlux Consultancy Services Pvt Ltd
  26. 26. Pointcuts <ul><li>Spring defines two types of Point Cuts namely the </li></ul><ul><li>Static and Dynamic Point Cuts. </li></ul><ul><li>Static Pointcuts </li></ul><ul><li>NameMatchMethod Pointcut </li></ul><ul><li>Regular Expression Pointcut </li></ul><ul><li>NameMatchMethod Pointcut : </li></ul><ul><li>Here the name of the methods that are to be given advices can be directly mentioned in the Configuration File. </li></ul>Adlux Consultancy Services Pvt Ltd
  27. 27. Pointcuts <ul><li>MyInterface.java </li></ul><ul><li>public interface MyInterface </li></ul><ul><li>{ public void setMessage(String msg); </li></ul><ul><li>public void method1(); </li></ul><ul><li>public void method2(); </li></ul><ul><li>public void getMethod1(); </li></ul><ul><li>public void getMethod2(); </li></ul><ul><li>} </li></ul><ul><li>MyClass.java </li></ul><ul><li>public class MyClass implements MyInterface </li></ul><ul><li>{  </li></ul><ul><li>private String message; </li></ul><ul><li>public void setMessage(String msg) </li></ul><ul><li>{ </li></ul><ul><li>this.message=msg; </li></ul><ul><li>} </li></ul><ul><li>public void method1(){} </li></ul><ul><li>public void method2(){}  </li></ul><ul><li>public void getMethod1() {} </li></ul><ul><li>public void getMethod2(){} </li></ul><ul><li>} </li></ul>Adlux Consultancy Services Pvt Ltd
  28. 28. Pointcuts <ul><li>ApplicationContext.xml </li></ul><ul><li><beans> </li></ul><ul><li><bean id=“getMethodsAdvisor&quot; class=&quot; org.springframework. aop. support.NameMatchMethodPointcutAdvisor &quot;> </li></ul><ul><li><property name=&quot;mappedName&quot;> </li></ul><ul><li><value>get*</value> </li></ul><ul><ul><li></property> </li></ul></ul><ul><ul><li>(OR) </li></ul></ul><ul><ul><li><property name=“mappedNames”> </li></ul></ul><ul><ul><li><list> <value>get*</value> </li></ul></ul><ul><ul><li><value>set*</value> </li></ul></ul><ul><ul><li><value>method1</value> </li></ul></ul><ul><ul><li></list> </li></ul></ul><ul><ul><li></property> </li></ul></ul><ul><li><property name=&quot;advice&quot;> </li></ul><ul><li><ref bean=“sampleAdvice &quot;/> </li></ul><ul><li></property> </li></ul><ul><li></bean> </li></ul>Adlux Consultancy Services Pvt Ltd
  29. 29. Pointcuts Adlux Consultancy Services Pvt Ltd <bean id=“myTargetClass&quot; class=“MyClass“/> <bean id=“sampleAdvice&quot; class=“MySampleAdvice“/> <bean id=“proxy“ class=“ org.springframework.aop.framework.ProxyFactoryBean “> <property name=&quot;proxyInterfaces“> <value>MyInterface</value> </property> <property name=&quot;target&quot;> <ref bean=“myTargetClass &quot;/> </property> <property name=&quot;interceptorNames&quot;> <value> getMethodsAdvisor </value> </property> </bean> </beans>
  30. 30. Pointcuts <ul><li>get* tells that all method names starting with the method name get will be given Advices . </li></ul><ul><li>If we want all the methods in the MyClass to be adviced, then the 'value' tag should be given '*' meaning all the methods in the Class. </li></ul>Adlux Consultancy Services Pvt Ltd
  31. 31. Pointcuts <ul><li>Regular Expression Pointcut </li></ul><ul><li>It is used if you want to match the name of the methods in the Class based on Regular Expression. </li></ul><ul><li>Spring distribution already comes with two supported flavors of Regular Expression namely Perl Regular Expression and Jdk Regular Expression . </li></ul>Adlux Consultancy Services Pvt Ltd
  32. 32. Pointcuts <ul><li>MyInterface.java </li></ul><ul><li>public interface MyInterface </li></ul><ul><li>{ </li></ul><ul><li>public void method1(); </li></ul><ul><li>public void method11(); </li></ul><ul><li>public void method2(); </li></ul><ul><li>public void getMethod1(); </li></ul><ul><li>public void getMethod2(); </li></ul><ul><li>} </li></ul><ul><li>MyClass.java </li></ul><ul><li>public class MyClass implements MyInterface </li></ul><ul><li>{  </li></ul><ul><li>public void method1(){} </li></ul><ul><li>public void method11(){} </li></ul><ul><li>public void method2(){}  </li></ul><ul><li>public void getMethod1(){}  </li></ul><ul><li>public void getMethod2(){} </li></ul><ul><li>} </li></ul>Adlux Consultancy Services Pvt Ltd
  33. 33. Pointcuts <ul><li>ApplicationContext.xml </li></ul><ul><li><bean id=&quot;regExpAdvisor“ class=&quot; org.springframework.aop. support.RegexpMethodPointcutAdvisor &quot;> </li></ul><ul><li><property name=“advice&quot;> </li></ul><ul><li><ref bean=&quot;sampleAdvice&quot;/> </li></ul><ul><li></property> </li></ul><ul><li><property name=“patterns”> </li></ul><ul><li> <list> </li></ul><ul><li> <value>m.*1</value> </li></ul><ul><li> <value>.*method.*</value> </li></ul><ul><li></list> </li></ul><ul><li></property> </li></ul><ul><li></bean> </li></ul>Adlux Consultancy Services Pvt Ltd
  34. 34. Adlux Consultancy Services Pvt Ltd <bean id=“myTargetClass&quot; class=“MyClass“/> <bean id=“sampleAdvice&quot; class=“MySampleAdvice“/> <bean id=&quot;person&quot; class=“ org.springframework.aop. framework.ProxyFactoryBean “> <property name=“proxyInterfaces” > <value>MyInterface</value> </property> <property name=“target”> <ref bean=“myTargetClass”/> </property> <property name=“interceptorNames”> <value> regExpAdvisor </value> </property> </bean> Pointcuts
  35. 35. Pointcuts Adlux Consultancy Services Pvt Ltd Symbol Description . Matches Any Single Character + Mathches the Preceding Character one or more times * Mathches the Preceding Character Zero or more times / Escapes any Regular Expression Symbols
  36. 36. Pointcuts <ul><li>Dynamic Pointcuts : </li></ul><ul><li>However, there may be some cases where your pointcuts will need to evaluate runtime attributes. </li></ul><ul><li>Spring provides one built-in dynamic pointcut: ControlFlowPointcut. </li></ul><ul><li>This pointcut matches based on information about the current thread’s call stack. </li></ul><ul><li>That is, it can be configured to return true only if a particular method or class is found in the current thread’s stack of execution . </li></ul>Adlux Consultancy Services Pvt Ltd
  37. 37. Pointcuts <ul><li>Dynamic Pointcut Configuration </li></ul><ul><li><bean id=&quot;dynamicPointcut“ class=&quot; org.springframework. aop. support.ControlFlowPointcut&quot;> </li></ul><ul><li><constructor-arg> </li></ul><ul><li><value>javax.servlet.http.HttpServlet</value> </li></ul><ul><li></constructor-arg> </li></ul><ul><li></bean> </li></ul><ul><li><bean id=&quot;dynamicAdvisor&quot; class=&quot; org.springframework. aop.support.DefaultPointcutAdvisor &quot;> </li></ul><ul><li><property name=&quot;advice&quot;> </li></ul><ul><li><ref bean=&quot; sampleAdvice &quot;/> </li></ul><ul><li></property> </li></ul><ul><li><property name=&quot;pointcut&quot;> </li></ul><ul><li><ref bean=&quot;dynamicPointcut&quot;/> </li></ul><ul><li></property> </li></ul><ul><li></bean> </li></ul>Adlux Consultancy Services Pvt Ltd
  38. 38. Adlux Consultancy Services Pvt Ltd <bean id=“myTargetClass&quot; class=“MyClass“/> <bean id=“sampleAdvice&quot; class=“MySampleAdvice“/> <bean id=&quot;person&quot; class=“ org.springframework.aop. framework.ProxyFactoryBean “> <property name=“proxyInterfaces” > <value>MyInterface</value> </property> <property name=“target”> <ref bean=“myTargetClass”/> </property> <property name=“interceptorNames”> <value> dynamicAdvisor </value> </property> </bean> Pointcuts
  39. 39. Target <ul><li>Object containing the joinpoint . </li></ul><ul><li>Also referred to as the advised or proxied object . </li></ul><ul><li>Example </li></ul><ul><li><bean id=“ myTargetClass ” class=“sample.MyClass”> </li></ul><ul><li><property name=“message”> </li></ul><ul><li><value>Welcome to Adlux</value> </li></ul><ul><li></property> </li></ul><ul><li></bean> </li></ul>Adlux Consultancy Services Pvt Ltd
  40. 40. Weaving <ul><li>It is the process of applying aspects to a target object to create a new proxied object. </li></ul><ul><li>The aspects are woven into the target object at the specified joinpoints. </li></ul><ul><li>different points where weaving can be applied ·  Compile Time </li></ul><ul><li>·   Class load Time </li></ul><ul><li>·    Runtime </li></ul>Adlux Consultancy Services Pvt Ltd
  41. 41. AOP Proxy <ul><li>A proxy is the object created after applying advice to the target object. </li></ul><ul><li>The target object (pre-AOP) & the proxy object </li></ul><ul><li>(post-AOP) are the same. </li></ul><ul><li>The object created by the AOP framework that includes the advise. </li></ul><ul><li>The three properties you will probably use most often are </li></ul><ul><li>1 . target </li></ul><ul><li>2 . proxyInterfaces </li></ul><ul><li>3 . interceptorNames </li></ul>Adlux Consultancy Services Pvt Ltd
  42. 42. AOP Proxy Adlux Consultancy Services Pvt Ltd Sample ProxyFactoryBean Configuration <bean id=“sampleProxy&quot; class=“org.springframework.aop. framework.ProxyFactoryBean“> <property name=&quot;proxyInterfaces“> <value> SampleInterface </value> </property> <property name=&quot;target&quot;> <ref bean=&quot; sampleTarget &quot;/> </property> <property name=&quot;interceptorNames&quot;> <value> sampleAdvice </value> </property> </bean> <bean id=“sampleTarget&quot; class=“MySampleTarget“/> <bean id=“sampleAdvice&quot; class=“MySampleAdvice“/>
  43. 43. AOP Proxy <ul><li>Spring will create a proxy using a JDK dynamic proxy or a CGLIB proxy. </li></ul><ul><li>First providing the ProxyFactory with all the aspects that you want to be woven into the proxy. </li></ul><ul><li>You typically use ProxyFactoryBean class to provide declarative proxy creation. </li></ul><ul><li>Different types of AutoProxying </li></ul><ul><li>·    DefaultAdvisorAutoProxyCreator </li></ul><ul><li>·    BeanNameAutoProxyCreator </li></ul>Adlux Consultancy Services Pvt Ltd
  44. 44. AOP Proxy <ul><li>BeanNameAutoProxyCreator </li></ul><ul><li><bean id=“beanNameAutoProxy” class=&quot;org.springframework.aop. framework.autoproxy.BeanNameAutoProxyCreator&quot;> </li></ul><ul><li><property name=&quot;beanNames&quot;> </li></ul><ul><li><list><value> *Service </value></list> </li></ul><ul><li></property> </li></ul><ul><li><property name=&quot;interceptorNames&quot;> </li></ul><ul><li><value> performanceThresholdInterceptor </value> </li></ul><ul><li></property> </li></ul><ul><li></bean> </li></ul><ul><li><bean id=“performanceThresholdInterceptor” class=“student.performanceThresholdInterceptor”/> </li></ul><ul><li><bean id=“studentService” class=“student.StudentService”/> </li></ul><ul><li><bean id=“courseService” class=“student.CourseService”/> </li></ul><ul><li><bean id=“sampleService” class=“sample.SampleService”/> </li></ul>Adlux Consultancy Services Pvt Ltd
  45. 45. AOP Proxy <ul><li>2. DefaultAdvisorAutoProxyCreator </li></ul><ul><li> <bean id=&quot;advisor&quot; class=&quot; org.springframework.aop.support. </li></ul><ul><li> RegexpMethodPointcutAdvisor &quot;> </li></ul><ul><li><property name=&quot;advice&quot;> </li></ul><ul><li><bean class=&quot;performanceThresholdInterceptor&quot;/> </li></ul><ul><li></property> </li></ul><ul><li><property name=&quot;pattern&quot;> </li></ul><ul><li><value> .+Service..+ </value> </li></ul><ul><li></property> </li></ul><ul><li></bean> </li></ul><ul><li><bean id=&quot;autoProxyCreator” class=&quot; org.springframework.aop. framework.autoproxy.DefaultAdvisorAutoProxyCreator &quot;/> </li></ul><ul><li><bean id=“studentService” class=“student.StudentService”/> </li></ul><ul><li><bean id=“courseService” class=“student.CourseService”/> </li></ul><ul><li><bean id=“sampleService” class=“sample.SampleService”/> </li></ul>Adlux Consultancy Services Pvt Ltd
  46. 46. Spring AOP Capabilities <ul><li>Implemented in pure Java </li></ul><ul><li>Suitable for use in J2EE container since does not need to control the class loader hierarchy </li></ul><ul><li>Spring supports interception of methods </li></ul><ul><li>Does not support field interception </li></ul><ul><li>Provides classes to represent pointcuts and different advise types </li></ul><ul><li>Spring advises object at instance, rather than class loader level </li></ul>Adlux Consultancy Services Pvt Ltd
  47. 47. Adlux Consultancy Services Pvt Ltd

×