[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
RE: [aspectj-users] Pointcut to calls to a specific field
|
Hi,
I'm still not happy with the field test in the advice. Is there really
no static way to capture field specific join points?
A new idea is to test the field reference within the pointcut
definition:
pointcut add(MyContainer container, Object child, Collection c) :
call(boolean Collection.add(Object)) && this(container) &&
args(child) && target(c) && if(c == container.children);
This works also with a "clean" advice. But we still need the Collection
parameter for the if statement. And the join point annotations in
Eclipse still show up at the local Collection.add() calls.
Has somebody a hint or a correction to my approaches? There must be
several situations for capturing calls to specific field members. I've
found the get-access definition, but I don't see a way to connect it to
a following call.
Thanks,
Bruno
> -----Original Message-----
> From: aspectj-users-admin@xxxxxxxxxxx
> [mailto:aspectj-users-admin@xxxxxxxxxxx] On Behalf Of Bruno Feurer
> Sent: Friday, June 18, 2004 16:16
> To: aspectj-users@xxxxxxxxxxx
> Subject: [aspectj-users] Pointcut to calls to a specific field
>
>
> Hi there,
>
> how can I define a pointcut picking out calls to specific field?
>
> ...
> this.children.add(someObj);
> ...
>
> definitions like
>
> pointcut add(MyContainer container, Object child) :
> call(boolean Collection.add(Object)) && this(container)
> && args(child);
>
> also match
>
> ...
> Collection c = new ArrayList();
> c.add(someObject);
> ...
>
> So I came up with the following solution:
>
> pointcut add(MyContainer container, Object child, Collection c) :
> call(boolean Collection.add(Object)) && this(container) &&
> args(child) && target(c);
>
> after(MyContainer container, Object child, Collection c) :
> add(container, child, c) {
> if (c != container.children)
> return;
> ...
> }
>
> Has somebody found a better solution? Some definition
> limiting the pointcut only to a specified field or something alike?
>
> Thanks for any ideas,
> Bruno Feurer
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/aspect> j-users
>