在学习SSM框架过程中,发现service中调用了mapper的方法,但是mapper仅仅是个接口,我找了半天,并没有在clone下来的SSM例子中找到mapper的实现类,why?遂进行了深入研究,看源码,看mybatis的源码,忽然发现我没有绑定源码,经过再三思考,决定百度,果然前人与我有相同的疑惑,并进行了探究:原博文
这里面,就设计到了反射+动态代理+工厂模式
public class MapperProxyFactory<T> {
private final Class<T> mapperInterface;
private Map<Method, MapperMethod> methodCache = new ConcurrentHashMap();
public MapperProxyFactory(Class<T> mapperInterface) {
this.mapperInterface = mapperInterface;