比方说,你有三个建议:各地,之前和后。AspectJ的“左右”和“前进”与“前/后”
1)前/后调用时进行在周围建议被调用, 或者是他们叫前/后的周围建议作为一个整体?
2)如果我各地意见不叫进行, 会把前/后建议无论如何运行?
比方说,你有三个建议:各地,之前和后。AspectJ的“左右”和“前进”与“前/后”
1)前/后调用时进行在周围建议被调用, 或者是他们叫前/后的周围建议作为一个整体?
2)如果我各地意见不叫进行, 会把前/后建议无论如何运行?
与这个测试
@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);
}
}
我具有以下执行之前在围绕输出
所以你可以看到前/后不叫
Thx为您的答案。它真的帮了大忙! –
非常感谢!!!!! – IloveIniesta
我会想象这是容易测试的;有没有一个特定的问题阻止你这样做? –
@DaveNewton嗯,我不是Java开发人员,也没有可用的环境。我用另一种语言移植AOP范例,并查看现有工具的文档。我认为最好问问那里的专家,但如果没有人能够帮助我,这就是我最后要做的。 –