List of usage examples for io.vertx.core Future succeededFuture
static <T> Future<T> succeededFuture(T result)
From source file:com.glt.rest.client.RestServiceVertxEBProxy.java
License:Apache License
public void put(JsonObject command, Handler<AsyncResult<String>> asyncHandler) { if (closed) { asyncHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed"))); return;//w ww .j av a2 s . c o m } JsonObject _json = new JsonObject(); _json.put("command", command); DeliveryOptions _deliveryOptions = new DeliveryOptions(); _deliveryOptions.addHeader("action", "put"); _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.glt.rest.client.RestServiceVertxEBProxy.java
License:Apache License
public void delete(JsonObject command, Handler<AsyncResult<String>> asyncHandler) { if (closed) { asyncHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed"))); return;// www . j av a 2s. c o m } JsonObject _json = new JsonObject(); _json.put("command", command); DeliveryOptions _deliveryOptions = new DeliveryOptions(); _deliveryOptions.addHeader("action", "delete"); _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.glt.rest.client.RestServiceVertxEBProxy.java
License:Apache License
public void getJson(JsonObject command, Handler<AsyncResult<JsonObject>> asyncHandler) { if (closed) { asyncHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed"))); return;//from w w w . j a v a 2 s . com } JsonObject _json = new JsonObject(); _json.put("command", command); DeliveryOptions _deliveryOptions = new DeliveryOptions(); _deliveryOptions.addHeader("action", "getJson"); _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 postJson(JsonObject command, Handler<AsyncResult<JsonObject>> asyncHandler) { if (closed) { asyncHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed"))); return;/* w ww . j av a2 s. c o m*/ } JsonObject _json = new JsonObject(); _json.put("command", command); DeliveryOptions _deliveryOptions = new DeliveryOptions(); _deliveryOptions.addHeader("action", "postJson"); _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 putJson(JsonObject command, Handler<AsyncResult<JsonObject>> asyncHandler) { if (closed) { asyncHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed"))); return;//from w w w.j a v a2 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 w w w. ja v a2 s. co m*/ } 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;/*from w ww.ja va2s. c o m*/ } 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.jedlab.vertee.DatabaseServiceVertxEBProxy.java
License:Apache License
public void persist(JsonObject document, Handler<AsyncResult<JsonObject>> resultHandle) { if (closed) { resultHandle.handle(Future.failedFuture(new IllegalStateException("Proxy is closed"))); return;//ww w . j av a2 s.c o m } JsonObject _json = new JsonObject(); _json.put("document", document); DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions(); _deliveryOptions.addHeader("action", "persist"); _vertx.eventBus().<JsonObject>send(_address, _json, _deliveryOptions, res -> { if (res.failed()) { resultHandle.handle(Future.failedFuture(res.cause())); } else { resultHandle.handle(Future.succeededFuture(res.result().body())); } }); }
From source file:com.klwork.spring.vertx.render.MyStaticHandlerImpl.java
License:Open Source License
private synchronized void getFileProps(RoutingContext context, String file, Handler<AsyncResult<FileProps>> resultHandler) { // FileSystem fs = context.vertx().fileSystem(); FileSystem fs = new WindowsFileSystem((VertxInternal) context.vertx()); if (alwaysAsyncFS || useAsyncFS) { wrapInTCCLSwitch(() -> fs.props(file, resultHandler), resultHandler); } else {/*from ww w . j a v a 2s . c o m*/ // Use synchronous access - it might well be faster! long start = 0; if (tuning) { start = System.nanoTime(); } try { FileProps props = wrapInTCCLSwitch(() -> fs.propsBlocking(file), resultHandler); if (tuning) { long end = System.nanoTime(); long dur = end - start; totalTime += dur; numServesBlocking++; if (numServesBlocking == Long.MAX_VALUE) { // Unlikely.. but... resetTuning(); } else if (numServesBlocking == nextAvgCheck) { double avg = (double) totalTime / numServesBlocking; if (avg > maxAvgServeTimeNanoSeconds) { useAsyncFS = true; log.info( "Switching to async file system access in static file server as fs access is slow! (Average access time of " + avg + " ns)"); tuning = false; } nextAvgCheck += NUM_SERVES_TUNING_FS_ACCESS; } } resultHandler.handle(Future.succeededFuture(props)); } catch (FileSystemException e) { resultHandler.handle(Future.failedFuture(e.getCause())); } } }
From source file:com.panjiesw.std.service.user.UserServiceVertxEBProxy.java
License:Apache License
public UserService save(JsonObject payload, Handler<AsyncResult<JsonArray>> resultHandler) { if (closed) { resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed"))); return this; }//from ww w . jav a2 s. com JsonObject _json = new JsonObject(); _json.put("payload", payload); DeliveryOptions _deliveryOptions = new DeliveryOptions(); _deliveryOptions.addHeader("action", "save"); _vertx.eventBus().<JsonArray>send(_address, _json, _deliveryOptions, res -> { if (res.failed()) { resultHandler.handle(Future.failedFuture(res.cause())); } else { resultHandler.handle(Future.succeededFuture(res.result().body())); } }); return this; }