, play.libs.F.Promise, : 1) a scala Future and Callback 2), play Function0 ( A ):
import static akka.dispatch.Futures.future;
Promise<A> promise=Promise.wrap(future(
new Callable<A>() {
public A call() {
return new A();
}
}, Akka.system().dispatcher()));
Promise<A> promise2= Promise.promise(
new Function0<A>() {
public A apply() {
return new A();
}
}
);
: , , (scala , ). , scala Promise, play.libs.F.Promise :
import akka.dispatch.Futures;
final scala.concurrent.Promise<String> promise = Futures.promise();
service.execute(new Handler() {
public void onSuccess(String result) {
promise.success(result);
}
})
return Promise.wrap(promise.future());