All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.penglecode.mybatis.ex.ExMapperProxyFactory Maven / Gradle / Ivy

Go to download

mybatis的自定义扩展。 版本1.0.0 支持mybatis 3.2|3.3版本 版本1.0.1 支持mybatis 3.4版本

There is a newer version: 1.0.1
Show newest version
package com.penglecode.mybatis.ex;

import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import org.apache.ibatis.session.SqlSession;

public class ExMapperProxyFactory {

	private final Class mapperInterface;
	private final Map methodCache = new ConcurrentHashMap();

	public ExMapperProxyFactory(Class mapperInterface) {
		this.mapperInterface = mapperInterface;
	}

	public Class getMapperInterface() {
		return mapperInterface;
	}

	public Map getMethodCache() {
		return methodCache;
	}

	@SuppressWarnings("unchecked")
	protected T newInstance(ExMapperProxy mapperProxy) {
		return (T) Proxy.newProxyInstance(mapperInterface.getClassLoader(), new Class[] { mapperInterface },
				mapperProxy);
	}

	public T newInstance(SqlSession sqlSession) {
		final ExMapperProxy mapperProxy = new ExMapperProxy(sqlSession, mapperInterface, methodCache);
		return newInstance(mapperProxy);
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy