mybatis按照層次可以劃分爲 一下三個層次
接口層(SqlSession)、
核心處理層(配置解析、參數映射、sql解析、SQL執行、結果集映射、插件)、
基礎支持層(數據源模塊、事務管理模塊、緩存模塊、Binding模塊、反射模塊、類型轉換、日誌模塊、資源加載、解析器模塊)。
*本文主要講解反射模塊。*
/**
* MyBatis uses an ObjectFactory to create all needed new Objects.
*
* @author Clinton Begin
*/
public interface ObjectFactory {
/**
* Sets configuration properties.
* @param properties configuration properties
*/
void setProperties(Properties properties);
/**
* Creates a new object with default constructor.
* @param type Object type
* @return
*/
<T> T create(Class<T> type);
/**
* Creates a new object with the specified constructor and params.
* @param type Object type
* @param constructorArgTypes Constructor argument types
* @param constructorArgs Constructor argument values
* @return
*/
<T> T create(Class<T> type, List<Class<?>> constructorArgTypes, List<Object> constructorArgs);
/**
* Returns true if this object can have a set of other objects.
* It's main purpose is to support non-java.util.Collection objects like Scala collections.
*
* @param type Object type
* @return whether it is a collection or not
* @since 3.1.0
*/
<T> boolean isCollection(Class<T> type);
}