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


Java ConfigFactory.load方法代码示例

本文整理汇总了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);
}
 
开发者ID:Azure,项目名称:pcs-storage-adapter-java,代码行数:12,代码来源:Config.java

示例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;
}
 
开发者ID:aaitor,项目名称:flink-charts,代码行数:10,代码来源:ArgsParser.java

示例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));
}
 
开发者ID:kenahrens,项目名称:newrelic-api-client-java,代码行数:14,代码来源:APIApplication.java

示例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;
}
 
开发者ID:mbari-media-management,项目名称:vars-annotation,代码行数:20,代码来源:Initializer.java

示例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;
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:29,代码来源:FileModuleShardConfigProvider.java

示例6: Config

import com.typesafe.config.ConfigFactory; //导入方法依赖的package包/类
public Config() {
    this.data = ConfigFactory.load();
}
 
开发者ID:Azure,项目名称:device-telemetry-java,代码行数:4,代码来源:Config.java

示例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);
    }
}
 
开发者ID:talentchain,项目名称:talchain,代码行数:56,代码来源:SystemProperties.java

示例8: setUp

import com.typesafe.config.ConfigFactory; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
    config= ConfigFactory.load();

}
 
开发者ID:aaitor,项目名称:flink-charts,代码行数:6,代码来源:StateChartsPipelineTest.java

示例9: akkaConfiguration

import com.typesafe.config.ConfigFactory; //导入方法依赖的package包/类
@Bean
public Config akkaConfiguration() {
  return ConfigFactory.load();
}
 
开发者ID:stefanstaniAIM,项目名称:IPPR2016,代码行数:5,代码来源:AkkaApplicationConfiguration.java

示例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");
            }
        }
    }
 
开发者ID:mautini,项目名称:google-assistant-java-demo,代码行数:60,代码来源:GoogleAssistantClient.java

示例11: Graphene

import com.typesafe.config.ConfigFactory; //导入方法依赖的package包/类
public Graphene() {
	this(ConfigFactory.load());
}
 
开发者ID:Lambda-3,项目名称:Graphene,代码行数:4,代码来源:Graphene.java

示例12: LocalSnapshotStoreSpecTest

import com.typesafe.config.ConfigFactory; //导入方法依赖的package包/类
public LocalSnapshotStoreSpecTest() {
    super(ConfigFactory.load("LocalSnapshotStoreTest.conf"));
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:4,代码来源:LocalSnapshotStoreSpecTest.java

示例13: MBARIInjectorModule

import com.typesafe.config.ConfigFactory; //导入方法依赖的package包/类
public MBARIInjectorModule() {
    this.config = ConfigFactory.load();
}
 
开发者ID:mbari-media-management,项目名称:vars-annotation,代码行数:4,代码来源:MBARIInjectorModule.java

示例14: config

import com.typesafe.config.ConfigFactory; //导入方法依赖的package包/类
@Provides
@Singleton
Config config() {
  return ConfigFactory.load();
}
 
开发者ID:curioswitch,项目名称:curiostack,代码行数:6,代码来源:ApplicationModule.java

示例15: akkaConfiguration

import com.typesafe.config.ConfigFactory; //导入方法依赖的package包/类
@Bean
public Config akkaConfiguration() {
    return ConfigFactory.load();
}
 
开发者ID:Fabbbrrr,项目名称:file-reader-akka-spring,代码行数:5,代码来源:AppConfiguration.java


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