1

I have the following class:

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

What is the AspectJ pointcut to capture execution of someFunc, and at the same time get a reference to outer class A?

I tried:

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
}

Thanks

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 に答える