首先在mybatis中要使用插件你必须实现:apache
- org.apache.ibatis.plugin.Interceptor接口
- 有三个方法:
- intercept 真个是插件真正运行的方法,
- 它将直接覆盖掉你真实拦截对象的方法。
- 里面有一个Invocation对象,利用它能够调用你本来要拦截的对象的方法
- plugin 它是一个生成动态代理对象的方法,
- setProperties 它是容许你在使用插件的时候设置参数值。
初始化:mybatis
- XMLConfigBuilder
- private void parseConfiguration(XNode root)
- pluginElement(root.evalNode("plugins"));
Executor对象的取出:ui
- Configuration 类下面
- public Executor newExecutor(Transaction transaction, ExecutorType executorType)
- executor = (Executor) interceptorChain.pluginAll(executor);