Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Question about matching JoinPoints

I don't have the time right now to create a fully fleshed out example,
but grabbing the method from the joinpoint object is where to start:

MethodSignature ms = (MethodSignature)thisJoinPointStaticPart.getSignature();
ms.getMethod().invoke();

Andy

On 13 November 2011 17:44, Andres Barrera <andres397@xxxxxxxxx> wrote:
> I think I can try it. Could you please explain me with some code how to do
> that? thank you
>
> On Sat, Nov 12, 2011 at 10:46 PM, Andy Clement <andrew.clement@xxxxxxxxx>
> wrote:
>>
>> Hi,
>>
>> AspectJ doesn't really support that kind of thing.
>>
>> If the pointcut you want to 'catch it again' can be an execution
>> pointcut, you could feasibly use reflection to invoke the joinpoint
>> again from your method (thisJoinPoint contains everything you need to
>> invoke it), then when it runs again the advice will fire again.
>>
>> Andy
>>
>> On 12 November 2011 12:19, Andres Barrera <andres397@xxxxxxxxx> wrote:
>> > Ok, what I mean is that, for example, I have some pointcuts and advices
>> > in
>> > an aspect, but also I have a method that receives a JoinPoint object. I
>> > need
>> > to declare a new Pointcut with that JoinPoint object, inside the method,
>> > so
>> > an advice can catch it. Its something like this:
>> > public aspect a1
>> > {
>> > pointcut p1(): call(* Class.method(*));
>> > before(): p1()
>> > {
>> > System.out.println("Inside the advice");
>> > method(thisJoinPoint);
>> > }
>> > public static void method(JoinPoint join)
>> > {
>> > //Evaluate it or match it, so advice can catch it again
>> > }
>> > }
>> > Thank you,
>> >
>> >
>> > On Sat, Nov 12, 2011 at 12:01 PM, Andy Clement
>> > <andrew.clement@xxxxxxxxx>
>> > wrote:
>> >>
>> >> Hi,
>> >>
>> >> Not quite sure what you want to achieve here, maybe share some
>> >> pseudocode that shows your intention?
>> >>
>> >> Once you have the joinpoint object it isn't used for matching a second
>> >> time.  If you want to advise advice, you use a pointcut that matches
>> >> it, like adviceexecution().
>> >>
>> >> If you want to 'call' some advice in a more direct way rather than
>> >> rely on implicit invocation, perhaps you could use annotation style
>> >> aspects and then call the advice directly passing everything it needs.
>> >>  (since the advice methods are not 'anonymous' like they are in code
>> >> style aspects).
>> >>
>> >> Andy
>> >>
>> >> On 11 November 2011 07:42, Andres Barrera <andres397@xxxxxxxxx> wrote:
>> >> > Hello, I got a question, I have a JoinPoint instance (for example,
>> >> > the
>> >> > one
>> >> > that you get when you use thisJoinPoint keyword), I´m receiving it
>> >> > from
>> >> > another aspect, and I need to match it in the receiving aspect, so an
>> >> > advice
>> >> > can intercept it. How can I do that?
>> >> > Thank you,
>> >> >
>> >> > --
>> >> > Andrés Barrera
>> >> >
>> >> > _______________________________________________
>> >> > aspectj-users mailing list
>> >> > aspectj-users@xxxxxxxxxxx
>> >> > https://dev.eclipse.org/mailman/listinfo/aspectj-users
>> >> >
>> >> >
>> >> _______________________________________________
>> >> aspectj-users mailing list
>> >> aspectj-users@xxxxxxxxxxx
>> >> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>> >
>> >
>> >
>> > --
>> > Andrés Barrera
>> >
>> > _______________________________________________
>> > aspectj-users mailing list
>> > aspectj-users@xxxxxxxxxxx
>> > https://dev.eclipse.org/mailman/listinfo/aspectj-users
>> >
>> >
>> _______________________________________________
>> aspectj-users mailing list
>> aspectj-users@xxxxxxxxxxx
>> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
>
> --
> Andrés Barrera
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>


Back to the top