我正在开发一个使用演员来处理请求的播放应用程序。应用程序行将是这样的..
MyController extends Controller {
system.actorOf(Props(new MyRequestProcessor))
val actorRef = MyRequestProcessor
def handle(parse.json) { request =>
actorRef ! request.body
Ok
}
}
基本上我想把 MyRequestProcessor 演员放在主管演员之下。由于控制器是由 play 框架创建的,我不知道在 Supervisor 中创建 RequestProcessor 并取回 ActorRef 的首选方法。
希望代码是这样的......
Supervisor extends Actor {
override val supevisorStrategy = OneForOneStrategy….
}
MyController extends Controller {
val supervisorRef = system.actorOf(Props[Supervisor]...
val processorRef = //NEED A WAY TO INSTANTIATE MyRequestProcessor WITHIN
//Supervisor and get that ActorRef back Using Supervisor's context.actorOf[]
def handle(parse.json) { request
processorRef ! request.body
}
}