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


Java ConcurrentCompositeConfiguration.addConfiguration方法代码示例

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


在下文中一共展示了ConcurrentCompositeConfiguration.addConfiguration方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testFullOperation

import com.netflix.config.ConcurrentCompositeConfiguration; //导入方法依赖的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

示例2: addArchaiusConfiguration

import com.netflix.config.ConcurrentCompositeConfiguration; //导入方法依赖的package包/类
private static void addArchaiusConfiguration(ConcurrentCompositeConfiguration config) {
	if (ConfigurationManager.isConfigurationInstalled()) {
		AbstractConfiguration installedConfiguration = ConfigurationManager
				.getConfigInstance();
		if (installedConfiguration instanceof ConcurrentCompositeConfiguration) {
			ConcurrentCompositeConfiguration configInstance = (ConcurrentCompositeConfiguration) installedConfiguration;
			configInstance.addConfiguration(config);
		}
		else {
			installedConfiguration.append(config);
			if (!(installedConfiguration instanceof AggregatedConfiguration)) {
				log.warn(
						"Appending a configuration to an existing non-aggregated installed configuration will have no effect");
			}
		}
	}
	else {
		ConfigurationManager.install(config);
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:21,代码来源:ArchaiusAutoConfiguration.java

示例3: testList

import com.netflix.config.ConcurrentCompositeConfiguration; //导入方法依赖的package包/类
@Test
public void testList() {
    Properties props = new Properties();
    props.setProperty("a", "${b.1},${d}");
    props.setProperty("b.1", "4,5,6,${c}");
    props.setProperty("c", "1,2,3");
    props.setProperty("d", "7,8,9");

    MapConfiguration mapConfig = new MapConfiguration(props);
    mapConfig.setDelimiterParsingDisabled(true);

    ConcurrentCompositeConfiguration config = new ConcurrentCompositeConfiguration();
    config.addConfiguration(mapConfig);
    config.addConfiguration(new MapConfiguration(new Properties()));

    assertEquals("4,5,6,1,2,3,7,8,9", config.getString("a"));

    ConfigurationBackedDynamicPropertySupportImpl impl = new ConfigurationBackedDynamicPropertySupportImpl(config);

    assertEquals("4,5,6,1,2,3,7,8,9", impl.getString("a"));
}
 
开发者ID:rancher,项目名称:cattle,代码行数:22,代码来源:NamedPropertiesConfigurationTest.java

示例4: duplicateServiceCombConfigToCse

import com.netflix.config.ConcurrentCompositeConfiguration; //导入方法依赖的package包/类
private static void duplicateServiceCombConfigToCse(ConcurrentCompositeConfiguration compositeConfiguration,
    AbstractConfiguration source,
    String sourceName) {
  duplicateServiceCombConfigToCse(source);

  compositeConfiguration.addConfiguration(source, sourceName);
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:8,代码来源:ConfigUtil.java

示例5: testCreateMicroserviceInstanceFromFile

import com.netflix.config.ConcurrentCompositeConfiguration; //导入方法依赖的package包/类
@Test
public void testCreateMicroserviceInstanceFromFile() {
  AbstractConfiguration config = ConfigUtil.createDynamicConfig();
  ConcurrentCompositeConfiguration configuration = new ConcurrentCompositeConfiguration();
  configuration.addConfiguration(config);
  ConfigurationManager.install(configuration);
  MicroserviceInstance instance = MicroserviceInstance.createFromDefinition(config);
  Assert.assertEquals(instance.getDataCenterInfo().getName(), "myDC");
  Assert.assertEquals(instance.getDataCenterInfo().getRegion(), "my-Region");
  Assert.assertEquals(instance.getDataCenterInfo().getAvailableZone(), "my-Zone");
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:12,代码来源:TestMicroServiceInstance.java

示例6: initSetup

import com.netflix.config.ConcurrentCompositeConfiguration; //导入方法依赖的package包/类
@BeforeClass
public static void initSetup() throws Exception {
  AbstractConfiguration dynamicConfig = ConfigUtil.createDynamicConfig();
  ConcurrentCompositeConfiguration configuration = new ConcurrentCompositeConfiguration();
  configuration.addConfiguration(dynamicConfig);
  configuration.addConfiguration(inMemoryConfig);

  ConfigurationManager.install(configuration);
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:10,代码来源:TestRegistry.java

示例7: locate

import com.netflix.config.ConcurrentCompositeConfiguration; //导入方法依赖的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

示例8: getApplicationConfiguration

import com.netflix.config.ConcurrentCompositeConfiguration; //导入方法依赖的package包/类
/**
 * @see ConfigurationProvider#getApplicationConfiguration(String, String, String, com.kixeye.chassis.bootstrap.aws.ServerInstanceContext)
 */
@Override
public AbstractConfiguration getApplicationConfiguration(String environment, String applicationName, String applicationVersion, ServerInstanceContext serverInstanceContext) {
    String instanceId = serverInstanceContext == null ? "local" : serverInstanceContext.getInstanceId();

    String configRoot = getPath(environment, applicationName, applicationVersion);
    String primaryConfigPath = configRoot += "/config";
    String instanceConfigNode = instanceId + "-config";

    checkPath(primaryConfigPath);

    ZooKeeperConfigurationSource source = new ZooKeeperConfigurationSource(curatorFramework, primaryConfigPath);

    try {
        source.start();
    } catch (Exception e) {
        source.close();
        BootstrapException.zookeeperInitializationFailed(zookeeperConnectionString, primaryConfigPath, e);
    }

    logger.debug("Initializing zookeeper configuration from host " + zookeeperConnectionString + " at path " + primaryConfigPath);

    ConcurrentCompositeConfiguration configuration = new ConcurrentCompositeConfiguration();
    configuration.addConfiguration(getServerInstanceSpecificApplicationConfiguration(configRoot, instanceConfigNode));
    configuration.addConfiguration(new DynamicWatchedConfiguration(source));

    return configuration;
}
 
开发者ID:Kixeye,项目名称:chassis,代码行数:31,代码来源:ZookeeperConfigurationProvider.java

示例9: buildConfiguration

import com.netflix.config.ConcurrentCompositeConfiguration; //导入方法依赖的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

示例10: build

import com.netflix.config.ConcurrentCompositeConfiguration; //导入方法依赖的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

示例11: doesNotIncludeSpringEnvironment

import com.netflix.config.ConcurrentCompositeConfiguration; //导入方法依赖的package包/类
@Test
public void doesNotIncludeSpringEnvironment() {
	ConcurrentCompositeConfiguration composite = new ConcurrentCompositeConfiguration(
			ConfigurationManager.getConfigInstance());
	ConfigurableEnvironmentConfiguration config = new ConfigurableEnvironmentConfiguration(
			new StandardEnvironment());
	assertTrue(config.containsKey("user.dir"));
	composite.addConfiguration(config);
	ConfigurationManager.getConfigInstance().setProperty("foo", "bar");
	Map<String, Object> map = this.endpoint.invoke();
	assertTrue(map.containsKey("foo"));
	assertFalse(map.containsKey("user.dir"));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:14,代码来源:ArchaiusEndpointTests.java

示例12: setLocations

import com.netflix.config.ConcurrentCompositeConfiguration; //导入方法依赖的package包/类
protected void setLocations(Resource[] locations,
                            boolean ignoreResourceNotFound,
                            int initialDelayMillis,
                            int delayMillis,
                            boolean ignoreDeletesFromSource) throws Exception {
    
    if (DynamicPropertyFactory.getBackingConfigurationSource() != null) {
        LOGGER.error("There was already a config source (or sources) configured.");
        throw new Exception("Archaius is already configured with a property source/sources.");
    }
    
    ConcurrentCompositeConfiguration config = new ConcurrentCompositeConfiguration();
    for (int i = locations.length -1 ; i >= 0 ; i--) {
        try {
            final String locationURL = locations[i].getURL().toString();
            config.addConfiguration(new DynamicURLConfiguration(
                    initialDelayMillis, delayMillis, ignoreDeletesFromSource, locationURL
            ));
        } catch (Exception ex) {
            if (ignoreResourceNotFound != true) {
                LOGGER.error("Exception thrown when adding a configuration location.", ex);
                throw ex;
            }
        }
    }

    DynamicPropertyFactory.initWithConfigurationSource(config);
}
 
开发者ID:andrewharmellaw,项目名称:archaius-spring-adapter,代码行数:29,代码来源:ArchaiusSpringPropertyPlaceholderSupport.java

示例13: init

import com.netflix.config.ConcurrentCompositeConfiguration; //导入方法依赖的package包/类
@PostConstruct
public void init() {
    if ( GLOBAL_DEFAULT == null ) {
        throw new IllegalStateException("setGlobalDefaults() must be set before init() is called");
    }

    baseConfig = new ConcurrentCompositeConfiguration();
    baseConfig.addConfiguration(new MapConfiguration(getOverride()));
    baseConfig.addConfiguration(new MapConfiguration(GLOBAL_DEFAULT));

    DynamicPropertyFactory.initWithConfigurationSource(baseConfig);
}
 
开发者ID:cloudnautique,项目名称:cloud-cattle,代码行数:13,代码来源:ArchaiusStartup.java

示例14: start

import com.netflix.config.ConcurrentCompositeConfiguration; //导入方法依赖的package包/类
@Override
public void start(BundleContext context) throws Exception {
	LOGGER.entering(CLASSNAME, "start", context);
	this.bContext = context;
	context.registerService(ManagedService.class, this, getDefaults())
			.getReference();
	ConcurrentCompositeConfiguration finalConfig = new ConcurrentCompositeConfiguration();
	finalConfig.addConfiguration(configuration);
	ConfigurationManager.install(finalConfig);
	LOGGER.exiting(CLASSNAME, "start");
}
 
开发者ID:WASdev,项目名称:sample.netflixoss.wlp,代码行数:12,代码来源:Activator.java

示例15: addClasspathConfig

import com.netflix.config.ConcurrentCompositeConfiguration; //导入方法依赖的package包/类
private void addClasspathConfig (String configName, ConcurrentCompositeConfiguration finalConfig) throws ConfigurationException {
  URL url = getClass().getResource (configName);
  if(url==null)
    url = getClass ().getClassLoader ().getResource (configName);
  
  if(url != null){      
    PropertiesConfiguration jarPropConfig = new PropertiesConfiguration (url);
    finalConfig.addConfiguration (jarPropConfig);
  }
}
 
开发者ID:dfci-cccb,项目名称:mev,代码行数:11,代码来源:ArchaiusConfig.java


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