List of usage examples for io.vertx.core.json JsonObject JsonObject
public JsonObject()
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 ww w . jav a2 s .c o 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; }/*from w w w . j a va 2s . 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 w w . ja v a 2s.co 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.PortfolioConverter.java
License:Apache License
public static void toJson(Portfolio obj, JsonObject json) { json.put("cash", obj.getCash()); if (obj.getShares() != null) { JsonObject map = new JsonObject(); obj.getShares().forEach((key, value) -> map.put(key, value)); json.put("shares", map); }/*from ww w .jav a 2 s.co m*/ }
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;/*from w w w.ja va2s. 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 ww . ja v a2 s . c o 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", "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 ww . j a va2s .c o 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;/*from ww w . j a va 2 s .co m*/ } 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())); } }); }
From source file:com.rbmhtechnology.example.vertx.japi.VertxAdapterExample.java
License:Open Source License
private static Observable<String> deployVerticles(Vertx vertx) { return Observable.zip(deployVerticle(ProcessorVerticle.class, new JsonObject(), vertx), deployVerticle(ReaderVerticle.class, new JsonObject().put("name", "v_reader-1"), vertx), deployVerticle(ReaderVerticle.class, new JsonObject().put("name", "v_reader-2"), vertx), (i1, i2, i3) -> i1);//from ww w. ja v a 2 s . c o m }
From source file:com.reachauto.account.AccountServiceVertxEBProxy.java
License:Apache License
public AccountService addAccount(Account account, Handler<AsyncResult<Void>> resultHandler) { if (closed) { resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed"))); return this; }//w w w . j a v a 2 s .co m JsonObject _json = new JsonObject(); _json.put("account", account == null ? null : account.toJson()); DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions(); _deliveryOptions.addHeader("action", "addAccount"); _vertx.eventBus().<Void>send(_address, _json, _deliveryOptions, res -> { if (res.failed()) { resultHandler.handle(Future.failedFuture(res.cause())); } else { resultHandler.handle(Future.succeededFuture(res.result().body())); } }); return this; }