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