Search in sources :

Example 6 with DPMethod

use of com.creditease.uav.monitorframework.dproxy.bytecode.DPMethod 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();
}
Also used : DPMethod(com.creditease.uav.monitorframework.dproxy.bytecode.DPMethod) RabbitmqIT(com.creditease.uav.hook.rabbitmq.interceptors.RabbitmqIT) DynamicProxyProcessor(com.creditease.uav.monitorframework.dproxy.DynamicProxyProcessor)

Example 7 with DPMethod

use of com.creditease.uav.monitorframework.dproxy.bytecode.DPMethod 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();
}
Also used : DPMethod(com.creditease.uav.monitorframework.dproxy.bytecode.DPMethod) DynamicProxyProcessor(com.creditease.uav.monitorframework.dproxy.DynamicProxyProcessor) JdbcDriverIT(com.creditease.uav.hook.jdbc.interceptors.JdbcDriverIT)

Example 8 with DPMethod

use of com.creditease.uav.monitorframework.dproxy.bytecode.DPMethod 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();
}
Also used : DPMethod(com.creditease.uav.monitorframework.dproxy.bytecode.DPMethod) DynamicProxyProcessor(com.creditease.uav.monitorframework.dproxy.DynamicProxyProcessor) JdbcDriverIT(com.creditease.uav.hook.jdbc.interceptors.JdbcDriverIT)

Example 9 with DPMethod

use of com.creditease.uav.monitorframework.dproxy.bytecode.DPMethod 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();
}
Also used : DPMethod(com.creditease.uav.monitorframework.dproxy.bytecode.DPMethod) DynamicProxyProcessor(com.creditease.uav.monitorframework.dproxy.DynamicProxyProcessor) JdbcDriverIT(com.creditease.uav.hook.jdbc.interceptors.JdbcDriverIT)

Example 10 with DPMethod

use of com.creditease.uav.monitorframework.dproxy.bytecode.DPMethod 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();
}
Also used : DPMethod(com.creditease.uav.monitorframework.dproxy.bytecode.DPMethod) InterceptContext(com.creditease.monitor.interceptframework.spi.InterceptContext) DynamicProxyProcessor(com.creditease.uav.monitorframework.dproxy.DynamicProxyProcessor) MybatisIT(com.creditease.uav.hook.jdbc.pools.mybatis.interceptors.MybatisIT)

Aggregations

DPMethod (com.creditease.uav.monitorframework.dproxy.bytecode.DPMethod)21 DynamicProxyProcessor (com.creditease.uav.monitorframework.dproxy.DynamicProxyProcessor)20 JdbcDriverIT (com.creditease.uav.hook.jdbc.interceptors.JdbcDriverIT)4 InterceptContext (com.creditease.monitor.interceptframework.spi.InterceptContext)3 ServerVendor (com.creditease.monitor.UAVServer.ServerVendor)2 DubboIT (com.creditease.uav.hook.dubbo.interceptors.DubboIT)1 ApacheAsyncHttpClientIT (com.creditease.uav.hook.httpclients.async.interceptors.ApacheAsyncHttpClientIT)1 JaxWSHookIT (com.creditease.uav.hook.jaxws.interceptors.JaxWSHookIT)1 DBCPIT (com.creditease.uav.hook.jdbc.pools.dbcp.interceptors.DBCPIT)1 MybatisIT (com.creditease.uav.hook.jdbc.pools.mybatis.interceptors.MybatisIT)1 MongoClientIT (com.creditease.uav.hook.mongoclients.interceptors.MongoClientIT)1 RabbitmqIT (com.creditease.uav.hook.rabbitmq.interceptors.RabbitmqIT)1 AredisCommandObjectIT (com.creditease.uav.hook.redis.aredis.interceptors.AredisCommandObjectIT)1 DPClass (com.creditease.uav.monitorframework.dproxy.bytecode.DPClass)1 WebServiceListenerIT (com.creditease.uav.monitorframework.webservice.interceptors.WebServiceListenerIT)1 FastClasspathScanner (io.github.lukehutch.fastclasspathscanner.FastClasspathScanner)1