Search in sources :

Example 1 with AredisCommandObjectIT

use of com.creditease.uav.hook.redis.aredis.interceptors.AredisCommandObjectIT in project uavstack by uavorg.

the class AredisHookProxy method doProxyInstall.

public void doProxyInstall(ClassLoader webapploader, final String appid) {
    /**
     * set the webapploader is the target classloader
     */
    dpInstaller.setTargetClassLoader(webapploader);
    dpInstaller.defineField("mMap", Map.class, "org.aredis.cache.RedisCommandObject", "new java.util.HashMap()");
    dpInstaller.installProxy("org.aredis.cache.RedisCommandObject", new String[] { "com.creditease.uav.hook.redis.aredis.interceptors" }, new DynamicProxyProcessor() {

        @Override
        public void process(DPMethod m) throws Exception {
            if ("sendRequest".equals(m.getName())) {
                dpInstaller.defineLocalVal(m, "mObj", AredisCommandObjectIT.class);
                m.insertBefore("{mObj = new AredisCommandObjectIT(\"" + appid + "\");" + "mObj.doAsyncStart(new Object[]{$1, $2, $3, commandInfo});" + "mMap.put(\"mObj\",mObj);}");
            }
            if ("receiveResponse".equals(m.getName())) {
                m.insertAfter("{AredisCommandObjectIT mObj = (AredisCommandObjectIT)mMap.get(\"mObj\");" + "mObj.doAsyncEnd(new Object[]{commandInfo});}");
            }
        }
    }, false);
}
Also used : DPMethod(com.creditease.uav.monitorframework.dproxy.bytecode.DPMethod) DynamicProxyProcessor(com.creditease.uav.monitorframework.dproxy.DynamicProxyProcessor) AredisCommandObjectIT(com.creditease.uav.hook.redis.aredis.interceptors.AredisCommandObjectIT)

Aggregations

AredisCommandObjectIT (com.creditease.uav.hook.redis.aredis.interceptors.AredisCommandObjectIT)1 DynamicProxyProcessor (com.creditease.uav.monitorframework.dproxy.DynamicProxyProcessor)1 DPMethod (com.creditease.uav.monitorframework.dproxy.bytecode.DPMethod)1