On Mon, Feb 8, 2010 at 3:28 AM, [email protected] <[email protected]> wrote: > You could use PrivateModules. Any bindings that need to be shared > could be installed in either the top-level injector, or in each of the > PrivateModules.
Here's how I finally solved my problem: I created a Provider<List<Injector>> which does the discovery for the present modules and builds child injectors for each using Injector.createChildInjector(). The discovery process is very expensive, so I put that in Singleton scope in my master module. Each child processor module (a.k.a. plugin) is used to produce an instance of an interface. It binds its own config objects used within that scope. I created another Provider<Map<ServiceID, Provider<IProcessor>>> which has a dependency on the List<Injector>. It just uses the injectors to get the instances of the interfaces, the same way a MapBinder would. Try as I might, I could not use private modules. 1. There is no way to expose a MapBinder from them. 2. There is no way to expose the same type from multiple private modules to an abstract module which can use a MapBinder. (Actually, not true... you could create a parameterized annotation and pass the parameter - generate some random UUID - into the private module and have it bind the type with annotatedWith(). This is horribly ugly.) Therefore, the _only_ way to use MapBinder or Multibinder so far as I can tell is when no two instances of the multi-bound type depend (anywhere down the graph) on different bindings for the same type. -- 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.
