[강운덕] [LUCYSUS-1744] 생성자 일때의 insertBefore 변경.

git-svn-id: http://svn.bds.nhncorp.com/pe/hippo-tomcat-profiler/trunk@552 84d0f5b1-2673-498c-a247-62c4ff18d310
This commit is contained in:
Woonduk Kang
2012-08-28 08:39:02 +00:00
parent 1295dc9532
commit fc6659ce20
2 changed files with 13 additions and 7 deletions
@@ -7,7 +7,6 @@ import java.util.logging.Logger;
import com.profiler.interceptor.*;
import javassist.*;
import javassist.bytecode.Descriptor;
public class JavaAssistClass implements InstrumentClass {
@@ -95,7 +94,12 @@ public class JavaAssistClass implements InstrumentClass {
if (logger.isLoggable(Level.INFO)) {
logger.info("addStaticBeforeInterceptor catch behavior:" + behavior.getLongName() + " code:" + buildBefore);
}
behavior.insertBefore(buildBefore);
if(behavior instanceof CtConstructor) {
((CtConstructor) behavior).insertBeforeBody(buildBefore);
} else {
behavior.insertBefore(buildBefore);
}
}
private void addGetBeforeInterceptor(int id, StringBuilder code) {
@@ -160,8 +164,9 @@ public class JavaAssistClass implements InstrumentClass {
String constructorName = constructor.getName();
String params = getParamsToString(constructor.getParameterTypes());
// constructor.insertBefore("{System.out.println(\"*****" + javassistClassName + " Constructor:Param=(" + sb + ") is started.\");}");
// constructor.insertAfter("{System.out.println(\"*****" + javassistClassName + " Constructor:Param=(" + sb + ") is finished.\");}");
// constructor.insertAfter("{System.out.println(\"*****" + constructorName + " Constructor:Param=(" + params + ") is finished. \" + $args);}");
// constructor.addCatch("{System.out.println(\"*****" + constructorName + " Constructor:Param=(" + params + ") is finished.\"); throw $e; }"
// , instrumentor.getClassPool().get("java.lang.Throwable"));
addAroundInterceptor(constructorName, id, constructor);
}
return true;