I recently had a discussion on how to do asynchronous programming in a Play-Java project (2.4)
in regards of where Play is heading (2.4 -> 2.5 -> 3.0).
Java 8 introduced CompletableFuture, yet Plays code base still is using play.libs.Promise.
The question now is how to proceed, especially for writing own code.
My current app will use a lot of WS-Requests against a backend system, so plays Promises are a natural fit for the webapp,
when the code stays in the project.
However, we're also evaluating if we should create a API out of the created code, to allow reusing it in other Java projects.
One approach would be to use CompeletableFuture in the interfaces and map from Plays WSClients Promise -> CompletableFuture in the
Impl of the interface. However, when using this interface from a Play-Controller, we have to remap from a CompletableFuture to a Promise.
Another approach would be to adjust the Play-Framework to also allow Actions that return a CompletableFuture<Result> to be used in Controllers.
Any ideas/insights are greatly appreciated.
Cheers,
Dominik