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
62 lines
2.1 KiB
Java
62 lines
2.1 KiB
Java
package com.profiler.modifier.db.cubrid;
|
|
|
|
import com.profiler.interceptor.bci.ByteCodeInstrumentor;
|
|
import javassist.CtClass;
|
|
import javassist.CtMethod;
|
|
|
|
import com.profiler.modifier.AbstractModifier;
|
|
import com.profiler.trace.DatabaseRequestTracer;
|
|
|
|
import java.security.ProtectionDomain;
|
|
import java.util.logging.Level;
|
|
import java.util.logging.Logger;
|
|
|
|
public class CubridResultSetModifier extends AbstractModifier {
|
|
|
|
private final Logger logger = Logger.getLogger(CubridResultSetModifier.class.getName());
|
|
|
|
public CubridResultSetModifier(ByteCodeInstrumentor byteCodeInstrumentor) {
|
|
super(byteCodeInstrumentor);
|
|
}
|
|
|
|
public String getTargetClass() {
|
|
return "cubrid/jdbc/driver/CUBRIDResultSet";
|
|
}
|
|
|
|
public byte[] modify(ClassLoader classLoader, String javassistClassName, ProtectionDomain protectedDomain, byte[] classFileBuffer) {
|
|
if (logger.isLoggable(Level.INFO)) {
|
|
logger.info("Modifing. " + javassistClassName);
|
|
}
|
|
this.byteCodeInstrumentor.checkLibrary(classLoader, javassistClassName);
|
|
return changeMethod(javassistClassName, classFileBuffer);
|
|
}
|
|
|
|
private byte[] changeMethod(String javassistClassName, byte[] classfileBuffer) {
|
|
try {
|
|
CtClass cc = classPool.get(javassistClassName);
|
|
|
|
updateNextMethod(cc);
|
|
updateCloseMethod(cc);
|
|
|
|
printClassConvertComplete(javassistClassName);
|
|
|
|
return cc.toBytecode();
|
|
} catch (Exception e) {
|
|
if (logger.isLoggable(Level.WARNING)) {
|
|
logger.log(Level.WARNING, e.getMessage(), e);
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
private void updateNextMethod(CtClass cc) throws Exception {
|
|
CtMethod method = cc.getDeclaredMethod("next", null);
|
|
method.insertBefore("{" + DatabaseRequestTracer.FQCN + ".updateFetchCount(); }");
|
|
}
|
|
|
|
private void updateCloseMethod(CtClass cc) throws Exception {
|
|
CtMethod method = cc.getDeclaredMethod("close", null);
|
|
method.insertBefore("{" + DatabaseRequestTracer.FQCN + ".addResultSetData(); } ");
|
|
}
|
|
}
|