AspectJ is a language with a full compiler and support for weaving binary class files either offline or at runtime, as classes are loaded into the virtual machine. Let's see how we can use load-time weaving (LTW) with Spring.
The Spring AOP framework only supports limited types of AspectJ pointcuts (method invocation). If you want use the complete set of AspectJ pointcuts, you must use AspectJ load-time weaver to enable the AspectJ framework.
This is an example of a class with call
pointcut:
package org.springaop.aspectj.aspects; public aspect AspectJAspectExample { before(): call(* relax(..)) { System.out.println("relax() method is about to be executed!"); } }
AspectJ load-time weaving happens when the target classes are loaded into JVM by a class loader. For a class to be woven, a special class loader is required to enhance the bytecode of the target class. The configuration of the AspectJ framework is done through a file named aop.xml
in the META-INF
directory...