當前位置: 首頁>>代碼示例>>Java>>正文


Java ConfigurationManager.loadPropertiesFromConfiguration方法代碼示例

本文整理匯總了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();
}
 
開發者ID:guggens,項目名稱:log-dropwizard-eureka-mongo-sample,代碼行數:28,代碼來源:EurekaInstance.java

示例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());
}
 
開發者ID:guggens,項目名稱:log-dropwizard-eureka-mongo-sample,代碼行數:30,代碼來源:EurekaServerBundle.java

示例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);
        }
    }
}
 
開發者ID:yammer,項目名稱:tenacity,代碼行數:34,代碼來源:ArchaiusPropertyRegister.java


注:本文中的com.netflix.config.ConfigurationManager.loadPropertiesFromConfiguration方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。