本文整理汇总了Java中com.typesafe.config.ConfigFactory.load方法的典型用法代码示例。如果您正苦于以下问题:Java ConfigFactory.load方法的具体用法?Java ConfigFactory.load怎么用?Java ConfigFactory.load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.typesafe.config.ConfigFactory
的用法示例。
在下文中一共展示了ConfigFactory.load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Config
import com.typesafe.config.ConfigFactory; //导入方法依赖的package包/类
public Config() {
// Load `application.conf` and replace placeholders with
// environment variables
data = ConfigFactory.load();
String connectionString = data.getString(documentdbConnectionStringKey);
String database = data.getString(documentdbDatabaseKey);
String collection = data.getString(documentdbCollectionKey);
int dbRUs = data.getInt(documentdbRUsKey);
this.servicesConfig = new ServicesConfig(connectionString, database, collection, dbRUs);
}
示例2: getConfig
import com.typesafe.config.ConfigFactory; //导入方法依赖的package包/类
public Config getConfig() {
if (config!= null)
return config;
if (fileConfPath == null || fileConfPath.equals(""))
config= ConfigFactory.load();
else
config= ConfigFactory.parseFile(new File(fileConfPath));
return config;
}
示例3: readConfig
import com.typesafe.config.ConfigFactory; //导入方法依赖的package包/类
/**
* Read the config file
*/
public static void readConfig() {
// Read the config and initialize
conf = ConfigFactory.load();
log.info("Config file used: " + conf.origin());
// These system properties control which tasks are enabled
System.setProperty(EXAMPLE_ENABLED, getConfString(EXAMPLE_ENABLED));
System.setProperty(SYNTHETICS_COPIER_ENABLED, getConfString(SYNTHETICS_COPIER_ENABLED));
System.setProperty(METRICS_COPIER_ENABLED, getConfString(METRICS_COPIER_ENABLED));
}
示例4: getConfig
import com.typesafe.config.ConfigFactory; //导入方法依赖的package包/类
/**
* First looks for the file `~/.vars/vars-annotation.conf` and, if found,
* loads that file. Otherwise used the usual `reference.conf`/`application.conf`
* combination for typesafe's config library.
* @return
*/
public static Config getConfig() {
if (config == null) {
final Path p0 = getSettingsDirectory();
final Path path = p0.resolve("vars-annotation.conf");
if (Files.exists(path)) {
config = ConfigFactory.parseFile(path.toFile());
}
else {
config = ConfigFactory.load();
}
}
return config;
}
示例5: 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;
}
示例6: Config
import com.typesafe.config.ConfigFactory; //导入方法依赖的package包/类
public Config() {
this.data = ConfigFactory.load();
}
示例7: SystemProperties
import com.typesafe.config.ConfigFactory; //导入方法依赖的package包/类
public SystemProperties(Config apiConfig, ClassLoader classLoader) {
try {
this.classLoader = classLoader;
Config javaSystemProperties = ConfigFactory.load("no-such-resource-only-system-props");
Config referenceConfig = ConfigFactory.parseResources("ethereumj.conf");
logger.info("Config (" + (referenceConfig.entrySet().size() > 0 ? " yes " : " no ") + "): default properties from resource 'ethereumj.conf'");
String res = System.getProperty("ethereumj.conf.res");
Config cmdLineConfigRes = res != null ? ConfigFactory.parseResources(res) : ConfigFactory.empty();
logger.info("Config (" + (cmdLineConfigRes.entrySet().size() > 0 ? " yes " : " no ") + "): user properties from -Dethereumj.conf.res resource '" + res + "'");
Config userConfig = ConfigFactory.parseResources("user.conf");
logger.info("Config (" + (userConfig.entrySet().size() > 0 ? " yes " : " no ") + "): user properties from resource 'user.conf'");
File userDirFile = new File(System.getProperty("user.dir"), "/config/ethereumj.conf");
Config userDirConfig = ConfigFactory.parseFile(userDirFile);
logger.info("Config (" + (userDirConfig.entrySet().size() > 0 ? " yes " : " no ") + "): user properties from file '" + userDirFile + "'");
Config testConfig = ConfigFactory.parseResources("test-ethereumj.conf");
logger.info("Config (" + (testConfig.entrySet().size() > 0 ? " yes " : " no ") + "): test properties from resource 'test-ethereumj.conf'");
Config testUserConfig = ConfigFactory.parseResources("test-user.conf");
logger.info("Config (" + (testUserConfig.entrySet().size() > 0 ? " yes " : " no ") + "): test properties from resource 'test-user.conf'");
String file = System.getProperty("ethereumj.conf.file");
Config cmdLineConfigFile = file != null ? ConfigFactory.parseFile(new File(file)) : ConfigFactory.empty();
logger.info("Config (" + (cmdLineConfigFile.entrySet().size() > 0 ? " yes " : " no ") + "): user properties from -Dethereumj.conf.file file '" + file + "'");
logger.info("Config (" + (apiConfig.entrySet().size() > 0 ? " yes " : " no ") + "): config passed via constructor");
config = apiConfig
.withFallback(cmdLineConfigFile)
.withFallback(testUserConfig)
.withFallback(testConfig)
.withFallback(userDirConfig)
.withFallback(userConfig)
.withFallback(cmdLineConfigRes)
.withFallback(referenceConfig);
logger.debug("Config trace: " + config.root().render(ConfigRenderOptions.defaults().
setComments(false).setJson(false)));
config = javaSystemProperties.withFallback(config)
.resolve(); // substitute variables in config if any
validateConfig();
Properties props = new Properties();
InputStream is = getClass().getResourceAsStream("/version.properties");
props.load(is);
this.projectVersion = props.getProperty("versionNumber");
this.projectVersion = this.projectVersion.replaceAll("'", "");
if (this.projectVersion == null) this.projectVersion = "-.-.-";
this.projectVersionModifier = "master".equals(BuildInfo.buildBranch) ? "RELEASE" : "SNAPSHOT";
this.databaseVersion = Integer.valueOf(props.getProperty("databaseVersion"));
} catch (Exception e) {
logger.error("Can't read config.", e);
throw new RuntimeException(e);
}
}
示例8: setUp
import com.typesafe.config.ConfigFactory; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
config= ConfigFactory.load();
}
示例9: akkaConfiguration
import com.typesafe.config.ConfigFactory; //导入方法依赖的package包/类
@Bean
public Config akkaConfiguration() {
return ConfigFactory.load();
}
示例10: main
import com.typesafe.config.ConfigFactory; //导入方法依赖的package包/类
public static void main(String[] args) throws AuthenticationException, AudioException, ConverseException, DeviceRegisterException {
Config root = ConfigFactory.load();
AuthenticationConf authenticationConf = ConfigBeanFactory.create(root.getConfig("authentication"), AuthenticationConf.class);
DeviceRegisterConf deviceRegisterConf = ConfigBeanFactory.create(root.getConfig("deviceRegister"), DeviceRegisterConf.class);
AssistantConf assistantConf = ConfigBeanFactory.create(root.getConfig("assistant"), AssistantConf.class);
AudioConf audioConf = ConfigBeanFactory.create(root.getConfig("audio"), AudioConf.class);
// Authentication
AuthenticationHelper authenticationHelper = new AuthenticationHelper(authenticationConf);
authenticationHelper
.authenticate()
.orElseThrow(() -> new AuthenticationException("Error during authentication"));
// Check if we need to refresh the access token to request the api
if (authenticationHelper.expired()) {
authenticationHelper
.refreshAccessToken()
.orElseThrow(() -> new AuthenticationException("Error refreshing access token"));
}
// Register Device model and device
DeviceRegister deviceRegister = new DeviceRegister(deviceRegisterConf, authenticationHelper.getOAuthCredentials().getAccessToken());
deviceRegister.register();
// Build the client (stub)
AssistantClient assistantClient = new AssistantClient(authenticationHelper.getOAuthCredentials(), assistantConf,
deviceRegister.getDeviceModel(), deviceRegister.getDevice());
// Build the objects to record and play the conversation
AudioRecorder audioRecorder = new AudioRecorder(audioConf);
AudioPlayer audioPlayer = new AudioPlayer(audioConf);
// Main loop
while (true) {
// Check if we need to refresh the access token to request the api
if (authenticationHelper.expired()) {
authenticationHelper
.refreshAccessToken()
.orElseThrow(() -> new AuthenticationException("Error refreshing access token"));
// Update the token for the assistant client
assistantClient.updateCredentials(authenticationHelper.getOAuthCredentials());
}
// Record
byte[] request = audioRecorder.getRecord();
// Request the api
byte[] response = assistantClient.requestAssistant(request);
// Play result if any
if (response.length > 0) {
audioPlayer.play(response);
} else {
LOGGER.info("No response from the API");
}
}
}
示例11: Graphene
import com.typesafe.config.ConfigFactory; //导入方法依赖的package包/类
public Graphene() {
this(ConfigFactory.load());
}
示例12: LocalSnapshotStoreSpecTest
import com.typesafe.config.ConfigFactory; //导入方法依赖的package包/类
public LocalSnapshotStoreSpecTest() {
super(ConfigFactory.load("LocalSnapshotStoreTest.conf"));
}
示例13: MBARIInjectorModule
import com.typesafe.config.ConfigFactory; //导入方法依赖的package包/类
public MBARIInjectorModule() {
this.config = ConfigFactory.load();
}
示例14: config
import com.typesafe.config.ConfigFactory; //导入方法依赖的package包/类
@Provides
@Singleton
Config config() {
return ConfigFactory.load();
}
示例15: akkaConfiguration
import com.typesafe.config.ConfigFactory; //导入方法依赖的package包/类
@Bean
public Config akkaConfiguration() {
return ConfigFactory.load();
}