本文整理汇总了Java中com.typesafe.config.ConfigFactory.parseFile方法的典型用法代码示例。如果您正苦于以下问题:Java ConfigFactory.parseFile方法的具体用法?Java ConfigFactory.parseFile怎么用?Java ConfigFactory.parseFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.typesafe.config.ConfigFactory
的用法示例。
在下文中一共展示了ConfigFactory.parseFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildConfigIfAbsent
import com.typesafe.config.ConfigFactory; //导入方法依赖的package包/类
private Config buildConfigIfAbsent(Config currentConfig) {
if (currentConfig != null) return currentConfig;
File configFile = new File(filePath);
if (configFile.exists()) {
return ConfigFactory.parseFile(configFile);
}
logger.debug("Missing configuration file at path: {}, ignore flag set to: {}", filePath, ignoreMissingFile);
if (ignoreMissingFile) {
return ConfigFactory.empty();
}
throw new IllegalStateException("Missing required configuration file at path: " + filePath);
}
示例2: main
import com.typesafe.config.ConfigFactory; //导入方法依赖的package包/类
public static void main(String []args) {
Config config = ConfigFactory.parseFile(new File("config/model/fm.conf"));
RandomParams randomParams = new RandomParams(config, "");
RandomParamsUtils randomParamsUtils = new RandomParamsUtils(randomParams);
System.out.println("normal sample:");
for (int i = 0; i < 50; i++) {
System.out.println(randomParamsUtils.next());
}
System.out.println("uniform sample:");
for (int i = 0; i < 50000; i++) {
double r = randomParamsUtils.next();
if (r < -0.01 || r > 0.01) {
System.out.println("error");
break;
}
}
}
示例3: parse
import com.typesafe.config.ConfigFactory; //导入方法依赖的package包/类
public static Config parse(File configFile) {
Config config = null;
if (configFile.exists() && configFile.canRead()) {
config = ConfigFactory.parseFile(configFile);
if (config.isEmpty()) {
throw new Error("Empty configuration!");
}
} else {
throw new Error("Configuration file " + configFile + " does not exist or is not readable!");
}
return config;
}
示例4: getTrainDataPath
import com.typesafe.config.ConfigFactory; //导入方法依赖的package包/类
public String getTrainDataPath() {
String configRealPath = (new File(configFile).exists()) ? configFile : configPath;
File realFile = new File(configRealPath);
CheckUtils.check(realFile.exists(), "config file(%s) doesn't exist!", configRealPath);
Config config = ConfigFactory.parseFile(realFile);
config = updateConfigWithCustom(config);
return config.getString("data.train.data_path");
}
示例5: initActorSystem
import com.typesafe.config.ConfigFactory; //导入方法依赖的package包/类
public void initActorSystem(File file, String akkaName, String configName) {
logger.debug("init Actor System start: akkaName=" + akkaName + " configName:" + configName);
Config cg = ConfigFactory.parseFile(file);
cg.withFallback(ConfigFactory.defaultReference(Thread.currentThread().getContextClassLoader()));
Config config = ConfigFactory.load(cg).getConfig(configName);
system = ActorSystem.create(akkaName, config);
inbox = Inbox.create(system);
logger.debug("init Actor System end");
}
示例6: retrieveModuleConfigs
import com.typesafe.config.ConfigFactory; //导入方法依赖的package包/类
@Override
public Map<String, ModuleConfig.Builder> retrieveModuleConfigs(final Configuration configuration) {
final File moduleShardsFile = new File(moduleShardsConfigPath);
final File modulesFile = new File(modulesConfigPath);
Config moduleShardsConfig = null;
if (moduleShardsFile.exists()) {
LOG.info("module shards config file exists - reading config from it");
moduleShardsConfig = ConfigFactory.parseFile(moduleShardsFile);
} else {
LOG.warn("module shards configuration read from resource");
moduleShardsConfig = ConfigFactory.load(moduleShardsConfigPath);
}
Config modulesConfig = null;
if (modulesFile.exists()) {
LOG.info("modules config file exists - reading config from it");
modulesConfig = ConfigFactory.parseFile(modulesFile);
} else {
LOG.warn("modules configuration read from resource");
modulesConfig = ConfigFactory.load(modulesConfigPath);
}
final Map<String, ModuleConfig.Builder> moduleConfigMap = readModuleShardsConfig(moduleShardsConfig);
readModulesConfig(modulesConfig, moduleConfigMap, configuration);
return moduleConfigMap;
}
示例7: read
import com.typesafe.config.ConfigFactory; //导入方法依赖的package包/类
@Override
public Config read() {
File customConfigFile = new File(CUSTOM_AKKA_CONF_PATH);
Preconditions.checkState(customConfigFile.exists(), "%s is missing", customConfigFile);
File factoryConfigFile = new File(FACTORY_AKKA_CONF_PATH);
if (factoryConfigFile.exists()) {
return ConfigFactory.parseFile(customConfigFile).withFallback(ConfigFactory.parseFile(factoryConfigFile));
}
return ConfigFactory.parseFile(customConfigFile);
}
示例8: getURI
import com.typesafe.config.ConfigFactory; //导入方法依赖的package包/类
public String getURI() {
String configRealPath = (new File(configFile).exists()) ? configFile : configPath;
File realFile = new File(configRealPath);
CheckUtils.check(realFile.exists(), "config file(%s) doesn't exist!", configRealPath);
Config config = ConfigFactory.parseFile(realFile);
config = updateConfigWithCustom(config);
return config.getString("fs_scheme");
}
示例9: OnlinePredictor
import com.typesafe.config.ConfigFactory; //导入方法依赖的package包/类
public OnlinePredictor(String configPath) throws Exception {
config = ConfigFactory.parseFile(new File(configPath));
LOG.info("load config from file, config_path:" + configPath + ", existed:" + new File(configPath).exists());
String uri = config.getString("fs_scheme");
fs = FileSystemFactory.createFileSystem(new URI(uri));
}
示例10: AgentConfig
import com.typesafe.config.ConfigFactory; //导入方法依赖的package包/类
public AgentConfig(final File configFile) {
requireNonNull(configFile);
Config agentConfig = ConfigFactory.parseFile(configFile);
clusterConfig = agentConfig.getConfig(AGENT_CLUSTER_TAG);
}
示例11: SystemProperties
import com.typesafe.config.ConfigFactory; //导入方法依赖的package包/类
public SystemProperties(File configFile) {
this(ConfigFactory.parseFile(configFile));
}
示例12: main
import com.typesafe.config.ConfigFactory; //导入方法依赖的package包/类
public static void main(String []args) {
Config config = ConfigFactory.parseFile(new File("config/model/linear.conf"));
System.out.println(CommonParams.loadParams(config));
}
示例13: main
import com.typesafe.config.ConfigFactory; //导入方法依赖的package包/类
public static void main(String []args) {
Config config = ConfigFactory.parseFile(new File("config/model/linear.conf"));
LossParams params = new LossParams(config, "");
System.out.println(params.toString());
}
示例14: main
import com.typesafe.config.ConfigFactory; //导入方法依赖的package包/类
public static void main(String []args) {
Config config = ConfigFactory.parseFile(new File("config/model/linear.conf"));
TransformParams params = new TransformParams(config, "feature.");
System.out.println(params.toString());
}
示例15: AppConfig
import com.typesafe.config.ConfigFactory; //导入方法依赖的package包/类
public AppConfig(String path)
{
File file = new File(path);
_config = ConfigFactory.parseFile(file);
}