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

org.apache.ibatis.binding.MybatisCommonsMapperProxyFactory Maven / Gradle / Ivy

The newest version!
package org.apache.ibatis.binding;

import java.lang.reflect.Method;
import java.util.Map;

import org.apache.commons.lang3.reflect.FieldUtils;
import org.apache.ibatis.binding.MapperProxy.MapperMethodInvoker;
import org.apache.ibatis.session.SqlSession;

/**
 * @author 潜行的青衣
 */
public class MybatisCommonsMapperProxyFactory extends MapperProxyFactory {

	/**
	 * @param mapperInterface
	 */
	public MybatisCommonsMapperProxyFactory(Class mapperInterface) {
		super(mapperInterface);
	}

	@SuppressWarnings("unchecked")
	@Override
	public T newInstance(SqlSession sqlSession) {
		Class mapperInterface = null;
		Map methodCache = null;
		try {
			mapperInterface = (Class) FieldUtils.readField(this, "mapperInterface", true);
			methodCache = (Map) FieldUtils.readField(this, "methodCache", true);
			final MapperProxy mapperProxy = new MybatisCommonsMapperProxy(sqlSession, mapperInterface, methodCache);
		    return newInstance(mapperProxy);
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		}
		return null;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy