diff --git a/src/main/java/com/profiler/interceptor/bci/ClassLoadChecker.java b/src/main/java/com/profiler/interceptor/bci/ClassLoadChecker.java index 4552ed894..82a76422e 100644 --- a/src/main/java/com/profiler/interceptor/bci/ClassLoadChecker.java +++ b/src/main/java/com/profiler/interceptor/bci/ClassLoadChecker.java @@ -2,9 +2,11 @@ package com.profiler.interceptor.bci; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; +import java.util.logging.Level; +import java.util.logging.Logger; public class ClassLoadChecker { - + private final Logger logger = Logger.getLogger(ClassLoadChecker.class.getName()); private static final Object EXIST = new Object(); private ConcurrentMap load = new ConcurrentHashMap(); @@ -13,8 +15,14 @@ public class ClassLoadChecker { LoadClass key = new LoadClass(cl, className); Object old = load.putIfAbsent(key, EXIST); if (old == null) { + if (logger.isLoggable(Level.INFO)) { + logger.info(className + " not exist from " + cl); + } return false; } + if (logger.isLoggable(Level.INFO)) { + logger.info(className + " already exist from " + cl); + } return true; } diff --git a/src/main/java/com/profiler/modifier/db/mysql/MySQLConnectionImplModifier.java b/src/main/java/com/profiler/modifier/db/mysql/MySQLConnectionImplModifier.java index cd4fa826a..2b7c681fc 100644 --- a/src/main/java/com/profiler/modifier/db/mysql/MySQLConnectionImplModifier.java +++ b/src/main/java/com/profiler/modifier/db/mysql/MySQLConnectionImplModifier.java @@ -4,6 +4,7 @@ import com.profiler.interceptor.Interceptor; import com.profiler.interceptor.bci.ByteCodeInstrumentor; import com.profiler.interceptor.bci.InstrumentClass; import com.profiler.interceptor.bci.InstrumentException; +import com.profiler.modifier.db.mysql.interceptors.*; import javassist.CtClass; import javassist.CtMethod; @@ -39,27 +40,31 @@ public class MySQLConnectionImplModifier extends AbstractModifier { mysqlConnection.addTraceVariable("__url", "__setUrl", "__getUrl", "java.lang.String"); // 해당 Interceptor를 공통클래스 만들경우 system에 로드해야 된다. - Interceptor createConnection = newInterceptor(classLoader, protectedDomain, "com.profiler.modifier.db.mysql.interceptors.CreateConnectionInterceptor"); +// Interceptor createConnection = newInterceptor(classLoader, protectedDomain, "com.profiler.modifier.db.mysql.interceptors.CreateConnectionInterceptor"); + Interceptor createConnection = new CreateConnectionInterceptor(); String[] params = new String[] { "java.lang.String", "int", "java.util.Properties", "java.lang.String", "java.lang.String" }; mysqlConnection.addInterceptor("getInstance", params, createConnection); - Interceptor closeConnection = newInterceptor(classLoader, protectedDomain, "com.profiler.modifier.db.mysql.interceptors.CloseConnectionInterceptor"); +// Interceptor closeConnection = newInterceptor(classLoader, protectedDomain, "com.profiler.modifier.db.mysql.interceptors.CloseConnectionInterceptor"); + Interceptor closeConnection = new CloseConnectionInterceptor(); mysqlConnection.addInterceptor("close", null, closeConnection); - Interceptor createStatement = newInterceptor(classLoader, protectedDomain, "com.profiler.modifier.db.mysql.interceptors.CreateStatementInterceptor"); +// Interceptor createStatement = newInterceptor(classLoader, protectedDomain, "com.profiler.modifier.db.mysql.interceptors.CreateStatementInterceptor"); + Interceptor createStatement = new CreateStatementInterceptor(); mysqlConnection.addInterceptor("createStatement", null, createStatement); - Interceptor preparedStatement = newInterceptor(classLoader, protectedDomain, "com.profiler.modifier.db.mysql.interceptors.CreatePreparedStatementInterceptor"); +// Interceptor preparedStatement = newInterceptor(classLoader, protectedDomain, "com.profiler.modifier.db.mysql.interceptors.CreatePreparedStatementInterceptor"); + Interceptor preparedStatement = new CreatePreparedStatementInterceptor(); mysqlConnection.addInterceptor("prepareStatement", new String[]{"java.lang.String"}, preparedStatement); - Interceptor transaction = newInterceptor(classLoader, protectedDomain, "com.profiler.modifier.db.mysql.interceptors.TransactionInterceptor"); - +// Interceptor transaction = newInterceptor(classLoader, protectedDomain, "com.profiler.modifier.db.mysql.interceptors.c"); + Interceptor transaction = new TransactionInterceptor(); mysqlConnection.addInterceptor("setAutoCommit", new String[]{"boolean"}, transaction); mysqlConnection.addInterceptor("commit", null, transaction); mysqlConnection.addInterceptor("rollback", null, transaction); diff --git a/src/main/java/com/profiler/modifier/db/mysql/MySQLPreparedStatementJDBC4Modifier.java b/src/main/java/com/profiler/modifier/db/mysql/MySQLPreparedStatementJDBC4Modifier.java index f350f7c91..1faa8230c 100644 --- a/src/main/java/com/profiler/modifier/db/mysql/MySQLPreparedStatementJDBC4Modifier.java +++ b/src/main/java/com/profiler/modifier/db/mysql/MySQLPreparedStatementJDBC4Modifier.java @@ -6,6 +6,7 @@ import com.profiler.interceptor.bci.InstrumentClass; import com.profiler.interceptor.bci.InstrumentException; import com.profiler.interceptor.bci.NotFoundInstrumentException; import com.profiler.modifier.AbstractModifier; +import com.profiler.modifier.db.mysql.interceptors.PreparedStatementBindVariableInterceptor; import com.profiler.util.*; import java.lang.reflect.Method; @@ -50,7 +51,8 @@ public class MySQLPreparedStatementJDBC4Modifier extends AbstractModifier { private void bindVariableIntercept(InstrumentClass preparedStatement, ClassLoader classLoader, ProtectionDomain protectedDomain) throws InstrumentException { BindVariableFilter exclude = new IncludeBindVariableFilter(includes); List bindMethod = PreparedStatementUtils.findBindVariableSetMethod(exclude); - Interceptor interceptor = newInterceptor(classLoader, protectedDomain, "com.profiler.modifier.db.mysql.interceptors.PreparedStatementBindVariableInterceptor"); +// Interceptor interceptor = newInterceptor(classLoader, protectedDomain, "com.profiler.modifier.db.mysql.interceptors.PreparedStatementBindVariableInterceptor"); + Interceptor interceptor = new PreparedStatementBindVariableInterceptor(); for (Method method : bindMethod) { String methodName = method.getName(); String[] parameterType = JavaAssistUtils.getParameterType(method.getParameterTypes()); diff --git a/src/main/java/com/profiler/modifier/db/mysql/MySQLPreparedStatementModifier.java b/src/main/java/com/profiler/modifier/db/mysql/MySQLPreparedStatementModifier.java index ab3221bd2..4c6a73fac 100644 --- a/src/main/java/com/profiler/modifier/db/mysql/MySQLPreparedStatementModifier.java +++ b/src/main/java/com/profiler/modifier/db/mysql/MySQLPreparedStatementModifier.java @@ -12,6 +12,8 @@ import java.util.logging.Logger; import com.profiler.interceptor.bci.InstrumentException; import com.profiler.interceptor.bci.NotFoundInstrumentException; +import com.profiler.modifier.db.mysql.interceptors.PreparedStatementBindVariableInterceptor; +import com.profiler.modifier.db.mysql.interceptors.PreparedStatementMethodInterceptor; import com.profiler.util.ExcludeBindVariableFilter; import com.profiler.util.JavaAssistUtils; import com.profiler.util.PreparedStatementUtils; @@ -48,7 +50,8 @@ public class MySQLPreparedStatementModifier extends AbstractModifier { checkLibrary(classLoader, javassistClassName); try { InstrumentClass preparedStatement = byteCodeInstrumentor.getClass(javassistClassName); - Interceptor interceptor = newInterceptor(classLoader, protectedDomain, "com.profiler.modifier.db.mysql.interceptors.PreparedStatementMethodInterceptor"); +// Interceptor interceptor = newInterceptor(classLoader, protectedDomain, "com.profiler.modifier.db.mysql.interceptors.PreparedStatementMethodInterceptor"); + Interceptor interceptor = new PreparedStatementMethodInterceptor(); preparedStatement.addInterceptor("executeQuery", null, interceptor); preparedStatement.addTraceVariable("__url", "__setUrl", "__getUrl", "java.lang.String"); @@ -82,7 +85,8 @@ public class MySQLPreparedStatementModifier extends AbstractModifier { private void bindVariableIntercept(InstrumentClass preparedStatement, ClassLoader classLoader, ProtectionDomain protectedDomain) throws InstrumentException { ExcludeBindVariableFilter exclude = new ExcludeBindVariableFilter(excludes); List bindMethod = PreparedStatementUtils.findBindVariableSetMethod(exclude); - Interceptor interceptor = newInterceptor(classLoader, protectedDomain, "com.profiler.modifier.db.mysql.interceptors.PreparedStatementBindVariableInterceptor"); +// Interceptor interceptor = newInterceptor(classLoader, protectedDomain, "com.profiler.modifier.db.mysql.interceptors.PreparedStatementBindVariableInterceptor"); + Interceptor interceptor = new PreparedStatementBindVariableInterceptor(); for (Method method : bindMethod) { String methodName = method.getName(); String[] parameterType = JavaAssistUtils.getParameterType(method.getParameterTypes()); diff --git a/src/main/java/com/profiler/modifier/db/mysql/MySQLStatementModifier.java b/src/main/java/com/profiler/modifier/db/mysql/MySQLStatementModifier.java index ee0268137..15d1ca7b4 100644 --- a/src/main/java/com/profiler/modifier/db/mysql/MySQLStatementModifier.java +++ b/src/main/java/com/profiler/modifier/db/mysql/MySQLStatementModifier.java @@ -8,6 +8,7 @@ import java.util.logging.Logger; import com.profiler.interceptor.Interceptor; import com.profiler.interceptor.bci.InstrumentException; import com.profiler.interceptor.bci.JavaAssistClass; +import com.profiler.modifier.db.mysql.interceptors.ExecuteQueryMethodInterceptor; import javassist.*; import com.profiler.interceptor.bci.ByteCodeInstrumentor; @@ -36,7 +37,8 @@ public class MySQLStatementModifier extends AbstractModifier { try { InstrumentClass statementClass = byteCodeInstrumentor.getClass(javassistClassName); - Interceptor interceptor = newInterceptor(classLoader, protectedDomain, "com.profiler.modifier.db.mysql.interceptors.ExecuteQueryMethodInterceptor"); +// Interceptor interceptor = newInterceptor(classLoader, protectedDomain, "com.profiler.modifier.db.mysql.interceptors.ExecuteQueryMethodInterceptor"); + Interceptor interceptor = new ExecuteQueryMethodInterceptor(); statementClass.addInterceptor("executeQuery", new String[]{"java.lang.String"}, interceptor);