public static Properties loadProperties ( String [ ] filesToLoad ) { Properties p = new Properties ( ) ; InputStream fis = null ; for ( String path : filesToLoad ) { try { fis = Db . class . getClassLoader ( ) . getResourceAsStream ( path ) ; if ( fis != null ) { p . load ( fis ) ; jqmlogger . info ( "A jqm.properties file was found at {}" , path ) ; } } catch ( IOException e ) { // We allow no configuration files, but not an unreadable configuration file. throw new DatabaseException ( "META-INF/jqm.properties file is invalid" , e ) ; } finally { closeQuietly ( fis ) ; } } // Overload the datasource name from environment variable if any (tests only). String dbName = System . getenv ( "DB" ) ; if ( dbName != null ) { p . put ( "com.enioka.jqm.jdbc.datasource" , "jdbc/" + dbName ) ; } // Done return p ; }
Helper method to load a property file from class path .