从内部类外部访问vertx verticle的部署ID?

时间:2015-01-29 16:32:32

标签: java inner-classes vert.x

您好我已经像这样部署了vertx Verticle,现在我想让asynchResult访问这个内部类。我已经经历了很多帖子,但没有找到任何解决方案。

container.deployVerticle("com.demo.vertx.FirstVert", snmp_trap_listener_count, new AsyncResultHandler<String>() {
                public void handle(AsyncResult<String> asyncResult) {
                    if (asyncResult.succeeded()) {
                        System.out.println("The verticle has been deployed, deployment ID is " + asyncResult.result());
                    } else {
                        asyncResult.cause().printStackTrace();
                    }
                }
                });

请帮忙解决此问题。

2 个答案:

答案 0 :(得分:0)

您可以从异步处理程序获取部署ID,如下所示:

container.deployVerticle("foo.ChildVerticle", new AsyncResultHandler<String>() {
public void handle(AsyncResult<String> asyncResult) {
    if (asyncResult.succeeded()) {
        System.out.println("The verticle has been deployed, deployment ID is " + asyncResult.result());
    } else {
        asyncResult.cause().printStackTrace();
    }
}

});

如果取消部署Verticle,他的所有孩子也将被取消部署。取消部署Verticle就像这样:

container.undeployVerticle(deploymentID);

答案 1 :(得分:0)

那家伙我得到了答案。我刚刚创建了一个setId本地方法,它将AsynchResult作为参数,并从内部类传递asynchResult到此方法。所以我在这种方法中得到了价值。

private void setDeployIds(AsyncResult<String> asyncResult){
          System.out.println("Deployment ID :" +asynchResult.result());
      }