title: Play 2.4: Schedule a recurring task at app startup with dependency injection
body: <p>I need to schedule a recurring task on the application start, the task itself is very simple just send to the application a fire-and-forget HTTP call. I'm not a play expert, buy i would assume that s straightforward solution would be something like using <code>play.api.libs.concurrent.Akka.system.schedule</code> in <code>Global.onStart</code>. Since Play 2.4, <code>Global</code> configuration is somewhat deprecated in favor of new Guice DI. Hacking the advice from the <a href="https://www.playframework.com/documentation/2.4.x/ScalaCompileTimeDependencyInjection" rel="nofollow">DI documentation</a> i couldn't come up with a nice solution for this issue. The best i managed to get is writing a wrapper on top of <code>GuiceApplicationLoader</code> calling a custom implementation of <code>BuiltInComponentsFromContext</code>, but in this case i can't use injection to get <code>WSClient</code>. What's the best way to rewrite something like this with Play 2.4:</p>
  
  <pre><code>object Global extends GlobalSettings {
    override def onStart(app: Application) = {
      Akka.system.schedule(2.hours, 2.hours, theTask)
    }
  }
  </code></pre>