增强方法也称为通知方法,指标注有@Before、@AfterRunning、@AfterThrowing、@After或@Around注解的Java方法。其中,有前置增强、后置增强、返回增强、异常增强和环绕增强五种增强方式。
前置增强
前置增强(@Before,又称前置通知):在目标方法执行之前执行。
@Pointcut("execution(public int com.jd.calculator.service.CalculatorService.*(..))")
public void pointcut() {
}
//前置增强
@Before("pointcut()")
public void b(JoinPoint jp) {
Object [] args = jp.getArgs();
for (Object object : args) {
System.out.println(object);
}
Signature signature = jp.getSignature();
String name =signature.getName();
System.out.println(name);
System.out.println("The "+name+" method begins");
System.out.println("The "+name+" method args:["</