I'm not using the servlet support because it relies on ThreadLocals, and my app is 90% asynchronous.
Your solution of wrapping new thread runnables with a scope re-introduction would work, but it requires replacing my 220 usages of Futures.transform and Futures.addCallback with something else. Text/replace is not hard, but my code base would not be robust against accidentally re-introducing Futures.transform or Futures.addCallback in the future - the error would not show up until runtime. Additionally, if any of the libraries I'm using don't allow me to override their executor services, then I would have to be very careful about which objects I pass to them. It's easy enough to wrap a callback being passed to a library (though it's also easy to forget), but things can get a lot harrier if the library calls methods on my objects deep in its own stack trace. I'd rather not take that excursion into debugging hell. On Wednesday, 10 July 2013 00:37:52 UTC-7, Tim Boudreau wrote: > > I'm guessing you're not using the servlet support that exists for Guice > for some reason? > > The whole child injector thing is overkill - what you want is a Guice > Scope with the missing things bound in that scope. > > Have a look at this - https://github.com/timboudreau/scopes - which I use > in an async http framework - in particular it lets you wrapper an > ExecutorService so that the scope contents are "frozen" when you submit a > Runnable/Callable, and the scope is reentered and reconstituted before your > Runnable/Callable is run - so you can dispatch work to other threads (there > is also AbstractScope.wrap() which will give you back a Runnable or > Callable to do that for you). > > In short, however you do it, setting up a whole Guice environment for the > rest of the objects is probably not what you want. > > -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.
