Use the MultiBinding functionality. http://publicobject.com/2008/05/guice-multibindings-extension-checked.html
On May 6, 4:21 pm, Olivier Grégoire <[email protected]> wrote: > Dears, > > Behind my title, I have to admit that I obviously know about the > Injector.createChildInjector(Module...) method. However I was wondering > essentially about modules that interact between them: > > I hope my explanation will be clear enough: > > Main module: > + interface Plugin (no implementation) > + Plugin manager > + injector mainInjector created through Guice.createInjector() > > Extension 1 module: > + defines an implementation of Plugin > + injector ext1Injector created through mainInjector.createChildInjector() > > Extension 2 module (does not require any components of Extension 1): > + defines an implementation of Plugin > + injector ext2Injector created through mainInjector.createChildInjector() > > Extension 3 module (requires components of Extension 1) > + defines an implementation of Plugin (aouch : it already exists) > + injector ext3Injector created through ext1Injector.createChildInjector() > > The problem of extension 3 is that, since I create an injector with the > extension 1 injector, I cannot provide a new implementation for my Plugin > interface. > > The file in attachment shows a basic implementation of the error I receive. > > The problem can easily be worked around by creating another entry point in > Extension 1 accessible to extension 3, but I don't find it efficient at all > since the plugin-manager is handled at the main module level, and the main > module shouldn't know the various entry points of extension 1. > > I've immediately thought about Modules.override() but it only overrides > Modules with Modules, not Injectors with Modules. > > I can clearly see a problem here. However I don't know how to solve it with > the current implementation of Guice. I also don't know how to handle a > single module that needs two modules as prerequisites. > > So, does anyone know how I can manage extensions that need components found > in other extensions with Guice? > > This is my first modular application, so if all this is based upon > misunderstood basics about modular applications, please let me know why. > > Thank you and best regards, > > Olivier > > ModularityTest.java > 2KViewDownload --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
