java - Pass object between before and after advice? -
Is it possible to make an object before advice and it is possible to pass it after the advice? For example, if I have an aspect:
public aspect logging estimation {pointcut allMethods (): execution (* com.foo.Bar. * (..)); First (): allMethods () {SomeObject foo = makeSomeObject (); } After (): allMethods () {// access foo? }}
I can not reference directly foo
because this is not the scope (triggers a compiler error), both are advised that I Foo
can store?
Background: In order to refer to this special invitation of this method, I intend to create a unique identifier and I need it since using it in both the advice, I included it in logging output Will do
Collecting a parameter in my recommended class is not an option (since I want to be unaware of this advice).
You can store it in a member variable, but then think about thread protection. Will happen. Instead I recommend giving advice
around the object (): allMethods () {SomeObject foo = makeSomeObject (); Object rate = moving forward (); Foo.magic (); Return writ; }
Comments
Post a Comment