現在、次のようなコントローラー内で UserService を接続するために Guice を使用しています。
@Singleton
class UserController @Inject()(userService: UserService) extends Controller {
def show(userId: Int) {
val user = userService.get(userId)
Ok("hello " + user.name)
}
}
私の UserService は次のようになります。
abstract class UserService {
def get(userId: Int): User
}
class UserServiceImpl @Inject()(val userDao: UserDao) extends UserService {
def get(userId: Int): User = {
// ....
}
}
依存関係として guice を削除して Cake パターンを使用したい場合、コードはどのようになり、これを Play に統合してコントローラーでこのサービスを使用できるようにするにはどうすればよいでしょうか?