This content has been marked as final.
Show 3 replies
-
1. Re: Logging Example
chiba May 29, 2003 11:31 PM (in response to chris_grind)You're right.
Since the before advice and the after advice belong
to separate scopes, "start" cannot be shared among
them. Fixing this problem is in my Todo list but, sorry,
I haven't done it. :<
A quick fix is to make "start" be a static field. -
2. Re: Logging Example
ravipal Jun 9, 2003 1:07 AM (in response to chris_grind)Hi,
There is a way to achieve the same in Javassist though:
You can use ExpEditor class to modify the method body and hence you could use the same Object /variable without declaring static.
e.g :
method.instrument(
//
new ExprEditor() {
public void edit(MethodCall m) throws CannotCompileException{
m.replace("{"+
"long start = System.currentMillis...();"+
"$_ = $proceed($$);"+
"System.out.println(System.current....-start);"+
"}");
}
}
); -
3. Re: Logging Example
ravipal Jun 9, 2003 1:09 AM (in response to chris_grind)sorry for being abstract.. but please ignore the syntax part.
Thanks
Ravi