use of com.jasonclawson.jackson.dataformat.hocon.HoconTreeTraversingParser in project oap by oaplatform.
the class HoconFactoryWithFallback method _createParser.
@Override
protected HoconTreeTraversingParser _createParser(Reader r, IOContext ctxt) throws IOException {
ConfigParseOptions options = ConfigParseOptions.defaults();
Config config = ConfigFactory.parseReader(r, options);
final Config unresolvedConfig = additinal.withFallback(config).withFallback(ConfigFactory.systemProperties());
try {
Config resolvedConfig = unresolvedConfig.resolve();
return new HoconTreeTraversingParser(resolvedConfig.root(), _objectCodec);
} catch (ConfigException e) {
log.error(unresolvedConfig.root().render());
throw e;
}
}
use of com.jasonclawson.jackson.dataformat.hocon.HoconTreeTraversingParser in project divolte-collector by divolte.
the class ValidatedConfiguration method mapped.
private static DivolteConfiguration mapped(final Config input) throws IOException {
final Config resolved = input.resolve();
final ObjectMapper mapper = new ObjectMapper();
// snake_casing
mapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE);
// Ignore unknown stuff in the config
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true);
// Deserialization for Duration
final SimpleModule module = new SimpleModule("Configuration Deserializers");
module.addDeserializer(Duration.class, new DurationDeserializer());
module.addDeserializer(Properties.class, new PropertiesDeserializer());
mapper.registerModules(// JDK8 types (Optional, etc.)
new Jdk8Module(), // Guava types (immutable collections)
new GuavaModule(), // Support JDK8 parameter name discovery
new ParameterNamesModule(), // Register custom deserializers module
module);
return mapper.readValue(new HoconTreeTraversingParser(resolved.root()), DivolteConfiguration.class);
}
use of com.jasonclawson.jackson.dataformat.hocon.HoconTreeTraversingParser in project oap by oaplatform.
the class HoconFactoryWithSystemProperties method _createParser.
@Override
protected HoconTreeTraversingParser _createParser(Reader r, IOContext ctxt) throws IOException {
var options = ConfigParseOptions.defaults();
var config = ConfigFactory.parseReader(r, options);
var unresolvedConfig = config.withFallback(ConfigFactory.systemProperties());
// log.trace( unresolvedConfig.root().render() );
try {
final Config resolvedConfig = unresolvedConfig.resolve();
return new HoconTreeTraversingParser(resolvedConfig.root(), _objectCodec);
} catch (ConfigException e) {
log.error(unresolvedConfig.root().render());
throw e;
}
}
Aggregations