Example usage for io.vertx.core.json JsonObject JsonObject

List of usage examples for io.vertx.core.json JsonObject JsonObject

Introduction

In this page you can find the example usage for io.vertx.core.json JsonObject JsonObject.

Prototype

public JsonObject() 

Source Link

Document

Create a new, empty instance

Usage

From source file:examples.AuthShiroExamples.java

License:Open Source License

public void example3(Vertx vertx) {

    JsonObject config = new JsonObject().put("properties_path", "classpath:test-auth.properties");

    AuthProvider provider = ShiroAuth.create(vertx, ShiroAuthRealmType.PROPERTIES, config);

}

From source file:examples.AuthShiroExamples.java

License:Open Source License

public void example4(AuthProvider authProvider) {

    JsonObject authInfo = new JsonObject().put("username", "tim").put("password", "sausages");

    authProvider.authenticate(authInfo, res -> {
        if (res.succeeded()) {
            User user = res.result();/*from w  ww .ja  va  2 s .  co  m*/
        } else {
            // Failed!
        }
    });
}

From source file:examples.client.Examples.java

License:Open Source License

public void example0_1_1(Vertx vertx, JsonObject config) {
    JsonObject save = new JsonObject().put("collection", "books").put("document",
            new JsonObject().put("title", "The Hobbit"));

    vertx.eventBus().send("vertx.io.vertx.ext.marklogic", save,
            new DeliveryOptions().addHeader("action", "save"), saveResult -> {
                if (saveResult.succeeded()) {
                    String id = (String) saveResult.result().body();
                    System.out.println("Saved book with id " + id);
                } else {
                    saveResult.cause().printStackTrace();
                }/*ww w . ja  va 2 s.c  o m*/
            });
}

From source file:examples.ConfigConsulExamples.java

License:Apache License

public void example1(Vertx vertx) {
    ConfigStoreOptions store = new ConfigStoreOptions().setType("consul")
            .setConfig(new JsonObject().put("host", "localhost").put("port", 8500).put("prefix", "foo"));

    ConfigRetriever retriever = ConfigRetriever.create(vertx, new ConfigRetrieverOptions().addStore(store));
}

From source file:examples.ConfigExamples.java

License:Apache License

public void example2(Vertx vertx) {
    ConfigStoreOptions httpStore = new ConfigStoreOptions().setType("http")
            .setConfig(new JsonObject().put("host", "localhost").put("port", 8080).put("path", "/conf"));

    ConfigStoreOptions fileStore = new ConfigStoreOptions().setType("file")
            .setConfig(new JsonObject().put("path", "my-config.json"));

    ConfigStoreOptions sysPropsStore = new ConfigStoreOptions().setType("sys");

    ConfigRetrieverOptions options = new ConfigRetrieverOptions().addStore(httpStore).addStore(fileStore)
            .addStore(sysPropsStore);/*from ww w  .  ja  v  a 2 s.  c  o  m*/

    ConfigRetriever retriever = ConfigRetriever.create(vertx, options);
}

From source file:examples.ConfigExamples.java

License:Apache License

public void example2_optional(Vertx vertx) {
    ConfigStoreOptions fileStore = new ConfigStoreOptions().setType("file").setOptional(true)
            .setConfig(new JsonObject().put("path", "my-config.json"));
    ConfigStoreOptions sysPropsStore = new ConfigStoreOptions().setType("sys");

    ConfigRetrieverOptions options = new ConfigRetrieverOptions().addStore(fileStore).addStore(sysPropsStore);

    ConfigRetriever retriever = ConfigRetriever.create(vertx, options);
}

From source file:examples.ConfigExamples.java

License:Apache License

public void file() {
    ConfigStoreOptions file = new ConfigStoreOptions().setType("file").setFormat("properties")
            .setConfig(new JsonObject().put("path", "path-to-file.properties"));
}

From source file:examples.ConfigExamples.java

License:Apache License

public void json() {
    ConfigStoreOptions json = new ConfigStoreOptions().setType("json")
            .setConfig(new JsonObject().put("key", "value"));
}

From source file:examples.ConfigExamples.java

License:Apache License

public void sys() {
    ConfigStoreOptions json = new ConfigStoreOptions().setType("sys")
            .setConfig(new JsonObject().put("cache", "false"));
}

From source file:examples.ConfigExamples.java

License:Apache License

public void env2() {
    ConfigStoreOptions json = new ConfigStoreOptions().setType("env")
            .setConfig(new JsonObject().put("raw-data", true));
}