Yup, this sucks! :) This (lame) workaround is simpler than the one I had in mind and looks like it works just fine for my use case.
Thanks for the quick reply. Regards, Árni Hermann On Mar 4, 2:21 am, "[email protected]" <[email protected]> wrote: > Regretfully, multibindings cannot span injectors and therefore they > cannot span private modules. This sucks! But there's a (lame) > workaround. Expose a key in the private module, and multibind it in a > regular module: > > Injector injector = Guice.createInjector( > new PrivateModule() { > public void configure() { > bind(Key.get(Source.class, named("one"))).to > (SourceImpl.class); > expose(Key.get(Source.class, named("one"))); > ... > } > }, > new PrivateModule() { > public void configure() { > bind(Key.get(Source.class, named("two"))).to > (SourceImpl.class); > expose(Key.get(Source.class, named("two"))); > ... > } > }, > new Module() { > public void configure() { > Multibinder<Source> multibinder > = Multibinder.newSetBinder(binder(), Source.class); > multibinder.addBinding().to(Key.get(Source.class, named > ("one"))); > multibinder.addBinding().to(Key.get(Source.class, named > ("two"))); > } > }); --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
