Capture one annotated parameter amongst many

View: New views
4 Messages — Rating Filter:   Alert me  

Capture one annotated parameter amongst many

by Christian Laireiter :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello there,

I've got a little problem, I haven't been able to solve.

What I'd like to have:
Advise executions of methods, which have at least one parameter with a specific annotation (say @NN).

  public void arbitrary (Object param1, Object param2, @NN String param3, Object Param4, ...)

(Consider param3 is a String and point1() will apply)

        public pointcut point1() : execution(* *.* (..,String,..));
       
        public pointcut point2() : execution(* *(..,@NN (String),*,*));
       
        public pointcut point3() : execution(* *(*,*,@NN (String),*,*));
       
        public pointcut point4() : execution(* *(Object,Object,@NN (String),Object,Object));

Now the interesting part here is the pointcut "point1()", which applies to "arbitrary(...)".
Even point2() applies.

However the following does not:

       public pointcut point5 () :execution(* *(..,@NN (String),..));

Do I make a mistake by assuming this should work, or do I misunderstand something ?

---------

If this can be solved, and you are not tired of one more question:

Would there be any way to additionally expose such a parameter ? ( args(..,param,..) is not allowed )


Thank you for reading (and considering to answer :) )

Re: Capture one annotated parameter amongst many

by Andy Clement :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

If:

execution(* *.* (..,String,..))

matches then

execution(* *(..,@NN (String),..))

should too - so that is a bug. I'll take a look at it in a second.

> Would there be any way to additionally expose such a parameter ? (
> args(..,param,..) is not allowed )

This is a problem we`ve had for a while.  There is currently no state
maintained such that the args() can see which thing actually matched
in execution.  For now, you need to grab the thisJoinPoint.getArgs()
and look through yourself in your advice.  I'd like to solve the
general problem of just writing advice that wants any annotated
parameter and you don't care where it is, but I can't get the syntax
right (and have it result in an implementation that can be implemented
in a short period of time).

Andy

2009/10/22 Christian Laireiter <Laireiter@...>:

>
> Hello there,
>
> I've got a little problem, I haven't been able to solve.
>
> What I'd like to have:
> Advise executions of methods, which have at least one parameter with a
> specific annotation (say @NN).
>
>  public void arbitrary (Object param1, Object param2, @NN String param3,
> Object Param4, ...)
>
> (Consider param3 is a String and point1() will apply)
>
>        public pointcut point1() : execution(* *.* (..,String,..));
>
>        public pointcut point2() : execution(* *(..,@NN (String),*,*));
>
>        public pointcut point3() : execution(* *(*,*,@NN (String),*,*));
>
>        public pointcut point4() : execution(* *(Object,Object,@NN
> (String),Object,Object));
>
> Now the interesting part here is the pointcut "point1()", which applies to
> "arbitrary(...)".
> Even point2() applies.
>
> However the following does not:
>
>       public pointcut point5 () :execution(* *(..,@NN (String),..));
>
> Do I make a mistake by assuming this should work, or do I misunderstand
> something ?
>
> ---------
>
> If this can be solved, and you are not tired of one more question:
>
> Would there be any way to additionally expose such a parameter ? (
> args(..,param,..) is not allowed )
>
>
> Thank you for reading (and considering to answer :) )
> --
> View this message in context: http://www.nabble.com/Capture-one-annotated-parameter-amongst-many-tp26021577p26021577.html
> Sent from the AspectJ - users mailing list archive at Nabble.com.
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@...
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
_______________________________________________
aspectj-users mailing list
aspectj-users@...
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Re: Capture one annotated parameter amongst many

by Andy Clement :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Me again,

I raised it as https://bugs.eclipse.org/bugs/show_bug.cgi?id=293203
and just committed the fix.  It will be in an AJ dev build today then
an AJDT in a few days.

(This is the problem of (..,String,..) matching and not (..,@NN (String),..) )

Andy

2009/10/23 Andy Clement <andrew.clement@...>:

> Hi,
>
> If:
>
> execution(* *.* (..,String,..))
>
> matches then
>
> execution(* *(..,@NN (String),..))
>
> should too - so that is a bug. I'll take a look at it in a second.
>
>> Would there be any way to additionally expose such a parameter ? (
>> args(..,param,..) is not allowed )
>
> This is a problem we`ve had for a while.  There is currently no state
> maintained such that the args() can see which thing actually matched
> in execution.  For now, you need to grab the thisJoinPoint.getArgs()
> and look through yourself in your advice.  I'd like to solve the
> general problem of just writing advice that wants any annotated
> parameter and you don't care where it is, but I can't get the syntax
> right (and have it result in an implementation that can be implemented
> in a short period of time).
>
> Andy
>
> 2009/10/22 Christian Laireiter <Laireiter@...>:
>>
>> Hello there,
>>
>> I've got a little problem, I haven't been able to solve.
>>
>> What I'd like to have:
>> Advise executions of methods, which have at least one parameter with a
>> specific annotation (say @NN).
>>
>>  public void arbitrary (Object param1, Object param2, @NN String param3,
>> Object Param4, ...)
>>
>> (Consider param3 is a String and point1() will apply)
>>
>>        public pointcut point1() : execution(* *.* (..,String,..));
>>
>>        public pointcut point2() : execution(* *(..,@NN (String),*,*));
>>
>>        public pointcut point3() : execution(* *(*,*,@NN (String),*,*));
>>
>>        public pointcut point4() : execution(* *(Object,Object,@NN
>> (String),Object,Object));
>>
>> Now the interesting part here is the pointcut "point1()", which applies to
>> "arbitrary(...)".
>> Even point2() applies.
>>
>> However the following does not:
>>
>>       public pointcut point5 () :execution(* *(..,@NN (String),..));
>>
>> Do I make a mistake by assuming this should work, or do I misunderstand
>> something ?
>>
>> ---------
>>
>> If this can be solved, and you are not tired of one more question:
>>
>> Would there be any way to additionally expose such a parameter ? (
>> args(..,param,..) is not allowed )
>>
>>
>> Thank you for reading (and considering to answer :) )
>> --
>> View this message in context: http://www.nabble.com/Capture-one-annotated-parameter-amongst-many-tp26021577p26021577.html
>> Sent from the AspectJ - users mailing list archive at Nabble.com.
>>
>> _______________________________________________
>> aspectj-users mailing list
>> aspectj-users@...
>> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>>
>
_______________________________________________
aspectj-users mailing list
aspectj-users@...
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Re: Capture one annotated parameter amongst many

by Christian Laireiter :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Sweet,

this was fast. Thanks.
This fix will help me a lot.


Christian

Andy Clement wrote:
Me again,

I raised it as https://bugs.eclipse.org/bugs/show_bug.cgi?id=293203
and just committed the fix.  It will be in an AJ dev build today then
an AJDT in a few days.

(This is the problem of (..,String,..) matching and not (..,@NN (String),..) )

Andy

2009/10/23 Andy Clement <andrew.clement@gmail.com>:
> Hi,
>
> If:
>
> execution(* *.* (..,String,..))
>
> matches then
>
> execution(* *(..,@NN (String),..))
>
> should too - so that is a bug. I'll take a look at it in a second.
>
>> Would there be any way to additionally expose such a parameter ? (
>> args(..,param,..) is not allowed )
>
> This is a problem we`ve had for a while.  There is currently no state
> maintained such that the args() can see which thing actually matched
> in execution.  For now, you need to grab the thisJoinPoint.getArgs()
> and look through yourself in your advice.  I'd like to solve the
> general problem of just writing advice that wants any annotated
> parameter and you don't care where it is, but I can't get the syntax
> right (and have it result in an implementation that can be implemented
> in a short period of time).
>
> Andy
>
> 2009/10/22 Christian Laireiter <Laireiter@gmx.de>:
>>
>> Hello there,
>>
>> I've got a little problem, I haven't been able to solve.
>>
>> What I'd like to have:
>> Advise executions of methods, which have at least one parameter with a
>> specific annotation (say @NN).
>>
>>  public void arbitrary (Object param1, Object param2, @NN String param3,
>> Object Param4, ...)
>>
>> (Consider param3 is a String and point1() will apply)
>>
>>        public pointcut point1() : execution(* *.* (..,String,..));
>>
>>        public pointcut point2() : execution(* *(..,@NN (String),*,*));
>>
>>        public pointcut point3() : execution(* *(*,*,@NN (String),*,*));
>>
>>        public pointcut point4() : execution(* *(Object,Object,@NN
>> (String),Object,Object));
>>
>> Now the interesting part here is the pointcut "point1()", which applies to
>> "arbitrary(...)".
>> Even point2() applies.
>>
>> However the following does not:
>>
>>       public pointcut point5 () :execution(* *(..,@NN (String),..));
>>
>> Do I make a mistake by assuming this should work, or do I misunderstand
>> something ?
>>
>> ---------
>>
>> If this can be solved, and you are not tired of one more question:
>>
>> Would there be any way to additionally expose such a parameter ? (
>> args(..,param,..) is not allowed )
>>
>>
>> Thank you for reading (and considering to answer :) )
>> --
>> View this message in context: http://www.nabble.com/Capture-one-annotated-parameter-amongst-many-tp26021577p26021577.html
>> Sent from the AspectJ - users mailing list archive at Nabble.com.
>>
>> _______________________________________________
>> aspectj-users mailing list
>> aspectj-users@eclipse.org
>> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>>
>
_______________________________________________
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users