本文整理汇总了Java中com.netflix.config.ConcurrentCompositeConfiguration类的典型用法代码示例。如果您正苦于以下问题:Java ConcurrentCompositeConfiguration类的具体用法?Java ConcurrentCompositeConfiguration怎么用?Java ConcurrentCompositeConfiguration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConcurrentCompositeConfiguration类属于com.netflix.config包,在下文中一共展示了ConcurrentCompositeConfiguration类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getStringProperty
import com.netflix.config.ConcurrentCompositeConfiguration; //导入依赖的package包/类
public static String getStringProperty(ConcurrentCompositeConfiguration configSource, String defaultValue,
String... keys) {
String property = null;
for (String key : keys) {
if (configSource != null) {
Object v = configSource.getProperty(key);
if (List.class.isInstance(v)) {
property = listToString(((List<?>) v).toArray());
} else {
property = (String) configSource.getProperty(key);
}
} else {
property = DynamicPropertyFactory.getInstance().getStringProperty(key, null).get();
}
if (property != null) {
break;
}
}
if (property != null) {
return property;
} else {
return defaultValue;
}
}
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:26,代码来源:SSLOption.java
示例2: getBooleanProperty
import com.netflix.config.ConcurrentCompositeConfiguration; //导入依赖的package包/类
private static boolean getBooleanProperty(ConcurrentCompositeConfiguration configSource, boolean defaultValue,
String... keys) {
String property = null;
for (String key : keys) {
if (configSource != null) {
if (configSource.getProperty(key) != null) {
return configSource.getBoolean(key);
}
} else {
property = DynamicPropertyFactory.getInstance().getStringProperty(key, null).get();
}
if (property != null) {
break;
}
}
if (property != null) {
return Boolean.parseBoolean(property);
} else {
return defaultValue;
}
}
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:23,代码来源:SSLOption.java
示例3: createLocalConfig
import com.netflix.config.ConcurrentCompositeConfiguration; //导入依赖的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
示例4: createDynamicConfig
import com.netflix.config.ConcurrentCompositeConfiguration; //导入依赖的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
示例5: testCreateDynamicConfigNoConfigCenterSPI
import com.netflix.config.ConcurrentCompositeConfiguration; //导入依赖的package包/类
@Test
public void testCreateDynamicConfigNoConfigCenterSPI() {
new Expectations(SPIServiceUtils.class) {
{
SPIServiceUtils.getTargetService(ConfigCenterConfigurationSource.class);
result = null;
}
};
AbstractConfiguration dynamicConfig = ConfigUtil.createDynamicConfig();
MicroserviceConfigLoader loader = ConfigUtil.getMicroserviceConfigLoader(dynamicConfig);
List<ConfigModel> list = loader.getConfigModels();
Assert.assertEquals(loader, ConfigUtil.getMicroserviceConfigLoader(dynamicConfig));
Assert.assertEquals(1, list.size());
Assert.assertNotEquals(DynamicWatchedConfiguration.class,
((ConcurrentCompositeConfiguration) dynamicConfig).getConfiguration(0).getClass());
}
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:18,代码来源:TestConfigUtil.java
示例6: 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
示例7: build
import com.netflix.config.ConcurrentCompositeConfiguration; //导入依赖的package包/类
public CuratorFramework build() {
if (this.exhibitors == null && this.zookeeperConnectionString == null) {
throw new BootstrapException("Cannot build a CuratorFramework instance because no Zookeeper or Exhibitor connection information was provided.");
}
ConcurrentCompositeConfiguration configuration = buildConfiguration();
CuratorFramework curatorFramework = null;
if (zookeeperConnectionString != null) {
curatorFramework = buildCuratorWithZookeeperDirectly(configuration);
} else {
curatorFramework = buildCuratorWithExhibitor(configuration);
}
if (startOnBuild) {
try {
curatorFramework.start();
} catch (Exception e) {
BootstrapException.zookeeperInitializationFailed(this.zookeeperConnectionString, this.exhibitors, e);
}
}
return curatorFramework;
}
开发者ID:Kixeye,项目名称:chassis,代码行数:21,代码来源:CuratorFrameworkBuilder.java
示例8: beforeClass
import com.netflix.config.ConcurrentCompositeConfiguration; //导入依赖的package包/类
@Before
public void beforeClass() throws Exception {
zookeeper = new TestingServer(SocketUtils.findAvailableTcpPort());
curatorFramework = CuratorFrameworkFactory.newClient(zookeeper.getConnectString(), new RetryOneTime(1000));
curatorFramework.start();
curatorFramework.create().forPath(CONFIG_BASE_PATH);
Map<String, Object> defaults = new HashMap<>();
defaults.put(DEF_KEY1, DEF_VAL1);
defaults.put(DEF_KEY2, DEF_VAL2);
defaultConfiguration = new MapConfiguration(defaults);
node = UUID.randomUUID().toString();
config = new ConcurrentCompositeConfiguration();
}
开发者ID:Kixeye,项目名称:chassis,代码行数:18,代码来源:DynamicZookeeperConfigurationSourceTest.java
示例9: 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
示例10: 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
示例11: createSSLOptionFactory
import com.netflix.config.ConcurrentCompositeConfiguration; //导入依赖的package包/类
static SSLOptionFactory createSSLOptionFactory(String tag, ConcurrentCompositeConfiguration configSource) {
String name = SSLOption.getStringProperty(configSource,
null,
"ssl." + tag + ".sslOptionFactory",
"ssl.sslOptionFactory");
return createSSLOptionFactory(name);
}
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:8,代码来源:SSLOptionFactory.java
示例12: testSSLOptionFactoryWrong
import com.netflix.config.ConcurrentCompositeConfiguration; //导入依赖的package包/类
@Test
public void testSSLOptionFactoryWrong(@Mocked SSLOption option) {
new Expectations() {
{
SSLOption.getStringProperty((ConcurrentCompositeConfiguration) any, anyString, (String[]) any);
result = "wrong";
}
};
expectedException.expect(IllegalStateException.class);
expectedException.expectMessage(Matchers.is("Failed to create SSLOptionFactory."));
SSLOptionFactory.createSSLOptionFactory("cc", null);
}
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:14,代码来源:TestSSLOptionFactory.java
示例13: testSSLOptionFactoryCorrent
import com.netflix.config.ConcurrentCompositeConfiguration; //导入依赖的package包/类
@Test
public void testSSLOptionFactoryCorrent() {
new MockUp<SSLOption>() {
@Mock
public String getStringProperty(ConcurrentCompositeConfiguration configSource, String defaultValue,
String... keys) {
return "org.apache.servicecomb.foundation.ssl.MyOptionFactory";
}
};
SSLOptionFactory factory = SSLOptionFactory.createSSLOptionFactory("cc", null);
Assert.assertEquals(factory.createSSLOption().getProtocols(), "TLSv1.2");
}
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:13,代码来源:TestSSLOptionFactory.java
示例14: testSSLOptionYamlOption2
import com.netflix.config.ConcurrentCompositeConfiguration; //导入依赖的package包/类
@Test
public void testSSLOptionYamlOption2() throws Exception {
System.setProperty("ssl.protocols", "TLSv1.2");
ConcurrentCompositeConfiguration finalConfig = ConfigUtil.createLocalConfig();
SSLOption option = SSLOption.buildFromYaml("server", finalConfig);
String protocols = option.getProtocols();
option.setProtocols(protocols);
Assert.assertEquals("TLSv1.2", protocols);
System.clearProperty("ssl.protocols");
}
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:13,代码来源:SSLOptionTest.java
示例15: testSSLOptionYamlOptionWithProperyFalse
import com.netflix.config.ConcurrentCompositeConfiguration; //导入依赖的package包/类
@Test
public void testSSLOptionYamlOptionWithProperyFalse() throws Exception {
System.setProperty("ssl.authPeer", "false");
ConcurrentCompositeConfiguration finalConfig = ConfigUtil.createLocalConfig();
SSLOption option = SSLOption.buildFromYaml("server", finalConfig);
boolean authPeer = option.isAuthPeer();
option.setAuthPeer(authPeer);
Assert.assertEquals(false, authPeer);
System.getProperties().remove("ssl.authPeer");
}
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:13,代码来源:SSLOptionTest.java
示例16: testSSLOptionYamlOptionWithProperyTrue
import com.netflix.config.ConcurrentCompositeConfiguration; //导入依赖的package包/类
@Test
public void testSSLOptionYamlOptionWithProperyTrue() throws Exception {
System.setProperty("ssl.authPeer", "true");
ConcurrentCompositeConfiguration finalConfig = ConfigUtil.createLocalConfig();
SSLOption option = SSLOption.buildFromYaml("server", finalConfig);
boolean authPeer = option.isAuthPeer();
option.setAuthPeer(authPeer);
Assert.assertEquals(true, authPeer);
System.getProperties().remove("ssl.authPeer");
}
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:13,代码来源:SSLOptionTest.java
示例17: 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
示例18: testCreateDynamicConfigHasConfigCenter
import com.netflix.config.ConcurrentCompositeConfiguration; //导入依赖的package包/类
@Test
public void testCreateDynamicConfigHasConfigCenter(
@Mocked ConfigCenterConfigurationSource configCenterConfigurationSource) {
AbstractConfiguration dynamicConfig = ConfigUtil.createDynamicConfig();
Assert.assertEquals(DynamicWatchedConfiguration.class,
((ConcurrentCompositeConfiguration) dynamicConfig).getConfiguration(0).getClass());
}
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:8,代码来源:TestConfigUtil.java
示例19: 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
示例20: 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
注:本文中的com.netflix.config.ConcurrentCompositeConfiguration类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论