I don't suppose this has gotten less lame over the years?

On Tuesday, March 3, 2009 at 6:21:45 PM UTC-8, Jesse Wilson 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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-guice.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-guice/7f4b6c07-a66e-4a5d-91a9-bc31d380e496%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to