当前位置: 首页>>代码示例>>Java>>正文


Java MapperRegistry类代码示例

本文整理汇总了Java中org.apache.ibatis.binding.MapperRegistry的典型用法代码示例。如果您正苦于以下问题:Java MapperRegistry类的具体用法?Java MapperRegistry怎么用?Java MapperRegistry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MapperRegistry类属于org.apache.ibatis.binding包,在下文中一共展示了MapperRegistry类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: refresh

import org.apache.ibatis.binding.MapperRegistry; //导入依赖的package包/类
/**
 * 刷新mapper
 *
 * @throws Exception
 */
@SuppressWarnings("rawtypes")
private void refresh(Resource resource) throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException {
    this.configuration = sqlSessionFactory.getConfiguration();
    boolean isSupper = configuration.getClass().getSuperclass() == Configuration.class;
    try {
        Field loadedResourcesField = isSupper ? configuration.getClass().getSuperclass().getDeclaredField("loadedResources")
                : configuration.getClass().getDeclaredField("loadedResources");
        loadedResourcesField.setAccessible(true);
        Set loadedResourcesSet = ((Set) loadedResourcesField.get(configuration));
        XPathParser xPathParser = new XPathParser(resource.getInputStream(), true, configuration.getVariables(),
                new XMLMapperEntityResolver());
        XNode context = xPathParser.evalNode("/mapper");
        String namespace = context.getStringAttribute("namespace");
        Field field = MapperRegistry.class.getDeclaredField("knownMappers");
        field.setAccessible(true);
        Map mapConfig = (Map) field.get(configuration.getMapperRegistry());
        mapConfig.remove(Resources.classForName(namespace));
        loadedResourcesSet.remove(resource.toString());
        configuration.getCacheNames().remove(namespace);
        cleanParameterMap(context.evalNodes("/mapper/parameterMap"), namespace);
        cleanResultMap(context.evalNodes("/mapper/resultMap"), namespace);
        cleanKeyGenerators(context.evalNodes("insert|update"), namespace);
        cleanSqlElement(context.evalNodes("/mapper/sql"), namespace);
        XMLMapperBuilder xmlMapperBuilder = new XMLMapperBuilder(resource.getInputStream(),
                sqlSessionFactory.getConfiguration(), // 注入的sql先不进行处理了
                resource.toString(), sqlSessionFactory.getConfiguration().getSqlFragments());
        xmlMapperBuilder.parse();
        logger.debug("refresh: '" + resource + "', success!");
    } catch (IOException e) {
        logger.error("Refresh IOException :" + e.getMessage());
    } finally {
        ErrorContext.instance().reset();
    }
}
 
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:40,代码来源:MybatisMapperRefresh.java

示例2: refresh

import org.apache.ibatis.binding.MapperRegistry; //导入依赖的package包/类
/**
 * 刷新mapper
 *
 * @throws Exception
 */
@SuppressWarnings("rawtypes")
private void refresh(Resource resource) throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException {
    this.configuration = sqlSessionFactory.getConfiguration();
    boolean isSupper = configuration.getClass().getSuperclass() == Configuration.class;
    try {
        Field loadedResourcesField = isSupper ? configuration.getClass().getSuperclass().getDeclaredField("loadedResources")
                : configuration.getClass().getDeclaredField("loadedResources");
        loadedResourcesField.setAccessible(true);
        Set loadedResourcesSet = ((Set) loadedResourcesField.get(configuration));
        XPathParser xPathParser = new XPathParser(resource.getInputStream(), true, configuration.getVariables(),
                new XMLMapperEntityResolver());
        XNode context = xPathParser.evalNode("/mapper");
        String namespace = context.getStringAttribute("namespace");
        Field field = MapperRegistry.class.getDeclaredField("knownMappers");
        field.setAccessible(true);
        Map mapConfig = (Map) field.get(configuration.getMapperRegistry());
        mapConfig.remove(Resources.classForName(namespace));
        loadedResourcesSet.remove(resource.toString());
        configuration.getCacheNames().remove(namespace);
        cleanParameterMap(context.evalNodes("/mapper/parameterMap"), namespace);
        cleanResultMap(context.evalNodes("/mapper/resultMap"), namespace);
        cleanKeyGenerators(context.evalNodes("insert|update"), namespace);
        cleanSqlElement(context.evalNodes("/mapper/sql"), namespace);
        XMLMapperBuilder xmlMapperBuilder = new XMLMapperBuilder(resource.getInputStream(),
                sqlSessionFactory.getConfiguration(),
                resource.toString(), sqlSessionFactory.getConfiguration().getSqlFragments());
        xmlMapperBuilder.parse();
        logger.debug("refresh: '" + resource + "', success!");
    } catch (IOException e) {
        logger.error("Refresh IOException :" + e.getMessage());
    } finally {
        ErrorContext.instance().reset();
    }
}
 
开发者ID:baomidou,项目名称:mybatis-plus,代码行数:40,代码来源:MybatisMapperRefresh.java

示例3: getMapperRegistry

import org.apache.ibatis.binding.MapperRegistry; //导入依赖的package包/类
@Override
public MapperRegistry getMapperRegistry() {
    return mybatisMapperRegistry;
}
 
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:5,代码来源:MybatisConfiguration.java

示例4: getMapperRegistry

import org.apache.ibatis.binding.MapperRegistry; //导入依赖的package包/类
/**
 * @since 3.2.2
 */
public MapperRegistry getMapperRegistry() {
  return mapperRegistry;
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:7,代码来源:Configuration.java

示例5: getMapperRegistry

import org.apache.ibatis.binding.MapperRegistry; //导入依赖的package包/类
/**
 * @since 3.2.2
 */
public MapperRegistry getMapperRegistry() {
	return mapperRegistry;
}
 
开发者ID:EleTeam,项目名称:Shop-for-JavaWeb,代码行数:7,代码来源:Configuration.java


注:本文中的org.apache.ibatis.binding.MapperRegistry类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。