本文整理汇总了Java中com.netflix.config.ConcurrentCompositeConfiguration类的典型用法代码示例。如果您正苦于以下问题:Java ConcurrentCompositeConfiguration类的具体用法?Java ConcurrentCompositeConfiguration怎么用?Java ConcurrentCompositeConfiguration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConcurrentCompositeConfiguration类属于com.netflix.config包,在下文中一共展示了ConcurrentCompositeConfiguration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
}
示例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;
}
}
示例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;
}
示例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;
}
示例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());
}
示例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());
}
示例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;
}
示例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();
}
示例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);
}
}
示例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"));
}
示例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);
}
示例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);
}
示例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");
}
示例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");
}
示例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");
}