Is it possible to create an object in a before advice and pass it to an after advice? For instance, if I have the aspect:
public aspect LoggingAspect {
pointcut allMethods() : execution(* com.foo.Bar.*(..));
before() : allMethods() {
SomeObject foo = makeSomeObject();
}
after() : allMethods() {
// access foo?
}
}
I can't directly reference foo
since it's not in scope (triggers a compiler error). Is there some context available to both advices that I can store foo
inside?
Background: I intend to create a unique identifier to refer to this particular invocation of the method and I need access to it in both advices, since I will include it in logging output.
Storing a parameter within my advised class is not an option (since I want it to be unaware of the advice).