title: Guice: Scope related questions
body: <p>I'd like to use a <strong><em>dependency injection framework</em></strong>.</p>
  
  <p>During my evaluation I came to the conclusion that <strong>Google Guice</strong> seems to fit best for my demands.</p>
  
  <p>However, some questions came into my mind:</p>
  
  <ol>
  <li><p>Imagine a web application in which a user can have <strong>independent windows within a http session</strong>. The <code>Session</code> scope is too general while the <code>Request</code> scope is too narrow for me.<br> Is there a scope which will help me out? (something I would call "<code>window</code>" or "<code>controller instance</code>" scope)</p></li>
  <li><p>Are there any <strong>pitfalls</strong> writing a <strong>custom scope</strong>?</p></li>
  <li><p>Our web application and several stand alone console applications are using the same classes. I am facing the problem that the <strong>scope of a class depends</strong> on the application type which is <strong>only known at runtime</strong>.<br>
  E.g. in a standalone application the scope would be "<em>No-Scope</em>" or "<em>per-Thread Scope</em>", while in a web application it would be bound to a <code>Session</code>/"<code>window</code>".<br>
  How to solve this problem?</p></li>
  </ol>