比方说,你有三个建议:各地,之前和之后.
1)为前/后调用时继续被称为在各地的意见,或者他们所谓的前/后的周围建议作为一个整体?
2)如果我的周围建议没有调用继续,那么是否会运行之前/之后的建议?
Fra*_* M. 38
有了这个测试
@Aspect
public class TestAspect {
private static boolean runAround = true;
public static void main(String[] args) {
new TestAspect().hello();
runAround = false;
new TestAspect().hello();
}
public void hello() {
System.err.println("in hello");
}
@After("execution(void aspects.TestAspect.hello())")
public void afterHello(JoinPoint joinPoint) {
System.err.println("after " + joinPoint);
}
@Around("execution(void aspects.TestAspect.hello())")
public void aroundHello(ProceedingJoinPoint joinPoint) throws Throwable {
System.err.println("in around before " + joinPoint);
if (runAround) {
joinPoint.proceed();
}
System.err.println("in around after " + joinPoint);
}
@Before("execution(void aspects.TestAspect.hello())")
public void beforeHello(JoinPoint joinPoint) {
System.err.println("before " + joinPoint);
}
}
Run Code Online (Sandbox Code Playgroud)
我有以下输出
所以你可以看到之前/之后没有被调用
| 归档时间: |
|
| 查看次数: |
22871 次 |
| 最近记录: |