1

我有以下课程:

package Test;
public class A
{
    private B b = new B()
    {
       @Override
       public boolean someFunc() {return false;}
    }
 }

什么是 AspectJ 切入点来捕获 someFunc 的执行,同时获得对外部类 A 的引用?

我试过了:

pointcut captureExec(): within(Test.A) && execution(boolean Test.B+.someFunc());
before(): captureExec()
{
    //here thisJoinPount.getTarget() returns object to class B, 
    //but I need reference object to the outer class A
}

谢谢

4

1 回答 1

0

应该是这样的:

pointcut captureExec(Test.A a): within(a) && execution(boolean Test.B+.someFunc());
before(Test.A a): captureExec(a) 
{
    if(a==blah) ...
}

虽然没试过

于 2013-01-23T12:02:26.833 回答