From a2d5a48f3fe8a6ff8204e78e926e4fabd601af99 Mon Sep 17 00:00:00 2001 From: Andrew Gaul Date: Wed, 18 Jul 2012 11:03:48 -0700 Subject: [PATCH] Inject TransientStorageStrategy Remove some unneeded checkNotNull as Guice does not inject null parameters. --- .../org/jclouds/filesystem/FilesystemAsyncBlobStore.java | 2 +- .../java/org/jclouds/blobstore/TransientAsyncBlobStore.java | 5 +++-- .../org/jclouds/blobstore/TransientStorageStrategy.java | 6 ++++-- .../blobstore/config/TransientBlobStoreContextModule.java | 3 +++ 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemAsyncBlobStore.java b/apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemAsyncBlobStore.java index b5cdd7e44e..82234a2919 100644 --- a/apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemAsyncBlobStore.java +++ b/apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemAsyncBlobStore.java @@ -141,7 +141,7 @@ public class FilesystemAsyncBlobStore extends BaseAsyncBlobStore { this.httpGetOptionsConverter = httpGetOptionsConverter; this.contentMetadataCodec = contentMetadataCodec; this.ifDirectoryReturnName = ifDirectoryReturnName; - this.storageStrategy = checkNotNull(storageStrategy, "Storage strategy"); + this.storageStrategy = storageStrategy; } /** diff --git a/blobstore/src/main/java/org/jclouds/blobstore/TransientAsyncBlobStore.java b/blobstore/src/main/java/org/jclouds/blobstore/TransientAsyncBlobStore.java index 463de6d3a4..edf59c7e13 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/TransientAsyncBlobStore.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/TransientAsyncBlobStore.java @@ -132,7 +132,8 @@ public class TransientAsyncBlobStore extends BaseAsyncBlobStore { @Named(Constants.PROPERTY_USER_THREADS) ExecutorService service, Supplier defaultLocation, @Memoized Supplier> locations, - Factory blobFactory, Provider uriBuilders) { + Factory blobFactory, LocalStorageStrategy storageStrategy, + Provider uriBuilders) { super(context, blobUtils, service, defaultLocation, locations); this.blobFactory = blobFactory; this.dateService = dateService; @@ -140,7 +141,7 @@ public class TransientAsyncBlobStore extends BaseAsyncBlobStore { this.httpGetOptionsConverter = httpGetOptionsConverter; this.contentMetadataCodec = contentMetadataCodec; this.ifDirectoryReturnName = ifDirectoryReturnName; - this.storageStrategy = new TransientStorageStrategy(defaultLocation); + this.storageStrategy = storageStrategy; this.uriBuilders = uriBuilders; } diff --git a/blobstore/src/main/java/org/jclouds/blobstore/TransientStorageStrategy.java b/blobstore/src/main/java/org/jclouds/blobstore/TransientStorageStrategy.java index 7b506c5aa6..4022444cac 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/TransientStorageStrategy.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/TransientStorageStrategy.java @@ -21,6 +21,7 @@ package org.jclouds.blobstore; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; +import javax.inject.Inject; import com.google.common.base.Preconditions; import com.google.common.base.Supplier; @@ -34,8 +35,9 @@ public class TransientStorageStrategy implements LocalStorageStrategy { private final ConcurrentMap containerToLocation = new ConcurrentHashMap(); private final Supplier defaultLocation; - public TransientStorageStrategy(final Supplier defaultLocation) { - this.defaultLocation = Preconditions.checkNotNull(defaultLocation); + @Inject + TransientStorageStrategy(final Supplier defaultLocation) { + this.defaultLocation = defaultLocation; } public Iterable getAllContainerNames() { diff --git a/blobstore/src/main/java/org/jclouds/blobstore/config/TransientBlobStoreContextModule.java b/blobstore/src/main/java/org/jclouds/blobstore/config/TransientBlobStoreContextModule.java index 659d27344b..a6d0bfc456 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/config/TransientBlobStoreContextModule.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/config/TransientBlobStoreContextModule.java @@ -21,8 +21,10 @@ package org.jclouds.blobstore.config; import org.jclouds.blobstore.AsyncBlobStore; import org.jclouds.blobstore.BlobRequestSigner; import org.jclouds.blobstore.BlobStore; +import org.jclouds.blobstore.LocalStorageStrategy; import org.jclouds.blobstore.TransientAsyncBlobStore; import org.jclouds.blobstore.TransientBlobRequestSigner; +import org.jclouds.blobstore.TransientStorageStrategy; import org.jclouds.blobstore.attr.ConsistencyModel; import org.jclouds.rest.config.BinderUtils; @@ -44,6 +46,7 @@ public class TransientBlobStoreContextModule extends AbstractModule { install(new BlobStoreMapModule()); bind(BlobStore.class).to(TransientBlobStore.class); bind(ConsistencyModel.class).toInstance(ConsistencyModel.STRICT); + bind(LocalStorageStrategy.class).to(TransientStorageStrategy.class); bind(BlobRequestSigner.class).to(TransientBlobRequestSigner.class); }