当前位置: 首页>>代码示例>>Java>>正文


Java ConfigSyntax类代码示例

本文整理汇总了Java中com.typesafe.config.ConfigSyntax的典型用法代码示例。如果您正苦于以下问题:Java ConfigSyntax类的具体用法?Java ConfigSyntax怎么用?Java ConfigSyntax使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ConfigSyntax类属于com.typesafe.config包,在下文中一共展示了ConfigSyntax类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseConfigFromClasspath

import com.typesafe.config.ConfigSyntax; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:cloudera,项目名称:director-azure-plugin,代码行数:13,代码来源:AzurePluginConfigHelper.java

示例2: parseConfigFromFile

import com.typesafe.config.ConfigSyntax; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:cloudera,项目名称:director-azure-plugin,代码行数:13,代码来源:AzurePluginConfigHelper.java

示例3: parseConfigFile

import com.typesafe.config.ConfigSyntax; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:cloudera,项目名称:director-aws-plugin,代码行数:14,代码来源:AWSLauncher.java

示例4: parseConfigFile

import com.typesafe.config.ConfigSyntax; //导入依赖的package包/类
private static Config parseConfigFile(File configFile) {
  ConfigParseOptions options = ConfigParseOptions.defaults()
      .setSyntax(ConfigSyntax.CONF)
      .setAllowMissing(false);

  return ConfigFactory.parseFileAnySyntax(configFile, options);
}
 
开发者ID:cloudera,项目名称:director-spi-tck,代码行数:8,代码来源:Runner.java

示例5: parseConfigFromClasspath

import com.typesafe.config.ConfigSyntax; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:cloudera,项目名称:director-google-plugin,代码行数:14,代码来源:GoogleLauncher.java

示例6: parseConfigFromFile

import com.typesafe.config.ConfigSyntax; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:cloudera,项目名称:director-google-plugin,代码行数:14,代码来源:GoogleLauncher.java

示例7: load

import com.typesafe.config.ConfigSyntax; //导入依赖的package包/类
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;
}
 
开发者ID:swift-lang,项目名称:swift-k,代码行数:38,代码来源:SwiftConfig.java

示例8: loadHoconConfigAtPath

import com.typesafe.config.ConfigSyntax; //导入依赖的package包/类
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)));
  }
}
 
开发者ID:apache,项目名称:incubator-gobblin,代码行数:9,代码来源:PullFileLoader.java

示例9: loadHoconConfigWithFallback

import com.typesafe.config.ConfigSyntax; //导入依赖的package包/类
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);
  }
}
 
开发者ID:apache,项目名称:incubator-gobblin,代码行数:10,代码来源:PullFileLoader.java

示例10: getOptions

import com.typesafe.config.ConfigSyntax; //导入依赖的package包/类
private ConfigParseOptions getOptions(Class beanClass) {
    return defaults().setSyntax(ConfigSyntax.valueOf(getAnnotationConfiguration(beanClass).syntax().name()));
}
 
开发者ID:yyvess,项目名称:gconf,代码行数:4,代码来源:InjectorBuilder.java

示例11: convertRecord

import com.typesafe.config.ConfigSyntax; //导入依赖的package包/类
/**
 * 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));
}
 
开发者ID:apache,项目名称:incubator-gobblin,代码行数:51,代码来源:AvroToRestJsonEntryConverter.java

示例12: setFormat

import com.typesafe.config.ConfigSyntax; //导入依赖的package包/类
public void setFormat(ConfigFormat format) {
    if (format != null) {
        this.options = this.options.setSyntax(ConfigSyntax.valueOf(format.name()));
    }
}
 
开发者ID:yyvess,项目名称:jsconf,代码行数:6,代码来源:ConfigurationFactory.java

示例13: ConfigMapParser

import com.typesafe.config.ConfigSyntax; //导入依赖的package包/类
public ConfigMapParser() {
	parser = config(defaults()
			.setSyntax(ConfigSyntax.CONF)
			.setAllowMissing(false));
}
 
开发者ID:resource4j,项目名称:resource4j,代码行数:6,代码来源:ConfigMapParser.java

示例14: ConfigParser

import com.typesafe.config.ConfigSyntax; //导入依赖的package包/类
public ConfigParser() {
	 options = ConfigParseOptions.defaults()
			 .setSyntax(ConfigSyntax.CONF)
			 .setAllowMissing(false);		
}
 
开发者ID:resource4j,项目名称:resource4j,代码行数:6,代码来源:ConfigParser.java


注:本文中的com.typesafe.config.ConfigSyntax类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。