mirror of
https://github.com/wahyd4/pinpoint.git
synced 2026-08-19 01:35:58 +10:00
[유치수] [NOBTS] add interceptor debugging code.
git-svn-id: http://svn.bds.nhncorp.com/pe/hippo-tomcat-profiler/trunk@532 84d0f5b1-2673-498c-a247-62c4ff18d310
This commit is contained in:
@@ -12,56 +12,51 @@ import com.profiler.modifier.DefaultModifierRegistry;
|
||||
import com.profiler.modifier.Modifier;
|
||||
import com.profiler.modifier.ModifierRegistry;
|
||||
|
||||
|
||||
import com.profiler.config.TomcatProfilerConfig;
|
||||
|
||||
public class TomcatProfiler implements ClassFileTransformer {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(TomcatProfiler.class.getName());
|
||||
private static final Logger logger = Logger.getLogger(TomcatProfiler.class.getName());
|
||||
|
||||
private String agentArgString = "";
|
||||
private Instrumentation instrumentation;
|
||||
private ByteCodeInstrumentor byteCodeInstrumentor;
|
||||
private String agentArgString = "";
|
||||
private Instrumentation instrumentation;
|
||||
private ByteCodeInstrumentor byteCodeInstrumentor;
|
||||
|
||||
private final ModifierRegistry modifierRepository;
|
||||
private TomcatProfilerConfig tomcatProfilerConfig;
|
||||
private final ModifierRegistry modifierRepository;
|
||||
private TomcatProfilerConfig tomcatProfilerConfig;
|
||||
|
||||
public static void premain(String agentArgs, Instrumentation inst) {
|
||||
TomcatProfilerConfig tomcatProfilerConfig = TomcatProfilerConfig.readConfigFile();
|
||||
new TomcatProfiler(agentArgs, inst, tomcatProfilerConfig);
|
||||
}
|
||||
public static void premain(String agentArgs, Instrumentation inst) {
|
||||
TomcatProfilerConfig tomcatProfilerConfig = TomcatProfilerConfig.readConfigFile();
|
||||
new TomcatProfiler(agentArgs, inst, tomcatProfilerConfig);
|
||||
}
|
||||
|
||||
public TomcatProfiler(String agentArgs, Instrumentation inst, TomcatProfilerConfig tomcatProfilerConfig) {
|
||||
this.agentArgString = agentArgs;
|
||||
this.instrumentation = inst;
|
||||
this.instrumentation.addTransformer(this);
|
||||
this.byteCodeInstrumentor = new JavaAssistByteCodeInstrumentor();
|
||||
// this.classPool = createClassPool();
|
||||
this.modifierRepository = createModifierRegistry(byteCodeInstrumentor, tomcatProfilerConfig);
|
||||
this.tomcatProfilerConfig = tomcatProfilerConfig;
|
||||
}
|
||||
public TomcatProfiler(String agentArgs, Instrumentation inst, TomcatProfilerConfig tomcatProfilerConfig) {
|
||||
this.agentArgString = agentArgs;
|
||||
this.instrumentation = inst;
|
||||
this.instrumentation.addTransformer(this);
|
||||
this.byteCodeInstrumentor = new JavaAssistByteCodeInstrumentor();
|
||||
// this.classPool = createClassPool();
|
||||
this.modifierRepository = createModifierRegistry(byteCodeInstrumentor, tomcatProfilerConfig);
|
||||
this.tomcatProfilerConfig = tomcatProfilerConfig;
|
||||
}
|
||||
|
||||
private ModifierRegistry createModifierRegistry(ByteCodeInstrumentor byteCodeInstrumentor, TomcatProfilerConfig tomcatProfilerConfig) {
|
||||
DefaultModifierRegistry modifierRepository = new DefaultModifierRegistry(byteCodeInstrumentor);
|
||||
modifierRepository.addTomcatModifier();
|
||||
if (tomcatProfilerConfig.enableJdbcProfile()) {
|
||||
modifierRepository.addJdbcModifier();
|
||||
}
|
||||
return modifierRepository;
|
||||
}
|
||||
private ModifierRegistry createModifierRegistry(ByteCodeInstrumentor byteCodeInstrumentor, TomcatProfilerConfig tomcatProfilerConfig) {
|
||||
DefaultModifierRegistry modifierRepository = new DefaultModifierRegistry(byteCodeInstrumentor);
|
||||
modifierRepository.addTomcatModifier();
|
||||
if (tomcatProfilerConfig.enableJdbcProfile()) {
|
||||
modifierRepository.addJdbcModifier();
|
||||
}
|
||||
return modifierRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] transform(ClassLoader classLoader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classFileBuffer) throws IllegalClassFormatException {
|
||||
Modifier findModifier = this.modifierRepository.findModifier(className);
|
||||
if (findModifier == null) {
|
||||
return null;
|
||||
}
|
||||
String javassistClassName = className.replace('/', '.');
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public byte[] transform(ClassLoader classLoader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classFileBuffer) throws IllegalClassFormatException {
|
||||
Modifier findModifier = this.modifierRepository.findModifier(className);
|
||||
if (findModifier == null) {
|
||||
return null;
|
||||
}
|
||||
String javassistClassName = className.replace('/', '.');
|
||||
|
||||
return findModifier.modify(classLoader, javassistClassName, classFileBuffer);
|
||||
}
|
||||
return findModifier.modify(classLoader, javassistClassName, classFileBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user