似乎我能够在不使用模块的情况下注入服务或 Akka Actor。我可以知道模块的目的是什么吗?
class Hello(implicit inj:Injector) extends Controller with AkkaInjectable {
val greetingService = inject[GreetingService]
implicit val system = inject [ActorSystem]
val greetingActor = injectActorRef[greetingActor]
def greet(person:Person) = Action {
Ok(greetingService.greet(person.name))
}
}
即使没有下面它也可以正常工作
class MainModule extends Module {
binding to new GreetingService
bind [ActorSystem] to ActorSystem("ScaldiAkkaExample") destroyWith (_.terminate())
binding toProvider new StatisticsProvider
}