mirror of
https://github.com/wahyd4/pinpoint.git
synced 2026-08-20 18:25:55 +10:00
[강운덕] [LUCYSUS-1744] tracevariable 추가api를 별도 클래스로 추출.
git-svn-id: http://svn.bds.nhncorp.com/pe/hippo-tomcat-profiler/trunk@577 84d0f5b1-2673-498c-a247-62c4ff18d310
This commit is contained in:
@@ -4,12 +4,7 @@ import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javassist.CannotCompileException;
|
||||
import javassist.CtBehavior;
|
||||
import javassist.CtClass;
|
||||
import javassist.CtConstructor;
|
||||
import javassist.CtMethod;
|
||||
import javassist.NotFoundException;
|
||||
import javassist.*;
|
||||
|
||||
import com.profiler.interceptor.Interceptor;
|
||||
import com.profiler.interceptor.InterceptorRegistry;
|
||||
@@ -34,6 +29,29 @@ public class JavaAssistClass implements InstrumentClass {
|
||||
return ctClass;
|
||||
}
|
||||
|
||||
// TODO return type을 별도 exception으로 할지 추가 검토가 필요함.
|
||||
public boolean addTraceVariable(String variableName, String setterName, String getterName, String variableType) {
|
||||
try {
|
||||
CtClass type = instrumentor.getClassPool().get(variableType);
|
||||
CtField traceVariable = new CtField(type, variableName, ctClass);
|
||||
ctClass.addField(traceVariable);
|
||||
CtMethod setterMethod = CtNewMethod.setter(setterName, traceVariable);
|
||||
ctClass.addMethod(setterMethod);
|
||||
CtMethod getterMethod = CtNewMethod.getter(getterName, traceVariable);
|
||||
ctClass.addMethod(getterMethod);
|
||||
return true;
|
||||
} catch (NotFoundException e) {
|
||||
if (logger.isLoggable(Level.WARNING)) {
|
||||
logger.log(Level.WARNING, e.getMessage(), e);
|
||||
}
|
||||
} catch (CannotCompileException e) {
|
||||
if (logger.isLoggable(Level.WARNING)) {
|
||||
logger.log(Level.WARNING, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addInterceptor(String methodName, String[] args, Interceptor interceptor) {
|
||||
return addInterceptor(methodName, args, interceptor, Type.auto);
|
||||
|
||||
Reference in New Issue
Block a user