Hi there again

This pointcut sounds right, but the aspect is not applied at all.

around() : get(@Annotation * *.*) -> Matches everything correctly, but no 
return value bound
around(Object val) : get(@Annotation * *.*) && args(val) -> Matches nothing

I tried to fiddle with the proceedingJoinPoint.proceed() to get the field 
access return value, but this always returns null.

Any ideas?

Regards
Mirko

-----Ursprüngliche Nachricht-----
Von: aspectj-users-boun...@eclipse.org 
[mailto:aspectj-users-boun...@eclipse.org] Im Auftrag von Sertic Mirko, Bedag
Gesendet: Freitag, 19. Oktober 2012 08:53
An: aspectj-users@eclipse.org
Betreff: Re: [aspectj-users] Intercepting field access and thread-safety

argg, yes, of course, you are right.

Regards
Mirko

-----Ursprüngliche Nachricht-----
Von: aspectj-users-boun...@eclipse.org 
[mailto:aspectj-users-boun...@eclipse.org] Im Auftrag von Romain MULLER
Gesendet: Freitag, 19. Oktober 2012 08:14
An: aspectj-users@eclipse.org
Betreff: Re: [aspectj-users] Intercepting field access and thread-safety

You'll want to use:

around(Object val) : get(@Annotation * *.*) && args(val) {...}

_________________________
Sent over RFC-1149 compliant transport - please excuse occasionnal packet loss

Le 19 oct. 2012 à 08:09, "Sertic Mirko, Bedag" <mirko.ser...@bedag.ch> a écrit :

> Hi Andy
>
> No problem, and yes, this is exactly what i want. I didn't know that it is 
> possible to use an around advice with field get access. Thank you. What would 
> be the pointcut for every field get access, regardless of the field type? I 
> need to pass also the original value of the field, so i can change it in 
> advice.
>
> I think the expression would be:
>
> get(@MyAnnotation * *.*)
>
> but how do i pass original value?
>
> Regards
> Mirko
>
> -----Ursprüngliche Nachricht-----
> Von: aspectj-users-boun...@eclipse.org 
> [mailto:aspectj-users-boun...@eclipse.org] Im Auftrag von Andy Clement
> Gesendet: Freitag, 19. Oktober 2012 04:53
> An: aspectj-users@eclipse.org
> Betreff: Re: [aspectj-users] Intercepting field access and 
> thread-safety
>
> Hi,
>
> Sorry for the late reply, we are all at Spring One 2GX.  How about:
>
> public class Code {
>  int i = 5;
>  public static void main(String[] argv) {
>    new Code().foo();
>  }
>  public void foo() {
>    System.out.println(i);
>  }
> }
>
> aspect X {
>  int around(): get(int Code.i) {
>    return 42;
>  }
> }
>
> Does that do what you want?
>
> Andy
>
> On 16 October 2012 12:16, Sertic Mirko, Bedag <mirko.ser...@bedag.ch> wrote:
>> Hi there
>>
>> I'd like to know if it's possible to incercept a get field access 
>> using AspectJ and modify the returned value.
>>
>> Of course i could modify the field and set a new value using a before 
>> advice, but if the affected instance would be used in a multi 
>> threaded environment, this could lead to unwanted race conditions. So 
>> it is possible to intercept a field get access and return a defined 
>> value without modifying the original value of the field?
>>
>> Thanks a lot
>>
>> Mirko
>>
>>
>> _______________________________________________
>> 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
> _______________________________________________
> 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
_______________________________________________
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to