博主脑子短路的操作
今天在研究aop的时候发现了一种神奇的情况:
首先,包结构如下:
包结构下有com.yankaizhang.aoptest.controller.Test.show()方法
情况1
想要分别在三个不同层级下,对show方法进行切入操作,三个层次的切面表达式如下:
- com.yankaizhang.aoptest.controller.Test1.*
- com.yankaizhang.aoptest.controller.*.*
- com.yankaizhang.aoptest.*.*.*
于是我写了一个切点类:
@Aspect
@Component
public class LogAspect {
@Before("execution(* com.yankaizhang.aoptest.controller.Test1.*(..))")
public void before1(){
System.out.println("before1");
}
@Before("execution(* com.yankaizhang.aoptest.controller.*.*(..))")
public void before2(){
System.out.println("before2");
}
@Before("execution(* com.yankaizhang.aoptest.*.*.*(..))")
public void before3(){
System.out.println("before3");
}
@AfterReturning("execution(* com.yankaizhang.aoptest.controller.Test1.*(..))")
public void after1(){
System.out.println("after1");
}
@AfterReturning("execution(* com.yankaizhang.aoptest.controller.*.*(..))")
public void after2(){
System.out.println("after2");
}
@AfterReturning