いくつかの「周りの」アドバイスに共通のコードを実行する必要があります。だから、私は共通コードを関数に移しました。しかし、私が持っている問題は、proceed()がこの共通関数の中で動作しないということです。以下のコードをご覧ください。'around'アドバイスの内容を別の関数から実行できますか?
aspect MyAspect {
pointcut myPointCut() : execution(* com.test.MyTestInterface.*(..));
Object around() : myPointCut() {
Object retVal = null;
try {
ProceedingJoinPoint pjp = (ProceedingJoinPoint) thisJoinPoint;
myfunction(pjp);
} catch (Throwable e) {
e.printStackTrace();
}
return retVal;
}
public void myfunction(ProceedingJoinPoint pjp) {
System.out.println("Inside myfunction()" + pjp.getSignature());
pjp.proceed();
}
}
thisJoinPointをProceedingJoinPointにキャストする機能が動作しません。 "inside myfunction()"が出力されますが、次のステートメントはpointcutによって傍受されたメソッドを実行しません。
これを達成する方法はありますか?
ありがとう、@フレッド。これはまさに私がやったことです。私は昨日それを理解し、私はこのフォーラムに復帰し、更新を残すことに注意しなければならなかった。あなたは私にそれを打つ! –