本文整理匯總了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");
}
}
示例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();
}
};
}
示例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();
}
};
}
示例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");
}
示例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();
}
};
}
示例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();
}
}