Merge pull request #730 from andrewgaul/local-storage-strategy-injection

Inject TransientStorageStrategy
This commit is contained in:
Adrian Cole 2012-07-19 04:33:53 -07:00
commit aec16c184a
4 changed files with 11 additions and 5 deletions

View File

@ -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;
}
/**

View File

@ -132,7 +132,8 @@ public class TransientAsyncBlobStore extends BaseAsyncBlobStore {
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService service,
Supplier<Location> defaultLocation,
@Memoized Supplier<Set<? extends Location>> locations,
Factory blobFactory, Provider<UriBuilder> uriBuilders) {
Factory blobFactory, LocalStorageStrategy storageStrategy,
Provider<UriBuilder> 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;
}

View File

@ -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<String, Location> containerToLocation = new ConcurrentHashMap<String, Location>();
private final Supplier<Location> defaultLocation;
public TransientStorageStrategy(final Supplier<Location> defaultLocation) {
this.defaultLocation = Preconditions.checkNotNull(defaultLocation);
@Inject
TransientStorageStrategy(final Supplier<Location> defaultLocation) {
this.defaultLocation = defaultLocation;
}
public Iterable<String> getAllContainerNames() {

View File

@ -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);
}