本文整理汇总了Java中io.vertx.config.ConfigRetrieverOptions类的典型用法代码示例。如果您正苦于以下问题:Java ConfigRetrieverOptions类的具体用法?Java ConfigRetrieverOptions怎么用?Java ConfigRetrieverOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConfigRetrieverOptions类属于io.vertx.config包,在下文中一共展示了ConfigRetrieverOptions类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: loadConfig
import io.vertx.config.ConfigRetrieverOptions; //导入依赖的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.ConfigRetrieverOptions; //导入依赖的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: retrieveConfig
import io.vertx.config.ConfigRetrieverOptions; //导入依赖的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.ConfigRetrieverOptions; //导入依赖的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.ConfigRetrieverOptions; //导入依赖的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.ConfigRetrieverOptions; //导入依赖的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.ConfigRetrieverOptions; //导入依赖的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.ConfigRetrieverOptions; //导入依赖的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.ConfigRetrieverOptions; //导入依赖的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.ConfigRetrieverOptions; //导入依赖的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.ConfigRetrieverOptions; //导入依赖的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.ConfigRetrieverOptions; //导入依赖的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.ConfigRetrieverOptions; //导入依赖的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.ConfigRetrieverOptions; //导入依赖的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.ConfigRetrieverOptions; //导入依赖的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.ConfigRetrieverOptions; //导入依赖的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.ConfigRetrieverOptions; //导入依赖的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.ConfigRetrieverOptions; //导入依赖的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.ConfigRetrieverOptions; //导入依赖的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.ConfigRetrieverOptions; //导入依赖的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.ConfigRetrieverOptions类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论