Search in sources :

Example 1 with MybatisIT

use of com.creditease.uav.hook.jdbc.pools.mybatis.interceptors.MybatisIT 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

InterceptContext (com.creditease.monitor.interceptframework.spi.InterceptContext)1 MybatisIT (com.creditease.uav.hook.jdbc.pools.mybatis.interceptors.MybatisIT)1 DynamicProxyProcessor (com.creditease.uav.monitorframework.dproxy.DynamicProxyProcessor)1 DPMethod (com.creditease.uav.monitorframework.dproxy.bytecode.DPMethod)1