• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java ConfigBeanFactory类的典型用法和代码示例

java 3次浏览

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

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

示例1: monitoringConfig

点赞 2

import com.typesafe.config.ConfigBeanFactory; //导入依赖的package包/类
@Provides
@Singleton
static MonitoringConfig monitoringConfig(Config config) {
  return ConfigBeanFactory.create(
          config.getConfig("monitoring"), ModifiableMonitoringConfig.class)
      .toImmutable();
}
 

开发者ID:curioswitch,
项目名称:curiostack,
代码行数:8,
代码来源:MonitoringModule.java

示例2: javascriptStaticConfig

点赞 2

import com.typesafe.config.ConfigBeanFactory; //导入依赖的package包/类
@Provides
@Singleton
static JavascriptStaticConfig javascriptStaticConfig(Config config) {
  return ConfigBeanFactory.create(
          config.getConfig("javascriptConfig"), ModifiableJavascriptStaticConfig.class)
      .toImmutable();
}
 

开发者ID:curioswitch,
项目名称:curiostack,
代码行数:8,
代码来源:ServerModule.java

示例3: getConfigValue

点赞 2

import com.typesafe.config.ConfigBeanFactory; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
private Object getConfigValue(Class<?> paramClass, Type paramType, String path) {
	Optional<Object> extractedValue = ConfigExtractors.extractConfigValue(config, paramClass, path);
	if (extractedValue.isPresent()) {
		return extractedValue.get();
	}

	ConfigValue configValue = config.getValue(path);
	ConfigValueType valueType = configValue.valueType();
	if (valueType.equals(ConfigValueType.OBJECT) && Map.class.isAssignableFrom(paramClass)) {
		ConfigObject object = config.getObject(path);
           return object.unwrapped();
	} else if (valueType.equals(ConfigValueType.OBJECT)) {
		Object bean = ConfigBeanFactory.create(config.getConfig(path), paramClass);
		return bean;
	} else if (valueType.equals(ConfigValueType.LIST) && List.class.isAssignableFrom(paramClass)) {
		Type listType = ((ParameterizedType) paramType).getActualTypeArguments()[0];
		
		Optional<List<?>> extractedListValue = 
			ListExtractors.extractConfigListValue(config, listType, path);
		
		if (extractedListValue.isPresent()) {
			return extractedListValue.get();
		} else {
			List<? extends Config> configList = config.getConfigList(path);
			return configList.stream()
				.map(cfg -> {
					Object created = ConfigBeanFactory.create(cfg, (Class) listType);
					return created;
				})
				.collect(Collectors.toList());
		}
	}
	
	throw new RuntimeException("Cannot obtain config value for " + paramType + " at path: " + path);
}
 

开发者ID:racc,
项目名称:typesafeconfig-guice,
代码行数:37,
代码来源:TypesafeConfigModule.java

示例4: main

点赞 2

import com.typesafe.config.ConfigBeanFactory; //导入依赖的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

示例5: dbConfig

点赞 2

import com.typesafe.config.ConfigBeanFactory; //导入依赖的package包/类
@Provides
@Singleton
static DatabaseConfig dbConfig(Config config) {
  return ConfigBeanFactory.create(config.getConfig("database"), ModifiableDatabaseConfig.class)
      .toImmutable();
}
 

开发者ID:curioswitch,
项目名称:curiostack,
代码行数:7,
代码来源:DatabaseModule.java

示例6: redisConfig

点赞 2

import com.typesafe.config.ConfigBeanFactory; //导入依赖的package包/类
@Provides
@Singleton
static RedisConfig redisConfig(Config config) {
  return ConfigBeanFactory.create(config.getConfig("redis"), ModifiableRedisConfig.class)
      .toImmutable();
}
 

开发者ID:curioswitch,
项目名称:curiostack,
代码行数:7,
代码来源:RedisModule.java

示例7: firebaseConfig

点赞 2

import com.typesafe.config.ConfigBeanFactory; //导入依赖的package包/类
@Provides
@Singleton
static FirebaseAuthConfig firebaseConfig(Config config) {
  return ConfigBeanFactory.create(
      config.getConfig("firebaseAuth"), ModifiableFirebaseAuthConfig.class);
}
 

开发者ID:curioswitch,
项目名称:curiostack,
代码行数:7,
代码来源:FirebaseAuthModule.java

示例8: serverConfig

点赞 2

import com.typesafe.config.ConfigBeanFactory; //导入依赖的package包/类
@Provides
@Singleton
static ServerConfig serverConfig(Config config) {
  return ConfigBeanFactory.create(config.getConfig("server"), ModifiableServerConfig.class)
      .toImmutable();
}
 

开发者ID:curioswitch,
项目名称:curiostack,
代码行数:7,
代码来源:ServerModule.java

示例9: yummlyConfig

点赞 2

import com.typesafe.config.ConfigBeanFactory; //导入依赖的package包/类
@Provides
static YummlyConfig yummlyConfig(Config config) {
  return ConfigBeanFactory.create(config.getConfig("yummly"), ModifiableYummlyConfig.class)
      .toImmutable();
}
 

开发者ID:curioswitch,
项目名称:curiostack,
代码行数:6,
代码来源:YummlyApiModule.java

示例10: run

点赞 1

import com.typesafe.config.ConfigBeanFactory; //导入依赖的package包/类
public void run() {
    logger.info("Starting application...");

    final Config config = ConfigFactory.load();
    final SparkSettings sparkConf = ConfigBeanFactory.create(config.getConfig("spark"), SparkSettings.class);

    logger.info("Loaded config: " + config.toString());

    new SparkInitializer(sparkConf).init();
}
 

开发者ID:fg-devs,
项目名称:sample-spark,
代码行数:11,
代码来源:SparkSample.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)