List of usage examples for org.apache.ibatis.io Resources getResourceAsProperties
public static Properties getResourceAsProperties(String resource) 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 ww w . ja va 2 s. co 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:Clases.ConsultaMedica.java
public String creaExpediente() { logger.info("\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t============ METODO: creaExpediente() ============"); String expediente = "/" + paciente.getIdPaciente() + "_" + paciente.getNombre().replace(" ", "_") + "_" + paciente.getApellidoPaterno().replaceAll(" ", "_") + "_" + paciente.getApellidoMaterno().replaceAll(" ", "_") + "/Consulta_" + id + "_" + new SimpleDateFormat("yyyy-MM-dd").format(new Date()); File directorio = null;//from ww w. j av a 2s. c o m try { Properties properties = Resources.getResourceAsProperties("configuracion.properties"); // Cargar las propiedades del archivo //String Escritorio=System.getProperty("user.home").replaceAll("\\", "/")+"/Desktop"; directorio = new File(System.getProperty("user.home") + System.getProperty("file.separator") + "Desktop" + System.getProperty("file.separator") + properties.getProperty("directorio") + expediente); //directorio = new File(System.getProperty("user.home")+System.getProperty("file.separator")+"Desktop"+ expediente); logger.info(directorio.toString()); if (!directorio.exists()) { directorio.mkdirs(); } } catch (FileNotFoundException e) { // System.out.println(e.getMessage()); logger.info("###ERROR### " + e.getMessage()); } catch (IOException e) { //System.out.println(e.getMessage()); logger.info("###ERROR### " + e.getMessage()); } return directorio.toString(); }
From source file:Clases.ConsultaMedica.java
public static void main(String[] args) { try {//from w w w. j av a 2 s .c o m File archivo = Resources.getResourceAsFile("configuracion.properties"); System.out.println(archivo.toString()); Properties properties = Resources.getResourceAsProperties("configuracion.properties"); System.out.println(properties.getProperty("directorio")); } catch (IOException ex) { Logger.getLogger(ConsultaMedica.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.collective.messages.persistence.dao.BaseDataTestCase.java
License:Apache License
public static UnpooledDataSource createUnpooledDataSource(String resource) throws IOException { Properties props = Resources.getResourceAsProperties(resource); UnpooledDataSource ds = createUnpooledDataSource(props); return ds;//w w w. ja va 2s. c o m }
From source file:com.collective.messages.persistence.dao.BaseDataTestCase.java
License:Apache License
public static PooledDataSource createPooledDataSource(String resource) throws IOException { Properties props = Resources.getResourceAsProperties(resource); PooledDataSource ds = createPooledDataSource(props); return ds;/*from w w w . j a v a 2 s. co m*/ }
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 ww w . jav a 2s.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); }
From source file:org.makersoft.shards.unit.BaseTest.java
License:Open Source License
public static UnpooledDataSource createUnpooledDataSource(String resource) throws IOException { Properties props = Resources.getResourceAsProperties(resource); UnpooledDataSource ds = new UnpooledDataSource(); ds.setDriver(props.getProperty("driver")); ds.setUrl(props.getProperty("url")); ds.setUsername(props.getProperty("username")); ds.setPassword(props.getProperty("password")); return ds;//from ww w.jav a2 s . c o m }
From source file:org.makersoft.shards.unit.BaseTest.java
License:Open Source License
public static PooledDataSource createPooledDataSource(String resource) throws IOException { Properties props = Resources.getResourceAsProperties(resource); PooledDataSource ds = new PooledDataSource(); ds.setDriver(props.getProperty("driver")); ds.setUrl(props.getProperty("url")); ds.setUsername(props.getProperty("username")); ds.setPassword(props.getProperty("password")); return ds;/* w ww . j a va2 s . c o m*/ }
From source file:org.makersoft.shards.unit.BaseTest.java
License:Open Source License
public static DataSource createDataSource_1() throws IOException, SQLException { Properties props = Resources.getResourceAsProperties(H2_PROPERTIES); UnpooledDataSource ds = new UnpooledDataSource(); ds.setDriver(props.getProperty("jdbc.driver")); ds.setUrl(props.getProperty("ds1.jdbc.url")); ds.setUsername(props.getProperty("ds1.jdbc.username")); ds.setPassword(props.getProperty("ds1.jdbc.password")); return ds;/* w w w . ja v a2 s .com*/ }
From source file:org.makersoft.shards.unit.BaseTest.java
License:Open Source License
public static DataSource createDataSource_2() throws IOException, SQLException { Properties props = Resources.getResourceAsProperties(H2_PROPERTIES); UnpooledDataSource ds = new UnpooledDataSource(); ds.setDriver(props.getProperty("jdbc.driver")); ds.setUrl(props.getProperty("ds2.jdbc.url")); ds.setUsername(props.getProperty("ds2.jdbc.username")); ds.setPassword(props.getProperty("ds2.jdbc.password")); return ds;//from w w w . j a va 2 s . co m }