本文整理匯總了Java中com.netflix.config.ConfigurationManager.loadPropertiesFromConfiguration方法的典型用法代碼示例。如果您正苦於以下問題:Java ConfigurationManager.loadPropertiesFromConfiguration方法的具體用法?Java ConfigurationManager.loadPropertiesFromConfiguration怎麽用?Java ConfigurationManager.loadPropertiesFromConfiguration使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.netflix.config.ConfigurationManager
的用法示例。
在下文中一共展示了ConfigurationManager.loadPropertiesFromConfiguration方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: start
import com.netflix.config.ConfigurationManager; //導入方法依賴的package包/類
@Override
public void start() throws Exception {
EurekaClientConfiguration eurekaClientConfiguration = configuration.getEureka();
ServerFactory serverFactory = configuration.getServerFactory();
BaseConfiguration baseConfiguration = new BaseConfiguration();
baseConfiguration.setProperty(eurekaNamespace + "name", eurekaClientConfiguration.getName());
baseConfiguration.setProperty(eurekaNamespace + "vipAddress", eurekaClientConfiguration.getVipAddress());
baseConfiguration.setProperty(eurekaNamespace + "serviceUrl.default", eurekaClientConfiguration.getDefaultServiceUrl());
baseConfiguration.setProperty(eurekaNamespace + "port", eurekaClientConfiguration.getPort());
Integer port = DropwizardServerHelpers.getPort(serverFactory);
Integer adminPort = DropwizardServerHelpers.getAdminPort(serverFactory);
baseConfiguration.setProperty(eurekaNamespace + "healthCheckUrl", String.format("http://${eureka.hostname}:%d/healthcheck", adminPort));
baseConfiguration.setProperty(eurekaNamespace + "secureHealthCheckUrl", String.format("http://${eureka.hostname}:%d/healthcheck", adminPort));
baseConfiguration.setProperty(eurekaNamespace + "statusPageUrl", String.format("http://${eureka.hostname}:%d/healthcheck", adminPort));
ConfigurationManager.loadPropertiesFromConfiguration(baseConfiguration);
EurekaInstanceConfig eurekaInstanceConfig = createEurekaInstanceConfig(discoveryMetadataProviders);
DiscoveryManager.getInstance().initComponent(eurekaInstanceConfig, new DefaultEurekaClientConfig(eurekaNamespace));
DiscoveryManager.getInstance().getDiscoveryClient().registerHealthCheckCallback(healthCheck);
markAsUp();
}
示例2: run
import com.netflix.config.ConfigurationManager; //導入方法依賴的package包/類
@Override
public void run(ConfiguresEurekaServer configuration, Environment environment) throws Exception {
BaseConfiguration baseConfiguration = new BaseConfiguration();
baseConfiguration.setProperty("eureka.waitTimeInMsWhenSyncEmpty", configuration.getEurekaServer().getWaitTimeInMsWhenSyncEmpty());
baseConfiguration.setProperty("eureka.numberRegistrySyncRetries", configuration.getEurekaServer().getNumberRegistrySyncRetries());
baseConfiguration.setProperty("eureka.serviceUrl.default", configuration.getEurekaServer().getDefaultServiceUrl());
baseConfiguration.setProperty("eureka.enableSelfPreservation", configuration.getEurekaServer().getEnableSelfPreservation());
baseConfiguration.setProperty("eureka.shouldFetchRegistry", false);
ConfigurationManager.loadPropertiesFromConfiguration(baseConfiguration);
environment.getObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
environment.getObjectMapper().configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
environment.servlets().addServletListeners(new EurekaBootStrap());
environment.healthChecks().register("eureka", new EurekaServerHealthCheck());
environment.jersey().register(ApplicationsResource.class);
environment.jersey().register(InstancesResource.class);
environment.jersey().register(PeerReplicationResource.class);
environment.jersey().register(SecureVIPResource.class);
environment.jersey().register(StatusResource.class);
environment.jersey().register(VIPResource.class);
environment.jersey().register(ASGResource.class);
environment.jersey().register(DiscoveryJerseyProvider.class);
environment.jersey().getResourceConfig().getSingletons().clear();
environment.jersey().getResourceConfig().getSingletons().add(new DiscoveryJerseyProvider());
}
示例3: register
import com.netflix.config.ConfigurationManager; //導入方法依賴的package包/類
public void register(BreakerboxConfiguration breakerboxConfiguration) {
if (breakerboxConfiguration.getUrls().isEmpty()) {
return;
}
final TenacityPollingScheduler tenacityPollingScheduler = new TenacityPollingScheduler(
Ints.checkedCast(breakerboxConfiguration.getInitialDelay().toMilliseconds()),
Ints.checkedCast(breakerboxConfiguration.getDelay().toMilliseconds()),
true);
final CountDownLatch countDownLatch = new CountDownLatch(1);
if (breakerboxConfiguration.isWaitForInitialLoad()) {
tenacityPollingScheduler.addPollListener((eventType, lastResult, exception) -> countDownLatch.countDown());
}
final DynamicConfiguration dynConfig = new DynamicConfiguration(
new URLConfigurationSource(breakerboxConfiguration.getUrls().split(",")),
tenacityPollingScheduler);
ConfigurationManager.getConfigInstance();
ConfigurationManager.loadPropertiesFromConfiguration(dynConfig);
if (breakerboxConfiguration.isWaitForInitialLoad()) {
final Duration duration = breakerboxConfiguration.getWaitForInitialLoad();
try {
final boolean success = countDownLatch.await(duration.getQuantity(), duration.getUnit());
LOGGER.info("Breakerbox initial configuration load: {}", success ? "SUCCESS" : "FAILURE");
} catch (Exception err) {
LOGGER.warn("Failed waiting for Breakerbox initial load", err);
}
}
}