Mybatis拦截器机制以及Mybatis物理分页操作指南
来源:互联网 发布:mac怎么制作手机铃声 编辑:程序博客网 时间:2024/05/22 06:49
以下按照代码执行顺序从.xml配置文件开始,浅析Mybatis拦截器机制在整个运行过程中的主要环节。
1. xml配置文件
1.解析xml中的plugin节点,将interceptor添加到Configuration中
XMLConfigBuilder.pluginElement(XNode parent)
从xml配置文件中生成的Configuration对象中包含了plugin在内的所有属性,
package org.apache.ibatis.binding;import java.io.Serializable;import java.lang.reflect.InvocationHandler;import java.lang.reflect.Method;import java.util.Map;import org.apache.ibatis.reflection.ExceptionUtil;import org.apache.ibatis.session.SqlSession;/** * @author Clinton Begin * @author Eduardo Macarron */public class MapperProxy<T> implements InvocationHandler, Serializable { private static final long serialVersionUID = -6424540398559729838L; private final SqlSession sqlSession; private final Class<T> mapperInterface; private final Map<Method, MapperMethod> methodCache; public MapperProxy(SqlSession sqlSession, Class<T> mapperInterface, Map<Method, MapperMethod> methodCache) { this.sqlSession = sqlSession; this.mapperInterface = mapperInterface; this.methodCache = methodCache; } @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if (Object.class.equals(method.getDeclaringClass())) { try { return method.invoke(this, args); } catch (Throwable t) { throw ExceptionUtil.unwrapThrowable(t); } } final MapperMethod mapperMethod = cachedMapperMethod(method); return mapperMethod.execute(sqlSession, args); } private MapperMethod cachedMapperMethod(Method method) { MapperMethod mapperMethod = methodCache.get(method); if (mapperMethod == null) { mapperMethod = new MapperMethod(mapperInterface, method, sqlSession.getConfiguration()); methodCache.put(method, mapperMethod); } return mapperMethod; }}
0 0
- Mybatis拦截器机制以及Mybatis物理分页操作指南
- Mybatis拦截器运用-物理分页
- mybatis分页拦截器
- Mybatis - 分页拦截器
- Mybatis拦截器分页
- mybatis分页拦截器
- MyBatis拦截器分页
- Mybatis分页拦截器
- Mybatis分页拦截器
- Mybatis拦截器,分页
- Mybatis拦截器分页
- MyBatis拦截器分页
- mybatis 拦截器分页
- Mybatis拦截器分页
- 【MyBatis】mybatis分页拦截器-自动封装
- MyBatis拦截器实现分页
- mybatis拦截器分页学习
- mybatis -mysql -分页拦截器
- 最佳java学习路线
- 添加pch文件
- (译)java NIO 示例代码
- c语言宏定义详解
- 开发中碰到的问题:小米note调用系统相机点击确定是取消
- Mybatis拦截器机制以及Mybatis物理分页操作指南
- object-c-协议-protocol
- Handler Class Should be Static or Leaks Occur
- CTreeCtrl 常用操作整理
- C语言变量的作用范围
- Vulkan的分层设计
- 获取元素CSS值之getComputedStyle方法
- 微信tiny框架介绍
- PPT的印象和学习