Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] how to intercept joinpoints ...

I was wondering if the following pointcut could do this:

pointcut x(): adviceexecution() && within(Aspect1);

[]'s,
Davi Pires

On 10/20/06, Fabio Fagundes Silveira <ffs@xxxxxx> wrote:
Hello,

  Is it possible to intercept an before, around or an after defined in
an aspect?

  Let's suppose that method "m1" of class Foo is an advised method.

public class Foo {
        public void m1() {
                System.out.println("I'm on m1");
        }

        public static void main(String[] args) {
                Foo foo = new Foo();
                foo.m1();
        }
}

public aspect Aspect1 {
        pointcut pc(): execution(* Foo.m1(..));

        before(): pc() {
                System.out.println("I'm before m1");
        }

        after(): pc() {
                System.out.println("I'm after m1");
        }

}


   This way, m1 is correctly being intercepted, ok? The output is of course:

I'm before m1
I'm on m1
I'm after m1

So far so good ... But I would like to implement an aspect that  could
print something like:

I'm before before m1
I'm before m1
I'm after before m1

I'm on m1

I'm before after m1
I'm after m1
I'm after after m1


(ie. an before and an after of an before, and an before and a after of
an after)

Is it possible?

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


Back to the top