[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-users] How to retrieve a parent argument.
|
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