title: Play Framework: Dependency Injection inside Action
body: <p>Short version: how to inject an object inside Action in Play Framework?</p>
  
  <p>Long version: In my project I have custom annotation action <code>@AuthenticationRequired</code> which loads <code>User</code> object from the database and puts it into <code>context.args</code>. It uses DAO class that implements <code>UserDAO</code>. Now I want to use DAO class injected into <code>Action</code> by Google Guice. I can use Guice and inject instances in controllers and tests, but I have difficulties injecting DAO class inside Action.</p>
  
  <p>Injector is a field on <code>GlobalSettings</code> instance.</p>
  
  <p>I tried to override <code>GlobalSettings#onRequest()</code> and put UserDAO instance to <code>context.args</code> and then retrieve it from inside <code>AuthenticationRequired</code> action, but it turns out that Action returned by <code>GlobalSettings#onRequest()</code> being called last in the chain of action used with @With and/or custom annotations, so, it is to late.</p>
  
  <p>I also tried to inject DAO instance by annotating action constructor, but but it uses no-args constructor to create an instance of action.</p>
  
  <p>Any ideas how can I achieve this?</p>