Search in sources :

Example 1 with MongoClientIT

use of com.creditease.uav.hook.mongoclients.interceptors.MongoClientIT in project uavstack by uavorg.

the class MongoClientHookProxy method doInstallDProxy.

public void doInstallDProxy(ClassLoader webapploader, final String appid) {
    /**
     * set the webapploader is the target classloader
     */
    dpInstall.setTargetClassLoader(webapploader);
    /**
     * install proxy to MongoClient
     */
    dpInstall.installProxy("com.mongodb.MongoClient", new String[] { "com.creditease.uav.hook.mongoclients.interceptors" }, new DynamicProxyProcessor() {

        @Override
        public void process(DPMethod m) throws Exception {
            if ("getDatabase".equals(m.getName())) {
                dpInstall.defineLocalVal(m, "mObj", MongoClientIT.class);
                m.insertAfter("{mObj=new MongoClientIT(\"" + appid + "\");$_=mObj.doInstall($_);}");
            }
        }
    }, false);
    dpInstall.releaseTargetClassLoader();
}
Also used : DPMethod(com.creditease.uav.monitorframework.dproxy.bytecode.DPMethod) MongoClientIT(com.creditease.uav.hook.mongoclients.interceptors.MongoClientIT) DynamicProxyProcessor(com.creditease.uav.monitorframework.dproxy.DynamicProxyProcessor)

Aggregations

MongoClientIT (com.creditease.uav.hook.mongoclients.interceptors.MongoClientIT)1 DynamicProxyProcessor (com.creditease.uav.monitorframework.dproxy.DynamicProxyProcessor)1 DPMethod (com.creditease.uav.monitorframework.dproxy.bytecode.DPMethod)1