本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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)));
}
}
示例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);
}
}
示例10: getOptions
import com.typesafe.config.ConfigSyntax; //导入依赖的package包/类
private ConfigParseOptions getOptions(Class beanClass) {
return defaults().setSyntax(ConfigSyntax.valueOf(getAnnotationConfiguration(beanClass).syntax().name()));
}
示例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));
}
示例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()));
}
}
示例13: ConfigMapParser
import com.typesafe.config.ConfigSyntax; //导入依赖的package包/类
public ConfigMapParser() {
parser = config(defaults()
.setSyntax(ConfigSyntax.CONF)
.setAllowMissing(false));
}
示例14: ConfigParser
import com.typesafe.config.ConfigSyntax; //导入依赖的package包/类
public ConfigParser() {
options = ConfigParseOptions.defaults()
.setSyntax(ConfigSyntax.CONF)
.setAllowMissing(false);
}