Created
September 30, 2011 10:22
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class ManagedDatasource { | |
final BoneCPDataSource ds; | |
final String url; | |
public ManagedDatasource(BoneCPDataSource ds, String url) { | |
this.ds = ds; | |
this.url = url; | |
} | |
} | |
private DBApi dbs = null; | |
private DBApi getDbs() { | |
synchronized(dbs) { | |
if(dbs == null) { | |
Configuration dbConf = app.configuration.getSub("db"); | |
Map<String,ManagedDatasource> datasources = new HashMap<String,ManagedDatasource>(); | |
if(dbConf != null) { | |
for(String key: dbConf.subkeys()) { | |
ManagedDatasource ds = DBApi.createDataSource(dbConf.getSub(key), app.classloader); | |
datasources.put(key, new ManagedDatasource(ds)); | |
} | |
} | |
dbs = new DBApi(datasources); | |
} | |
return dbs; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lazy val dbs = { | |
DBApi(app.configuration.getSub("db").map { dbConf => | |
dbConf.subKeys.map { db => | |
db -> DBApi.createDataSource(dbConf.getSub(db).get, app.classloader) | |
}.toMap | |
}.getOrElse(Map.empty)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment