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.glt.rest.client.RestServiceVertxEBProxy.java

License:Apache License

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

From source file:com.glt.rest.client.RestServiceVertxEBProxy.java

License:Apache License

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

From source file:com.glt.rest.client.RestServiceVertxEBProxy.java

License:Apache License

public void request(JsonObject command, Handler<AsyncResult<String>> asyncHandler) {
    if (closed) {
        asyncHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return;//w  w w .  j av  a2s.  com
    }
    JsonObject _json = new JsonObject();
    _json.put("command", command);
    DeliveryOptions _deliveryOptions = new DeliveryOptions();
    _deliveryOptions.addHeader("action", "request");
    _vertx.eventBus().<String>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            asyncHandler.handle(Future.failedFuture(res.cause()));
        } else {
            asyncHandler.handle(Future.succeededFuture(res.result().body()));
        }
    });
}

From source file:com.groupon.vertx.memcache.codec.DeleteCommandResponseCodec.java

License:Apache License

@Override
public void encodeToWire(Buffer buffer, DeleteCommandResponse commandResponse) {
    JsonObject json = new JsonObject();
    json.put("status", commandResponse.getStatus());
    json.put("message", commandResponse.getMessage());
    json.put("data", commandResponse.getData());

    CodecManager.JSON_OBJECT_MESSAGE_CODEC.encodeToWire(buffer, json);
}

From source file:com.groupon.vertx.memcache.codec.MemcacheCommandCodec.java

License:Apache License

@Override
public void encodeToWire(Buffer buffer, MemcacheCommand memcacheCommand) {
    JsonObject json = new JsonObject();
    json.put("key", memcacheCommand.getKey());
    json.put("value", memcacheCommand.getValue());
    json.put("expires", memcacheCommand.getExpires());
    json.put("type", memcacheCommand.getType());

    CodecManager.JSON_OBJECT_MESSAGE_CODEC.encodeToWire(buffer, json);
}

From source file:com.groupon.vertx.memcache.codec.MemcacheCommandResponseCodec.java

License:Apache License

@Override
public void encodeToWire(Buffer buffer, MemcacheCommandResponse commandResponse) {
    JsonObject json = new JsonObject();
    json.put("status", commandResponse.getStatus());
    json.put("message", commandResponse.getMessage());

    CodecManager.JSON_OBJECT_MESSAGE_CODEC.encodeToWire(buffer, json);
}

From source file:com.groupon.vertx.memcache.codec.ModifyCommandResponseCodec.java

License:Apache License

@Override
public void encodeToWire(Buffer buffer, ModifyCommandResponse commandResponse) {
    JsonObject json = new JsonObject();
    json.put("status", commandResponse.getStatus());
    json.put("message", commandResponse.getMessage());
    json.put("data", commandResponse.getData());

    CodecManager.JSON_OBJECT_MESSAGE_CODEC.encodeToWire(buffer, json);
}

From source file:com.groupon.vertx.memcache.codec.RetrieveCommandResponseCodec.java

License:Apache License

@Override
public void encodeToWire(Buffer buffer, RetrieveCommandResponse commandResponse) {
    JsonObject json = new JsonObject();
    json.put("status", commandResponse.getStatus());
    json.put("message", commandResponse.getMessage());
    json.put("data", commandResponse.getData());

    CodecManager.JSON_OBJECT_MESSAGE_CODEC.encodeToWire(buffer, json);
}

From source file:com.groupon.vertx.memcache.codec.StoreCommandResponseCodec.java

License:Apache License

@Override
public void encodeToWire(Buffer buffer, StoreCommandResponse commandResponse) {
    JsonObject json = new JsonObject();
    json.put("status", commandResponse.getStatus());
    json.put("message", commandResponse.getMessage());
    json.put("data", commandResponse.getData());

    CodecManager.JSON_OBJECT_MESSAGE_CODEC.encodeToWire(buffer, json);
}

From source file:com.groupon.vertx.memcache.codec.TouchCommandResponseCodec.java

License:Apache License

@Override
public void encodeToWire(Buffer buffer, TouchCommandResponse commandResponse) {
    JsonObject json = new JsonObject();
    json.put("status", commandResponse.getStatus());
    json.put("message", commandResponse.getMessage());
    json.put("data", commandResponse.getData());

    CodecManager.JSON_OBJECT_MESSAGE_CODEC.encodeToWire(buffer, json);
}