从 Play Framework 2.4 开始,就有可能使用依赖注入(使用 Guice)。
在我的 ActionBuilders 中使用对象(例如AuthenticationService
)之前:
object AuthenticatedAction extends ActionBuilder[AuthenticatedRequest] {
override def invokeBlock[A](request: Request[A], block: (AuthenticatedRequest[A]) => Future[Result]): Future[Result] = {
...
AuthenticationService.authenticate (...)
...
}
}
现在AuthenticationService
不再是一个对象,而是一个类。我怎样才能仍然使用AuthenticationService
我的ActionBuilder
?