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:com.dinstone.example.HelloResource.java

License:Apache License

@Get("/g/:name")
public void hello(@Context RoutingContext ctx) {
    String message = "hello";
    String name = ctx.request().getParam("name");
    if (name != null) {
        message += " " + name;
    }//w w w .  j a  v  a  2  s.c  o m

    JsonObject json = new JsonObject().put("message", message);
    ctx.response().end(json.encode());
}

From source file:com.dinstone.vertx.web.resource.HelloResourceSubclass.java

License:Apache License

public void hello(RoutingContext ctx) {
    String message = "hello";
    String name = ctx.request().getParam("name");
    if (name != null) {
        message += " " + name;
    }//w  w  w.j  a va 2s.  co m

    JsonObject json = new JsonObject().put("message", message);
    ctx.response().end(json.encode());
}

From source file:com.edgar.vertx.service.discovery.eventbus.MyServiceVertxEBProxy.java

License:Apache License

public void say() {
    if (closed) {
        throw new IllegalStateException("Proxy is closed");
    }//from ww w .ja va 2 s  .  co m
    JsonObject _json = new JsonObject();
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "say");
    _vertx.eventBus().send(_address, _json, _deliveryOptions);
}

From source file:com.edgar.vertx.serviceproxy.provider.ProcessorServiceVertxEBProxy.java

License:Apache License

public void process(JsonObject document, Handler<AsyncResult<JsonObject>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return;/*from w ww  .j a va 2s .  c  o m*/
    }
    JsonObject _json = new JsonObject();
    _json.put("document", document);
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "process");
    _vertx.eventBus().<JsonObject>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            resultHandler.handle(Future.failedFuture(res.cause()));
        } else {
            resultHandler.handle(Future.succeededFuture(res.result().body()));
        }
    });
}

From source file:com.emikra.vertx.oak.OakServiceVertxEBProxy.java

License:Apache License

public void createNode(CreateNodeOptions options, Handler<AsyncResult<JsonObject>> handler) {
    if (closed) {
        handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return;/*ww w .  ja  va 2  s  . co m*/
    }
    JsonObject _json = new JsonObject();
    _json.put("options", options == null ? null : options.toJson());
    DeliveryOptions _deliveryOptions = new DeliveryOptions();
    _deliveryOptions.addHeader("action", "createNode");
    _vertx.eventBus().<JsonObject>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            handler.handle(Future.failedFuture(res.cause()));
        } else {
            handler.handle(Future.succeededFuture(res.result().body()));
        }
    });
}

From source file:com.emikra.vertx.orientdb.OrientDBServiceVertxEBProxy.java

License:Apache License

public void createDatabase(CreateDatabaseParams options, Handler<AsyncResult<JsonObject>> handler) {
    if (closed) {
        handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return;/*from w w w . j a  va  2s . c  o  m*/
    }
    JsonObject _json = new JsonObject();
    _json.put("options", options == null ? null : options.toJson());
    DeliveryOptions _deliveryOptions = new DeliveryOptions();
    _deliveryOptions.addHeader("action", "createDatabase");
    _vertx.eventBus().<JsonObject>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            handler.handle(Future.failedFuture(res.cause()));
        } else {
            handler.handle(Future.succeededFuture(res.result().body()));
        }
    });
}

From source file:com.emikra.vertx.orientdb.OrientDBServiceVertxEBProxy.java

License:Apache License

public void createDocument(JsonObject document, Handler<AsyncResult<JsonObject>> handler) {
    if (closed) {
        handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return;/* w  w  w .j  a  v a2 s.  co m*/
    }
    JsonObject _json = new JsonObject();
    _json.put("document", document);
    DeliveryOptions _deliveryOptions = new DeliveryOptions();
    _deliveryOptions.addHeader("action", "createDocument");
    _vertx.eventBus().<JsonObject>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            handler.handle(Future.failedFuture(res.cause()));
        } else {
            handler.handle(Future.succeededFuture(res.result().body()));
        }
    });
}

From source file:com.emikra.vertx.orientdb.OrientDBServiceVertxEBProxy.java

License:Apache License

public void createVertex(JsonObject vertexDoc, Handler<AsyncResult<JsonObject>> handler) {
    if (closed) {
        handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return;/*from  ww w.  j a v a 2 s  .  c  o  m*/
    }
    JsonObject _json = new JsonObject();
    _json.put("vertexDoc", vertexDoc);
    DeliveryOptions _deliveryOptions = new DeliveryOptions();
    _deliveryOptions.addHeader("action", "createVertex");
    _vertx.eventBus().<JsonObject>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            handler.handle(Future.failedFuture(res.cause()));
        } else {
            handler.handle(Future.succeededFuture(res.result().body()));
        }
    });
}

From source file:com.emikra.vertx.orientdb.OrientDBServiceVertxEBProxy.java

License:Apache License

public void createEdge(JsonObject edgeDoc, Handler<AsyncResult<JsonObject>> handler) {
    if (closed) {
        handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return;//from   w ww  . j  ava2 s . c o m
    }
    JsonObject _json = new JsonObject();
    _json.put("edgeDoc", edgeDoc);
    DeliveryOptions _deliveryOptions = new DeliveryOptions();
    _deliveryOptions.addHeader("action", "createEdge");
    _vertx.eventBus().<JsonObject>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            handler.handle(Future.failedFuture(res.cause()));
        } else {
            handler.handle(Future.succeededFuture(res.result().body()));
        }
    });
}

From source file:com.emikra.vertx.orientdb.OrientDBServiceVertxEBProxy.java

License:Apache License

public void createClass(CreateClassParams params, Handler<AsyncResult<JsonObject>> handler) {
    if (closed) {
        handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return;/*  w  w w  . jav  a 2s  .co  m*/
    }
    JsonObject _json = new JsonObject();
    _json.put("params", params == null ? null : params.toJson());
    DeliveryOptions _deliveryOptions = new DeliveryOptions();
    _deliveryOptions.addHeader("action", "createClass");
    _vertx.eventBus().<JsonObject>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            handler.handle(Future.failedFuture(res.cause()));
        } else {
            handler.handle(Future.succeededFuture(res.result().body()));
        }
    });
}