3、 ... and 、getMapper Get the proxy object of the interface

1. First call DefaultSqlSession Of getMapper Method . The code is as follows :

 @Override
public <T> T getMapper(Class<T> type) {
return configuration.<T>getMapper(type, this);
}

2. It's actually called configuration Of getMapper Method . The specific code is as follows :

 public <T> T getMapper(Class<T> type, SqlSession sqlSession) {
return mapperRegistry.getMapper(type, sqlSession);
}

3. It's called again mapperRegistry Of getMapper Method . The code is as follows :

 @SuppressWarnings("unchecked")
public <T> T getMapper(Class<T> type, SqlSession sqlSession) {
// 4. Get... According to the interface type mapperProxyFactory
final MapperProxyFactory<T> mapperProxyFactory = (MapperProxyFactory<T>) knownMappers.get(type);
if (mapperProxyFactory == null) {
throw new BindingException("Type " + type + " is not known to the MapperRegistry.");
}
try {
return mapperProxyFactory.newInstance(sqlSession);
} catch (Exception e) {
throw new BindingException("Error getting mapper instance. Cause: " + e, e);
}
}

4. Specifically, we can look at this industry :return mapperProxyFactory.newInstance(sqlSession);.mapperProxyFactory The method is as follows :

 @SuppressWarnings("unchecked")
protected T newInstance(MapperProxy<T> mapperProxy) {
return (T) Proxy.newProxyInstance(mapperInterface.getClassLoader(), new Class[] { mapperInterface }, mapperProxy);
}
public T newInstance(SqlSession sqlSession) {
final MapperProxy<T> mapperProxy = new MapperProxy<T>(sqlSession, mapperInterface, methodCache);
return newInstance(mapperProxy);
}

MyBatis 3 The source code parsing ( 3、 ... and ) More articles about

  1. Mybatis The source code parsing ( 3、 ... and ) —— Mapper Generation of proxy classes

    Mybatis The source code parsing ( 3、 ... and ) -- Mapper Generation of proxy classes In the first article of this series, I have talked about Mybatis-Spring In the project , It's through MapperFactoryBean Of getObject( ...

  2. Celery Source code analysis 3 : Task Object implementation

    Task Implementation in Celery You'll find that there are two places , One is located in celery/app/task.py, This is the first one : The second is in celery/task/base.py in , This is the second . There is a relationship between them , ...

  3. ReactiveCocoa The source code parsing ( 3、 ... and ) Signal The basic implementation of the code

    Last blog we talked about in detail ReactiveSwift In the source Bag Containers , For details, see <ReactiveSwift Source code analysis Bag Containers >. In this blog, let's talk about semaphores , That is to say Signal There are several forms of ...

  4. ReactiveSwift The source code parsing ( 3、 ... and ) Signal The basic implementation of the code

    Last blog we talked about in detail ReactiveSwift In the source Bag Containers , For details, see <ReactiveSwift Source code analysis Bag Containers >. In this blog, let's talk about semaphores , That is to say Signal There are several forms of ...

  5. React Of React.createRef()/forwardRef() The source code parsing ( 3、 ... and )

    1.refs Three uses 1. character string 1.1 dom Use... On nodes Get real dom node // Use steps : 1. <input ref="stringRef" /> 2. t ...

  6. MyBatis Detailed source code analysis ( Part 1 )

    Preface I will take you step by step to analyze MyBatis This classic half ORM Source code of framework ! I use it. Spring Boot + MyBatis The way to test , But it's not integrated , Or in the most primitive way . Project structure Import dependence : ...

  7. Spring Source code analysis 3 :IOC Dependency injection of container

    In general , The process of dependency injection takes place when the user first asks the container for Bean It's triggered , And what triggers dependency injection is BeanFactory Of getBean Method . Here we use DefaultListableBeanFactory ...

  8. jQuery The source code parsing ( 3、 ... and ) pushStack Method Detailed explanation

    This function is used to create a new jQuery object , And then put a DOM Element collection added to jQuery In the stack , Finally return to the jQuery object , There are three parameters , as follows : elems Array type About to be pressed in jQuery Array elements of stack ...

  9. AFNetworking2.0 The source code parsing &lt; 3、 ... and &gt;

    This article talks about safety related AFSecurityPolicy modular ,AFSecurityPolicy Used to verify HTTPS Requested certificate , First look at it. HTTPS The principle of certificate and several problems related to certificate . HTTPS HTTPS Connection establishment process ...

Random recommendation

  1. Show oracle Table partition information

    Display partition table information Display the information of all partition tables in the database :DBA_PART_TABLES Display all partition table information that the current user can access :ALL_PART_TABLES Display the information of all partition tables of the current user :USER_PART_TAB ...

  2. [ original ]java WEB Learning notes 59:Struts2 Way of learning ---OGNL, valuestack , Read the properties of objects in the object stack , Read Context Map The properties of objects in , Call fields and methods , Array ,list,map

    The purpose of this blog :① Summarize your learning process , It's like learning notes ② Share your experience with you , Learn from each other , Communicate with each other , Not for commercial use There are bound to be problems with the content , Welcome to correct , communication , discuss , You can leave a message , You can also contact through the following ways . I love internet technology ...

  3. Seam carving Learning notes

    Today, I first came into contact with seam carving knowledge , It's amazing . Although I may not understand very deeply , But write it down , It's always good . seam carving It's a direct translation “ Line clipping ” It means . Its main purpose is to ...

  4. 2014.06.20 ( turn )IEEE With the Forum

    from " When one drinks water, one must not forget where it comes from "       Most electronics students know IEEE, This IEEE It's like a big BBS Forum , And there are a lot of magazines under this association , For example, image processing , signal processing , Microwave technology, etc . These magazines are the sub editions of the forum ...

  5. iOS Get ready

    iOS Programming knowledge iOS Basic knowledge points iOS And System mechanism Xcode Using skills Mac Using skills iOS And English iOS And Extra staff knowledge iOS Knowledge base links

  6. Spring Boot introduce Oracle Jar

    Oracle The driver of the database depends on ,maven The warehouse doesn't offer , Need to be manually added 1. download jar file Such as ojdbc7.jar file Put the file in D:\oracle\ojdbc7.jar Under the path 2. Then type on the command line ...

  7. Penetration test ===kali linux Installation

    Method 1 : kali linux Installed locally vitural box perhaps wm ware in Method 2 : Installed on a mobile hard disk or memory card , Plug it into the computer and you can use it

  8. Linux Basic course 32- Unzip command

    Compressing the file will improve the efficiency of data transmission , Reduce transmission bandwidth , Managing backup data has very important functions , Therefore, file compression and decompression skills become essential skills . be relative to Windows In the file decompression tool hundred flowers contend for beauty , stay Linux The decompression tool in is ...

  9. Detailed explanation QT Source code Qt Principle of event mechanism

    QT  Source code  Qt The principle of event mechanism is the content of this paper , In use Qt Write Gui When it comes to programming , stay main The final basis in the function is app.exec(); The explanation for this sentence in many books is , send  Qt  The program enters the message loop . Now we're going to ex ...

  10. [JSON].toXMLString()

    grammar :[JSON].toXMLString() return :[String] explain : take [JSON] Instance into XML Format results . Example : <% jsonString = "{div: 'hell ...