| 1 | /** |
| 2 | * Licensed to jclouds, Inc. (jclouds) under one or more |
| 3 | * contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. jclouds licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
| 19 | package org.jclouds.filesystem.config; |
| 20 | |
| 21 | import org.jclouds.blobstore.AsyncBlobStore; |
| 22 | import org.jclouds.blobstore.BlobRequestSigner; |
| 23 | import org.jclouds.blobstore.BlobStore; |
| 24 | import org.jclouds.blobstore.BlobStoreContext; |
| 25 | import org.jclouds.blobstore.TransientBlobRequestSigner; |
| 26 | import org.jclouds.blobstore.attr.ConsistencyModel; |
| 27 | import org.jclouds.blobstore.config.BlobStoreMapModule; |
| 28 | import org.jclouds.blobstore.config.BlobStoreObjectModule; |
| 29 | import org.jclouds.blobstore.internal.BlobStoreContextImpl; |
| 30 | import org.jclouds.blobstore.util.BlobUtils; |
| 31 | import org.jclouds.filesystem.FilesystemBlobStore; |
| 32 | import org.jclouds.filesystem.predicates.validators.FilesystemBlobKeyValidator; |
| 33 | import org.jclouds.filesystem.predicates.validators.FilesystemContainerNameValidator; |
| 34 | import org.jclouds.filesystem.predicates.validators.internal.FilesystemBlobKeyValidatorImpl; |
| 35 | import org.jclouds.filesystem.predicates.validators.internal.FilesystemContainerNameValidatorImpl; |
| 36 | import org.jclouds.filesystem.strategy.FilesystemStorageStrategy; |
| 37 | import org.jclouds.filesystem.strategy.internal.FilesystemStorageStrategyImpl; |
| 38 | import org.jclouds.filesystem.util.internal.FileSystemBlobUtilsImpl; |
| 39 | import org.jclouds.location.config.JustProviderLocationModule; |
| 40 | |
| 41 | import com.google.inject.AbstractModule; |
| 42 | import com.google.inject.Provides; |
| 43 | import com.google.inject.Scopes; |
| 44 | import com.google.inject.Singleton; |
| 45 | import com.google.inject.TypeLiteral; |
| 46 | |
| 47 | /** |
| 48 | * |
| 49 | * @author Alfredo "Rainbowbreeze" Morresi |
| 50 | */ |
| 51 | public class FilesystemBlobStoreContextModule extends AbstractModule { |
| 52 | |
| 53 | @Override |
| 54 | protected void configure() { |
| 55 | bind(new TypeLiteral<BlobStoreContext>() { |
| 56 | }).to(new TypeLiteral<BlobStoreContextImpl<FilesystemBlobStore, AsyncBlobStore>>() { |
| 57 | }).in(Scopes.SINGLETON); |
| 58 | install(new BlobStoreObjectModule()); |
| 59 | install(new BlobStoreMapModule()); |
| 60 | bind(ConsistencyModel.class).toInstance(ConsistencyModel.STRICT); |
| 61 | bind(FilesystemStorageStrategy.class).to(FilesystemStorageStrategyImpl.class); |
| 62 | bind(BlobUtils.class).to(FileSystemBlobUtilsImpl.class); |
| 63 | bind(FilesystemBlobKeyValidator.class).to(FilesystemBlobKeyValidatorImpl.class); |
| 64 | bind(FilesystemContainerNameValidator.class).to(FilesystemContainerNameValidatorImpl.class); |
| 65 | bind(BlobRequestSigner.class).to(TransientBlobRequestSigner.class); |
| 66 | install(new JustProviderLocationModule()); |
| 67 | } |
| 68 | |
| 69 | @Provides |
| 70 | @Singleton |
| 71 | BlobStore provide(FilesystemBlobStore in) { |
| 72 | return in; |
| 73 | } |
| 74 | |
| 75 | } |