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


Java XPathParser类代码示例

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


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

示例1: init

import org.apache.ibatis.parsing.XPathParser; //导入依赖的package包/类
public void init() throws IOException, SAXException, ParserConfigurationException, ClassNotFoundException {
	log.info("parse " + configLocation);
	// 解析xml
	InputStream inputStream=MapperScanApplication.class.getClassLoader().getResourceAsStream(configLocation);
	
	Configuration configuration = sqlSessionFactory.getConfiguration();

	if(inputStream==null){
		return;
	}
	XPathParser xPathParser = new XPathParser(inputStream);
	XNode root = xPathParser.evalNode("/configuration");

	handleSetting(configuration, root);

	handleTypeAlias(configuration, root);

	handleMappers(configuration, root);
}
 
开发者ID:babymm,项目名称:mumu,代码行数:20,代码来源:MapperScanApplication.java

示例2: createSqlSource

import org.apache.ibatis.parsing.XPathParser; //导入依赖的package包/类
@Override
public SqlSource createSqlSource(Configuration configuration, String script, Class<?> parameterType) {
  // issue #3
  if (script.startsWith("<script>")) {
    XPathParser parser = new XPathParser(script, false, configuration.getVariables(), new XMLMapperEntityResolver());
    return createSqlSource(configuration, parser.evalNode("/script"), parameterType);
  } else {
    // issue #127
    script = PropertyParser.parse(script, configuration.getVariables());
    TextSqlNode textSqlNode = new TextSqlNode(script);
    if (textSqlNode.isDynamic()) {
      return new DynamicSqlSource(configuration, textSqlNode);
    } else {
      return new RawSqlSource(configuration, script, parameterType);
    }
  }
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:18,代码来源:XMLLanguageDriver.java

示例3: createSqlSource

import org.apache.ibatis.parsing.XPathParser; //导入依赖的package包/类
@Override
public SqlSource createSqlSource(Configuration configuration, String script, Class<?> parameterType) {
  // issue #3
  if (script.startsWith("<script>")) {
    XPathParser parser = new XPathParser(script, false, configuration.getVariables(), new XMLMapperEntityResolver());
    return createSqlSource(configuration, parser.evalNode("/script"), parameterType);
  } else {
    // issue #127
    script = PropertyParser.parse(script, configuration.getVariables());
    TextSqlNode textSqlNode = new TextSqlNode(script);
    //一种是动态,一种是原始
    if (textSqlNode.isDynamic()) {
      return new DynamicSqlSource(configuration, textSqlNode);
    } else {
      return new RawSqlSource(configuration, script, parameterType);
    }
  }
}
 
开发者ID:shurun19851206,项目名称:mybaties,代码行数:19,代码来源:XMLLanguageDriver.java

示例4: refresh

import org.apache.ibatis.parsing.XPathParser; //导入依赖的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

示例5: MybatisXMLMapperBuilder

import org.apache.ibatis.parsing.XPathParser; //导入依赖的package包/类
private MybatisXMLMapperBuilder(XPathParser parser, Configuration configuration, String resource, Map<String, XNode> sqlFragments) {
    super(configuration);
    this.builderAssistant = new MapperBuilderAssistant(configuration, resource);
    this.parser = parser;
    this.sqlFragments = sqlFragments;
    this.resource = resource;
}
 
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:8,代码来源:MybatisXMLMapperBuilder.java

示例6: MybatisXMLConfigBuilder

import org.apache.ibatis.parsing.XPathParser; //导入依赖的package包/类
private MybatisXMLConfigBuilder(XPathParser parser, String environment, Properties props) {
    //TODO 自定义 Configuration
    super(new MybatisConfiguration());
    ErrorContext.instance().resource("SQL Mapper Configuration");
    this.configuration.setVariables(props);
    this.parsed = false;
    this.environment = environment;
    this.parser = parser;
}
 
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:10,代码来源:MybatisXMLConfigBuilder.java

示例7: HierarchicalXMLConfigBuilder

import org.apache.ibatis.parsing.XPathParser; //导入依赖的package包/类
public HierarchicalXMLConfigBuilder(HierarchicalResourceLoader resourceLoader, InputStream inputStream, String environment, Properties props)
{
    super(new Configuration());
    
    // EXTENDED
    this.resourceLoader = resourceLoader;
    
    ErrorContext.instance().resource("SQL Mapper Configuration");
    this.configuration.setVariables(props);
    this.parsed = false;
    this.environment = environment;
    this.parser = new XPathParser(inputStream, true, props, new XMLMapperEntityResolver());
}
 
开发者ID:Alfresco,项目名称:alfresco-core,代码行数:14,代码来源:HierarchicalXMLConfigBuilder.java

示例8: XMLMapperBuilder

import org.apache.ibatis.parsing.XPathParser; //导入依赖的package包/类
private XMLMapperBuilder(XPathParser parser, Configuration configuration, String resource, Map<String, XNode> sqlFragments) {
  super(configuration);
  this.builderAssistant = new MapperBuilderAssistant(configuration, resource);
  this.parser = parser;
  this.sqlFragments = sqlFragments;
  this.resource = resource;
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:8,代码来源:XMLMapperBuilder.java

示例9: XMLConfigBuilder

import org.apache.ibatis.parsing.XPathParser; //导入依赖的package包/类
private XMLConfigBuilder(XPathParser parser, String environment, Properties props) {
  super(new Configuration());
  ErrorContext.instance().resource("SQL Mapper Configuration");
  this.configuration.setVariables(props);
  this.parsed = false;
  this.environment = environment;
  this.parser = parser;
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:9,代码来源:XMLConfigBuilder.java

示例10: XMLMapperBuilder

import org.apache.ibatis.parsing.XPathParser; //导入依赖的package包/类
@Deprecated
public XMLMapperBuilder(Reader reader, Configuration configuration,
		String resource, Map<String, XNode> sqlFragments) {
	this(new XPathParser(reader, true, configuration.getVariables(),
			new XMLMapperEntityResolver()), configuration, resource,
			sqlFragments);
}
 
开发者ID:EleTeam,项目名称:Shop-for-JavaWeb,代码行数:8,代码来源:XMLMapperBuilder.java

示例11: refresh

import org.apache.ibatis.parsing.XPathParser; //导入依赖的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

示例12: XMLConfigBuilder

import org.apache.ibatis.parsing.XPathParser; //导入依赖的package包/类
private XMLConfigBuilder(XPathParser parser, String environment, Properties props) {
	super(new Configuration());
	ErrorContext.instance().resource("SQL Mapper Configuration");
	this.configuration.setVariables(props);
	this.parsed = false;
	this.environment = environment;
	this.parser = parser;
}
 
开发者ID:whatlookingfor,项目名称:spring-boot-sample,代码行数:9,代码来源:XMLConfigBuilder.java

示例13: XMLConfigBuilder

import org.apache.ibatis.parsing.XPathParser; //导入依赖的package包/类
private XMLConfigBuilder(XPathParser parser, String environment, Properties props) {
  //首先调用父类初始化Configuration
  super(new Configuration());
  //错误上下文设置成SQL Mapper Configuration(XML文件配置),以便后面出错了报错用吧
  ErrorContext.instance().resource("SQL Mapper Configuration");
  //将Properties全部设置到Configuration里面去
  this.configuration.setVariables(props);
  this.parsed = false;
  this.environment = environment;
  this.parser = parser;
}
 
开发者ID:shurun19851206,项目名称:mybaties,代码行数:12,代码来源:XMLConfigBuilder.java


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