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


Java ConfigurationManager.loadPropertiesFromResources方法代碼示例

本文整理匯總了Java中com.netflix.config.ConfigurationManager.loadPropertiesFromResources方法的典型用法代碼示例。如果您正苦於以下問題:Java ConfigurationManager.loadPropertiesFromResources方法的具體用法?Java ConfigurationManager.loadPropertiesFromResources怎麽用?Java ConfigurationManager.loadPropertiesFromResources使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.netflix.config.ConfigurationManager的用法示例。


在下文中一共展示了ConfigurationManager.loadPropertiesFromResources方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: Plugin

import com.netflix.config.ConfigurationManager; //導入方法依賴的package包/類
/** Create a new instance. */
@Inject
Plugin(Registry registry) throws IOException {

  AbstractConfiguration config = ConfigurationManager.getConfigInstance();
  final boolean enabled = config.getBoolean(ENABLED_PROP, true);
  if (enabled) {
    ConfigurationManager.loadPropertiesFromResources(CONFIG_FILE);
    if (config.getBoolean("spectator.gc.loggingEnabled")) {
      GC_LOGGER.start(null);
      LOGGER.info("gc logging started");
    } else {
      LOGGER.info("gc logging is not enabled");
    }

    Jmx.registerStandardMXBeans(registry);
  } else {
    LOGGER.debug("plugin not enabled, set " + ENABLED_PROP + "=true to enable");
  }
}
 
開發者ID:Netflix,項目名稱:spectator,代碼行數:21,代碼來源:Plugin.java

示例2: archaiusPropertyPlaceholderConfigurer

import com.netflix.config.ConfigurationManager; //導入方法依賴的package包/類
@Bean
static public PropertyPlaceholderConfigurer archaiusPropertyPlaceholderConfigurer() throws IOException, ConfigurationException {

    ConfigurationManager.loadPropertiesFromResources("chassis-test.properties");
    ConfigurationManager.loadPropertiesFromResources("chassis-default.properties");

    // force disable eureka
    ConfigurationManager.getConfigInstance().setProperty("chassis.eureka.disable", true);

    return new PropertyPlaceholderConfigurer() {
        @Override
        protected String resolvePlaceholder(String placeholder, Properties props, int systemPropertiesMode) {
            return DynamicPropertyFactory.getInstance().getStringProperty(placeholder, "null").get();
        }
    };
}
 
開發者ID:Kixeye,項目名稱:chassis,代碼行數:17,代碼來源:ChassisHystrixTestConfiguration.java

示例3: archaiusPropertyPlaceholderConfigurer

import com.netflix.config.ConfigurationManager; //導入方法依賴的package包/類
@Bean
static public PropertyPlaceholderConfigurer archaiusPropertyPlaceholderConfigurer() throws IOException, ConfigurationException {
	
    ConfigurationManager.loadPropertiesFromResources("chassis-test.properties");
    ConfigurationManager.loadPropertiesFromResources("chassis-default.properties");
    
    // force disable eureka
    ConfigurationManager.getConfigInstance().setProperty("chassis.eureka.disable", true);
    
    return new PropertyPlaceholderConfigurer() {
        @Override
        protected String resolvePlaceholder(String placeholder, Properties props, int systemPropertiesMode) {
            return DynamicPropertyFactory.getInstance().getStringProperty(placeholder, "null").get();
        }
    };
}
 
開發者ID:Kixeye,項目名稱:chassis,代碼行數:17,代碼來源:ChassisConfigTestConfiguration.java

示例4: beforeClass

import com.netflix.config.ConfigurationManager; //導入方法依賴的package包/類
@BeforeClass
public static void beforeClass() throws IOException {

    LOGGER.info("Starting beforeClass");
    ConfigurationManager
            .loadPropertiesFromResources("sample-client.properties");

    final RestAdapter restAdapter = RestAdapter
            .getNamedAdapter("sample-client");
    fakeClient = restAdapter.create(FakeClient.class);

    final RestAdapter restAdapter2 = RestAdapter.getNamedAdapter(
            "sample-client", RestAdapterConfig.custom()
                    .withMessageSerializer(new JacksonMessageSerializer())
                    .withEncoding(Encoding.gzip).build());

    fakeClient2 = restAdapter2.create(FakeClient.class);

    cache = GuavaRestCache.newDefaultCache();

    final RestAdapter restAdapter3 = RestAdapter.getNamedAdapter(
            "sample-client", RestAdapterConfig.custom()
                    .withMessageSerializer(new JacksonMessageSerializer())
                    .withRestCache(cache).build());

    fakeClient3 = restAdapter3.create(FakeClient.class);

    user = new FakeUser();
    user.setName("John Doe");
}
 
開發者ID:kenzanlabs,項目名稱:bowtie,代碼行數:31,代碼來源:RestAdapterTest.java

示例5: archaiusPropertyPlaceholderConfigurer

import com.netflix.config.ConfigurationManager; //導入方法依賴的package包/類
@Bean
static public PropertyPlaceholderConfigurer archaiusPropertyPlaceholderConfigurer() throws IOException, ConfigurationException {
	
    ConfigurationManager.loadPropertiesFromResources("chassis-test.properties");
    ConfigurationManager.loadPropertiesFromResources("chassis-default.properties");
    
    return new PropertyPlaceholderConfigurer() {
        @Override
        protected String resolvePlaceholder(String placeholder, Properties props, int systemPropertiesMode) {
            return DynamicPropertyFactory.getInstance().getStringProperty(placeholder, "null").get();
        }
    };
}
 
開發者ID:Kixeye,項目名稱:chassis,代碼行數:14,代碼來源:ChassisEurekaTestConfiguration.java

示例6: testServerWeights

import com.netflix.config.ConfigurationManager; //導入方法依賴的package包/類
@Test
public void testServerWeights(){
    try{
        ConfigurationManager.loadPropertiesFromResources("sample-client.properties"); 

        ConfigurationManager.getConfigInstance().setProperty(
                "sample-client.ribbon.NFLoadBalancerClassName", "com.netflix.loadbalancer.DynamicServerListLoadBalancer");
        ConfigurationManager.getConfigInstance().setProperty(
                "sample-client.ribbon.NFLoadBalancerRuleClassName", "com.netflix.loadbalancer.WeightedResponseTimeRule");
        // shorter weight adjusting interval
        ConfigurationManager.getConfigInstance().setProperty(
                "sample-client.ribbon." + WeightedResponseTimeRule.WEIGHT_TASK_TIMER_INTERVAL_CONFIG_KEY, "5000");
        ConfigurationManager.getConfigInstance().setProperty(
                "sample-client.ribbon.InitializeNFLoadBalancer", "true");       

        RestClient client = (RestClient) ClientFactory.getNamedClient("sample-client"); 

        HttpRequest request = HttpRequest.newBuilder().uri(new URI("/")).build(); 

        for (int i = 0; i < 20; i++) {
            client.executeWithLoadBalancer(request);
        }
        System.out.println(((AbstractLoadBalancer) client.getLoadBalancer()).getLoadBalancerStats());
        // wait for the weights to be adjusted
        Thread.sleep(5000);
        for (int i = 0; i < 50; i++) {
            client.executeWithLoadBalancer(request);
        }
        System.out.println(((AbstractLoadBalancer) client.getLoadBalancer()).getLoadBalancerStats());
    }
    catch (Exception e){
        e.printStackTrace();
    }
}
 
開發者ID:Netflix,項目名稱:ribbon,代碼行數:35,代碼來源:ResponseTimeWeightedRuleTest.java


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