Example usage for io.vertx.core Future succeededFuture

List of usage examples for io.vertx.core Future succeededFuture

Introduction

In this page you can find the example usage for io.vertx.core Future succeededFuture.

Prototype

static <T> Future<T> succeededFuture(T result) 

Source Link

Document

Created a succeeded future with the specified result.

Usage

From source file:com.panjiesw.std.service.user.UserServiceVertxEBProxy.java

License:Apache License

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

From source file:com.panjiesw.std.service.user.UserServiceVertxEBProxy.java

License:Apache License

public UserService queryOne(String sql, Handler<AsyncResult<JsonObject>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }/*  ww  w.  j  av a 2s.c  o  m*/
    JsonObject _json = new JsonObject();
    _json.put("sql", sql);
    DeliveryOptions _deliveryOptions = new DeliveryOptions();
    _deliveryOptions.addHeader("action", "queryOne");
    _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()));
        }
    });
    return this;
}

From source file:com.panjiesw.std.service.user.UserServiceVertxEBProxy.java

License:Apache License

public UserService one(Long id, Handler<AsyncResult<JsonObject>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }/*from  w ww .j  ava 2s.  c  om*/
    JsonObject _json = new JsonObject();
    _json.put("id", id);
    DeliveryOptions _deliveryOptions = new DeliveryOptions();
    _deliveryOptions.addHeader("action", "one");
    _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()));
        }
    });
    return this;
}

From source file:com.panjiesw.std.service.user.UserServiceVertxEBProxy.java

License:Apache License

public UserService findByUsername(String username, Handler<AsyncResult<JsonObject>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }//from w  w  w  . j av a2  s. co  m
    JsonObject _json = new JsonObject();
    _json.put("username", username);
    DeliveryOptions _deliveryOptions = new DeliveryOptions();
    _deliveryOptions.addHeader("action", "findByUsername");
    _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()));
        }
    });
    return this;
}

From source file:com.panjiesw.std.service.user.UserServiceVertxEBProxy.java

License:Apache License

public UserService findByEmail(String email, Handler<AsyncResult<JsonObject>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return this;
    }/*ww w.  java2  s .  c om*/
    JsonObject _json = new JsonObject();
    _json.put("email", email);
    DeliveryOptions _deliveryOptions = new DeliveryOptions();
    _deliveryOptions.addHeader("action", "findByEmail");
    _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()));
        }
    });
    return this;
}

From source file:com.panjiesw.std.service.user.UserServiceVertxEBProxy.java

License:Apache License

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

From source file:com.pluralsight.dockerproductionaws.portfolio.PortfolioServiceVertxEBProxy.java

License:Apache License

public void getPortfolio(Handler<AsyncResult<Portfolio>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return;// w w w .j  ava2 s .co  m
    }
    JsonObject _json = new JsonObject();
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "getPortfolio");
    _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() == null ? null : new Portfolio(res.result().body())));
        }
    });
}

From source file:com.pluralsight.dockerproductionaws.portfolio.PortfolioServiceVertxEBProxy.java

License:Apache License

public void buy(int amount, JsonObject quote, Handler<AsyncResult<Portfolio>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return;//from  w w w.  j a v  a 2s .  c  om
    }
    JsonObject _json = new JsonObject();
    _json.put("amount", amount);
    _json.put("quote", quote);
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "buy");
    _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() == null ? null : new Portfolio(res.result().body())));
        }
    });
}

From source file:com.pluralsight.dockerproductionaws.portfolio.PortfolioServiceVertxEBProxy.java

License:Apache License

public void sell(int amount, JsonObject quote, Handler<AsyncResult<Portfolio>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return;//from w  w w.j  av a 2 s  . co m
    }
    JsonObject _json = new JsonObject();
    _json.put("amount", amount);
    _json.put("quote", quote);
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "sell");
    _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() == null ? null : new Portfolio(res.result().body())));
        }
    });
}

From source file:com.pluralsight.dockerproductionaws.portfolio.PortfolioServiceVertxEBProxy.java

License:Apache License

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