播放框架2,如何在Java中使用执行上下文?

播放框架2,如何在Java中使用执行上下文?,java,playframework,playframework-2.1,Java,Playframework,Playframework 2.1,官方文件只描述了如何在scala中使用它 我可以得到如下的执行上下文: ExecutionContext myExecutionContext = Akka.system().dispatchers().lookup("my-context"); 但是如何在代码中添加它呢 return async( future(new Callable<String>() { public String call() { return doSt

官方文件只描述了如何在scala中使用它

我可以得到如下的执行上下文:

ExecutionContext myExecutionContext = Akka.system().dispatchers().lookup("my-context");
但是如何在代码中添加它呢

return async(
    future(new Callable<String>() {
        public String call() {
              return doSth();
        }).map(new F.Function<String,Result>() {
           public Result apply(String i) {
              return ok(i);
           }
        })  
返回异步(
future(新的Callable(){
公共字符串调用(){
返回doSth();
}).map(新的F.函数(){
公共结果应用(字符串i){
返回ok(i);
}
})  

我认为答案应该是:

    ExecutionContext myExecutionContext = Akka.system().dispatchers().lookup("my-context");
    return async(
            Akka.asPromise(Futures.future(new Callable<String>() {
              public String call() {
                return doSth();
              }   
            }, myExecutionContext)).map(new F.Function<String,Result>() {
              public Result apply(String i) {
                return ok(i);
              }
            })
    );
ExecutionContext myExecutionContext=Akka.system().dispatchers().lookup(“我的上下文”);
异步返回(
Akka.asPromise(期货.未来(新可赎回)(){
公共字符串调用(){
返回doSth();
}   
},myExecutionContext)).map(新的F.Function(){
公共结果应用(字符串i){
返回ok(i);
}
})
);
    ExecutionContext myExecutionContext = Akka.system().dispatchers().lookup("my-context");
    return async(
            Akka.asPromise(Futures.future(new Callable<String>() {
              public String call() {
                return doSth();
              }   
            }, myExecutionContext)).map(new F.Function<String,Result>() {
              public Result apply(String i) {
                return ok(i);
              }
            })
    );