/** * {@inheritDoc} */ @Override public int compare(ConfigSource configSource1, ConfigSource configSource2) { return (configSource1.getOrdinal() > configSource2.getOrdinal()) ? 1 : -1; } });
/** * {@inheritDoc} */ @Override public int compare(ConfigSource configSource1, ConfigSource configSource2) { return (configSource1.getOrdinal() > configSource2.getOrdinal()) ? -1 : 1; } });
/** * {@inheritDoc} */ @Override public int compare(ConfigSource configSource1, ConfigSource configSource2) { int o1 = configSource1.getOrdinal(); int o2 = configSource2.getOrdinal(); if (o1 == o2) { return configSource1.getConfigName().compareTo(configSource2.getConfigName()); } return (o1 > o2) ? -1 : 1; } });
@Override public String[] getConfigSourcesAsString() { ClassLoader originalCl = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(appConfigClassLoader); ConfigSource[] configSources = ConfigResolver.getConfigSources(); List<String> configSourceInfo = new ArrayList<String>(); for (ConfigSource configSource : configSources) { configSourceInfo.add(Integer.toString(configSource.getOrdinal()) + " - " + configSource.getConfigName()); } return configSourceInfo.toArray(new String[configSourceInfo.size()]); } finally { // set back the original TCCL Thread.currentThread().setContextClassLoader(originalCl); } }
private void logConfiguration() { Boolean logConfig = ConfigResolver.resolve(ConfigResolver.DELTASPIKE_LOG_CONFIG).as(Boolean.class).getValue(); if (logConfig != null && logConfig && LOG.isLoggable(Level.INFO)) { StringBuilder sb = new StringBuilder(1 << 16); // first log out the config sources in descendent ordinal order sb.append("ConfigSources: "); ConfigSource[] configSources = ConfigResolver.getConfigSources(); for (ConfigSource configSource : configSources) { sb.append("\n\t").append(configSource.getOrdinal()).append(" - ").append(configSource.getConfigName()); } // and all the entries in no guaranteed order Map<String, String> allProperties = ConfigResolver.getAllProperties(); sb.append("\n\nConfigured Values:"); for (Map.Entry<String, String> entry : allProperties.entrySet()) { sb.append("\n\t") .append(entry.getKey()) .append(" = ") .append(ConfigResolver.filterConfigValueForLog(entry.getKey(), entry.getValue())); } LOG.info(sb.toString()); } }
private static synchronized ConfigSource[] getConfigSources() { ClassLoader currentClassLoader = ClassUtils.getClassLoader(null); ConfigSource[] appConfigSources = configSources.get(currentClassLoader); if (appConfigSources == null) { appConfigSources = sortDescending(resolveConfigSources()); if (LOG.isLoggable(Level.FINE)) { for (ConfigSource cs : appConfigSources) { LOG.log(Level.FINE, "Adding ordinal {0} ConfigSource {1}", new Object[]{cs.getOrdinal(), cs.getConfigName()}); } } configSources.put(currentClassLoader, appConfigSources); } return appConfigSources; }
new Object[]{configSource.getOrdinal(), configSource.getConfigName()}));
/** * Performs all the initialisation of the default * ConfigSources, ConfigFilters, etc */ void init() { List<ConfigSource> appConfigSources = ServiceUtils.loadServiceImplementations(ConfigSource.class, false, classLoader); List<ConfigSourceProvider> configSourceProviderServiceLoader = ServiceUtils.loadServiceImplementations(ConfigSourceProvider.class, false, classLoader); for (ConfigSourceProvider configSourceProvider : configSourceProviderServiceLoader) { appConfigSources.addAll(configSourceProvider.getConfigSources()); } addConfigSources(appConfigSources); if (LOG.isLoggable(Level.FINE)) { for (ConfigSource cs : appConfigSources) { LOG.log(Level.FINE, "Adding ordinal {0} ConfigSource {1}", new Object[]{cs.getOrdinal(), cs.getConfigName()}); } } List<ConfigFilter> configFilters = ServiceUtils.loadServiceImplementations(ConfigFilter.class, false, classLoader); this.configFilters = new CopyOnWriteArrayList<>(configFilters); }