What I'm looking for is a way to specify a pointcut around a class level variable. Something like:
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.FIELD)
@interface MyPointCut
{
}
public class Foo
{
@MyPointCut
BarAPI api = new BarAPI();
}
@Aspect
public class MyAspect
{
@Around(value="execution(* *(..)) && @annotation(MyPointCut)")
public Object doSomethingBeforeAndAfterEachMethodCall()
{
...
}
}
I would then like to have an aspect that performs some work before and after each method invocation of the api field. Is this doable? Could you please point me to some documentation where I can read how to do it?