设为首页 - 加入收藏 ASP站长网(Aspzz.Cn)- 科技、建站、经验、云计算、5G、大数据,站长网!
热搜: 创业者 数据 手机
当前位置: 首页 > 站长学院 > MySql教程 > 正文

Mybatis超详细插件机制解析,弄懂拦截器So easy(4)

发布时间:2019-12-25 22:25 所属栏目:115 来源:站长网
导读:returnProxy.newProxyInstance(Interceptor.class.getClassLoader(),target.getClass().getInterfaces(),newInvocationHandler(){ publicObjectinvoke(Objectproxy,Methodmethod,Object[]args)throwsThrowable{ ret

    return Proxy.newProxyInstance(Interceptor.class.getClassLoader(), target.getClass().getInterfaces(), new InvocationHandler() { 

      public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { 

        return intercept(new Invocation(target, method, args)); 

      } 

    }); 

  } 

  public void setProperties(Properties properties) { 

  } 

当然,Mybatis插件的那这个时候Intercepts的注解起不到作用了。

小结

我们在MyBatis配置了一个插件,在运行发生了什么

所有可能被拦截的处理类都会生成一个代理

处理类代理在执行对应方法时,判断要不要执行插件中的拦截方法

执行插接中的拦截方法后,推进目标的执行

(编辑:ASP站长网)

网友评论
推荐文章
    热点阅读