2016-09-28 7 views
0

アノテーションスタイルを使用してAndroidStudioでAspectJプロジェクトを作成しようとしているときに、 "シンボル変数thisJoinPointを見つけることができません"を解決するにはどうすればよいですか?シンボル変数thisJoinPointを見つけることができません

プラットフォームの詳細:AspectJの1.8.1、AndroidStudio 2.1.3

コード例:私はちょうど、注釈のスタイルのために、我々はthisJoinPointを宣言する必要があることを発見いくつかのテストと研究の後

import org.aspectj.lang.JoinPoint.*;   // Not used! 
import org.aspectj.lang.ProceedingJoinPoint; // Not used! 
import org.aspectj.lang.annotation.After; 
import org.aspectj.lang.annotation.Pointcut; 

@Aspect 
public class MyAspect { 
    @Pointcut("execution(* *(..))") 
    public void methodExecution() {} 

    @After("methodExecution()") 
    public void accessThisJoinPointData() { 
     if (thisJointPoint != null) { // HERE the variable isn’t recognized! 
      // Do something with thisJoinPoint... 
     } 
    } 
} 

答えて

0

アドバイスのパラメータとして使用します。だから、問題は次のように解決される。

@After("methodExecution()") 
    public void accessThisJoinPointData(JoinPoint thisJoinPoint) { 
     if (thisJointPoint != null) { // Now the variable can be recognized! 
      // Do something with thisJoinPoint... 
     } 
} 

参考:

「アドバイス本体はthisJoinPoint、thisJoinPointStaticPartにアクセスする必要がある場合は、注釈のスタイルを使用した場合、thisEnclosingJoinPointStaticPartが、これらは、追加のメソッドのパラメータとして宣言する必要があります。 "

https://eclipse.org/aspectj/doc/released/adk15notebook/ataspectj-pcadvice.html

関連する問題