private void loadProviders(String providersString) { String[] providerArray = providersString.split(","); for (String p : providerArray) { try { log.info(String.format("Loading Configuration Provider :: %s", p)); ConfigurationProvider cp = (ConfigurationProvider) Class.forName(p).newInstance(); cp.init(); providers.add(cp); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { log.warn("Could not load provider class", e); } catch (IOException e) { log.warn("Could not initialize provider"); } } }
private String lookupKey(String key) { for (ConfigurationProvider cp : providers) { String value = null; try { value = cp.getValue(key); } catch (IOException e) { log.warn( String.format( "Error retrieving value for \"%s\" from provider (%s)", key, cp.getName()), e); } if (value != null) { return value; } } return null; }