01: package org.claros.commons.db;
02:
03: import java.util.HashMap;
04:
05: import javax.sql.DataSource;
06:
07: import org.apache.commons.logging.Log;
08: import org.apache.commons.logging.LogFactory;
09:
10: public class DbConfigList {
11: private static Log log = LogFactory.getLog(DbConfigList.class);
12:
13: public static HashMap dbList = new HashMap();
14:
15: public void addDbConfig(DbConfig db) {
16: dbList.put(db.getId(), db);
17: }
18:
19: public static HashMap getDbList() {
20: return dbList;
21: }
22:
23: public static DataSource getDataSourceById(String id) {
24: DbConfig db = (DbConfig) dbList.get(id);
25: if (db != null) {
26: return db.getDataSource();
27: } else {
28: log
29: .warn("The Id Searched at the DbConfigList does not correspond to a DbConfig");
30: return null;
31: }
32: }
33: }
|