mirror of
https://github.com/wahyd4/pinpoint.git
synced 2026-08-21 10:45:59 +10:00
[강운덕] [LUCYSUS-1744] classPathResolver기반으로 lib의 위치를 획득할수 있도록 변경. lib의 위치를 기반으로 config 파일을 획득하므로 명시적으로 위치를 지정하지 않아도 자동으로 위치를 찾게 수정
git-svn-id: http://svn.bds.nhncorp.com/pe/hippo-tomcat-profiler/trunk@1356 84d0f5b1-2673-498c-a247-62c4ff18d310
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
package com.profiler;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.instrument.ClassFileTransformer;
|
||||
import java.lang.instrument.IllegalClassFormatException;
|
||||
import java.lang.instrument.Instrumentation;
|
||||
import java.net.URL;
|
||||
import java.security.ProtectionDomain;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
@@ -38,11 +41,19 @@ public class TomcatProfiler implements ClassFileTransformer {
|
||||
if (agentArgs != null) {
|
||||
logger.info("HIPPO agentArgs:" + agentArgs);
|
||||
}
|
||||
dumpSystemProperties();
|
||||
// dumpSystemProperties();
|
||||
|
||||
ClassPathResolver classPathResolver = new ClassPathResolver();
|
||||
boolean agentJarNotFound = classPathResolver.findAgentJar();
|
||||
if (!agentJarNotFound) {
|
||||
logger.severe("hippo-tomcat-profiler-x.x.x.jar not found.");
|
||||
return;
|
||||
}
|
||||
// 이게 로드할 lib List임.
|
||||
List<URL> libUrlList = resolveLib(classPathResolver);
|
||||
|
||||
try {
|
||||
ProfilerConfig profilerConfig = new ProfilerConfig();
|
||||
profilerConfig.readConfigFile();
|
||||
ProfilerConfig profilerConfig = readConfig(classPathResolver);
|
||||
if (!profilerConfig.isProfileEnable()) {
|
||||
logger.warning("Profiler Agent not started. profile.enable=" + profilerConfig.isProfileEnable());
|
||||
return;
|
||||
@@ -54,6 +65,35 @@ public class TomcatProfiler implements ClassFileTransformer {
|
||||
}
|
||||
}
|
||||
|
||||
private static ProfilerConfig readConfig(ClassPathResolver classPathResolver) throws IOException {
|
||||
|
||||
ProfilerConfig profilerConfig = new ProfilerConfig();
|
||||
String hippoConfigFormSystemProperty = findHippoConfigFormSystemProeprty();
|
||||
if (hippoConfigFormSystemProperty != null) {
|
||||
profilerConfig.readConfigFile(hippoConfigFormSystemProperty);
|
||||
} else {
|
||||
String agentConfigPath = classPathResolver.getAgentConfigPath();
|
||||
profilerConfig.readConfigFile(agentConfigPath);
|
||||
}
|
||||
return profilerConfig;
|
||||
}
|
||||
|
||||
private static List<URL> resolveLib(ClassPathResolver classPathResolver) {
|
||||
String agentJarFullPath = classPathResolver.getAgentJarFullPath();
|
||||
logger.info("agentJarPath:" + agentJarFullPath);
|
||||
|
||||
String agentLibPath = classPathResolver.getAgentLibPath();
|
||||
logger.info("agentLibPath:" + agentLibPath);
|
||||
|
||||
List<URL> urlList = classPathResolver.resolveLib();
|
||||
logger.info("agent lib list:" + urlList);
|
||||
|
||||
String agentConfigPath = classPathResolver.getAgentConfigPath();
|
||||
logger.info("agent config:" + agentConfigPath);
|
||||
|
||||
return urlList;
|
||||
}
|
||||
|
||||
private static void dumpSystemProperties() {
|
||||
if (logger.isLoggable(Level.FINE)) {
|
||||
Properties properties = System.getProperties();
|
||||
@@ -78,6 +118,15 @@ public class TomcatProfiler implements ClassFileTransformer {
|
||||
this.modifierRepository = createModifierRegistry();
|
||||
}
|
||||
|
||||
public static String findHippoConfigFormSystemProeprty() {
|
||||
String hippoConfigFileName = System.getProperty("hippo.config");
|
||||
if (hippoConfigFileName == null) {
|
||||
return null;
|
||||
}
|
||||
logger.info("hippo.config property found. " + hippoConfigFileName);
|
||||
return hippoConfigFileName;
|
||||
}
|
||||
|
||||
private String[] getTomcatlibPath() {
|
||||
String catalinaHome = System.getProperty("catalina.home");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user