List of usage examples for org.apache.ibatis.io Resources getUrlAsProperties
public static Properties getUrlAsProperties(String urlString) throws IOException
From source file:cc.oit.dao.impl.mybatis.session.XMLConfigBuilder.java
License:Apache License
private void propertiesElement(XNode context) throws Exception { if (context != null) { Properties defaults = context.getChildrenAsProperties(); String resource = context.getStringAttribute("resource"); String url = context.getStringAttribute("url"); if (resource != null && url != null) { throw new BuilderException( "The properties element cannot specify both a URL and a resource based property file reference. Please specify one or the other."); }//from w w w. j ava2s .c o m if (resource != null) { defaults.putAll(Resources.getResourceAsProperties(resource)); } else if (url != null) { defaults.putAll(Resources.getUrlAsProperties(url)); } Properties vars = configuration.getVariables(); if (vars != null) { defaults.putAll(vars); } parser.setVariables(defaults); configuration.setVariables(defaults); } }
From source file:com.ibatis.sqlmap.engine.builder.XmlSqlMapConfigParser.java
License:Apache License
@NodeEvent("/sqlMapConfig/properties") public void sqlMapConfigproperties(XNode context) throws Exception { String resource = context.getStringAttribute("resource"); String url = context.getStringAttribute("url"); Properties fileVariables;/*from w w w . j a va 2 s . c o m*/ if (resource != null) { fileVariables = Resources.getResourceAsProperties(resource); } else if (url != null) { fileVariables = Resources.getUrlAsProperties(url); } else { throw new RuntimeException("The properties element requires either a resource or a url attribute."); } // Override file variables with those passed in programmatically Properties passedVariables = config.getVariables(); if (passedVariables != null) { fileVariables.putAll(passedVariables); } config.setVariables(fileVariables); parser.setVariables(fileVariables); }