[유치수] [NOBTS] change project type.

git-svn-id: http://svn.bds.nhncorp.com/pe/hippo-tomcat-profiler/trunk@431 84d0f5b1-2673-498c-a247-62c4ff18d310
This commit is contained in:
Chisu Yu
2012-06-27 02:21:11 +00:00
parent 3be294bc76
commit 34cb3fbd1e
62 changed files with 263 additions and 33 deletions
@@ -0,0 +1,42 @@
package com.profiler.modifier.tomcat;
import static com.profiler.config.TomcatProfilerConstant.CLASS_NAME_AGENT_STATE_MANAGER;
import com.profiler.modifier.AbstractModifier;
import javassist.ClassPool;
import javassist.CtClass;
import javassist.CtMethod;
/**
* When org.apache.catalina.core.StandardService class is loaded in ClassLoader,
* this class modifies methods.
* @author cowboy93
*
*/
public class TomcatStandardServiceModifier extends AbstractModifier{
public static byte[] modify(ClassPool classPool,ClassLoader classLoader,String javassistClassName,byte[] classFileBuffer) {
// printClassInfo(javassistClassName);
return changeMethod(classPool,classLoader,javassistClassName,classFileBuffer);
}
public static byte[] changeMethod(ClassPool classPool,ClassLoader classLoader,String javassistClassName,byte[] classfileBuffer) {
try {
CtClass cc = classPool.get(javassistClassName);
CtMethod startMethod=cc.getDeclaredMethod("start", null);
startMethod.insertBefore("{" +
"System.out.println(\"*** Start TomcatProfiler JVMStat Thread ***\");" +
CLASS_NAME_AGENT_STATE_MANAGER+".startJVMTraceThread();" +
"}");
CtMethod stopMethod=cc.getDeclaredMethod("stop", null);
stopMethod.insertBefore("{" +
"System.out.println(\"*** TomcatProfiler send JVM is stopped info ***\");" +
CLASS_NAME_AGENT_STATE_MANAGER+".sendJVMStoppedInfo();" +
"}");
printClassConvertComplete(javassistClassName);
return cc.toBytecode();
} catch(Exception e) {
e.printStackTrace();
}
return null;
}
}