VertX Multiple Futures 返回一个 Future

VertX Multiple Futures returning a Future

我正在尝试调用 3 个期货,等待它们完成,处理结果,然后 return 所有这些也作为一个期货。我似乎无法弄清楚如何将未来的 3 个期货“包装”成 returned,这样它就不会立即 return。我是 vertx 的新手。

public Future<MyObject> getProjectStatus(int projectId) {

      Future future = Future.future(ar -> {
        MyObject object = new Myobject();

        Future<x> f1 = callf1();
        Future<y> f2 = callf2();
        Future<z> f3 = callf3();

        CompositeFuture cf = CompositeFuture.all(f1, f2, f3);
        cf.onComplete(ar2 -> {
          //Check Succeeds
          if(ar2.succeeded()){
            System.out.println("Completed!");
            //DO FURTHER PROCESSING
          } else {
            System.out.println("Failure " + ar2.cause().getMessage());
          }
        }).map((object));

      });

      return future;

    }

public Future<MyObject> getProjectStatus(int projectId) {

        MyObject object = new Myobject();

        Future<x> f1 = callf1();
        Future<y> f2 = callf2();
        Future<z> f3 = callf3();

        return CompositeFuture.all(f1, f2, f3).onComplete(ar2 -> {
          //Check Succeeds
          if(ar2.succeeded()){
            System.out.println("Completed!");
            //DO FURTHER PROCESSING
          } else {
            System.out.println("Failure " + ar2.cause().getMessage());
          }
        }).map(object);

    }

public Future<MyObject> getProjectStatus(int projectId) {

      Future future = Future.future(ar -> {
        MyObject object = new Myobject();

        Future<x> f1 = callf1();
        Future<y> f2 = callf2();
        Future<z> f3 = callf3();

        CompositeFuture cf = CompositeFuture.all(f1, f2, f3);
        cf.onComplete(ar2 -> {
          //Check Succeeds
          if(ar2.succeeded()){
            System.out.println("Completed!");
            //DO FURTHER PROCESSING
          } else {
            System.out.println("Failure " + ar2.cause().getMessage());
          }
          ar.complete(object);
        });

      });

      return future;

    }