mybatis流程图
2019-05-20 11:20:17 0 举报
mybatis源码
作者其他创作
大纲/内容
statement-pojoStr
new CachingExecutor(new SimpleExecutor());
knownMappers.get(clazz)
Proxy.newProxyInstance
MapperProxy.invoke.
target=Plugin的代理,实现Executor接口类
this
Configuration
ResourceBundle.getBundle(\"sql\");ResourceBundle.getBundle(\"mybatis\");
interceptorChain.pluginAll(executor);
(T)proxyFactory.newInstance(sqlSession);
DefaultSqlSession
private Configuration configuration;
private Executor executor;
SqlSessionFactory
newInstance(DefaultSqlSession sqlSession)
MyPlugin
+ intercept:Invocation = Object
+ plugin(Object):Object
clazz就是mapper接口
mapperList.add(clazz);
parsingClass(mapper);
MapperProxy的代理类
Executor
Interceptor
+intercept(Invocation):Object+plugin(Object target):Object
target = interceptor.plugin(target);
selectBlogById
build
sqlSession.getMapper(BlogMapper.class)
MapperProxyFactory
private Class<T> mapperInterface
private Class object;public T newInstance(DefaultSqlSession sqlSession)
InterceptorChain
openSqlSession
Invocation
private Object target; private Method method; private Object[] args;
interceptorChain.addInterceptor(interceptor);
new DefaultSqlSession(configuration)
MapperProxy
private DefaultSqlSession sqlSession;
private Class object;pojo
scanPackage(mapperPath);
this.executor = configuration.newExecutor();
Plugin
+ invoke(params):returnType
0 条评论
下一页