0

Possible Duplicate:
Spring AOP vs AspectJ

I am reading spring reference document. In that it is written

  1. If you need field access and update join points, consider a language such as AspectJ.
  2. There are something that you can not do with Spring AOP, such as advise very fine grained objects (such as domain objects), AspectJ is the best case to work with it.
  3. What is AspectJ compiler or weaver?

I did not get the meaning of above three points and hence confused. Please elaborate with simple example.

Community
  • 1
  • 1
user900721
  • 1,417
  • 4
  • 17
  • 29

3 Answers3

3

AFAIK Spring AOP doesn't support all functionalities of AspectJ, but only a limited set. For example, Spring AOP supports only method-level pointcuts, so if you want fine grained control (i.e. field-level) you need to use AspectJ natively.

davioooh
  • 23,742
  • 39
  • 159
  • 250
2

Your first point simply conveys that you can only apply point-cuts on method level, field interception is not implemented in spring-aop.

Next point tells that you cannot add advices on domain-objects(which are simple pojo entities),

The last is about weaving ,weaving is wiring of Aspects into objects in the spring XML file in the way as JavaBean. OR simply say, weaving is about adding new bytecode to your java class to make it usable to the framework.

Bruce_Wayne
  • 1,564
  • 3
  • 18
  • 41
0

also there is more important difference - AspectJ can inject AOP stuff at compile time(with aspectj maven pluging for example), spring AOP only at runtime using cglib or javasist according to the version of spring. However generally you would prefer spring AOP anyway - just because it much easier...

Andrey Borisov
  • 3,160
  • 18
  • 18