Hi Edward,
In that case it is easy: When an actor need to start a child, I'll pass a Props instance for that actor. So that the actor will be supervised by the parent but the dependencies of the constructor for the child are hidden.
ex:
class ParentActor(childProps: Props) {
val child = context.actorOf(childProps.withRouter(...), "child")
...
}
object ParentActor {
def props(childProps: Props) = Props(classOf[ParentActor], childProps)
}
class ChildActor(mailServer: MailServer, ....) {
....
}
object ChildActor {
def props(mailServer: MailServer, ....) = Props(classOf[ChildActor], mailServer, ....)
}
val childProps = ChildActor.props(mailServer, ....)
....
val toTest = system.actorOf(ParentActor.props(childProps), "parent")