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


Java ConfigurationManager.getConfigInstance方法代碼示例

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


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

示例1: testAll

import com.netflix.config.ConfigurationManager; //導入方法依賴的package包/類
@Test
public void testAll() {
  ConfigurationSpringInitializer configurationSpringInitializer = new ConfigurationSpringInitializer();

  Assert.assertEquals(Ordered.LOWEST_PRECEDENCE / 2, configurationSpringInitializer.getOrder());
  Assert.assertEquals(true,
      Deencapsulation.getField(configurationSpringInitializer, "ignoreUnresolvablePlaceholders"));

  Object o = ConfigUtil.getProperty("zq");
  @SuppressWarnings("unchecked")
  List<Map<String, Object>> listO = (List<Map<String, Object>>) o;
  Assert.assertEquals(3, listO.size());
  Assert.assertEquals(null, ConfigUtil.getProperty("notExist"));

  MicroserviceConfigLoader loader = ConfigUtil.getMicroserviceConfigLoader();
  Assert.assertNotNull(loader);

  Configuration instance = ConfigurationManager.getConfigInstance();
  ConfigUtil.installDynamicConfig();
  // must not reinstall
  Assert.assertEquals(instance, ConfigurationManager.getConfigInstance());
}
 
開發者ID:apache,項目名稱:incubator-servicecomb-java-chassis,代碼行數:23,代碼來源:TestConfigurationSpringInitializer.java

示例2: resolve

import com.netflix.config.ConfigurationManager; //導入方法依賴的package包/類
/**
 * Attempts to acquire the Vault URL from Archaius.
 *
 * @return Vault URL
 */
@Nullable
@Override
public  String resolve() {
    final AbstractConfiguration configuration = ConfigurationManager.getConfigInstance();
    final String envUrl = configuration.getString(CERBERUS_ADDR_ENV_PROPERTY);
    final String sysUrl = configuration.getString(CERBERUS_ADDR_SYS_PROPERTY);

    if (StringUtils.isNotBlank(envUrl) && HttpUrl.parse(envUrl) != null) {
        return envUrl;
    } else if (StringUtils.isNotBlank(sysUrl) && HttpUrl.parse(sysUrl) != null) {
        return sysUrl;
    }

    logger.warn("Unable to resolve the Cerberus URL.");

    return null;
}
 
開發者ID:Nike-Inc,項目名稱:cerberus-archaius-client,代碼行數:23,代碼來源:ArchaiusCerberusUrlResolver.java

示例3: 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");
}
 
開發者ID:spinnaker,項目名稱:kork,代碼行數:18,代碼來源:ArchaiusConfiguration.java

示例4: 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

示例5: doGet

import com.netflix.config.ConfigurationManager; //導入方法依賴的package包/類
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    // get list of properties
    TreeSet<String> properties = new TreeSet<String>();
	AbstractConfiguration config = ConfigurationManager.getConfigInstance();
    Iterator<String> keys = config.getKeys();
    while (keys.hasNext()) {
        String key = keys.next();
        Object value = config.getProperty(key);
        if ("aws.accessId".equals(key)
                || "aws.secretKey".equals(key)
                || "experiments-service.secret".equals(key)
                || "java.class.path".equals(key)
                || key.contains("framework.securityDefinition")
                || key.contains("password")
                || key.contains("secret")) {
            value = "*****";
        }
        properties.add(key + "=" + value.toString());
    }

    // write them out in sorted order
    for (String line : properties) {
        resp.getWriter().append(line).println();
    }
}
 
開發者ID:Kixeye,項目名稱:chassis,代碼行數:27,代碼來源:PropertiesServlet.java

示例6: onApplicationEvent

import com.netflix.config.ConfigurationManager; //導入方法依賴的package包/類
@Override
public void onApplicationEvent(EnvironmentChangeEvent event) {
	AbstractConfiguration manager = ConfigurationManager.getConfigInstance();
	for (String key : event.getKeys()) {
		for (ConfigurationListener listener : manager
				.getConfigurationListeners()) {
			Object source = event.getSource();
			// TODO: Handle add vs set vs delete?
			int type = AbstractConfiguration.EVENT_SET_PROPERTY;
			String value = this.env.getProperty(key);
			boolean beforeUpdate = false;
			listener.configurationChanged(new ConfigurationEvent(source, type,
					key, value, beforeUpdate));
		}
	}
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-netflix,代碼行數:17,代碼來源:ArchaiusAutoConfiguration.java

示例7: 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);
	}
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-netflix,代碼行數:21,代碼來源:ArchaiusAutoConfiguration.java

示例8: testBuildWithArchaiusProperties

import com.netflix.config.ConfigurationManager; //導入方法依賴的package包/類
@Test
public void testBuildWithArchaiusProperties() {
    Configuration config = ConfigurationManager.getConfigInstance();
    config.setProperty("client1.niws.client." + Keys.DeploymentContextBasedVipAddresses, "dummy:7001");
    config.setProperty("client1.niws.client." + Keys.InitializeNFLoadBalancer, "true");
    config.setProperty("client1.niws.client." + Keys.NFLoadBalancerClassName, DynamicServerListLoadBalancer.class.getName());
    config.setProperty("client1.niws.client." + Keys.NFLoadBalancerRuleClassName, RoundRobinRule.class.getName());
    config.setProperty("client1.niws.client." + Keys.NIWSServerListClassName, DiscoveryEnabledNIWSServerList.class.getName());
    config.setProperty("client1.niws.client." + Keys.NIWSServerListFilterClassName, ZoneAffinityServerListFilter.class.getName());
    config.setProperty("client1.niws.client." + Keys.ServerListUpdaterClassName, PollingServerListUpdater.class.getName());
    IClientConfig clientConfig = IClientConfig.Builder.newBuilder(NiwsClientConfig.class, "client1").build();
    ILoadBalancer lb = LoadBalancerBuilder.newBuilder().withClientConfig(clientConfig).buildLoadBalancerFromConfigWithReflection();
    assertNotNull(lb);
    assertEquals(DynamicServerListLoadBalancer.class.getName(), lb.getClass().getName());
    DynamicServerListLoadBalancer<Server> dynamicLB = (DynamicServerListLoadBalancer<Server>) lb;
    assertTrue(dynamicLB.getServerListUpdater() instanceof PollingServerListUpdater);
    assertTrue(dynamicLB.getFilter() instanceof ZoneAffinityServerListFilter);
    assertTrue(dynamicLB.getRule() instanceof RoundRobinRule);
    assertTrue(dynamicLB.getPing() instanceof DummyPing);
    assertEquals(Lists.newArrayList(expected), lb.getAllServers());
}
 
開發者ID:Netflix,項目名稱:ribbon,代碼行數:22,代碼來源:LBBuilderTest.java

示例9: testPrimeConnectionsLargePool

import com.netflix.config.ConfigurationManager; //導入方法依賴的package包/類
@Test
public void testPrimeConnectionsLargePool() throws Exception {
	Configuration config = ConfigurationManager.getConfigInstance();
	config.setProperty("PrimeConnectionsTest2.ribbon.NFLoadBalancerClassName", 
			com.netflix.loadbalancer.DynamicServerListLoadBalancer.class.getName());
	config.setProperty("PrimeConnectionsTest2.ribbon.NIWSServerListClassName", LargeFixedServerList.class.getName());
	config.setProperty("PrimeConnectionsTest2.ribbon.EnablePrimeConnections", "true");
	DynamicServerListLoadBalancer<Server> lb = (DynamicServerListLoadBalancer<Server>) ClientFactory.getNamedLoadBalancer("PrimeConnectionsTest2");
	PrimeConnectionEndStats stats = lb.getPrimeConnections().getEndStats();
	assertEquals(stats.success, LARGE_FIXED_SERVER_LIST_SIZE);
}
 
開發者ID:Netflix,項目名稱:ribbon,代碼行數:12,代碼來源:PrimeConnectionsTest.java

示例10: testSunnyDayNoClientAuth

import com.netflix.config.ConfigurationManager; //導入方法依賴的package包/類
@Test
public void testSunnyDayNoClientAuth() throws Exception{

	AbstractConfiguration cm = ConfigurationManager.getConfigInstance();

	String name = "GetPostSecureTest" + ".testSunnyDayNoClientAuth";

	String configPrefix = name + "." + "ribbon";

	cm.setProperty(configPrefix + "." + CommonClientConfigKey.IsSecure, "true");
	cm.setProperty(configPrefix + "." + CommonClientConfigKey.SecurePort, Integer.toString(PORT2));
	cm.setProperty(configPrefix + "." + CommonClientConfigKey.IsHostnameValidationRequired, "false");
	cm.setProperty(configPrefix + "." + CommonClientConfigKey.TrustStore, FILE_TS2.getAbsolutePath());
	cm.setProperty(configPrefix + "." + CommonClientConfigKey.TrustStorePassword, PASSWORD);

	RestClient rc = (RestClient) ClientFactory.getNamedClient(name);

	testServer2.accept();

	URI getUri = new URI(SERVICE_URI2 + "test/");
       HttpRequest request = HttpRequest.newBuilder().uri(getUri).queryParams("name", "test").build();
	HttpResponse response = rc.execute(request);
	assertEquals(200, response.getStatus());
}
 
開發者ID:Netflix,項目名稱:ribbon,代碼行數:25,代碼來源:SecureGetTest.java

示例11: init

import com.netflix.config.ConfigurationManager; //導入方法依賴的package包/類
@BeforeClass
public static void init() {
    Configuration config = ConfigurationManager.getConfigInstance();
    config.setProperty(
            DefaultClientConfigImpl.DEFAULT_PROPERTY_NAME_SPACE + ".ServerListSubsetFilter.forceEliminatePercent", "0.6");
    config.setProperty(
            DefaultClientConfigImpl.DEFAULT_PROPERTY_NAME_SPACE + ".ServerListSubsetFilter.eliminationFailureThresold", 2);
    config.setProperty(
            DefaultClientConfigImpl.DEFAULT_PROPERTY_NAME_SPACE + ".ServerListSubsetFilter.eliminationConnectionThresold", 2);
    config.setProperty(
            DefaultClientConfigImpl.DEFAULT_PROPERTY_NAME_SPACE + ".ServerListSubsetFilter.size", "5");
    
    config.setProperty("SubsetFilerTest.ribbon.NFLoadBalancerClassName", 
            com.netflix.loadbalancer.DynamicServerListLoadBalancer.class.getName());
    config.setProperty("SubsetFilerTest.ribbon.NIWSServerListClassName", MockServerList.class.getName());
    config.setProperty("SubsetFilerTest.ribbon.NIWSServerListFilterClassName", ServerListSubsetFilter.class.getName());
    // turn off auto refresh
    config.setProperty("SubsetFilerTest.ribbon.ServerListRefreshInterval", String.valueOf(Integer.MAX_VALUE));
    config.setProperty("SubsetFilerTest.ribbon.ServerListSubsetFilter.forceEliminatePercent", "0.6");
    config.setProperty("SubsetFilerTest.ribbon.ServerListSubsetFilter.eliminationFailureThresold", 2);
    config.setProperty("SubsetFilerTest.ribbon.ServerListSubsetFilter.eliminationConnectionThresold", 2);
    config.setProperty("SubsetFilerTest.ribbon.ServerListSubsetFilter.size", "5");
}
 
開發者ID:Netflix,項目名稱:ribbon,代碼行數:24,代碼來源:SubsetFilterTest.java

示例12: testAnnotation

import com.netflix.config.ConfigurationManager; //導入方法依賴的package包/類
@Test
public void testAnnotation() {
    MyTransportFactory transportFactory = new MyTransportFactory(ClientConfigFactory.DEFAULT);
    RibbonResourceFactory resourceFactory = new DefaultResourceFactory(ClientConfigFactory.DEFAULT, transportFactory);
    RibbonDynamicProxy.newInstance(SampleMovieService.class, resourceFactory, ClientConfigFactory.DEFAULT, transportFactory);
    IClientConfig clientConfig = transportFactory.getClientConfig();
    assertEquals(1000, clientConfig.get(Keys.ConnectTimeout).longValue());
    assertEquals(2000, clientConfig.get(Keys.ReadTimeout).longValue());

    Configuration config = ConfigurationManager.getConfigInstance();
    assertEquals("2000", config.getProperty("SampleMovieService.ribbon.ReadTimeout"));
    assertEquals("1000", config.getProperty("SampleMovieService.ribbon.ConnectTimeout"));

    config.setProperty("SampleMovieService.ribbon.ReadTimeout", "5000");
    assertEquals(5000, clientConfig.get(Keys.ReadTimeout).longValue());
}
 
開發者ID:Netflix,項目名稱:ribbon,代碼行數:17,代碼來源:ClientPropertiesTest.java

示例13: mergeProperties

import com.netflix.config.ConfigurationManager; //導入方法依賴的package包/類
@Override
protected Properties mergeProperties() throws IOException {
  Properties properties = super.mergeProperties();

  AbstractConfiguration config = ConfigurationManager.getConfigInstance();
  Iterator<String> iter = config.getKeys();
  while (iter.hasNext()) {
    String key = iter.next();
    Object value = config.getProperty(key);
    properties.put(key, value);
  }
  return properties;
}
 
開發者ID:apache,項目名稱:incubator-servicecomb-java-chassis,代碼行數:14,代碼來源:ConfigurationSpringInitializer.java

示例14: configure

import com.netflix.config.ConfigurationManager; //導入方法依賴的package包/類
private void configure(String namespace, String appName){
    URI serviceUri = server.getServiceURI();
    AbstractConfiguration configInstance = ConfigurationManager.getConfigInstance();
    configInstance.setProperty(namespace + ".serviceUrl.default", serviceUri.toString());
    configInstance.setProperty(namespace + ".port", serviceUri.getPort());
    configInstance.setProperty(namespace + ".name", appName);
}
 
開發者ID:hazelcast,項目名稱:hazelcast-eureka,代碼行數:8,代碼來源:HazelcastClientTestCase.java

示例15: infrastructureInit

import com.netflix.config.ConfigurationManager; //導入方法依賴的package包/類
/**
 * Initializes the Archaius system and configures the Netty leak detection level (if necessary).
 * DO NOT CALL THIS DIRECTLY. Use {@link #launchServer(String[])} when you're ready to start the server.
 */
protected void infrastructureInit() {
    MainClassUtils.setupJbossLoggingToUseSlf4j();

    try {
        Pair<String, String> appIdAndEnvironmentPair = MainClassUtils.getAppIdAndEnvironmentFromSystemProperties();
        ConfigurationManager.loadCascadedPropertiesFromResources(appIdAndEnvironmentPair.getLeft());
    }
    catch (IOException e) {
        throw new RuntimeException("Error loading Archaius properties", e);
    }

    AbstractConfiguration appConfig = ConfigurationManager.getConfigInstance();
    Function<String, Boolean> hasPropertyFunction = (propKey) -> appConfig.getProperty(propKey) != null;
    Function<String, String> propertyExtractionFunction = (propKey) -> {
        // Properties in Archaius might be a Collection or an Object.
        Object propValObj = appConfig.getProperty(propKey);
        return (propValObj instanceof Collection)
               ? ((Collection<?>) propValObj).stream().map(String::valueOf).collect(Collectors.joining(","))
               : String.valueOf(propValObj);
    };
    Set<String> propKeys = new LinkedHashSet<>();
    appConfig.getKeys().forEachRemaining(propKeys::add);

    MainClassUtils.logApplicationPropertiesIfDebugActionsEnabled(
        hasPropertyFunction, propertyExtractionFunction, propKeys, false
    );

    MainClassUtils.setupNettyLeakDetectionLevel(hasPropertyFunction, propertyExtractionFunction);
}
 
開發者ID:Nike-Inc,項目名稱:riposte,代碼行數:34,代碼來源:ArchaiusServer.java


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