I am learning Ratpack and working from multiple resources. I have the following interface and class that works in Ratpack v0.9.18 but fails in v1.1.1 because of removal of the ExecControl interface.
//file: src/main/groovy/app/UserService.groovy
package app
import ratpack.exec.Promise
interface UserService {
Promise<Void> save (User user)
Promise<List<User>> getUsers ()
}
//file: src/main/groovy/app/DefaultUserService.groovy
package app
import ratpack.exec.ExecControl
import ratpack.exec.Promise
class DefaultUserService implements UserService {
private final List storage = []
@Override
Promise<Void> save (User user) {
storage << user
ExecControl.current ().promiseOf (null)
}
@Override
Promise<List<User>> getUsers () {
ExecControl.current ().promiseOf (storage)
}
}
I thought that changing the line with ExecControl with:
Promise.of (storage)
would work but results in
MissingMethodException: No signature of method: static ratpack.exec.Promise.of() is applicable for argument types: (java.util.ArrayList).
The Promise.of () method is expecting a type of ratpack.exec.Upstream.
How should the above DefaultUserService class be modified to work with Ratpack v1.1.1?