jclouds-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adrian Cole <notificati...@github.com>
Subject Re: [jclouds] JCLOUDS-753: Make ConnectionSpec configurable in the OkHttp driver (#619)
Date Sun, 30 Nov 2014 16:57:46 GMT
>        private final HostnameVerifier verifier;
>        private final Supplier<SSLContext> untrustedSSLContextProvider;
>        private final HttpUtils utils;
> +      @Inject(optional = true)
> +      private Supplier<SSLContext> sslContextSupplier;
> +
> +      @Inject(optional = true)

optional injection is something we should move away from. [set bindings](http://google.github.io/guice/api-docs/latest/javadoc/index.html?com/google/inject/multibindings/Multibinder.html
) are supported in guice (even 4) and new injectors like [dagger](https://github.com/google/dagger/blob/master/core/src/main/java/dagger/Provides.java#L49).
It is probably better to use that instead, particularly for things like this. 

Ex. add a ctor param for `Set<ConnectionSpec> connectionSpecs`. In the okhttp module,
use Multibinder.newSetBinder [without binding anything](https://groups.google.com/forum/#!topic/google-guice/5Rnm-d7MU34).
This will apply no specs as defaults, and allow users to supply additional specs without using
optional injection or module overrides. In the ctor, only apply connectionSpecs if not empty.

p.s. Another example of things to move to set bindings are [authentication methods](https://github.com/jclouds/jclouds/blob/master/apis/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/config/SwiftAuthenticationModule.java#L76),
as that eliminates needing to use inheritance just to add another mechanism in a subtype.

Reply to this email directly or view it on GitHub:
View raw message