use of org.apache.commons.configuration.AbstractConfiguration in project chassis by Kixeye.
the class PropertiesServlet method doGet.
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
// get list of properties
TreeSet<String> properties = new TreeSet<String>();
AbstractConfiguration config = ConfigurationManager.getConfigInstance();
Iterator<String> keys = config.getKeys();
while (keys.hasNext()) {
String key = keys.next();
Object value = config.getProperty(key);
if ("aws.accessId".equals(key) || "aws.secretKey".equals(key) || "experiments-service.secret".equals(key) || "java.class.path".equals(key) || key.contains("framework.securityDefinition") || key.contains("password") || key.contains("secret")) {
value = "*****";
}
properties.add(key + "=" + value.toString());
}
// write them out in sorted order
for (String line : properties) {
resp.getWriter().append(line).println();
}
}
use of org.apache.commons.configuration.AbstractConfiguration in project riposte by Nike-Inc.
the class ArchaiusServer method infrastructureInit.
/**
* Initializes the Archaius system and configures the Netty leak detection level (if necessary).
* DO NOT CALL THIS DIRECTLY. Use {@link #launchServer(String[])} when you're ready to start the server.
*/
protected void infrastructureInit() {
MainClassUtils.setupJbossLoggingToUseSlf4j();
try {
Pair<String, String> appIdAndEnvironmentPair = MainClassUtils.getAppIdAndEnvironmentFromSystemProperties();
ConfigurationManager.loadCascadedPropertiesFromResources(appIdAndEnvironmentPair.getLeft());
} catch (IOException e) {
throw new RuntimeException("Error loading Archaius properties", e);
}
AbstractConfiguration appConfig = ConfigurationManager.getConfigInstance();
Function<String, Boolean> hasPropertyFunction = (propKey) -> appConfig.getProperty(propKey) != null;
Function<String, String> propertyExtractionFunction = (propKey) -> {
// Properties in Archaius might be a Collection or an Object.
Object propValObj = appConfig.getProperty(propKey);
return (propValObj instanceof Collection) ? ((Collection<?>) propValObj).stream().map(String::valueOf).collect(Collectors.joining(",")) : String.valueOf(propValObj);
};
Set<String> propKeys = new LinkedHashSet<>();
appConfig.getKeys().forEachRemaining(propKeys::add);
MainClassUtils.logApplicationPropertiesIfDebugActionsEnabled(hasPropertyFunction, propertyExtractionFunction, propKeys, false);
MainClassUtils.setupNettyLeakDetectionLevel(hasPropertyFunction, propertyExtractionFunction);
}
use of org.apache.commons.configuration.AbstractConfiguration in project wildfly-swarm by wildfly-swarm.
the class ArchaiusCustomizer method customize.
@Override
public void customize() {
AbstractConfiguration config = ConfigurationManager.getConfigInstance();
Set<ConfigKey> seen = new HashSet<>();
this.configurableManager.configurables().stream().filter(this::shouldLink).forEach(e -> {
try {
Object value = e.currentValue();
if (value != null) {
config.setProperty(e.key().subkey(1).name(), e.currentValue());
}
seen.add(e.key());
} catch (Exception ex) {
throw new RuntimeException(ex);
}
});
this.configurableManager.configView().allKeysRecursively().filter(this::shouldLink).filter(k -> !seen.contains(k)).forEach(k -> {
Object value = this.configurableManager.configView().valueOf(k);
if (value != null) {
config.setProperty(k.subkey(1).name(), value);
}
});
}
use of org.apache.commons.configuration.AbstractConfiguration in project spring-cloud-netflix by spring-cloud.
the class ArchaiusAutoConfiguration method addArchaiusConfiguration.
private static void addArchaiusConfiguration(ConcurrentCompositeConfiguration config) {
if (ConfigurationManager.isConfigurationInstalled()) {
AbstractConfiguration installedConfiguration = ConfigurationManager.getConfigInstance();
if (installedConfiguration instanceof ConcurrentCompositeConfiguration) {
ConcurrentCompositeConfiguration configInstance = (ConcurrentCompositeConfiguration) installedConfiguration;
configInstance.addConfiguration(config);
} else {
installedConfiguration.append(config);
if (!(installedConfiguration instanceof AggregatedConfiguration)) {
log.warn("Appending a configuration to an existing non-aggregated installed configuration will have no effect");
}
}
} else {
ConfigurationManager.install(config);
}
}
use of org.apache.commons.configuration.AbstractConfiguration in project spring-cloud-netflix by spring-cloud.
the class ArchaiusDelegatingProxyUtils method addApplicationContext.
public static void addApplicationContext(ConfigurableApplicationContext context) {
AbstractConfiguration config = ConfigurationManager.getConfigInstance();
config.clearProperty(APPLICATION_CONTEXT);
config.setProperty(APPLICATION_CONTEXT, context);
}
Aggregations