Aspectj weaving point Syntax:
1. execution (public ** (..) any method of any return value of any class
2. execution (* set * (..) method starting with set of any class
3. execution (* com. xyz. service. AccountService. * (..) specifies the methods in the class for any returned values
4. If execution (* com. xyz. service... *. * (...) returns any value, specify any class or method of the package
Advise summary. Example:
1. Example: directly specify the location and logic to be woven
[Java]
// Specify the weaving method.
@ Before ("execution (public * com. spring. service ..*.*(..))")
Public void BeforeMethod (){
System. out. println ("method start! ");
}
@ AfterReturning ("execution (public * com. spring. service ..*.*(..))")
Public void AfterMethod (){
System. out. println ("After returnning ");
}
2. Specify by defining pointcut:
[Java]
// Define the pointcut woven vertex set
@ Pointcut ("execution (public * com. spring. service ..*.*(..))")
Public void MyMethod (){}
@ Before ("MyMethod ()")
Public void BeforeMethod (){
System. out. println ("method start! ");
}
@ AfterReturning ("MyMethod ()")
Public void AfterMethod (){
System. out. println ("After returnning ");
}
// Intercept before and after execution. Separated by the pjp. proceed Method
@ Around ("MyMethod ()")
Public void aroundProcced (ProceedingJoinPoint pjp) throws Throwable {
System. out. println ("und start ");
Pjp. proceed ();
System. out. println ("und end ");
}
Output result:
Method start!
Und und start
Helloworld
After returnning
Around end
Author: zhang6622056