Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.taobao.profile.dependence_query.mysql;

import java.util.HashSet;
import java.util.Set;

import com.taobao.profile.config.ProfFilter;

/**
Expand All @@ -10,13 +13,32 @@ public class MysqlProfFilter extends ProfFilter {

public final static String MysqlPath = "com/mysql/jdbc/ConnectionImpl";

protected static Set<String> includeMysqlPackage = new HashSet<String>();

private static MysqlProfFilter instance = new MysqlProfFilter();
protected MysqlProfFilter() {
includePackage.add(MysqlPath.toLowerCase());
includeMysqlPackage.add(MysqlPath.toLowerCase());
}

public static MysqlProfFilter getInstance(){
return instance;
}


/**
* 为mysql重写isNeedInject方法
*
* 是否是需要注入的类
*
* @param className
* @return
*/
public static boolean isNeedInjectMysql(String className) {
String icaseName = className.toLowerCase().replace('.', '/');
for (String v : includeMysqlPackage) {
if (icaseName.startsWith(v)) {
return true;
}
}
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class ProfTransformer implements ClassFileTransformer {
private byte[] transform4Mysql(ClassLoader loader, String className, Class<?> classBeingRedefined,
ProtectionDomain protectionDomain, byte[] classfileBuffer){
try {
if(!MysqlProfFilter.getInstance().isNeedInject(className)){
if(!MysqlProfFilter.isNeedInjectMysql(className)){
return null;
}

Expand Down