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


Java ConfigurationManager類代碼示例

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


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

示例1: getEurekaStatus

import com.netflix.config.ConfigurationManager; //導入依賴的package包/類
private Map<String, Object> getEurekaStatus() {

        Map<String, Object> stats = new HashMap<>();
        stats.put("time", new Date());
        stats.put("currentTime", StatusResource.getCurrentTimeAsString());
        stats.put("upTime", StatusInfo.getUpTime());
        stats.put("environment", ConfigurationManager.getDeploymentContext()
            .getDeploymentEnvironment());
        stats.put("datacenter", ConfigurationManager.getDeploymentContext()
            .getDeploymentDatacenter());

        PeerAwareInstanceRegistry registry = getRegistry();

        stats.put("isBelowRenewThreshold", registry.isBelowRenewThresold() == 1);

        populateInstanceInfo(stats);

        return stats;
    }
 
開發者ID:oktadeveloper,項目名稱:jhipster-microservices-example,代碼行數:20,代碼來源:EurekaResource.java

示例2: configure

import com.netflix.config.ConfigurationManager; //導入依賴的package包/類
@Override
protected void configure() {
	bind(HealthCheckHandler.class).toInstance(new HealthcheckResource());
	
	bind(RequrestAdapter.class).to(RxNettyServiceAdapter.class);
	
	bind(MeetupResource.class).asEagerSingleton();
	bind(MeetupService.class).to(MeetupServiceImpl.class);
	bind(MeetupDAO.class).to(MeetupDAOImpl.class);

	bind(JedisPool.class).toInstance(
			new JedisPool(
					new JedisPoolConfig(), 
					 ConfigurationManager.getConfigInstance().getString("redis_ip","localhost")));
	
}
 
開發者ID:diegopacheco,項目名稱:Building_Effective_Microservices,代碼行數:17,代碼來源:GuiceBindings.java

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

示例4: populateHeader

import com.netflix.config.ConfigurationManager; //導入依賴的package包/類
private void populateHeader(Map<String, Object> model) {
	model.put("currentTime", StatusResource.getCurrentTimeAsString());
	model.put("upTime", StatusInfo.getUpTime());
	model.put("environment", ConfigurationManager.getDeploymentContext()
			.getDeploymentEnvironment());
	model.put("datacenter", ConfigurationManager.getDeploymentContext()
			.getDeploymentDatacenter());
	PeerAwareInstanceRegistry registry = getRegistry();
	model.put("registry", registry);
	model.put("isBelowRenewThresold", registry.isBelowRenewThresold() == 1);
	DataCenterInfo info = applicationInfoManager.getInfo().getDataCenterInfo();
	if (info.getName() == DataCenterInfo.Name.Amazon) {
		AmazonInfo amazonInfo = (AmazonInfo) info;
		model.put("amazonInfo", amazonInfo);
		model.put("amiId", amazonInfo.get(AmazonInfo.MetaDataKey.amiId));
		model.put("availabilityZone",
				amazonInfo.get(AmazonInfo.MetaDataKey.availabilityZone));
		model.put("instanceId", amazonInfo.get(AmazonInfo.MetaDataKey.instanceId));
	}
}
 
開發者ID:dyc87112,項目名稱:didi-eureka-server,代碼行數:21,代碼來源:EurekaController.java

示例5: testSecretIsDecrypted

import com.netflix.config.ConfigurationManager; //導入依賴的package包/類
@Test
public void testSecretIsDecrypted() {
    String secretValue = "test_secret_value";
    long version = 1;
    RawSecretEntry rawSecret = new RawSecretEntry(secretIdentifier,
            version,
            State.ENABLED,
            Optional.empty(),
            Optional.empty(),
            new SecretValue(secretValue, SecretType.OPAQUE).asByteArray());
    SecretEntry secretEntry = new SecretEntryMock.Builder().secretValue(secretValue).build();
    when(mockSecretsGroup.decrypt(rawSecret, secretIdentifier, version)).thenReturn(secretEntry);

    InMemoryPlaintextSecret p = new InMemoryPlaintextSecret(mockSecretsGroup, secretIdentifier);
    ConfigurationManager.getConfigInstance().setProperty(secretIdentifier.name, rawSecret.toJsonBlob());
    assertEquals(p.getValue(), secretValue);
}
 
開發者ID:schibsted,項目名稱:strongbox,代碼行數:18,代碼來源:InMemoryPlaintextSecretTest.java

示例6: testSecretIsDecryptedBeforeBeingPassedToDecoder

import com.netflix.config.ConfigurationManager; //導入依賴的package包/類
@Test
public void testSecretIsDecryptedBeforeBeingPassedToDecoder() {
    String secretValue = "test_secret_value";
    long version = 1;
    RawSecretEntry rawSecret = new RawSecretEntry(secretIdentifier,
            version,
            State.ENABLED,
            Optional.empty(),
            Optional.empty(),
            new SecretValue(secretValue, SecretType.OPAQUE).asByteArray());
    SecretEntry secretEntry = new SecretEntryMock.Builder().secretValue(secretValue).build();
    when(mockSecretsGroup.decrypt(rawSecret, secretIdentifier, version)).thenReturn(secretEntry);

    InMemoryPlaintextSecretDerived<Integer> p = new InMemoryPlaintextSecretDerived<>(mockSecretsGroup,
            secretIdentifier,
            String::length);
    ConfigurationManager.getConfigInstance().setProperty(secretIdentifier.name, rawSecret.toJsonBlob());
    assertEquals(p.getValue().intValue(), secretValue.length());
}
 
開發者ID:schibsted,項目名稱:strongbox,代碼行數:20,代碼來源:InMemoryPlaintextSecretDerivedTest.java

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

示例8: createCluster

import com.netflix.config.ConfigurationManager; //導入依賴的package包/類
public static DynoJedisClient createCluster(String clusterName,final List<DynomiteNodeInfo> nodes){
	
	ConfigurationManager.getConfigInstance().setProperty("dyno." + clusterName + ".retryPolicy","RetryNTimes:1:true");
	
	DynoJedisClient dynoClient = new DynoJedisClient.Builder().withApplicationName(clusterName)
	.withDynomiteClusterName(clusterName)
	.withCPConfig(
			new ArchaiusConnectionPoolConfiguration(clusterName)
				.withTokenSupplier(TokenMapSupplierFactory.build(nodes))
				.setMaxConnsPerHost(1)
			    .setRetryPolicyFactory(new RetryNTimes.RetryFactory(1,true))
	)
	.withHostSupplier(HostSupplierFactory.build(nodes))
	.build();
	
	return dynoClient;
}
 
開發者ID:diegopacheco,項目名稱:dynomite-cluster-checker,代碼行數:18,代碼來源:DCCConnectionManager.java

示例9: testDnsResolution

import com.netflix.config.ConfigurationManager; //導入依賴的package包/類
@Test
public void testDnsResolution() throws Exception {
    CharMatcher oneThroughFive = CharMatcher.anyOf("12345");
    ConfigurationManager.getConfigInstance().setProperty(TURBINE_AGGREGATOR_CLUSTER_CONFIG, "test");
    ConfigurationManager.getConfigInstance().setProperty("turbine.ConfigPropertyBasedDiscovery.test.instances", "comment-api%d.prod,like-api%03d");
    DnsInstanceDiscovery instanceDiscovery = spy(new DnsInstanceDiscovery() {
        @Override
        protected InetAddress resolveHost(String host) {
            if(oneThroughFive.matchesAnyOf(host)) {
                try {
                    return InetAddress.getByName("127.0.0.1");
                } catch (UnknownHostException e) {
                }
            }
            return null;
        }
    });

    List<Instance> instances = (List<Instance>) instanceDiscovery.getInstanceList();
    assertEquals(10, instances.size());
    assertEquals("comment-api1.prod", instances.get(0).getHostname());
    assertEquals("comment-api5.prod", instances.get(4).getHostname());
    assertEquals("like-api001", instances.get(5).getHostname());
    assertEquals("like-api005", instances.get(9).getHostname());
}
 
開發者ID:bbcom,項目名稱:turbine-plugins,代碼行數:26,代碼來源:DnsInstanceDiscoveryTest.java

示例10: createConfig

import com.netflix.config.ConfigurationManager; //導入依賴的package包/類
@Override
public Config createConfig(String name) {
  if (CONFIG != null) {
    return CONFIG;
  }
  synchronized (ArchaiusBaseFactory.class) {
    if (CONFIG == null) {
      AbstractConfiguration configuration = getConfiguration();
      ConfigurationManager.install(configuration);
      CONFIG = new ArchaiusWrapper(configuration);
      ConfigFactory.setContext(CONFIG);
      configuration.addConfigurationListener(event -> {
        if (!event.isBeforeUpdate()) {
          CONFIG.fire(event.getPropertyName());
        }
      });
    }
  }
  return CONFIG;
}
 
開發者ID:irenical,項目名稱:jindy,代碼行數:21,代碼來源:ArchaiusBaseFactory.java

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

示例12: testReadAll

import com.netflix.config.ConfigurationManager; //導入依賴的package包/類
@Test
public void testReadAll() {
    Properties properties = new Properties();
    properties.put("id1.sometype.a", "_a1");
    properties.put("id2.sometype", "{\"type\":\"_type\",\"a\":\"_a2\"}");
    properties.put("id3.sometype", "{\"type\":\"_type\",\"a\":\"_a3\"}");
    
    System.out.println(properties);
    properties.put("id1.someothertype.a", "_a");
    
    ConfigurationManager.loadProperties(properties);
    
    ArchaiusTypeConfigurationResolver resolver = new ArchaiusTypeConfigurationResolver(null);
    Map<String, ConfigurationNode> someTypeConfigs = resolver.getConfigurationFactory("sometype").getAllConfigurations();
    Assert.assertEquals(3, someTypeConfigs.keySet().size());
    Assert.assertEquals("_a1", someTypeConfigs.get("id1").getChild("a").getValue(String.class));
    Assert.assertEquals("_a2", someTypeConfigs.get("id2").getChild("a").getValue(String.class));
    Assert.assertEquals("_a3", someTypeConfigs.get("id3").getChild("a").getValue(String.class));
    
    Map<String, ConfigurationNode> someOtherTypeConfigs = resolver.getConfigurationFactory("someothertype").getAllConfigurations();
    Assert.assertEquals(1, someOtherTypeConfigs.keySet().size());
    Assert.assertEquals("_a", someOtherTypeConfigs.get("id1").getChild("a").getValue(String.class));
}
 
開發者ID:Netflix,項目名稱:fabricator,代碼行數:24,代碼來源:ArchaiusTypeConfigurationResolverTest.java

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

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

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


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