比方說,你有三個建議:各地,之前和後。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範例,並查看現有工具的文檔。我認爲最好問問那裏的專家,但如果沒有人能夠幫助我,這就是我最後要做的。 –