[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Binding pointcut arguments to static values

I don't think you can express that in quite the way you wish, but this
would work in the case you have:

    pointcut foo() : call(public void HelloWorld.foo());
    pointcut bar() : call(public void HelloWorld.bar());

    pointcut interesting() : foo() || bar();
    before() : interesting() {
        String name =(( CodeSignature)
thisJoinPoint.getSignature()).getMethod().getName();
        String typename =(( CodeSignature)
thisJoinPoint.getSignature()).getMethod().getDeclaringClass().getName();
        System.out.println("Going to call method " + name+ " on type
"+typename);
    }

If the data (FOO or BAR) were in an annotation attached to foo() or
bar() you might be able to get closer to your desired syntax, but that
doesn't seem a good solution.

Andy

2009/5/14 Binil Thomas <binil.thomas.public@xxxxxxxxx>:
>
> Hi all,
>
> I am trying to get help with a pointcut I have to write.
>
> Suppose I have two pointcuts:
>    pointcut foo() : call(public void HelloWorld.foo());
>    pointcut bar() : call(public void HelloWorld.bar());
>
> Furthermore, I have this advice:
>    pointcut interesting(String name) : ...
>    before(String name) : interesting(name) {
>        System.out.println("Going to call method of type " + name);
>    }
>
> I want to write the pointcut as (in pseduo-code):
>    pointcut interesting(String name) : foo() && name="FOO" || bar() &&
> name="BAR";
> i.e. when a joinpoint picked out by foo() is encountered I want the name
> argument of interesting() to be "FOO".
>
> How do I go about expressing this?
>
> Thanks,
> Binil
> --
> View this message in context: http://www.nabble.com/Binding-pointcut-arguments-to-static-values-tp23545841p23545841.html
> Sent from the AspectJ - users mailing list archive at Nabble.com.
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>