org.apache.ibatis.parsing.XPathParser Java Examples

The following examples show how to use org.apache.ibatis.parsing.XPathParser. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MapperScanApplication.java    From mumu with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example #2
Source File: XMLLanguageDriver.java    From mybatis with Apache License 2.0 6 votes vote down vote up
@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);
    }
  }
}
 
Example #3
Source File: XMLLanguageDriver.java    From mybaties with Apache License 2.0 6 votes vote down vote up
@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);
    }
  }
}
 
Example #4
Source File: XMLMapperBuilder.java    From Shop-for-JavaWeb with MIT License 5 votes vote down vote up
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;
}
 
Example #5
Source File: XMLMapperBuilder.java    From Shop-for-JavaWeb with MIT License 5 votes vote down vote up
@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);
}
 
Example #6
Source File: XMLMapperBuilder.java    From Shop-for-JavaWeb with MIT License 5 votes vote down vote up
public XMLMapperBuilder(InputStream inputStream,
		Configuration configuration, String resource,
		Map<String, XNode> sqlFragments) {
	this(new XPathParser(inputStream, true, configuration.getVariables(),
			new XMLMapperEntityResolver()), configuration, resource,
			sqlFragments);
}
 
Example #7
Source File: XMLMapperBuilder.java    From mybaties with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #8
Source File: XMLConfigBuilder.java    From QuickProject with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #9
Source File: XMLConfigBuilder.java    From mybaties with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #10
Source File: HierarchicalXMLConfigBuilder.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
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());
}
 
Example #11
Source File: XMLConfigBuilder.java    From mybatis with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #12
Source File: XMLMapperBuilder.java    From mybatis with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #13
Source File: XPathParserCaller.java    From HotswapAgent with GNU General Public License v2.0 4 votes vote down vote up
public static boolean refreshDocument(XPathParser parser) {
    return (boolean) ReflectionHelper.invoke(parser, MyBatisTransformers.REFRESH_DOCUMENT_METHOD);
}
 
Example #14
Source File: XPathParserCaller.java    From HotswapAgent with GNU General Public License v2.0 4 votes vote down vote up
public static String getSrcFileName(XPathParser parser) {
    return (String) ReflectionHelper.get(parser, MyBatisTransformers.SRC_FILE_NAME_FIELD);
}
 
Example #15
Source File: XMLConfigBuilder.java    From QuickProject with Apache License 2.0 4 votes vote down vote up
public XMLConfigBuilder(InputStream inputStream, String environment, Properties props) {
  this(new XPathParser(inputStream, true, props, new XMLMapperEntityResolver()), environment, props);
}
 
Example #16
Source File: XMLConfigBuilder.java    From QuickProject with Apache License 2.0 4 votes vote down vote up
public XMLConfigBuilder(Reader reader, String environment, Properties props) {
  this(new XPathParser(reader, true, props, new XMLMapperEntityResolver()), environment, props);
}
 
Example #17
Source File: XMLConfigBuilder.java    From mybatis with Apache License 2.0 4 votes vote down vote up
public XMLConfigBuilder(InputStream inputStream, String environment, Properties props) {
  this(new XPathParser(inputStream, true, props, new XMLMapperEntityResolver()), environment, props);
}
 
Example #18
Source File: XMLConfigBuilder.java    From mybatis with Apache License 2.0 4 votes vote down vote up
public XMLConfigBuilder(Reader reader, String environment, Properties props) {
  //构造一个需要验证,XMLMapperEntityResolver的XPathParser
  this(new XPathParser(reader, true, props, new XMLMapperEntityResolver()), environment, props);
}
 
Example #19
Source File: XMLMapperBuilder.java    From mybatis with Apache License 2.0 4 votes vote down vote up
public XMLMapperBuilder(InputStream inputStream, Configuration configuration, String resource, Map<String, XNode> sqlFragments) {
  this(new XPathParser(inputStream, true, configuration.getVariables(), new XMLMapperEntityResolver()),
      configuration, resource, sqlFragments);
}
 
Example #20
Source File: XMLMapperBuilder.java    From mybatis with Apache License 2.0 4 votes vote down vote up
@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);
}
 
Example #21
Source File: XMLConfigBuilder.java    From mybaties with Apache License 2.0 4 votes vote down vote up
public XMLConfigBuilder(InputStream inputStream, String environment, Properties props) {
  this(new XPathParser(inputStream, true, props, new XMLMapperEntityResolver()), environment, props);
}
 
Example #22
Source File: XMLConfigBuilder.java    From mybaties with Apache License 2.0 4 votes vote down vote up
public XMLConfigBuilder(Reader reader, String environment, Properties props) {
  //构造一个需要验证,XMLMapperEntityResolver的XPathParser
  this(new XPathParser(reader, true, props, new XMLMapperEntityResolver()), environment, props);
}
 
Example #23
Source File: XMLMapperBuilder.java    From mybaties with Apache License 2.0 4 votes vote down vote up
public XMLMapperBuilder(InputStream inputStream, Configuration configuration, String resource, Map<String, XNode> sqlFragments) {
  this(new XPathParser(inputStream, true, configuration.getVariables(), new XMLMapperEntityResolver()),
      configuration, resource, sqlFragments);
}
 
Example #24
Source File: XMLMapperBuilder.java    From mybaties with Apache License 2.0 4 votes vote down vote up
@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);
}