• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ConcurrentMapConfiguration类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: createLocalConfig

import com.netflix.config.ConcurrentMapConfiguration; //导入依赖的package包/类
public static ConcurrentCompositeConfiguration createLocalConfig(List<ConfigModel> configModelList) {
  ConcurrentCompositeConfiguration config = new ConcurrentCompositeConfiguration();

  duplicateServiceCombConfigToCse(config,
      new ConcurrentMapConfiguration(new SystemConfiguration()),
      "configFromSystem");
  duplicateServiceCombConfigToCse(config,
      convertEnvVariable(new ConcurrentMapConfiguration(new EnvironmentConfiguration())),
      "configFromEnvironment");
  duplicateServiceCombConfigToCse(config,
      new DynamicConfiguration(
          new MicroserviceConfigurationSource(configModelList), new NeverStartPollingScheduler()),
      "configFromYamlFile");

  return config;
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:17,代码来源:ConfigUtil.java


示例2: createDynamicConfig

import com.netflix.config.ConcurrentMapConfiguration; //导入依赖的package包/类
public static AbstractConfiguration createDynamicConfig() {
  LOGGER.info("create dynamic config:");
  ConcurrentCompositeConfiguration config = ConfigUtil.createLocalConfig();
  DynamicWatchedConfiguration configFromConfigCenter = createConfigFromConfigCenter(config);
  if (configFromConfigCenter != null) {
    ConcurrentMapConfiguration injectConfig = new ConcurrentMapConfiguration();
    config.addConfigurationAtFront(injectConfig, "extraInjectConfig");

    duplicateServiceCombConfigToCse(configFromConfigCenter);
    config.addConfigurationAtFront(configFromConfigCenter, "configCenterConfig");

    configFromConfigCenter.getSource().addUpdateListener(new ServiceCombPropertyUpdateListener(injectConfig));
  }

  return config;
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:17,代码来源:ConfigUtil.java


示例3: testFullOperation

import com.netflix.config.ConcurrentMapConfiguration; //导入依赖的package包/类
@Test
public void testFullOperation() {
  // configuration from system properties
  ConcurrentMapConfiguration configFromSystemProperties =
      new ConcurrentMapConfiguration(new SystemConfiguration());
  // configuration from yaml file
  DynamicConfiguration configFromYamlFile =
      new DynamicConfiguration(yamlConfigSource(), new NeverStartPollingScheduler());
  // create a hierarchy of configuration that makes
  // 1) dynamic configuration source override system properties
  ConcurrentCompositeConfiguration finalConfig = new ConcurrentCompositeConfiguration();
  finalConfig.addConfiguration(configFromYamlFile, "yamlConfig");
  finalConfig.addConfiguration(configFromSystemProperties, "systemEnvConfig");
  Assert.assertEquals(0.5, finalConfig.getDouble("trace.handler.sampler.percent"), 0.5);

  Object o = finalConfig.getProperty("zq");
  @SuppressWarnings("unchecked")
  List<Map<String, Object>> listO = (List<Map<String, Object>>) o;
  Assert.assertEquals(3, listO.size());
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:21,代码来源:TestYAMLConfigurationSource.java


示例4: initModuleConfiguration

import com.netflix.config.ConcurrentMapConfiguration; //导入依赖的package包/类
private void initModuleConfiguration() {
    if (!scanModuleConfigurations) {
        this.moduleDefaultConfiguration = new ConcurrentMapConfiguration();
        return;
    }
    HashMap<String, Object> base = new HashMap<>();
    Set<Class<?>> types = reflections
            .getTypesAnnotatedWith(PropertySource.class);
    for (Class<?> type : types) {
        PropertySource propertySource = type
                .getAnnotation(PropertySource.class);
        String[] propertiesFiles = propertySource.value();
        for (String propertyFile : propertiesFiles) {
            Properties properties = new Properties();
            try (InputStream is = resourceLoader.getResource(SystemPropertyUtils.resolvePlaceholders(propertyFile))
                    .getInputStream()) {
                properties.load(is);
                LOGGER.debug("Initializing module properties from path " + propertyFile);
            } catch (Exception e) {
                BootstrapException.resourceLoadingFailed(propertyFile, e);
            }
            join(base, properties, propertyFile, propertiesFiles);
        }
    }
    this.moduleDefaultConfiguration = new ConcurrentMapConfiguration(base);
}
 
开发者ID:Kixeye,项目名称:chassis,代码行数:27,代码来源:ConfigurationBuilder.java


示例5: setUpClass

import com.netflix.config.ConcurrentMapConfiguration; //导入依赖的package包/类
@BeforeClass
public static void setUpClass() throws Exception {
  tearDown();
  configuration = new ConcurrentMapConfiguration();
  writeInitialConfig();
  dynamicProperties = new DynamicPropertiesImpl(configuration);
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:8,代码来源:DynamicPropertiesTest.java


示例6: locate

import com.netflix.config.ConcurrentMapConfiguration; //导入依赖的package包/类
@Override
	public PropertySource<?> locate(Environment environment) {
		
		try {
			// configuration from local properties file
			ConcurrentMapConfiguration configFromPropertiesFile = new ConcurrentMapConfiguration(new PropertiesConfiguration("application.yml"));
			
			// configuration from system properties
			ConcurrentMapConfiguration configFromSystemProperties = new ConcurrentMapConfiguration(new SystemConfiguration());
			
			// configuration from a dynamic source
//			PolledConfigurationSource source = new NetflixUrlPolledConfigurationSource();
			PolledConfigurationSource source = new NetflixEurekaPolledConfigurationSource();
			AbstractPollingScheduler scheduler = new FixedDelayPollingScheduler();
			DynamicConfiguration dynamicConfiguration = new DynamicConfiguration(source, scheduler);
			
			// create a hierarchy of configuration that makes
			// 1) dynamic configuration source override system properties
			// 2) system properties override properties file
			ConcurrentCompositeConfiguration finalConfig = new ConcurrentCompositeConfiguration();
			finalConfig.addConfiguration(dynamicConfiguration, "dynamicConfig");
			finalConfig.addConfiguration(configFromSystemProperties, "systemConfig");
			finalConfig.addConfiguration(configFromPropertiesFile, "fileConfig");
			
			// install with ConfigurationManager so that finalConfig
			// becomes the source of dynamic properties
			ConfigurationManager.install(finalConfig);
		} catch(Exception e) {
			logger.error(e.getMessage());
		}
		
		return null;
	}
 
开发者ID:colddew,项目名称:micro-service-netflix,代码行数:34,代码来源:NetflixPropertySourceLocator.java


示例7: buildConfiguration

import com.netflix.config.ConcurrentMapConfiguration; //导入依赖的package包/类
private ConcurrentCompositeConfiguration buildConfiguration() {
    ConcurrentCompositeConfiguration configuration = new ConcurrentCompositeConfiguration();
    configuration.addConfiguration(new ConcurrentMapConfiguration(new SystemConfiguration()));
    configuration.addConfiguration(this.configuration);
    configuration.addConfiguration(defaults);
    return configuration;
}
 
开发者ID:Kixeye,项目名称:chassis,代码行数:8,代码来源:CuratorFrameworkBuilder.java


示例8: build

import com.netflix.config.ConcurrentMapConfiguration; //导入依赖的package包/类
/**
 * Build the Configuration
 *
 * @return the configuration
 */
public AbstractConfiguration build() {
    initApplicationFileConfiguration();
    initAppVersion();
    initApplicationConfiguration();
    initModuleConfiguration();

    ConcurrentCompositeConfiguration finalConfiguration = new ConcurrentCompositeConfiguration();
    if (addSystemConfigs) {
        finalConfiguration.addConfiguration(new ConcurrentMapConfiguration(new SystemConfiguration()));
    }

    finalConfiguration.addProperty(BootstrapConfigKeys.APP_VERSION_KEY.getPropertyName(), appVersion);

    addServerInstanceProperties(finalConfiguration);

    if (applicationConfiguration == null) {
        LOGGER.warn("\n\n    ****** Default configuration being used ******\n    client application \"" + appName + "\" is being configured with modules defaults. Defaults should only be used in development environments.\n    In non-developement environments, a configuration provider should be used to configure the client application and it should define ALL required configuration properties.\n");
        finalConfiguration.addConfiguration(applicationFileConfiguration);
        finalConfiguration.addConfiguration(moduleDefaultConfiguration);
    } else {
        finalConfiguration.addConfiguration(applicationConfiguration);
        finalConfiguration.addConfiguration(applicationFileConfiguration);
    }

    finalConfiguration.setProperty(BootstrapConfigKeys.APP_VERSION_KEY.getPropertyName(), appVersion);

    configureArchaius(finalConfiguration);

    logConfiguration(finalConfiguration);

    return finalConfiguration;
}
 
开发者ID:Kixeye,项目名称:chassis,代码行数:38,代码来源:ConfigurationBuilder.java


示例9: initApplicationFileConfiguration

import com.netflix.config.ConcurrentMapConfiguration; //导入依赖的package包/类
@SuppressWarnings({"unchecked", "rawtypes"})
private void initApplicationFileConfiguration() {
    if (applicationPropertiesPath == null) {
        LOGGER.debug("No client application properties to configure. Skipping...");
        applicationFileConfiguration = new ConcurrentMapConfiguration();
        return;
    }

    this.applicationFileConfiguration = new ConcurrentCompositeConfiguration();

    String path = SystemPropertyUtils.resolvePlaceholders(applicationPropertiesPath);
    LOGGER.debug("Configuring client application properties from path " + applicationPropertiesPath);

    Map applicationProperties = new Properties();

    if (SystemUtils.IS_OS_WINDOWS) {
        if (path.startsWith("file://")) {
            if (!path.startsWith("file:///")) {
                path = path.replaceFirst(Pattern.quote("file://"), "file:///");
            }
        }
    }

    try (InputStream is = resourceLoader.getResource(path).getInputStream()) {
        ((Properties) applicationProperties).load(is);
    } catch (Exception e) {
        BootstrapException.resourceLoadingFailed(path, applicationPropertiesPath, e);
    }

    Map environmentApplicationProperties = getEnvironmentSpecificProperties(path);
    if (environmentApplicationProperties != null) {
        ((ConcurrentCompositeConfiguration) this.applicationFileConfiguration).addConfiguration(new ConcurrentMapConfiguration(environmentApplicationProperties));
    }
    ((ConcurrentCompositeConfiguration) this.applicationFileConfiguration).addConfiguration(new ConcurrentMapConfiguration(applicationProperties));

    if (applicationFileConfiguration.containsKey(BootstrapConfigKeys.PUBLISH_DEFAULTS_KEY.getPropertyName())) {
        this.publishDefaults = applicationFileConfiguration.getBoolean(BootstrapConfigKeys.PUBLISH_DEFAULTS_KEY.getPropertyName());
    }
}
 
开发者ID:Kixeye,项目名称:chassis,代码行数:40,代码来源:ConfigurationBuilder.java


示例10: createDynamicConfiguration

import com.netflix.config.ConcurrentMapConfiguration; //导入依赖的package包/类
@Bean
@Qualifier("dynamicConfiguration")
public AbstractConfiguration createDynamicConfiguration() {
	ConcurrentMapConfiguration config = new ConcurrentMapConfiguration();
	config.addProperty("db.property","this is a db property");
	config.addProperty("db.second.property","this is another db property");
	return config;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:9,代码来源:TestArchaiusExternalConfiguration.java


示例11: ServiceCombPropertyUpdateListener

import com.netflix.config.ConcurrentMapConfiguration; //导入依赖的package包/类
ServiceCombPropertyUpdateListener(ConcurrentMapConfiguration injectConfig) {
  this.injectConfig = injectConfig;
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:4,代码来源:ConfigUtil.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Loop类代码示例发布时间:2022-05-22
下一篇:
Java JungleTreePopulator类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap