title: How to get a reference to an existing ActorSystem in Akka?
body: <p>is it possible in Akka (scala) to get a reference to an existing ActorSystem?</p>
  
  <p>I am working on a Spray application with another Actor for DB. I am also extending Directives to have an object per path. the directives are not actors by themselves, but they need to pass messages to the DBActor. here:</p>
  
  <pre><code>class HttpActor extends Actor with HttpService {
  
    val actorRefFactory = context
  
    def receive = runRoute(
      IndexService.route ~ 
      HostsService.route    
    )
  }
  
  object HostsService extends Directives{
    def route(implicit dm: DetachMagnet2) = {
      path("hosts") {
        get {  
          detach() {
            **dbActor ! CreateHost** 
            complete("get me hosts!")
          }
        } ~
        post {
          detach() {
            entity(as[String]) { payload =&gt;
              complete(s"post hosts $payload")     
            }
          }
        }
      }
    }
  }
  </code></pre>
  
  <p>is there a way for HostsService to discover the ActorSystem itself so he can find the DBActor, or must HttpActor pass it in? the latter seems less elegant, as it HostsService will need to become a class (not an object), so no longer a singleton.</p>