Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Pointcut based on field annotation

I've searched around and looked through the documentation but can't seem to
find a way to create a pointcut for the following situation. 

Is there a way to match any calls when the target of a function call is a
field/member annotated with a particular annotation? I know this is very
simple if the type of the field is annotated, as I would just add an @target
pointcut. I have tried to play around with the cflow poincuts, but the
function call I'd like to advise is not within the cflow of the field
access, but after.

Here is the situation expressed in code:

public class TestItem {
   @Weak public Collection<String> values;
   ...
}


TestItem item = new TestItem(...)
item.values.add("foo"); // want to advise this function call add


// my poor attempts thus far
1. after() : call(* *.*(..)) && @annotation(Weak) 
2. after() : call(* *.*(..)) && @target(Weak)     // the type isn't
annotated, the field is
3. after() : cflowbelow(get(@Weak Object+ *.*)) && call(* *.*(..))     //
the function call is not in the control flow of the field access


Is this behavior supported by aspectj in any way? Have I overlooked a
solution? It seems like another pointcut may be added, like @field(X), which
matches join points where the target is a field/member annotated with X.

Thanks in advance,
Mike
-- 
View this message in context: http://www.nabble.com/Pointcut-based-on-field-annotation-tp18795275p18795275.html
Sent from the AspectJ - users mailing list archive at Nabble.com.



Back to the top