Comment by orlando....@gmail.com:

I saw this code in a Misko Hevery's presentation: "Conditionals VS Polymorphism. He explains how to create a provider that selects between two types of update based on the state of the variable isI18N. He is injecting that value in the provider definition. However, what I can't see is where that value comes from? it is injected into the provider but where the value is? In a Module?

Java? Use Guice!

{{{
class UpdateProvider implements Provider<Update> {

     @Inject Provider<I18NUpdate> i18n;
     @Inject Provider<NonI18NUpdate> ni18n;

     @Inject @Named("i18n_ENABLED") boolean isI18N;

     Update get() {
          return isI18N ? i18n.get() : ni18n.get();
     }
}

}}}

For more information:
http://code.google.com/p/google-guice/wiki/InjectingProviders

--
You received this message because you are subscribed to the Google Groups 
"google-guice-dev" group.
To post to this group, send email to google-guice-dev@googlegroups.com.
To unsubscribe from this group, send email to 
google-guice-dev+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-guice-dev?hl=en.

Reply via email to