• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ConfigRetriever类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: main

import io.vertx.config.ConfigRetriever; //导入依赖的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


示例2: start

import io.vertx.config.ConfigRetriever; //导入依赖的package包/类
@Override
public void start(Future<Void> fut) {
    ConfigRetriever retriever = ConfigRetriever.create(vertx);
    retriever.getConfig(
        config -> {
            if (config.failed()) {
                fut.fail(config.cause());
            } else {
                vertx
                    .createHttpServer()
                    .requestHandler(r ->
                        r.response().end("<h1>Hello from my first Vert.x application</h1>"))
                    .listen(config.result().getInteger("HTTP_PORT", 8080), result -> {
                        if (result.succeeded()) {
                            fut.complete();
                        } else {
                            fut.fail(result.cause());
                        }
                    });
            }
        }
    );
}
 
开发者ID:cescoffier,项目名称:introduction-to-vert.x,代码行数:24,代码来源:MyFirstVerticle.java


示例3: retrieveConfig

import io.vertx.config.ConfigRetriever; //导入依赖的package包/类
private Future<Void> retrieveConfig() {
    Future<Void> future = Future.future();
    ConfigRetrieverOptions options = new ConfigRetrieverOptions();
    this.addHoconConfigStoreOptions(options);
    this.addDeploymentConfigStoreOptions(options);
    ConfigRetriever retriever = ConfigRetriever.create(vertx, options);
    retriever.getConfig(ar -> {
        if (ar.succeeded()) {
            this.configuration = ar.result();
            LOG.debug("Retrieved configuration: {}", this.configuration.encodePrettily());
            future.complete();
        } else {
            LOG.error("Unable to retrieve configuration", ar.cause());
            future.fail(ar.cause());
        }
    });
    return future;
}
 
开发者ID:Deutsche-Boerse-Risk,项目名称:DAVe,代码行数:19,代码来源:MainVerticle.java


示例4: testWithFooDev

import io.vertx.config.ConfigRetriever; //导入依赖的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


示例5: testWithUnknownConfiguration

import io.vertx.config.ConfigRetriever; //导入依赖的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


示例6: testWithErrorConfiguration

import io.vertx.config.ConfigRetriever; //导入依赖的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


示例7: testWithWrongServerConfiguration

import io.vertx.config.ConfigRetriever; //导入依赖的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


示例8: testOnMasterWithASingleFile

import io.vertx.config.ConfigRetriever; //导入依赖的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


示例9: testOnDevWithATwoFiles

import io.vertx.config.ConfigRetriever; //导入依赖的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


示例10: testWithEmptyRepository

import io.vertx.config.ConfigRetriever; //导入依赖的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


示例11: testWithACustomBranch

import io.vertx.config.ConfigRetriever; //导入依赖的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


示例12: testWithNonExistingPath

import io.vertx.config.ConfigRetriever; //导入依赖的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


示例13: testWith2FileSetsAndNoIntersection

import io.vertx.config.ConfigRetriever; //导入依赖的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


示例14: testWith2FileSetsAndWithIntersection

import io.vertx.config.ConfigRetriever; //导入依赖的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


示例15: testWith2FileSetsAndWithIntersectionReversed

import io.vertx.config.ConfigRetriever; //导入依赖的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


示例16: testWithAFileSetMatching2FilesWithConflict

import io.vertx.config.ConfigRetriever; //导入依赖的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


示例17: testWithAFileSetMatching2FilesOneNotBeingAJsonFile

import io.vertx.config.ConfigRetriever; //导入依赖的package包/类
@Test
public void testWithAFileSetMatching2FilesOneNotBeingAJsonFile(TestContext tc) throws GitAPIException, IOException {
  Async async = tc.async();
  add(git, root, new File("src/test/resources/files/a-bad.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"))
      ))));

  retriever.getConfig(ar -> {
    assertThat(ar.failed());
    assertThat(ar.cause()).isInstanceOf(DecodeException.class);
    async.complete();
  });

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


示例18: testEmptyYaml

import io.vertx.config.ConfigRetriever; //导入依赖的package包/类
@Test
public void testEmptyYaml(TestContext tc) {
  Async async = tc.async();
  retriever = ConfigRetriever.create(vertx,
      new ConfigRetrieverOptions().addStore(
          new ConfigStoreOptions()
              .setType("file")
              .setFormat("yaml")
              .setConfig(new JsonObject().put("path", "src/test/resources/empty.yaml"))));

  retriever.getConfig(ar -> {
    expectSuccess(ar);
    assertThat(ar.result()).isNotNull();
    assertThat(ar.result()).isEmpty();
    async.complete();
  });
}
 
开发者ID:vert-x3,项目名称:vertx-config,代码行数:18,代码来源:YamlProcessorTest.java


示例19: testWithTextFile

import io.vertx.config.ConfigRetriever; //导入依赖的package包/类
@Test
public void testWithTextFile(TestContext tc) {
  Async async = tc.async();
  retriever = ConfigRetriever.create(vertx,
      new ConfigRetrieverOptions().addStore(
          new ConfigStoreOptions()
              .setType("file")
              .setFormat("yaml")
              .setConfig(new JsonObject().put("path", "src/test/resources/some-text.txt"))));

  retriever.getConfig(ar -> {
    assertThat(ar.failed()).isTrue();
    assertThat(ar.cause()).isNotNull().isInstanceOf(DecodeException.class);
    async.complete();
  });
}
 
开发者ID:vert-x3,项目名称:vertx-config,代码行数:17,代码来源:YamlProcessorTest.java


示例20: testWithMissingFile

import io.vertx.config.ConfigRetriever; //导入依赖的package包/类
@Test
public void testWithMissingFile(TestContext tc) {
  Async async = tc.async();
  retriever = ConfigRetriever.create(vertx,
      new ConfigRetrieverOptions().addStore(
          new ConfigStoreOptions()
              .setType("file")
              .setFormat("yaml")
              .setConfig(new JsonObject().put("path", "src/test/resources/some-missing-file.yaml"))));

  retriever.getConfig(ar -> {
    assertThat(ar.failed()).isTrue();
    assertThat(ar.cause()).isNotNull().isInstanceOf(FileSystemException.class);
    async.complete();
  });
}
 
开发者ID:vert-x3,项目名称:vertx-config,代码行数:17,代码来源:YamlProcessorTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ValidityReport类代码示例发布时间:2022-05-22
下一篇:
Java TextSize类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap