nacx commented on a change in pull request #43: JCLOUDS-1511: allow configuration of S3 to use V4 signatures URL: https://github.com/apache/jclouds/pull/43#discussion_r317846051
########## File path: apis/s3/src/main/java/org/jclouds/s3/config/S3HttpApiModule.java ########## @@ -183,8 +183,16 @@ protected void bindErrorHandlers() { bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(ParseS3ErrorFromXmlContent.class); } - protected void bindRequestSigner() { - bind(RequestAuthorizeSignature.class).to(RequestAuthorizeSignatureV2.class).in(Scopes.SINGLETON); + @Provides + @Singleton + protected void bindRequestSigner(@Named(Constants.PROPERTY_V4_REQUEST_SIGNATURES) boolean v4Signatures) { + Class<? extends RequestAuthorizeSignature> clazz; + if (v4Signatures) { + clazz = RequestAuthorizeSignatureV4.class; + } else { + clazz = RequestAuthorizeSignatureV2.class; + } + bind(RequestAuthorizeSignature.class).to(clazz).in(Scopes.SINGLETON); Review comment: A better approach to avoid instantiating the objects you're not using would be something like: ```java @Provides @Singleton protected RequestAuthorizeSignature bindRequestSigner( @Named(Constants.PROPERTY_V4_REQUEST_SIGNATURES) boolean v4Signatures, Injector i) { return i.getInstance(v4Signatures ? RequestAuthorizeSignatureV4.class : RequestAuthorizeSignatureV2.class); } ``` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services