| 1 | /** |
| 2 | * |
| 3 | * Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com> |
| 4 | * |
| 5 | * ==================================================================== |
| 6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | * you may not use this file except in compliance with the License. |
| 8 | * 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, software |
| 13 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | * See the License for the specific language governing permissions and |
| 16 | * limitations under the License. |
| 17 | * ==================================================================== |
| 18 | */ |
| 19 | package org.jclouds.filesystem.config; |
| 20 | |
| 21 | import org.jclouds.blobstore.AsyncBlobStore; |
| 22 | import org.jclouds.blobstore.BlobStore; |
| 23 | import org.jclouds.blobstore.BlobStoreContext; |
| 24 | import org.jclouds.blobstore.attr.ConsistencyModel; |
| 25 | import org.jclouds.blobstore.config.BlobStoreMapModule; |
| 26 | import org.jclouds.blobstore.config.BlobStoreObjectModule; |
| 27 | import org.jclouds.blobstore.internal.BlobStoreContextImpl; |
| 28 | import org.jclouds.blobstore.util.BlobUtils; |
| 29 | import org.jclouds.filesystem.FilesystemBlobStore; |
| 30 | import org.jclouds.filesystem.predicates.validators.FilesystemBlobKeyValidator; |
| 31 | import org.jclouds.filesystem.predicates.validators.FilesystemContainerNameValidator; |
| 32 | import org.jclouds.filesystem.predicates.validators.internal.FilesystemBlobKeyValidatorImpl; |
| 33 | import org.jclouds.filesystem.predicates.validators.internal.FilesystemContainerNameValidatorImpl; |
| 34 | import org.jclouds.filesystem.strategy.FilesystemStorageStrategy; |
| 35 | import org.jclouds.filesystem.strategy.internal.FilesystemStorageStrategyImpl; |
| 36 | import org.jclouds.filesystem.util.internal.FileSystemBlobUtilsImpl; |
| 37 | import org.jclouds.location.config.JustProviderLocationModule; |
| 38 | |
| 39 | import com.google.inject.AbstractModule; |
| 40 | import com.google.inject.Provides; |
| 41 | import com.google.inject.Scopes; |
| 42 | import com.google.inject.Singleton; |
| 43 | import com.google.inject.TypeLiteral; |
| 44 | |
| 45 | /** |
| 46 | * |
| 47 | * @author Alfredo "Rainbowbreeze" Morresi |
| 48 | */ |
| 49 | public class FilesystemBlobStoreContextModule extends AbstractModule { |
| 50 | |
| 51 | @Override |
| 52 | protected void configure() { |
| 53 | bind(new TypeLiteral<BlobStoreContext>() { |
| 54 | }).to(new TypeLiteral<BlobStoreContextImpl<FilesystemBlobStore, AsyncBlobStore>>() { |
| 55 | }).in(Scopes.SINGLETON); |
| 56 | install(new BlobStoreObjectModule()); |
| 57 | install(new BlobStoreMapModule()); |
| 58 | bind(ConsistencyModel.class).toInstance(ConsistencyModel.STRICT); |
| 59 | bind(FilesystemStorageStrategy.class).to(FilesystemStorageStrategyImpl.class); |
| 60 | bind(BlobUtils.class).to(FileSystemBlobUtilsImpl.class); |
| 61 | bind(FilesystemBlobKeyValidator.class).to(FilesystemBlobKeyValidatorImpl.class); |
| 62 | bind(FilesystemContainerNameValidator.class).to(FilesystemContainerNameValidatorImpl.class); |
| 63 | install(new JustProviderLocationModule()); |
| 64 | } |
| 65 | |
| 66 | @Provides |
| 67 | @Singleton |
| 68 | BlobStore provide(FilesystemBlobStore in) { |
| 69 | return in; |
| 70 | } |
| 71 | |
| 72 | } |