Since there are no assisted parameters here, nothing prevents you from just 
writing an implementation of Factory by hand.

But if there were assisted parameters, how would you expect it to work?

On Friday, 2 December 2016 16:42:18 UTC-5, Matthew Madson wrote:
>
> Hi Guice Devs:
>
> I assume this is a feature request but I was wondering if there was a way 
> to do something like the following:
>
> interface Factory {
>
>   @Named("secure")
>   CloseableHttpClient createSecureClient();
>
>   @Named("insecure")
>   CloseableHttpClient createSecureClient();
> }
>
> class Module extends AbstractModule {
>   @Override
>   protected void configure() {
>     install(new FactoryModuleBuilder()
>        .implement(CloseableHttpClient.class, Names.named("secure"), 
> getProvider(Key.get(CloseableHttpClient.class, Names.named("secure"))))
>        .implement(CloseableHttpClient.class, Names.named("insecure"), 
> getProvider(Key.get(CloseableHttpClient.class, Names.named("insecure"))))
>        .build(Factory.class));
>   }
>   
>   @Provides
>   @Named("secure")
>   CloseableHttpClient provideSecureHttpClient() {
>     return HttpClientBuilder.create()....build();
>   }
>
>   @Provides
>   @Named("insecure")
>   CloseableHttpClient provideInsecureHttpClient() {
>     return HttpClientBuilder.create().setSslcontext(SSLContexts.custom().
> loadTrustMaterial(...).build()).build();
>   }
> }
>
> Basically I'd like to have the factory method bound to a provides method.
>
> Best,
> Matt
>

-- 
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/f552f940-0f6a-4387-b47d-f381e0349e0d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to