mirror of https://github.com/apache/jclouds.git
Merge pull request #730 from andrewgaul/local-storage-strategy-injection
Inject TransientStorageStrategy
This commit is contained in:
commit
aec16c184a
|
@ -141,7 +141,7 @@ public class FilesystemAsyncBlobStore extends BaseAsyncBlobStore {
|
||||||
this.httpGetOptionsConverter = httpGetOptionsConverter;
|
this.httpGetOptionsConverter = httpGetOptionsConverter;
|
||||||
this.contentMetadataCodec = contentMetadataCodec;
|
this.contentMetadataCodec = contentMetadataCodec;
|
||||||
this.ifDirectoryReturnName = ifDirectoryReturnName;
|
this.ifDirectoryReturnName = ifDirectoryReturnName;
|
||||||
this.storageStrategy = checkNotNull(storageStrategy, "Storage strategy");
|
this.storageStrategy = storageStrategy;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -132,7 +132,8 @@ public class TransientAsyncBlobStore extends BaseAsyncBlobStore {
|
||||||
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService service,
|
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService service,
|
||||||
Supplier<Location> defaultLocation,
|
Supplier<Location> defaultLocation,
|
||||||
@Memoized Supplier<Set<? extends Location>> locations,
|
@Memoized Supplier<Set<? extends Location>> locations,
|
||||||
Factory blobFactory, Provider<UriBuilder> uriBuilders) {
|
Factory blobFactory, LocalStorageStrategy storageStrategy,
|
||||||
|
Provider<UriBuilder> uriBuilders) {
|
||||||
super(context, blobUtils, service, defaultLocation, locations);
|
super(context, blobUtils, service, defaultLocation, locations);
|
||||||
this.blobFactory = blobFactory;
|
this.blobFactory = blobFactory;
|
||||||
this.dateService = dateService;
|
this.dateService = dateService;
|
||||||
|
@ -140,7 +141,7 @@ public class TransientAsyncBlobStore extends BaseAsyncBlobStore {
|
||||||
this.httpGetOptionsConverter = httpGetOptionsConverter;
|
this.httpGetOptionsConverter = httpGetOptionsConverter;
|
||||||
this.contentMetadataCodec = contentMetadataCodec;
|
this.contentMetadataCodec = contentMetadataCodec;
|
||||||
this.ifDirectoryReturnName = ifDirectoryReturnName;
|
this.ifDirectoryReturnName = ifDirectoryReturnName;
|
||||||
this.storageStrategy = new TransientStorageStrategy(defaultLocation);
|
this.storageStrategy = storageStrategy;
|
||||||
this.uriBuilders = uriBuilders;
|
this.uriBuilders = uriBuilders;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ package org.jclouds.blobstore;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ConcurrentMap;
|
import java.util.concurrent.ConcurrentMap;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.google.common.base.Supplier;
|
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 ConcurrentMap<String, Location> containerToLocation = new ConcurrentHashMap<String, Location>();
|
||||||
private final Supplier<Location> defaultLocation;
|
private final Supplier<Location> defaultLocation;
|
||||||
|
|
||||||
public TransientStorageStrategy(final Supplier<Location> defaultLocation) {
|
@Inject
|
||||||
this.defaultLocation = Preconditions.checkNotNull(defaultLocation);
|
TransientStorageStrategy(final Supplier<Location> defaultLocation) {
|
||||||
|
this.defaultLocation = defaultLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Iterable<String> getAllContainerNames() {
|
public Iterable<String> getAllContainerNames() {
|
||||||
|
|
|
@ -21,8 +21,10 @@ package org.jclouds.blobstore.config;
|
||||||
import org.jclouds.blobstore.AsyncBlobStore;
|
import org.jclouds.blobstore.AsyncBlobStore;
|
||||||
import org.jclouds.blobstore.BlobRequestSigner;
|
import org.jclouds.blobstore.BlobRequestSigner;
|
||||||
import org.jclouds.blobstore.BlobStore;
|
import org.jclouds.blobstore.BlobStore;
|
||||||
|
import org.jclouds.blobstore.LocalStorageStrategy;
|
||||||
import org.jclouds.blobstore.TransientAsyncBlobStore;
|
import org.jclouds.blobstore.TransientAsyncBlobStore;
|
||||||
import org.jclouds.blobstore.TransientBlobRequestSigner;
|
import org.jclouds.blobstore.TransientBlobRequestSigner;
|
||||||
|
import org.jclouds.blobstore.TransientStorageStrategy;
|
||||||
import org.jclouds.blobstore.attr.ConsistencyModel;
|
import org.jclouds.blobstore.attr.ConsistencyModel;
|
||||||
import org.jclouds.rest.config.BinderUtils;
|
import org.jclouds.rest.config.BinderUtils;
|
||||||
|
|
||||||
|
@ -44,6 +46,7 @@ public class TransientBlobStoreContextModule extends AbstractModule {
|
||||||
install(new BlobStoreMapModule());
|
install(new BlobStoreMapModule());
|
||||||
bind(BlobStore.class).to(TransientBlobStore.class);
|
bind(BlobStore.class).to(TransientBlobStore.class);
|
||||||
bind(ConsistencyModel.class).toInstance(ConsistencyModel.STRICT);
|
bind(ConsistencyModel.class).toInstance(ConsistencyModel.STRICT);
|
||||||
|
bind(LocalStorageStrategy.class).to(TransientStorageStrategy.class);
|
||||||
bind(BlobRequestSigner.class).to(TransientBlobRequestSigner.class);
|
bind(BlobRequestSigner.class).to(TransientBlobRequestSigner.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue