本文整理匯總了Java中com.netflix.config.ConfigurationManager.install方法的典型用法代碼示例。如果您正苦於以下問題:Java ConfigurationManager.install方法的具體用法?Java ConfigurationManager.install怎麽用?Java ConfigurationManager.install使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.netflix.config.ConfigurationManager
的用法示例。
在下文中一共展示了ConfigurationManager.install方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createConfig
import com.netflix.config.ConfigurationManager; //導入方法依賴的package包/類
@Override
public Config createConfig(String name) {
if (CONFIG != null) {
return CONFIG;
}
synchronized (ArchaiusBaseFactory.class) {
if (CONFIG == null) {
AbstractConfiguration configuration = getConfiguration();
ConfigurationManager.install(configuration);
CONFIG = new ArchaiusWrapper(configuration);
ConfigFactory.setContext(CONFIG);
configuration.addConfigurationListener(event -> {
if (!event.isBeforeUpdate()) {
CONFIG.fire(event.getPropertyName());
}
});
}
}
return CONFIG;
}
示例2: ArchaiusInitializingBeanPostProcessor
import com.netflix.config.ConfigurationManager; //導入方法依賴的package包/類
public ArchaiusInitializingBeanPostProcessor(ConfigurableApplicationContext applicationContext, AbstractPollingScheduler pollingScheduler, SpringEnvironmentPolledConfigurationSource polledConfigurationSource, List<ClasspathPropertySource> propertyBindings) {
this.applicationContext = Objects.requireNonNull(applicationContext, "applicationContext");
this.pollingScheduler = Objects.requireNonNull(pollingScheduler, "pollingScheduler");
this.polledConfigurationSource = Objects.requireNonNull(polledConfigurationSource, "polledConfigurationSource");
this.propertyBindings = propertyBindings != null ? propertyBindings : Collections.emptyList();
initPropertyBindings();
configurationInstance = new DynamicConfiguration(polledConfigurationSource, pollingScheduler);
if (!ConfigurationManager.isConfigurationInstalled()) {
ConfigurationManager.install(new CompositeConfiguration());
}
CompositeConfiguration config = (CompositeConfiguration) ConfigurationManager.getConfigInstance();
config.addConfiguration(configurationInstance);
applicationContext.getBeanFactory().registerSingleton("environmentBackedConfig", ConfigurationManager.getConfigInstance());
applicationContext.getBeanFactory().registerAlias("environmentBackedConfig", "abstractConfiguration");
}
示例3: addArchaiusConfiguration
import com.netflix.config.ConfigurationManager; //導入方法依賴的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);
}
}
示例4: installDynamicConfig
import com.netflix.config.ConfigurationManager; //導入方法依賴的package包/類
public static void installDynamicConfig() {
if (ConfigurationManager.isConfigurationInstalled()) {
LOGGER.warn("Configuration installed by others, will ignore this configuration.");
return;
}
AbstractConfiguration dynamicConfig = ConfigUtil.createDynamicConfig();
ConfigurationManager.install(dynamicConfig);
}
示例5: testCreateMicroserviceInstanceFromFile
import com.netflix.config.ConfigurationManager; //導入方法依賴的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");
}
示例6: initSetup
import com.netflix.config.ConfigurationManager; //導入方法依賴的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);
}
示例7: installZkConfig
import com.netflix.config.ConfigurationManager; //導入方法依賴的package包/類
@PostConstruct
public void installZkConfig() throws Exception {
String zkConfigRootPath = "/config/"+appName;
ZooKeeperConfigurationSource zkConfigSource = new ZooKeeperConfigurationSource(client, zkConfigRootPath);
zkConfigSource.start();
DynamicWatchedConfiguration zkDynamicConfig = new DynamicWatchedConfiguration(zkConfigSource);
ConfigurationManager.install(zkDynamicConfig);
}
示例8: locate
import com.netflix.config.ConfigurationManager; //導入方法依賴的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;
}
示例9: configureArchaius
import com.netflix.config.ConfigurationManager; //導入方法依賴的package包/類
private void configureArchaius(ConcurrentCompositeConfiguration finalConfiguration) {
if (configureArchaius) {
Properties systemProps = System.getProperties();
if (systemProps.getProperty(ARCHAIUS_DEPLOYMENT_ENVIRONMENT) == null) {
systemProps.setProperty(ARCHAIUS_DEPLOYMENT_ENVIRONMENT, appEnvironment);
}
ConfigurationManager.install(finalConfiguration);
}
}
示例10: start
import com.netflix.config.ConfigurationManager; //導入方法依賴的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");
}
示例11: DynamicPropertiesImpl
import com.netflix.config.ConfigurationManager; //導入方法依賴的package包/類
DynamicPropertiesImpl(AbstractConfiguration... configurations) {
ConcurrentCompositeConfiguration configuration = new ConcurrentCompositeConfiguration();
Arrays.stream(configurations).forEach(configuration::addConfiguration);
ConfigurationManager.install(configuration);
}