private void initService(String dbId, Map<String, String> conf) { Map<String, String> svcConf = new HashMap<>(); String prefix = "db." + (S.blank(dbId) ? "" : dbId + "."); for (String key : conf.keySet()) { if (key.startsWith(prefix)) { String o = conf.get(key); svcConf.put(key.substring(prefix.length()), o); } } String impl = svcConf.remove("impl"); String svcId = S.empty(dbId) ? DEFAULT : dbId; if (null == impl) { throw new ConfigurationException("Cannot init db service[%s]: implementation not specified", svcId); } DbPlugin plugin = Act.dbManager().plugin(impl); if (null == plugin) { throw new ConfigurationException("Cannot init db service[%s]: implementation not found: %s", svcId, impl); } DbService svc = plugin.initDbService(S.blank(dbId) ? DEFAULT : dbId, app(), svcConf); serviceMap.put(svcId, svc); logger.info("db service[%s] initialized", svcId); }
private void initService(String dbId, Map<String, String> conf) { Map<String, String> svcConf = new HashMap<>(); String prefix = "db." + (S.blank(dbId) ? "" : dbId + "."); for (String key : conf.keySet()) { if (key.startsWith(prefix)) { String o = conf.get(key); svcConf.put(key.substring(prefix.length()), o); } } String impl = svcConf.remove("impl"); String svcId = S.empty(dbId) ? DEFAULT : dbId; if (null == impl) { throw new ConfigurationException("Cannot init db service[%s]: implementation not specified", svcId); } DbPlugin plugin = Act.dbManager().plugin(impl); if (null == plugin) { throw new ConfigurationException("Cannot init db service[%s]: implementation not found: %s", svcId, impl); } DbService svc = plugin.initDbService(S.blank(dbId) ? DEFAULT : dbId, app(), svcConf); serviceMap.put(svcId, svc); logger.info("db service[%s] initialized", svcId); }
} else { logger.warn("DB configuration not found. Will try to init default service with the sole db plugin: %s", db); DbService svc = db.initDbService(DEFAULT, app(), new HashMap<String, String>()); serviceMap.put(DEFAULT, svc); return; DbService svc = db.initDbService(DEFAULT, app(), svcConf); serviceMap.put(DEFAULT, svc);
} else { logger.warn("DB configuration not found. Will try to init default service with the sole db plugin: %s", db); DbService svc = db.initDbService(DEFAULT, app(), new HashMap<String, String>()); serviceMap.put(DEFAULT, svc); return; DbService svc = db.initDbService(DEFAULT, app(), svcConf); serviceMap.put(DEFAULT, svc);