[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[List Home]
|
Re: [aspectj-users] How to retrieve a parent argument.
|
- From: Adrian Colyer <adrian.colyer@xxxxxxxxx>
- Date: Thu, 10 Nov 2005 09:18:56 +0000
- Delivered-to: aspectj-users@eclipse.org
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=SpDI9g6DX+1so/wrFE+/tjApQQDso39teTBOUDiMb+GzyrZmcbIX1gQ0y+6NWCvvuYut9Wo8q0kBkimHlI6p6EcQeK8N6TvQWuVZlHa6nksaL1wfbDFcArCBT2K4++LYhvS0qHFhGU/P7N88kKQtiS6avfBWqmgVd6/G87rvDGI=
On 03/11/05, Laurent Burgy <burgy@xxxxxxxxxx> wrote:
> Hi all,
>
> maybe it's really simple but i didn't know how to do...
>
> if i have:
>
> public void m1( int foo ) {
>
> m2();
> m3();
>
> }
>
> If i want to do something around m2 considering the value of foo, how
> may i do it?
>
> public void m1( int foo) {
>
> if( foo < 42 )
> titi.m2();
> else
> toto.m4();
>
> tutu.m3();
> }
>
> How can i retrieve the value of foo or a reference to it ?
> In the same time, how can I retrieve a reference to the current object (
> the one to which "this" refers in the m1 method ) ?
>
>
>
> Regards,
>
> PS: Sorry for my english
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
You need to bind the foo argument of m1 in a control-flow context so
that it is available at join points in the cflow below the execution
of m1. For example:
pointcut m1Execution(int foo) : execution(* m1(..)) && args(foo);
pointcut callTo_m2() : call(* m2(..));
Object around(int foo) : callTo_m2() && cflowbelow(m1Execution(foo)) {
// now you can use foo in the advice body, e.g.
if (foo > 5) {.....
return proceed(29);
}
}
--
-- Adrian
adrian.colyer@xxxxxxxxx