This is not possible without first constructing some sort of "bootstrap" injector. Modules tell the Injector what to do -- there's no way to inject them before they're used. See also http://code.google.com/p/google-guice/wiki/AvoidConditionalLogicInModulesfor some more information about best practices in modules.
sam On Sun, Oct 3, 2010 at 7:49 PM, yarco <[email protected]> wrote: > Hi, > It is possible to perform injections in modules. > Say in: > > class Mod extends AbstractModule{ > > @Inject > MyClass myclass; > > .... > //use myclass in "this" assuming that Guice would create a new > instance for it and inject it to myclass > > } > I kind of assumed that Guice would Inject myclass (run a default > constructor of MyClass) when I created an injector from Mod, but it > did not.. > > Any help would be appreciated! > > -- > You received this message because you are subscribed to the Google Groups > "google-guice" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<google-guice%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/google-guice?hl=en. > > -- You received this message because you are subscribed to the Google Groups "google-guice" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-guice?hl=en.
