Java 类com.typesafe.config.ConfigSyntax 实例源码

项目:director-azure-plugin    文件:AzurePluginConfigHelper.java   
/**
 * Helper to parse the specified configuration file from the classpath.
 *
 * @param configPath the path to the configuration file
 * @return the parsed configuration
 */
public static Config parseConfigFromClasspath(String configPath) throws IOException {
  ConfigParseOptions options = ConfigParseOptions.defaults()
      .setSyntax(ConfigSyntax.CONF)
      .setAllowMissing(false);
  return ConfigFactory.parseResourcesAnySyntax(AzureLauncher.class, configPath, options);
}
项目:director-azure-plugin    文件:AzurePluginConfigHelper.java   
/**
 * Helper to parse the specified configuration file.
 *
 * @param configFile the configuration file
 * @return the parsed configuration
 */
static Config parseConfigFromFile(File configFile) throws IOException {
  ConfigParseOptions options = ConfigParseOptions.defaults()
      .setSyntax(ConfigSyntax.CONF)
      .setAllowMissing(false);
  return ConfigFactory.parseFileAnySyntax(configFile, options);
}
项目:director-aws-plugin    文件:AWSLauncher.java   
/**
 * Parses the specified configuration file.
 *
 * @param configFile the configuration file
 * @return the parsed configuration
 */
private static Config parseConfigFile(File configFile) {
  ConfigParseOptions options = ConfigParseOptions.defaults()
      .setSyntax(ConfigSyntax.CONF)
      .setAllowMissing(false);

  return ConfigFactory.parseFileAnySyntax(configFile, options);
}
项目:director-spi-tck    文件:Runner.java   
private static Config parseConfigFile(File configFile) {
  ConfigParseOptions options = ConfigParseOptions.defaults()
      .setSyntax(ConfigSyntax.CONF)
      .setAllowMissing(false);

  return ConfigFactory.parseFileAnySyntax(configFile, options);
}
项目:director-google-plugin    文件:GoogleLauncher.java   
/**
 * Parses the specified configuration file from the classpath.
 *
 * @param configPath the path to the configuration file
 * @return the parsed configuration
 */
private static Config parseConfigFromClasspath(String configPath) {
  ConfigParseOptions options = ConfigParseOptions.defaults()
      .setSyntax(ConfigSyntax.CONF)
      .setAllowMissing(false);

  return ConfigFactory.parseResourcesAnySyntax(GoogleLauncher.class, configPath, options);
}
项目:director-google-plugin    文件:GoogleLauncher.java   
/**
 * Parses the specified configuration file.
 *
 * @param configFile the configuration file
 * @return the parsed configuration
 */
private static Config parseConfigFromFile(File configFile) {
  ConfigParseOptions options = ConfigParseOptions.defaults()
      .setSyntax(ConfigSyntax.CONF)
      .setAllowMissing(false);

  return ConfigFactory.parseFileAnySyntax(configFile, options);
}
项目:swift-k    文件:SwiftConfig.java   
public static SwiftConfig load(String cmdLineConfig, List<String> configSearchPath, Map<String, Object> cmdLineOptions) {
    List<String> loadedFiles = new ArrayList<String>();
    List<String> loadedFileIndices = new ArrayList<String>();

    ConfigParseOptions opt = ConfigParseOptions.defaults();
    opt = opt.setIncluder(new IncluderWrapper(opt.getIncluder(), loadedFiles, loadedFileIndices)).
        setSyntax(ConfigSyntax.CONF).setAllowMissing(false);

    Config conf;

    if (configSearchPath == null) {
        String envSearchPath = System.getenv("SWIFT_CONF_PATH");
        if (envSearchPath != null) {
            configSearchPath = splitConfigSearchPath(envSearchPath);
        }
    }
    if (configSearchPath == null) {
        conf = loadNormal(cmdLineConfig, opt, loadedFiles, loadedFileIndices);
    }
    else {
        conf = loadFromSearchPath(configSearchPath, cmdLineConfig, opt, 
            loadedFiles, loadedFileIndices);
    }

    if (cmdLineOptions != null) {
        Config oconf = ConfigFactory.parseMap(cmdLineOptions, "<Command Line>");
        conf = oconf.withFallback(conf);
        loadedFiles.add("<Command Line>");
        loadedFileIndices.add("C");
    }

    conf = conf.resolveWith(getSubstitutions());
    ConfigTree<ValueLocationPair> out = SCHEMA.validate(conf);
    SwiftConfig sc = new SwiftConfig(loadedFiles, loadedFileIndices);
    sc.build(out);
    return sc;
}
项目:incubator-gobblin    文件:PullFileLoader.java   
private Config loadHoconConfigAtPath(Path path) throws IOException {
  try (InputStream is = fs.open(path);
      Reader reader = new InputStreamReader(is, Charsets.UTF_8)) {
      return ConfigFactory.parseMap(ImmutableMap.of(ConfigurationKeys.JOB_CONFIG_FILE_PATH_KEY,
          PathUtils.getPathWithoutSchemeAndAuthority(path).toString()))
          .withFallback(ConfigFactory.parseReader(reader, ConfigParseOptions.defaults().setSyntax(ConfigSyntax.CONF)));
  }
}
项目:incubator-gobblin    文件:PullFileLoader.java   
private Config loadHoconConfigWithFallback(Path path, Config fallback) throws IOException {
  try (InputStream is = fs.open(path);
       Reader reader = new InputStreamReader(is, Charsets.UTF_8)) {
    return ConfigFactory.parseMap(ImmutableMap.of(ConfigurationKeys.JOB_CONFIG_FILE_PATH_KEY,
        PathUtils.getPathWithoutSchemeAndAuthority(path).toString()))
        .withFallback(ConfigFactory.parseReader(reader, ConfigParseOptions.defaults().setSyntax(ConfigSyntax.CONF)))
        .withFallback(fallback);
  }
}
项目:gconf    文件:InjectorBuilder.java   
private ConfigParseOptions getOptions(Class beanClass) {
    return defaults().setSyntax(ConfigSyntax.valueOf(getAnnotationConfiguration(beanClass).syntax().name()));
}
项目:incubator-gobblin    文件:AvroToRestJsonEntryConverter.java   
/**
 * Use resource key(Optional) and rest json entry as a template and fill in template using Avro as a reference.
 * e.g:
 *  Rest JSON entry HOCON template:
 *    AccountId=${sf_account_id},Member_Id__c=${member_id}
 *  Avro:
 *    {"sf_account_id":{"string":"0016000000UiCYHAA3"},"member_id":{"long":296458833}}
 *
 *  Converted Json:
 *    {"AccountId":"0016000000UiCYHAA3","Member_Id__c":296458833}
 *
 *  As it's template based approach, it can produce nested JSON structure even Avro is flat (or vice versa).
 *
 * e.g:
 *  Rest resource template:
 *    /sobject/account/memberId/${member_id}
 *  Avro:
 *    {"sf_account_id":{"string":"0016000000UiCYHAA3"},"member_id":{"long":296458833}}
 *  Converted resource:
 *    /sobject/account/memberId/296458833
 *
 *  Converted resource will be used to form end point.
 *    http://www.server.com:9090/sobject/account/memberId/296458833
 *
 * {@inheritDoc}
 * @see org.apache.gobblin.converter.Converter#convertRecord(java.lang.Object, java.lang.Object, org.apache.gobblin.configuration.WorkUnitState)
 */
@Override
public Iterable<RestEntry<JsonObject>> convertRecord(Void outputSchema, GenericRecord inputRecord, WorkUnitState workUnit)
    throws DataConversionException {

  Config srcConfig = ConfigFactory.parseString(inputRecord.toString(),
                                               ConfigParseOptions.defaults().setSyntax(ConfigSyntax.JSON));

  String resourceKey = workUnit.getProp(CONVERTER_AVRO_REST_ENTRY_RESOURCE_KEY, "");
  if(!StringUtils.isEmpty(resourceKey)) {
    final String dummyKey = "DUMMY";
    Config tmpConfig = ConfigFactory.parseString(dummyKey + "=" + resourceKey).resolveWith(srcConfig);
    resourceKey = tmpConfig.getString(dummyKey);
  }

  String hoconInput = workUnit.getProp(CONVERTER_AVRO_REST_JSON_ENTRY_TEMPLATE);
  if(StringUtils.isEmpty(hoconInput)) {
    return new SingleRecordIterable<>(new RestEntry<>(resourceKey, parser.parse(inputRecord.toString()).getAsJsonObject()));
  }

  Config destConfig = ConfigFactory.parseString(hoconInput).resolveWith(srcConfig);
  JsonObject json = parser.parse(destConfig.root().render(ConfigRenderOptions.concise())).getAsJsonObject();
  return new SingleRecordIterable<>(new RestEntry<>(resourceKey, json));
}
项目:jsconf    文件:ConfigurationFactory.java   
public void setFormat(ConfigFormat format) {
    if (format != null) {
        this.options = this.options.setSyntax(ConfigSyntax.valueOf(format.name()));
    }
}
项目:resource4j    文件:ConfigMapParser.java   
public ConfigMapParser() {
    parser = config(defaults()
            .setSyntax(ConfigSyntax.CONF)
            .setAllowMissing(false));
}
项目:resource4j    文件:ConfigParser.java   
public ConfigParser() {
     options = ConfigParseOptions.defaults()
             .setSyntax(ConfigSyntax.CONF)
             .setAllowMissing(false);       
}