@Test public void testInit() { MyConfigurationSource mcs1 = new MyConfigurationSource(1); MyConfigurationSource mcs2 = new MyConfigurationSource(2); MyConfigurationSource mcs3 = new MyConfigurationSource(3); MyConfigurationSource mcs4 = new MyConfigurationSource(4); MyConfigurationSource mcs5 = new MyConfigurationSource(5); MyConfigurationSource[] testCSArray = {mcs4, mcs3, mcs5, mcs1, mcs2}; DefaultConfigurationManager manager = new DefaultConfigurationManager(testCSArray); for (ConfigurationSource cs : manager.sources()) { System.out.println("The source value: " + cs.configuration().getPropertyValue("key")); } System.out.println("The default first priority source value: " + manager.getPropertyValue("key")); }
protected void init(List<ConfigurationSource> sources) { if (CollectionValues.isNullOrEmpty(sources)) { _sources = EMPTY_CONFIGURATION_SOURCE_LIST; _logger.warn("sources is null or empty"); return; } _sources = new ArrayList<ConfigurationSource>(); for (ConfigurationSource source : sources) { if (source == null || source.configuration() == null) continue; _sources.add(source); } Collections.sort(_sources, ConfigurationSourceComparator.DEFAULT); StringBuffer sourcesInfo = new StringBuffer("The sorted sources info: { "); for (ConfigurationSource cs : sources()) { sourcesInfo.append(cs.sourceId()).append(": ").append(cs.priority()).append(", "); } sourcesInfo = new StringBuffer(sourcesInfo.substring(0, sourcesInfo.length() - 2)).append(" }"); _logger.info(sourcesInfo.toString()); }
DefaultConfigurationManager implements ConfigurationManager { protected void init(List<ConfigurationSource> sources) { if (CollectionValues.isNullOrEmpty(sources)) { _sources = EMPTY_CONFIGURATION_SOURCE_LIST; _logger.warn("sources is null or empty"); return; } _sources = new ArrayList<ConfigurationSource>(); for (ConfigurationSource source : sources) { if (source == null || source.configuration() == null) continue; _sources.add(source); } Collections.sort(_sources, ConfigurationSourceComparator.DEFAULT); StringBuffer sourcesInfo = new StringBuffer("The sorted sources info: { "); for (ConfigurationSource cs : sources()) { sourcesInfo.append(cs.sourceId()).append(": ").append(cs.priority()).append(", "); } sourcesInfo = new StringBuffer(sourcesInfo.substring(0, sourcesInfo.length() - 2)).append(" }"); _logger.info(sourcesInfo.toString()); } }
DefaultConfigurationManager implements ConfigurationManager { protected void init(List<ConfigurationSource> sources) { if (CollectionValues.isNullOrEmpty(sources)) { _sources = EMPTY_CONFIGURATION_SOURCE_LIST; _logger.warn("sources is null or empty"); return; } _sources = new ArrayList<ConfigurationSource>(); for (ConfigurationSource source : sources) { if (source == null || source.configuration() == null) continue; _sources.add(source); } Collections.sort(_sources, ConfigurationSourceComparator.DEFAULT); StringBuffer sourcesInfo = new StringBuffer("The sorted sources info: { "); for (ConfigurationSource cs : sources()) { sourcesInfo.append(cs.sourceId()).append(": ").append(cs.priority()).append(", "); } sourcesInfo = new StringBuffer(sourcesInfo.substring(0, sourcesInfo.length() - 2)).append(" }"); _logger.info(sourcesInfo.toString()); } DefaultConfigurationManager(ConfigurationSource... sources); }
DefaultConfigurationManager implements ConfigurationManager { protected void init(List<ConfigurationSource> sources) { if (CollectionValues.isNullOrEmpty(sources)) { _sources = EMPTY_CONFIGURATION_SOURCE_LIST; _logger.warn("sources is null or empty"); return; } _sources = new ArrayList<ConfigurationSource>(); for (ConfigurationSource source : sources) { if (source == null || source.configuration() == null) continue; _sources.add(source); } Collections.sort(_sources, ConfigurationSourceComparator.DEFAULT); StringBuffer sourcesInfo = new StringBuffer("The sorted sources info: { "); for (ConfigurationSource cs : sources()) { sourcesInfo.append(cs.sourceId()).append(": ").append(cs.priority()).append(", "); } sourcesInfo = new StringBuffer(sourcesInfo.substring(0, sourcesInfo.length() - 2)).append(" }"); _logger.info(sourcesInfo.toString()); } DefaultConfigurationManager(ConfigurationSource... sources); @Override String getPropertyValue(String key); @Override Property getProperty(String key); @Override Collection<ConfigurationSource> sources(); }
DefaultConfigurationManager implements ConfigurationManager { protected void init(List<ConfigurationSource> sources) { if (CollectionValues.isNullOrEmpty(sources)) { _sources = EMPTY_CONFIGURATION_SOURCE_LIST; _logger.warn("sources is null or empty"); return; } _sources = new ArrayList<ConfigurationSource>(); for (ConfigurationSource source : sources) { if (source == null || source.configuration() == null) continue; _sources.add(source); } Collections.sort(_sources, ConfigurationSourceComparator.DEFAULT); StringBuffer sourcesInfo = new StringBuffer("The sorted sources info: { "); for (ConfigurationSource cs : sources()) { sourcesInfo.append(cs.sourceId()).append(": ").append(cs.priority()).append(", "); } sourcesInfo = new StringBuffer(sourcesInfo.substring(0, sourcesInfo.length() - 2)).append(" }"); _logger.info(sourcesInfo.toString()); } DefaultConfigurationManager(ConfigurationSource... sources); @Override String getPropertyValue(String key); @Override Property getProperty(String key); @Override Collection<ConfigurationSource> sources();  }