Tuesday, April 26, 2011

Weaving style of working with AOP

 Earlier we saw proxy style of handling aop, now we will see weaving style. Spring 2.5 supported LTW (load time weaving).
Weaving means bytecode instrumentation.

Types of Weaving
Code weaving comes in three flavors:

  • Load-time weaving(LTW): Aspect weaving is performed by the class loader when classes are first loaded.
    Weave class files when being loaded in VM
    i.e. Add aspect to class files OR Aspect + class files
  • Compile-time weaving: Aspects are weaved into the class files when they are compiled.
    Aspect + source code = class files
  • Binary Weaving (linker)
    Aspect + source/byte code = class files


Aspectwerkz and AspectJ works with both compile and load-time weaving.

Compile time weaving and binary weaving requires a seperate AspectJ compiler, which has nothing to do with spring. You will have to seperate lean AspectJ or try it out. Eclipse plugins are also available for AspectJ making it easier to achieve the same.

See how to configure the weaving method and proxy method of AOP in spring.


No comments:

Post a Comment

Chitika