title: How can I access request in Play Guice Module?
body: <p>I am writing an application which handles multiple systems. The user can choose the system which he wants to work with and I store that system ID in session (client session)</p>
  
  <p>Now I have Service classes, lets say CustomerService. </p>
  
  <pre><code>class CustomerService(val systemID: String) {
      // Implementation
  }
  </code></pre>
  
  <p>I want to use Guice to inject the Customer instance to the Controllers. But I want to instantiate the CustomerService with SystemID which is stored in the session.</p>
  
  <p>How can I access <code>request.session</code> in Guice Module?</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>Had simplified my code above. My actual code uses interfaces. How can I use assisted inject for this?</p>
  
  <pre><code>trait CustomerService(val systemID: String) {
      // Definition
  }
  
  object CustomerService{
  
    trait Factory {
      def apply(systemID: String) : CustomerService
    }
  
  }
  
  class DefaultCustomerService @Inject() (@Assisted systemID: String)
    extends CustomerService {
      // Definition
  }
  
  class CustomerController @Inject()(
                              val messagesApi: MessagesApi,
                              csFactory: CustomerService.Factory)
  {
  }
  </code></pre>
  
  <p>This gives me:
  CustomerService is an interface, not a concrete class.  Unable to create AssistedInject factory.</p>
  
  <p>And I do not want to put the Factory under <code>DefaultCustomerService</code> and use <code>DefaultCustomerService.Factory</code> in the controller. This is because for unit testing I will be using <code>TestCustomerService</code> stub and want Dependency Injection to inject <code>TestCustomerService</code> into the controller instead of <code>DefaultCustomerService</code>.</p>