I had somewhat similar problems and wrote a library to solve it:
https://github.com/timboudreau/scopes (you can pick it up from the Maven
repo here: http://timboudreau.com/builds/ )
Basically you should just be able to do something like
ReentrantScope myOtherScope = new ReentrantScope();
// in your binder
myOtherScope.bindTypes(binder(), ApplicationConfiguration.class);
then when you have your instance:
try (QuietAutoCloseable ac = myOtherScope.enter( theConfiguration )) {
// do what you need to
}
The pattern I wind up using this for (not a servlet environment) is to take
a scope's contents, and sort of freeze that, throw some work on thread
pool. To make that easy, there is ReentrantScope.wrap(ExecutorService),
which gets you an ExecutorService which will freeze the scope's contents at
the time a Runnable/Callable is submitted, and then reenter the scope with
the same contents before the submitted code is invoked.
All that being said, if you have the objects that would be injected to run
whatever needs the ApplicationConfiguration, it may be simplest to just
call what you need to call - in other words, be sure that injection is
buying you more than the complexity you seem to be adding to do it with
injection.
-Tim
--
You received this message because you are subscribed to the Google Groups
"google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-guice.
For more options, visit https://groups.google.com/groups/opt_out.