« Return to Thread: Annotations, inner classes and set && withincode

Annotations, inner classes and set && withincode

by Captain Haddock-2 :: Rate this Message:

Reply to Author | View in Thread

Can't seem to get a pointcut to work on a setter that is within a method
of an inner class.

A pointcut on the outer class works fine (see "doSomething").

Also a pointcut of just the "set" or just the "within" works fine, just
not the && of the two.

Any thoughts?

thx in advance, Haddock

package foo;
public class App
{
     private int count;

     public static void main( String[] args )
     {
         try {
             App app = new App();
             app.doSomething();
         } catch (Exception e) {
             e.printStackTrace();
         }

         System.exit(1);
     }

     public App() {
     }

     private void doSomething() {
         System.out.println("> before");
         count = 30;
         System.out.println("> after");
         new App.Inner().innerDoSomething();
     }

     private class Inner {
         private void innerDoSomething() {
             System.out.println(">> before");
             count = 25;
             System.out.println(">> after");
         }
     }
}

package aspects;
@Aspect
public class LoggingAspect {
     @Pointcut("set(int foo.App.count) && withincode(void
foo.App.doSomething())")
     void doSomething() {}

     @Before("doSomething()")
     public void logDoSomething() {
         System.out.println("doSomething()");
     }

     @Pointcut("set(int foo.App.count) && withincode(void
foo.App.Inner.innerDoSomething())")
     void innerDoSomething() {}

     @Before("innerDoSomething()")
     public void logInnerDoSomething() {
         System.out.println("innerDoSomething()");
     }
}

_______________________________________________
aspectj-users mailing list
aspectj-users@...
https://dev.eclipse.org/mailman/listinfo/aspectj-users

 « Return to Thread: Annotations, inner classes and set && withincode