use of com.creditease.uav.monitorframework.dproxy.DynamicProxyProcessor in project uavstack by uavorg.
the class RabbitmqHookProxy method doInstallDProxy.
public void doInstallDProxy(ClassLoader webapploader, final String appid) {
/**
* set the webapploader is the target classloader
*/
dpInstall.setTargetClassLoader(webapploader);
/**
* install proxy to rabbitMQClient
*/
dpInstall.installProxy("com.rabbitmq.client.ConnectionFactory", new String[] { "com.creditease.uav.hook.rabbitmq.interceptors" }, new DynamicProxyProcessor() {
@Override
public void process(DPMethod m) throws Exception {
if ("newConnection".equals(m.getName()) && m.getParameterTypes().length >= 2) {
dpInstall.defineLocalVal(m, "mObj", RabbitmqIT.class);
m.insertAfter("{mObj=new RabbitmqIT(\"" + appid + "\");$_=mObj.doInstall($_);}");
}
}
}, false);
dpInstall.releaseTargetClassLoader();
}
use of com.creditease.uav.monitorframework.dproxy.DynamicProxyProcessor in project uavstack by uavorg.
the class JdbcHookProxy method injectDBCP2.
/**
* inject DBCP2
*
* NOTE: DBCP is default injected by injectDriverManager
*
* @param webapploader
* @param ic
*/
private void injectDBCP2(ClassLoader webapploader, InterceptContext ic) {
try {
webapploader.loadClass("org.apache.commons.dbcp2.Constants");
} catch (ClassNotFoundException e) {
return;
}
if (isHookEventDone("isInjectDBCP2")) {
return;
}
final String appid = this.getAppID(ic);
/**
* set the webapploader is the target classloader
*/
dpInstall.setTargetClassLoader(webapploader);
/**
* inject DBCP2 BasicDataSource
*/
dpInstall.installProxy("org.apache.commons.dbcp2.DriverConnectionFactory", new String[] { "com.creditease.uav.hook.jdbc.interceptors" }, new DynamicProxyProcessor() {
@Override
public void process(DPMethod m) throws Exception {
if ("createConnection".equals(m.getName())) {
dpInstall.defineLocalVal(m, "mObj", JdbcDriverIT.class);
m.insertBefore("{mObj=new JdbcDriverIT(\"" + appid + "\");mObj.setJDBCUrlByObjField(this,\"_connectUri\");}");
m.insertAfter("{$_=mObj.doProxyConnection($_);}");
}
}
}, false);
// release loader
dpInstall.releaseTargetClassLoader();
}
use of com.creditease.uav.monitorframework.dproxy.DynamicProxyProcessor in project uavstack by uavorg.
the class JdbcHookProxy method injectHikari.
/**
* inject Hikari
*
* @param webapploader
* @param ic
*/
private void injectHikari(ClassLoader webapploader, InterceptContext ic) {
try {
webapploader.loadClass("com.zaxxer.hikari.HikariConfigMXBean");
} catch (ClassNotFoundException e) {
return;
}
if (isHookEventDone("isInjectHikari")) {
return;
}
final String appid = this.getAppID(ic);
final String contextPath = (String) ic.get(InterceptConstants.CONTEXTPATH);
/**
* set the webapploader is the target classloader
*/
dpInstall.setTargetClassLoader(webapploader);
/**
* inject DBCP2 BasicDataSource
*/
dpInstall.installProxy("com.zaxxer.hikari.HikariDataSource", new String[] { "com.creditease.uav.hook.jdbc.interceptors", "com.creditease.uav.hook.jdbc.pools.hikari.interceptors" }, new DynamicProxyProcessor() {
@Override
public void process(DPMethod m) throws Exception {
if ("getConnection".equals(m.getName()) && (m.getParameterTypes() == null || m.getParameterTypes().length == 0)) {
dpInstall.defineLocalVal(m, "mObj", JdbcDriverIT.class);
// dpInstall.defineLocalVal(m, "mObj2", HikariIT.class);
m.insertBefore("{mObj=new JdbcDriverIT(\"" + appid + "\");mObj.setJDBCUrl(this.getJdbcUrl());new HikariIT(\"" + contextPath + "\",this);}");
m.insertAfter("{$_=mObj.doProxyConnection($_);}");
}
}
}, false);
// release loader
dpInstall.releaseTargetClassLoader();
}
use of com.creditease.uav.monitorframework.dproxy.DynamicProxyProcessor in project uavstack by uavorg.
the class JdbcHookProxy method injectTomcatDBCP2.
/**
* inject TomcatDBCP2
*
* @param webapploader
* @param ic
*/
private void injectTomcatDBCP2(ClassLoader webapploader, InterceptContext ic) {
try {
webapploader.loadClass("org.apache.tomcat.dbcp.dbcp2.Constants");
} catch (ClassNotFoundException e) {
return;
}
if (isHookEventDone("isInjectTomcatDBCP2")) {
return;
}
final String appid = this.getAppID(ic);
/**
* set the webapploader is the target classloader
*/
dpInstall.setTargetClassLoader(webapploader);
/**
* inject Tomcat DBCP2 BasicDataSource
*/
dpInstall.installProxy("org.apache.tomcat.dbcp.dbcp2.DriverConnectionFactory", new String[] { "com.creditease.uav.hook.jdbc.interceptors" }, new DynamicProxyProcessor() {
@Override
public void process(DPMethod m) throws Exception {
if ("createConnection".equals(m.getName())) {
dpInstall.defineLocalVal(m, "mObj", JdbcDriverIT.class);
m.insertBefore("{mObj=new JdbcDriverIT(\"" + appid + "\");mObj.setJDBCUrlByObjField(this,\"_connectUri\");}");
m.insertAfter("{$_=mObj.doProxyConnection($_);}");
}
}
}, false);
// release loader
dpInstall.releaseTargetClassLoader();
}
use of com.creditease.uav.monitorframework.dproxy.DynamicProxyProcessor in project uavstack by uavorg.
the class MybatisHookProxy method InsertInterceptToClients.
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);
dpInstall.setTargetClassLoader(webapploader);
dpInstall.installProxy("org.apache.ibatis.datasource.pooled.PooledDataSource", new String[] { "com.creditease.uav.hook.jdbc.pools.mybatis.interceptors" }, new DynamicProxyProcessor() {
@Override
public void process(DPMethod m) throws Exception {
if ("setUrl".equals(m.getName())) {
dpInstall.defineLocalVal(m, "mObj", MybatisIT.class);
m.insertBefore("{mObj=new MybatisIT(\"" + id + "\",this);}");
}
}
}, false);
// release loader
dpInstall.releaseTargetClassLoader();
}
Aggregations