Injecting the Ginjector?

15 views
Skip to first unread message

Brice

unread,
Jan 31, 2009, 1:47:18 PM1/31/09
to google-gin
Good afternoon!

How would I go about injecting the Ginjector that is created in my
EntryModule? I tried the intuitive @Inject private HomeGinjector
injector; - but the injector that is injected is not what is created
from GWT.create() in my EntryModule. The easiest thing at the moment
is probably just to make that field static in my EntryModule, but was
wondering if there was a supported mechanism for this?

Thanks,
Brice

Brian Stoler

unread,
Jan 31, 2009, 9:20:40 PM1/31/09
to googl...@googlegroups.com
What is the use case? Gin could but does not support this, mostly because I believed it was unnecessary. Injecting Provider<T> for anything you'd get from the ginjector should be sufficient.

Brice

unread,
Jan 31, 2009, 9:51:16 PM1/31/09
to google-gin
Well, I had a circular injection dependency that sent Gin for a loop
(literally, bad mojo!)

So, instead, I thought I'd inject the Ginjector and just get the
object I needed (which was already configured because its also used by
the EntryModule.

I don't often have a use for this, but on server-side stuff, too, I
have occasionally needed to inject the injector ... its rare, but
usually there isn't any other pretty way to go about it ;-)

Thanks,
Brice

Brian Stoler

unread,
Feb 3, 2009, 12:03:44 AM2/3/09
to googl...@googlegroups.com
Ah -- well, we should fix the fact that circular dependencies don't work. :) Can you file an issue for that? We should at least support the cases Guice supports, if we can. You shouldn't need to inject the Ginjector just for that.

That said, Guice supports injecting the Injector, so I guess we should support it too. Could you file an issue for that? This is likely easier to implement that the circular dependency support.

In server-side Guice you sometimes need to inject the Injector if you want to dynamically decide what Key to request, but you can't do that in Gin anyhow, so I don't think injecting the Ginjector is strictly needed for any case (if we fix the circularity issue).

-brian

Brice

unread,
Feb 3, 2009, 9:21:32 AM2/3/09
to google-gin
Will do!
Reply all
Reply to author
Forward
0 new messages