当前位置: 首页>>代码示例>>Java>>正文


Java ConfigStoreOptions类代码示例

本文整理汇总了Java中io.vertx.config.ConfigStoreOptions的典型用法代码示例。如果您正苦于以下问题:Java ConfigStoreOptions类的具体用法?Java ConfigStoreOptions怎么用?Java ConfigStoreOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ConfigStoreOptions类属于io.vertx.config包,在下文中一共展示了ConfigStoreOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loadConfig

import io.vertx.config.ConfigStoreOptions; //导入依赖的package包/类
private Single<JsonObject> loadConfig(JsonObject config) {
	if(config != null) {
		AppGlobals.get().setConfig(config);
		return Single.just(config);
	}
	
	String path = "conf/config.json";
	return vertx.fileSystem().rxExists(path)
			.flatMap(exists -> {
				if(exists) {
					ConfigStoreOptions fileStore = new ConfigStoreOptions()
							.setType("file")
							.setConfig(new JsonObject().put("path", path));

					ConfigRetrieverOptions configRetrieverOptions = new ConfigRetrieverOptions()
							.addStore(fileStore);

					ConfigRetriever retriever = ConfigRetriever.create(vertx, configRetrieverOptions);
					return retriever.rxGetConfig().map(loadedConfig -> {
						AppGlobals.get().setConfig(loadedConfig);
						return loadedConfig;
					});
				} else {
					// empty config
					JsonObject emptyConfig = new JsonObject();
					AppGlobals.get().setConfig(emptyConfig);
					return Single.just(emptyConfig);
				}
			});
}
 
开发者ID:FroMage,项目名称:redpipe,代码行数:31,代码来源:Server.java

示例2: main

import io.vertx.config.ConfigStoreOptions; //导入依赖的package包/类
/**
 * @param args
 */
public static void main(String[] args) {
	Vertx vertx = Vertx.vertx();
	ConfigStoreOptions env = new ConfigStoreOptions()
			.setType("file")
			.setFormat("json")
			.setConfig(new JsonObject().put("path", "sampleconfig.json"));
	ConfigRetrieverOptions options = new ConfigRetrieverOptions().addStore(env);
	ConfigRetriever retriever = ConfigRetriever.create(vertx, options);
	
	retriever.getConfig(ar -> {
		JsonObject rc = ar.result();
		System.out.println(rc.encodePrettily());
		AppConfig a = rc.mapTo(AppConfig.class);
		System.out.println(a);
		System.out.println(a.port);
		vertx.close();
	});

}
 
开发者ID:Stwissel,项目名称:vertx-sfdc-platformevents,代码行数:23,代码来源:TestConfig.java

示例3: testWithFooDev

import io.vertx.config.ConfigStoreOptions; //导入依赖的package包/类
@Test
public void testWithFooDev(TestContext tc) {
  Async async = tc.async();
  retriever = ConfigRetriever.create(vertx,
      new ConfigRetrieverOptions().addStore(
          new ConfigStoreOptions()
              .setType("spring-config-server")
              .setConfig(new JsonObject().put("url", "http://localhost:8888/foo/development"))));


  retriever.getConfig(json -> {
    assertThat(json.succeeded()).isTrue();
    JsonObject config = json.result();

    assertThat(config.getString("bar")).isEqualToIgnoringCase("spam");
    assertThat(config.getString("foo")).isEqualToIgnoringCase("baz");
    assertThat(config.getString("info.description")).isEqualToIgnoringCase("Spring Cloud Samples");

    async.complete();
  });

}
 
开发者ID:vert-x3,项目名称:vertx-config,代码行数:23,代码来源:SpringConfigServerStoreTest.java

示例4: testWithUnknownConfiguration

import io.vertx.config.ConfigStoreOptions; //导入依赖的package包/类
@Test
public void testWithUnknownConfiguration(TestContext tc) {
  Async async = tc.async();
  retriever = ConfigRetriever.create(vertx,
      new ConfigRetrieverOptions().addStore(
          new ConfigStoreOptions()
              .setType("spring-config-server")
              .setConfig(new JsonObject()
                  .put("url", "http://localhost:8888/missing/missing")
                  .put("timeout", 10000))));


  retriever.getConfig(json -> {
    assertThat(json.succeeded()).isTrue();
    JsonObject config = json.result();
    assertThat(config.getString("eureka.client.serviceUrl.defaultZone"))
        .isEqualToIgnoringCase("http://localhost:8761/eureka/");
    async.complete();
  });
}
 
开发者ID:vert-x3,项目名称:vertx-config,代码行数:21,代码来源:SpringConfigServerStoreTest.java

示例5: testWithErrorConfiguration

import io.vertx.config.ConfigStoreOptions; //导入依赖的package包/类
@Test
public void testWithErrorConfiguration(TestContext tc) {
  Async async = tc.async();
  retriever = ConfigRetriever.create(vertx,
      new ConfigRetrieverOptions().addStore(
          new ConfigStoreOptions()
              .setType("spring-config-server")
              .setConfig(new JsonObject()
                  .put("url", "http://localhost:8888/missing/missing/missing")
                  .put("timeout", 10000))));


  retriever.getConfig(json -> {
    assertThat(json.succeeded()).isFalse();
    async.complete();
  });
}
 
开发者ID:vert-x3,项目名称:vertx-config,代码行数:18,代码来源:SpringConfigServerStoreTest.java

示例6: testWithWrongServerConfiguration

import io.vertx.config.ConfigStoreOptions; //导入依赖的package包/类
@Test
public void testWithWrongServerConfiguration(TestContext tc) {
  Async async = tc.async();
  retriever = ConfigRetriever.create(vertx,
      new ConfigRetrieverOptions().addStore(
          new ConfigStoreOptions()
              .setType("spring-config-server")
              .setConfig(new JsonObject()
                  .put("url", "http://not-valid.de")
                  .put("timeout", 10000))));


  retriever.getConfig(json -> {
    assertThat(json.succeeded()).isFalse();
    async.complete();
  });
}
 
开发者ID:vert-x3,项目名称:vertx-config,代码行数:18,代码来源:SpringConfigServerStoreTest.java

示例7: testOnMasterWithASingleFile

import io.vertx.config.ConfigStoreOptions; //导入依赖的package包/类
@Test
public void testOnMasterWithASingleFile(TestContext tc) throws GitAPIException, IOException {
  Async async = tc.async();

  retriever = ConfigRetriever.create(vertx, new ConfigRetrieverOptions().addStore(new
      ConfigStoreOptions().setType("git").setConfig(new JsonObject()
      .put("url", REPO)
      .put("path", "target/junk/work")
      .put("filesets", new JsonArray().add(new JsonObject().put("pattern", "a.json"))))));

  retriever.getConfig(ar -> {
    assertThat(ar.succeeded()).isTrue();
    assertThat(ar.result()).isNotEmpty();
    JsonObject json = ar.result();
    assertThat(json).isNotNull();
    assertThat(json.getString("branch")).isEqualToIgnoringCase("master");
    assertThat(json.getString("name")).isEqualToIgnoringCase("A");
    async.complete();
  });

}
 
开发者ID:vert-x3,项目名称:vertx-config,代码行数:22,代码来源:GitConfigStoreWithGithubTest.java

示例8: testOnDevWithATwoFiles

import io.vertx.config.ConfigStoreOptions; //导入依赖的package包/类
@Test
public void testOnDevWithATwoFiles(TestContext tc) throws GitAPIException, IOException {
  Async async = tc.async();

  retriever = ConfigRetriever.create(vertx, new ConfigRetrieverOptions().addStore(new
      ConfigStoreOptions().setType("git").setConfig(new JsonObject()
      .put("url", REPO)
      .put("path", "target/junk/work")
      .put("branch", "dev")
      .put("filesets", new JsonArray().add(new JsonObject().put("pattern", "*.json"))))));

  retriever.getConfig(ar -> {
    assertThat(ar.succeeded()).isTrue();
    assertThat(ar.result()).isNotEmpty();
    JsonObject json = ar.result();
    assertThat(json).isNotNull();
    assertThat(json.getString("branch")).isEqualToIgnoringCase("dev");
    assertThat(json.getString("key")).isEqualToIgnoringCase("value");
    assertThat(json.getString("keyB")).isEqualToIgnoringCase("valueB");
    assertThat(json.getString("name")).isEqualToIgnoringCase("B");
    async.complete();
  });
}
 
开发者ID:vert-x3,项目名称:vertx-config,代码行数:24,代码来源:GitConfigStoreWithGithubTest.java

示例9: testWithEmptyRepository

import io.vertx.config.ConfigStoreOptions; //导入依赖的package包/类
@Test
public void testWithEmptyRepository(TestContext tc) throws GitAPIException, IOException {
  Async async = tc.async();
  add(git, root, new File("src/test/resources/files/some-text.txt"), null);
  push(git);

  retriever = ConfigRetriever.create(vertx, new ConfigRetrieverOptions().addStore(new
      ConfigStoreOptions().setType("git").setConfig(new JsonObject()
      .put("url", bareRoot.getAbsolutePath())
      .put("path", "target/junk/work")
      .put("filesets", new JsonArray().add(new JsonObject().put("pattern", "**/*.json"))))));

  retriever.getConfig(ar -> {
    assertThat(ar.succeeded()).isTrue();
    assertThat(ar.result()).isEmpty();
    async.complete();
  });

}
 
开发者ID:vert-x3,项目名称:vertx-config,代码行数:20,代码来源:GitConfigStoreTest.java

示例10: testWithACustomBranch

import io.vertx.config.ConfigStoreOptions; //导入依赖的package包/类
@Test
public void testWithACustomBranch(TestContext tc) throws GitAPIException, IOException {
  Async async = tc.async();
  add(git, root, new File("src/test/resources/files/a.json"), null);
  branch = "dev";
  add(git, root, new File("src/test/resources/files/regular.json"), null);
  push(git);

  retriever = ConfigRetriever.create(vertx, new ConfigRetrieverOptions().addStore(new
      ConfigStoreOptions().setType("git").setConfig(new JsonObject()
      .put("url", bareRoot.getAbsolutePath())
      .put("path", "target/junk/work")
      .put("branch", branch)
      .put("filesets", new JsonArray().add(new JsonObject().put("pattern", "*.json"))))));

  retriever.getConfig(ar -> {
    assertThat(ar.succeeded()).isTrue();
    assertThat(ar.result()).isNotEmpty();
    JsonObject json = ar.result();
    assertThat(json).isNotNull();
    assertThat(json.getString("key")).isEqualTo("value");
    async.complete();
  });

}
 
开发者ID:vert-x3,项目名称:vertx-config,代码行数:26,代码来源:GitConfigStoreTest.java

示例11: testWithNonExistingPath

import io.vertx.config.ConfigStoreOptions; //导入依赖的package包/类
@Test
public void testWithNonExistingPath(TestContext tc) throws IOException, GitAPIException {
  add(git, root, new File("src/test/resources/files/some-text.txt"), null);
  add(git, root, new File("src/test/resources/files/regular.json"), null);
  push(git);

  Async async = tc.async();

  retriever = ConfigRetriever.create(vertx, new ConfigRetrieverOptions().addStore(new
      ConfigStoreOptions().setType("git").setConfig(new JsonObject()
      .put("url", bareRoot.getAbsolutePath())
      .put("path", "target/junk/do-not-exist")
      .put("filesets", new JsonArray().add(new JsonObject().put("pattern", "*.json"))))));
  retriever.getConfig(ar -> {
    assertThat(ar.succeeded()).isTrue();
    assertThat(ar.result()).isNotEmpty();
    async.complete();
  });
}
 
开发者ID:vert-x3,项目名称:vertx-config,代码行数:20,代码来源:GitConfigStoreTest.java

示例12: testWith2FileSetsAndNoIntersection

import io.vertx.config.ConfigStoreOptions; //导入依赖的package包/类
@Test
public void testWith2FileSetsAndNoIntersection(TestContext tc) throws GitAPIException, IOException {
  Async async = tc.async();
  add(git, root, new File("src/test/resources/files/regular.json"), "file");
  add(git, root, new File("src/test/resources/files/a.json"), "dir");
  push(git);

  retriever = ConfigRetriever.create(vertx, new ConfigRetrieverOptions().addStore(new
      ConfigStoreOptions().setType("git").setConfig(new JsonObject()
      .put("url", bareRoot.getAbsolutePath())
      .put("path", "target/junk/work")
      .put("filesets", new JsonArray()
          .add(new JsonObject().put("pattern", "file/reg*.json"))
          .add(new JsonObject().put("pattern", "dir/a.*son"))
      ))));

  retriever.getConfig(ar -> {
    assertThat(ar.result().getString("key")).isEqualTo("value");
    assertThat(ar.result().getString("a.name")).isEqualTo("A");
    async.complete();
  });

}
 
开发者ID:vert-x3,项目名称:vertx-config,代码行数:24,代码来源:GitConfigStoreTest.java

示例13: testWith2FileSetsAndWithIntersection

import io.vertx.config.ConfigStoreOptions; //导入依赖的package包/类
@Test
public void testWith2FileSetsAndWithIntersection(TestContext tc) throws GitAPIException, IOException {
  Async async = tc.async();
  add(git, root, new File("src/test/resources/files/b.json"), "dir");
  add(git, root, new File("src/test/resources/files/a.json"), "dir");
  push(git);

  retriever = ConfigRetriever.create(vertx, new ConfigRetrieverOptions().addStore(new
      ConfigStoreOptions().setType("git").setConfig(new JsonObject()
      .put("url", bareRoot.getAbsolutePath())
      .put("path", "target/junk/work")
      .put("filesets", new JsonArray()
          .add(new JsonObject().put("pattern", "dir/b.json"))
          .add(new JsonObject().put("pattern", "dir/a.*son"))
      ))));

  retriever.getConfig(ar -> {
    assertThat(ar.result().getString("a.name")).isEqualTo("A");
    assertThat(ar.result().getString("b.name")).isEqualTo("B");
    assertThat(ar.result().getString("conflict")).isEqualTo("A");
    async.complete();
  });

}
 
开发者ID:vert-x3,项目名称:vertx-config,代码行数:25,代码来源:GitConfigStoreTest.java

示例14: testWith2FileSetsAndWithIntersectionReversed

import io.vertx.config.ConfigStoreOptions; //导入依赖的package包/类
@Test
public void testWith2FileSetsAndWithIntersectionReversed(TestContext tc) throws GitAPIException, IOException {
  Async async = tc.async();
  add(git, root, new File("src/test/resources/files/b.json"), "dir");
  add(git, root, new File("src/test/resources/files/a.json"), "dir");
  push(git);

  retriever = ConfigRetriever.create(vertx, new ConfigRetrieverOptions().addStore(new
      ConfigStoreOptions().setType("git").setConfig(new JsonObject()
      .put("url", bareRoot.getAbsolutePath())
      .put("path", "target/junk/work")
      .put("filesets", new JsonArray()
          .add(new JsonObject().put("pattern", "dir/a.*son"))
          .add(new JsonObject().put("pattern", "dir/b.json"))
      ))));

  retriever.getConfig(ar -> {
    assertThat(ar.result().getString("conflict")).isEqualTo("B");
    assertThat(ar.result().getString("a.name")).isEqualTo("A");
    assertThat(ar.result().getString("b.name")).isEqualTo("B");
    async.complete();
  });

}
 
开发者ID:vert-x3,项目名称:vertx-config,代码行数:25,代码来源:GitConfigStoreTest.java

示例15: testWithAFileSetMatching2FilesWithConflict

import io.vertx.config.ConfigStoreOptions; //导入依赖的package包/类
@Test
public void testWithAFileSetMatching2FilesWithConflict(TestContext tc) throws GitAPIException, IOException {
  Async async = tc.async();
  add(git, root, new File("src/test/resources/files/b.json"), "dir");
  add(git, root, new File("src/test/resources/files/a.json"), "dir");
  push(git);

  retriever = ConfigRetriever.create(vertx, new ConfigRetrieverOptions().addStore(new
      ConfigStoreOptions().setType("git").setConfig(new JsonObject()
      .put("url", bareRoot.getAbsolutePath())
      .put("path", "target/junk/work")
      .put("filesets", new JsonArray()
          .add(new JsonObject().put("pattern", "dir/?.*son"))
      ))));

  retriever.getConfig(ar -> {
    assertThat(ar.result().getString("b.name")).isEqualTo("B");
    assertThat(ar.result().getString("a.name")).isEqualTo("A");
    // Alphabetical order, so B is last.
    assertThat(ar.result().getString("conflict")).isEqualTo("B");
    async.complete();
  });

}
 
开发者ID:vert-x3,项目名称:vertx-config,代码行数:25,代码来源:GitConfigStoreTest.java


注:本文中的io.vertx.config.ConfigStoreOptions类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。