Search in sources :

Example 1 with ConfigParseOptions

use of com.typesafe.config.ConfigParseOptions 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;
    }
}
Also used : HoconTreeTraversingParser(com.jasonclawson.jackson.dataformat.hocon.HoconTreeTraversingParser) Config(com.typesafe.config.Config) ConfigException(com.typesafe.config.ConfigException) ConfigParseOptions(com.typesafe.config.ConfigParseOptions)

Example 2 with ConfigParseOptions

use of com.typesafe.config.ConfigParseOptions in project oap by oaplatform.

the class HoconFactoryWithSystemProperties method _createParser.

@Override
protected HoconTreeTraversingParser _createParser(Reader r, IOContext ctxt) throws IOException {
    final ConfigParseOptions options = ConfigParseOptions.defaults();
    final Config config = ConfigFactory.parseReader(r, options);
    final Config 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;
    }
}
Also used : HoconTreeTraversingParser(com.jasonclawson.jackson.dataformat.hocon.HoconTreeTraversingParser) Config(com.typesafe.config.Config) ConfigException(com.typesafe.config.ConfigException) ConfigParseOptions(com.typesafe.config.ConfigParseOptions)

Example 3 with ConfigParseOptions

use of com.typesafe.config.ConfigParseOptions in project helios by spotify.

the class HeliosConfig method loadConfig.

/**
 * Return the root configuration loaded from the helios configuration files.
 */
static Config loadConfig() {
    final ConfigResolveOptions resolveOptions = ConfigResolveOptions.defaults().setAllowUnresolved(true);
    final ConfigParseOptions parseOptions = ConfigParseOptions.defaults();
    final Config baseConfig = ConfigFactory.load(BASE_CONFIG_FILE, parseOptions, resolveOptions);
    final Config appConfig = ConfigFactory.load(APP_CONFIG_FILE, parseOptions, resolveOptions);
    return appConfig.withFallback(baseConfig);
}
Also used : ConfigResolveOptions(com.typesafe.config.ConfigResolveOptions) Config(com.typesafe.config.Config) ConfigParseOptions(com.typesafe.config.ConfigParseOptions)

Aggregations

Config (com.typesafe.config.Config)3 ConfigParseOptions (com.typesafe.config.ConfigParseOptions)3 HoconTreeTraversingParser (com.jasonclawson.jackson.dataformat.hocon.HoconTreeTraversingParser)2 ConfigException (com.typesafe.config.ConfigException)2 ConfigResolveOptions (com.typesafe.config.ConfigResolveOptions)1