Implementing a Lagom service
We have seen already how to define a service. The next natural step is to implement the service interface, and this is materialized in the hello-impl
project. The HelloServiceImpl
class is responsible for implementing your API interface. We have seen this throughout the code snippets listed earlier. One important thing to notice is that all the methods don't actually execute the call, but rather return a method handle via the instance of ServiceCall
. The reason behind this approach is to allows function composition in order to achieve a processing pipeline where authentication, authorization, logging, and exception handling can easily be added.
Let's move the focus back to ServiceCall
class. From the definition presented already, you can see it takes a request object and returns a CompletionStage<Response>
. This container is nothing but a promise the API makes. At some point in the future, the Response
will be computed and...