Example usage for org.apache.ibatis.binding MapperProxyFactory MapperProxyFactory

List of usage examples for org.apache.ibatis.binding MapperProxyFactory MapperProxyFactory

Introduction

In this page you can find the example usage for org.apache.ibatis.binding MapperProxyFactory MapperProxyFactory.

Prototype

public MapperProxyFactory(Class<T> mapperInterface) 

Source Link

Usage

From source file:com.baomidou.mybatisplus.MybatisMapperRegistry.java

License:Apache License

@Override
public <T> void addMapper(Class<T> type) {
    if (type.isInterface()) {
        if (hasMapper(type)) {
            // TODO ? 
            return;
            // throw new BindingException("Type " + type +
            // " is already known to the MybatisPlusMapperRegistry.");
        }//from   ww  w.  ja  va2 s  . co m
        boolean loadCompleted = false;
        try {
            knownMappers.put(type, new MapperProxyFactory<>(type));
            // It's important that the type is added before the parser is
            // run
            // otherwise the binding may automatically be attempted by the
            // mapper parser. If the type is already known, it won't try.

            // TODO  XML 
            MybatisMapperAnnotationBuilder parser = new MybatisMapperAnnotationBuilder(config, type);
            parser.parse();
            loadCompleted = true;
        } finally {
            if (!loadCompleted) {
                knownMappers.remove(type);
            }
        }
    }
}

From source file:com.mybatisX.core.MybatisMapperRegistry.java

License:Apache License

public <T> void addMapper(Class<T> type) {
    if (type.isInterface()) {
        if (hasMapper(type)) {
            //TODO ? 
            return;
            // throw new BindingException("Type " + type +
            // " is already known to the MybatisPlusMapperRegistry.");
        }//from ww  w  .j a  v a 2 s .  c om
        boolean loadCompleted = false;
        try {
            knownMappers.put(type, new MapperProxyFactory<T>(type));
            // It's important that the type is added before the parser is
            // run
            // otherwise the binding may automatically be attempted by the
            // mapper parser. If the type is already known, it won't try.

            //TODO  XML 
            MybatisMapperAnnotationBuilder parser = new MybatisMapperAnnotationBuilder(config, type);
            parser.parse();
            loadCompleted = true;
        } finally {
            if (!loadCompleted) {
                knownMappers.remove(type);
            }
        }
    }
}