Пример #1
0
 public static <T> T result(FutureHandler<AsyncResult<T>> future) throws Exception {
   AsyncResult<T> asyncResult = future.await();
   if (asyncResult.failed()) {
     throw new Exception(asyncResult.cause());
   } else {
     return asyncResult.result();
   }
 }
Пример #2
0
 private void authorise(
     final JsonObject message, final String sessionID, final AsyncResultHandler<Boolean> handler) {
   // If session id is in local cache we'll consider them authorised
   final AsyncResult<Boolean> res = new AsyncResult<>();
   if (authCache.containsKey(sessionID)) {
     res.setResult(true).setHandler(handler);
   } else {
     eb.send(
         authAddress,
         message,
         new Handler<Message<JsonObject>>() {
           public void handle(Message<JsonObject> reply) {
             boolean authed = reply.body.getString("status").equals("ok");
             res.setResult(authed).setHandler(handler);
           }
         });
   }
 }