0

As much i get from the spring 3 documentation that there are two ways of AOP

  1. AspectJ - which include <aop:config> metadata in xml or using annotation @Aspect

  2. Spring own implementation - which is using interfaces for advice(BeforeAdvice , AfterAdvice etc)

--please correct me if i am wrong till now --

Now spring own implementation is implemented by AutoproxyCreator (BeanNameAutoproxyCreator , DefaultAdvisorAutoproxyCreator) which creates the proxy at the time of bean creation using BeanPostProcessor .

But how proxy of AspectJ is done in Spring .How Aspect class either provided by @Aspect of by

<aop:config>
    <aop:aspect ref= "anyclasshavingAllAdviceMethod">
       <!-- (all aop:before,aop:after-throwing etc) -->
    </aop:aspect>
</aop:config>

is used for creating proxy . What is mechanism behind implementation of <aop:config> or @Aspect .

or load-time waever is used for these .

Note: to implement aop:config we don't have to provide any extra bean or load-time-weaver then how it works ?

Sean Patrick Floyd
  • 292,901
  • 67
  • 465
  • 588
Virendra
  • 387
  • 1
  • 7
  • 15
  • Please refer to this thread for an example: [http://stackoverflow.com/a/14326373/405117][1] [1]: http://stackoverflow.com/a/14326373/405117 – Vikram Jan 21 '13 at 03:37

1 Answers1

0

There are several levels of distinction here.

  1. Spring AOP
    This Comes in Two flavors:
    • Classic (XML) Spring AOP
    • @AspectJ-Style Spring AOP
  2. Aspect-J
    This also comes in two flavors:
    • Classic AspectJ (.aj)
    • @AspectJ-Style AspectJ

Both flavors of Spring AOP are implemented using BeanPostProcessors and proxies.

Both flavors of AspectJ are implemented at compile time (byte code manipulation or separate compilation) or at Class Load time (when using a Load Time Weaver)

The modern version of Spring AOP and the modern version of AspectJ share the @AspectJ-Syntax, but they are not to be confused with each other: Spring AOP only works on Spring Beans using proxies, and hence only intercepting method calls from the outside. AspectJ changes the actual byte code of a method and therefore works completely independent of Spring.

If you want to learn more about the different technologies and flavors, I recommend the Book AspectJ in Action by Spring Committer and AspectJ Guru Ramnivas Laddad.

You should also read: Spring Reference: 8.4. Choosing which AOP declaration style to use

Community
  • 1
  • 1
Sean Patrick Floyd
  • 292,901
  • 67
  • 465
  • 588
  • But how exactly ` ` is used to create proxy .Is it used `DefaultAdvisorAutoproxyCreator` .But aspect(child of ``) is not a advisor and moreover we never defined `DefaultAdvisorAutoproxyCreator ` bean in `application.xml` then how it works ,I am really confused . somewhere these metadata is being read and proxy will being created . Could you please give me the whole picture of that . – Virendra Nov 15 '12 at 19:08