use of com.creditease.uav.hook.jdbc.pools.dbcp.interceptors.DBCPIT in project uavstack by uavorg.
the class DBCPHookProxy method InsertInterceptToClients.
/**
* InsertInterceptToClients
*
* @param ic
*/
private void InsertInterceptToClients(HookContext context, ClassLoader webapploader) {
if (isHookEventDone("InsertInterceptToClients")) {
return;
}
InterceptContext ic = (InterceptContext) context.get(HookConstants.INTERCEPTCONTEXT);
String contextPath = (String) ic.get(InterceptConstants.CONTEXTPATH);
String basePath = (String) ic.get(InterceptConstants.BASEPATH);
appid = MonitorServerUtil.getApplicationId(contextPath, basePath);
/**
* set the webapploader is the target classloader
*/
dpInstall.setTargetClassLoader(webapploader);
/**
* DBCP 1.x
*/
dpInstall.installProxy("org.apache.commons.dbcp.BasicDataSource", new String[] { "com.creditease.uav.hook.jdbc.pools.dbcp.interceptors" }, new DynamicProxyProcessor() {
@Override
public void process(DPMethod m) throws Exception {
if ("setUrl".equals(m.getName())) {
dpInstall.defineLocalVal(m, "mObj", DBCPIT.class);
m.insertBefore("{mObj=new DBCPIT(\"" + id + "\",this);}");
}
}
}, false);
/**
* DBCP 2.x
*/
dpInstall.installProxy("org.apache.commons.dbcp2.BasicDataSource", new String[] { "com.creditease.uav.hook.jdbc.pools.dbcp.interceptors" }, new DynamicProxyProcessor() {
@Override
public void process(DPMethod m) throws Exception {
if ("setUrl".equals(m.getName())) {
dpInstall.defineLocalVal(m, "mObj", DBCPIT.class);
m.insertBefore("{mObj=new DBCPIT(\"" + id + "\",this);}");
}
}
}, false);
/**
* Tomcat DBCP 2.x after 8
*/
dpInstall.installProxy("org.apache.tomcat.dbcp.dbcp2.BasicDataSource", new String[] { "com.creditease.uav.hook.jdbc.pools.dbcp.interceptors" }, new DynamicProxyProcessor() {
@Override
public void process(DPMethod m) throws Exception {
if ("setUrl".equals(m.getName())) {
dpInstall.defineLocalVal(m, "mObj", DBCPIT.class);
m.insertBefore("{mObj=new DBCPIT(\"" + id + "\",this);}");
}
}
}, false);
// release loader
dpInstall.releaseTargetClassLoader();
}
Aggregations