mirror of
https://github.com/wahyd4/pinpoint.git
synced 2026-08-22 19:27:13 +10:00
git-svn-id: http://svn.bds.nhncorp.com/pe/hippo-tomcat-profiler/trunk@880 84d0f5b1-2673-498c-a247-62c4ff18d310
51 lines
2.0 KiB
Java
51 lines
2.0 KiB
Java
package com.profiler.modifier.db.mysql;
|
|
|
|
import java.security.ProtectionDomain;
|
|
import java.util.logging.Level;
|
|
import java.util.logging.Logger;
|
|
|
|
import com.profiler.interceptor.Interceptor;
|
|
import com.profiler.interceptor.bci.InstrumentException;
|
|
import com.profiler.modifier.db.interceptor.StatementExecuteQueryInterceptor;
|
|
|
|
import com.profiler.interceptor.bci.ByteCodeInstrumentor;
|
|
import com.profiler.interceptor.bci.InstrumentClass;
|
|
import com.profiler.modifier.AbstractModifier;
|
|
|
|
public class MySQLStatementModifier extends AbstractModifier {
|
|
|
|
private final Logger logger = Logger.getLogger(MySQLStatementModifier.class.getName());
|
|
|
|
public MySQLStatementModifier(ByteCodeInstrumentor byteCodeInstrumentor) {
|
|
super(byteCodeInstrumentor);
|
|
}
|
|
|
|
public String getTargetClass() {
|
|
return "com/mysql/jdbc/StatementImpl";
|
|
}
|
|
|
|
public byte[] modify(ClassLoader classLoader, String javassistClassName, ProtectionDomain protectedDomain, byte[] classFileBuffer) {
|
|
if (logger.isLoggable(Level.INFO)) {
|
|
logger.info("Modifing. " + javassistClassName);
|
|
}
|
|
|
|
byteCodeInstrumentor.checkLibrary(classLoader, javassistClassName);
|
|
|
|
try {
|
|
InstrumentClass statementClass = byteCodeInstrumentor.getClass(javassistClassName);
|
|
Interceptor interceptor = new StatementExecuteQueryInterceptor();
|
|
statementClass.addInterceptor("executeQuery", new String[]{"java.lang.String"}, interceptor);
|
|
|
|
// TODO 이거 고쳐야 됨.
|
|
Interceptor executeUpdate = byteCodeInstrumentor.newInterceptor(classLoader, protectedDomain, "com.profiler.modifier.db.interceptor.StatementExecuteUpdateInterceptor");
|
|
statementClass.addInterceptor("executeUpdate", new String[]{"java.lang.String", "boolean", "boolean"}, executeUpdate);
|
|
|
|
statementClass.addTraceVariable("__url", "__setUrl", "__getUrl", "java.lang.Object");
|
|
return statementClass.toBytecode();
|
|
} catch (InstrumentException e) {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
} |