mybatis源码分析(3)——SqlSessionManager类
从上图可能看出,在 mybatis 中, SqlSession 的实现类有两个,其中 SqlSessionManager 类不但实现了 SqlSession 接口,同时也实现了 SqlSessionFactory 接口。那么 SqlSessionManager 类究竟有何作用 ? 由于源码中缺少注释,所以从 mybatis 目前的提供官方文档来看,似乎该类已被弃用,其功能被 DefaultSqlSession 类和 DefaultSqlSessionFactory 类所代替。只是该类的部分代码对我们理解 mybatis 的一些底层机制还具有一定的参考价值,例如: SqlSessionManager的下面的构造方法,会产生一个SqlSession 的一个代理对象: private SqlSessionManager(SqlSessionFactory sqlSessionFactory) { this.sqlSessionFactory = sqlSessionFactory; this.sqlSessionProxy = (SqlSession) Proxy.newProxyInstance( SqlSessionFactory.class.getClassLoader(), new Class[]{SqlSession.class}, new