title: Play! 2.0 Scala - Accessing global object
body: <p>I've declared an object which gets instantiated on application start. I want to access it inside a controller, which is part of a plugin. I want to be able to use that plugin, but I can't seem to get past the first part -- finding the <code>MyWebsocketConnection</code> object. None of the examples show how to do this. I don't want to inject into the controller because I'm writing a plugin (I saw static examples of how to do that somewhere).</p>
  
  <p><code>Global.scala</code>, plugin application \app\Global.scala</p>
  
  <pre><code>object Global extends GlobalSettings {
  
    object MyWebsocketConnection {
      val logger = // return something that gets instantiated once, like websocket object for logging to ui
    }
  
    class MyWebsocketConnection {
      import MyWebsocketConnection.logger
    }
  
    override def onStart(app: Application) {
      Logger.info("Application has started...");
    }
  
  }
  </code></pre>
  
  <p>My custom logging plugin controller:</p>
  
  <p><code>MyLogger.Scala</code>, plugin application \app\controllers\MyLogger.scala</p>
  
  <pre><code>object MyLogger {
  
    def info(message: String) = {
      // THIS CAN'T BE FOUND ?
      // MyWebsocketConnection.logger.send(message)
    }
  
  }
  </code></pre>
  
  <p>So, from the Play! 2.0 app that references the plugin, I would (probably) do something like below, but I can't even get past the part before this:</p>
  
  <p><code>MyFutureController.scala</code>, another Play! application \app\controllers\MyFutureController.scala</p>
  
  <pre><code>object MyFutureController extends Controller {
    def someRandomMethod = Action {
      // Custom logging
      MyLogger.info("Here's my log message!");
      Ok("This documentation stinks!")
    }
  }
  </code></pre>