[강운덕] [LUCYSUS-1744] agent의 config 파일 수정.

git-svn-id: http://svn.bds.nhncorp.com/pe/hippo-tomcat-profiler/trunk@718 84d0f5b1-2673-498c-a247-62c4ff18d310
This commit is contained in:
Woonduk Kang
2012-09-27 07:40:01 +00:00
parent 0e106a93b6
commit e3052bcb35
24 changed files with 450 additions and 403 deletions
+28 -22
View File
@@ -1,5 +1,12 @@
package com.profiler;
import com.profiler.config.ProfilerConfig;
import com.profiler.interceptor.bci.ByteCodeInstrumentor;
import com.profiler.interceptor.bci.JavaAssistByteCodeInstrumentor;
import com.profiler.modifier.DefaultModifierRegistry;
import com.profiler.modifier.Modifier;
import com.profiler.modifier.ModifierRegistry;
import java.lang.instrument.ClassFileTransformer;
import java.lang.instrument.IllegalClassFormatException;
import java.lang.instrument.Instrumentation;
@@ -7,14 +14,6 @@ import java.security.ProtectionDomain;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.profiler.interceptor.bci.ByteCodeInstrumentor;
import com.profiler.interceptor.bci.JavaAssistByteCodeInstrumentor;
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());
@@ -24,21 +23,26 @@ public class TomcatProfiler implements ClassFileTransformer {
private ByteCodeInstrumentor byteCodeInstrumentor;
private final ModifierRegistry modifierRepository;
private TomcatProfilerConfig tomcatProfilerConfig;
private ProfilerConfig profilerConfig;
public static void premain(String agentArgs, Instrumentation inst) {
TomcatProfilerConfig tomcatProfilerConfig = TomcatProfilerConfig.readConfigFile();
new TomcatProfiler(agentArgs, inst, tomcatProfilerConfig);
try {
ProfilerConfig profilerConfig = new ProfilerConfig();
profilerConfig.readConfigFile();
new TomcatProfiler(agentArgs, inst, profilerConfig);
} catch (Exception e) {
logger.log(Level.SEVERE, "Profiler Agent start fail. Cause:" + e.getMessage(), e);
}
}
public TomcatProfiler(String agentArgs, Instrumentation inst, TomcatProfilerConfig tomcatProfilerConfig) {
public TomcatProfiler(String agentArgs, Instrumentation inst, ProfilerConfig profilerConfig) {
this.agentArgString = agentArgs;
this.instrumentation = inst;
this.instrumentation.addTransformer(this);
this.profilerConfig = profilerConfig;
this.instrumentation = inst;
this.instrumentation.addTransformer(this);
String[] paths = getTomcatlibPath();
this.byteCodeInstrumentor = new JavaAssistByteCodeInstrumentor(paths);
this.modifierRepository = createModifierRegistry(byteCodeInstrumentor, tomcatProfilerConfig);
this.tomcatProfilerConfig = tomcatProfilerConfig;
this.byteCodeInstrumentor = new JavaAssistByteCodeInstrumentor(paths);
this.modifierRepository = createModifierRegistry(byteCodeInstrumentor);
}
@@ -53,12 +57,14 @@ public class TomcatProfiler implements ClassFileTransformer {
return new String[] {catalinaHome + "/lib/servlet-api.jar", catalinaHome + "/lib/catalina.jar"};
}
private ModifierRegistry createModifierRegistry(ByteCodeInstrumentor byteCodeInstrumentor, TomcatProfilerConfig tomcatProfilerConfig) {
DefaultModifierRegistry modifierRepository = new DefaultModifierRegistry(byteCodeInstrumentor);
private ModifierRegistry createModifierRegistry(ByteCodeInstrumentor byteCodeInstrumentor) {
DefaultModifierRegistry modifierRepository = new DefaultModifierRegistry(byteCodeInstrumentor, profilerConfig);
modifierRepository.addTomcatModifier();
if (tomcatProfilerConfig.enableJdbcProfile()) {
modifierRepository.addJdbcModifier();
}
// jdbc
modifierRepository.addJdbcModifier();
// rpc
modifierRepository.addConnectorModifier();
return modifierRepository;
}