EMMA Coverage Report (generated Mon Oct 17 05:41:20 EDT 2011)
[all classes][org.jclouds.s3.blobstore.config]

COVERAGE SUMMARY FOR SOURCE FILE [S3BlobStoreContextModule.java]

nameclass, %method, %block, %line, %
S3BlobStoreContextModule.java75%  (3/4)60%  (6/10)72%  (76/105)78%  (14/18)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class S3BlobStoreContextModule$30%   (0/1)0%   (0/3)0%   (0/16)0%   (0/3)
S3BlobStoreContextModule$3 (S3BlobStoreContextModule, S3Client): void 0%   (0/1)0%   (0/9)0%   (0/1)
apply (String): AccessControlList 0%   (0/1)0%   (0/5)0%   (0/1)
toString (): String 0%   (0/1)0%   (0/2)0%   (0/1)
     
class S3BlobStoreContextModule100% (1/1)80%  (4/5)83%  (64/77)93%  (14/15)
bucketAcls (S3Client): Map 0%   (0/1)0%   (0/13)0%   (0/1)
S3BlobStoreContextModule (): void 100% (1/1)100% (3/3)100% (1/1)
bindBucketLocationStrategy (): void 100% (1/1)100% (10/10)100% (2/2)
bindContext (): void 100% (1/1)100% (11/11)100% (2/2)
configure (): void 100% (1/1)100% (40/40)100% (9/9)
     
class S3BlobStoreContextModule$1100% (1/1)100% (1/1)100% (6/6)100% (1/1)
S3BlobStoreContextModule$1 (S3BlobStoreContextModule): void 100% (1/1)100% (6/6)100% (1/1)
     
class S3BlobStoreContextModule$2100% (1/1)100% (1/1)100% (6/6)100% (1/1)
S3BlobStoreContextModule$2 (S3BlobStoreContextModule): void 100% (1/1)100% (6/6)100% (1/1)

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 */
19package org.jclouds.s3.blobstore.config;
20 
21import java.util.Map;
22import java.util.concurrent.TimeUnit;
23 
24import javax.inject.Singleton;
25 
26import org.jclouds.blobstore.AsyncBlobStore;
27import org.jclouds.blobstore.BlobRequestSigner;
28import org.jclouds.blobstore.BlobStore;
29import org.jclouds.blobstore.BlobStoreContext;
30import org.jclouds.blobstore.attr.ConsistencyModel;
31import org.jclouds.blobstore.config.BlobStoreMapModule;
32import org.jclouds.blobstore.internal.BlobStoreContextImpl;
33import org.jclouds.domain.Location;
34import org.jclouds.location.config.RegionsLocationModule;
35import org.jclouds.s3.S3AsyncClient;
36import org.jclouds.s3.S3Client;
37import org.jclouds.s3.blobstore.S3AsyncBlobStore;
38import org.jclouds.s3.blobstore.S3BlobRequestSigner;
39import org.jclouds.s3.blobstore.S3BlobStore;
40import org.jclouds.s3.blobstore.functions.LocationFromBucketLocation;
41import org.jclouds.s3.domain.AccessControlList;
42import org.jclouds.s3.domain.BucketMetadata;
43 
44import com.google.common.base.Function;
45import com.google.common.collect.MapMaker;
46import com.google.inject.AbstractModule;
47import com.google.inject.Provides;
48import com.google.inject.Scopes;
49import com.google.inject.TypeLiteral;
50 
51/**
52 * Configures the {@link S3BlobStoreContext}; requires {@link S3AsyncBlobStore} bound.
53 * 
54 * @author Adrian Cole
55 */
56public class S3BlobStoreContextModule extends AbstractModule {
57 
58   @Override
59   protected void configure() {
60      install(new BlobStoreMapModule());
61      install(new RegionsLocationModule());
62      bind(ConsistencyModel.class).toInstance(ConsistencyModel.EVENTUAL);
63      bind(AsyncBlobStore.class).to(S3AsyncBlobStore.class).in(Scopes.SINGLETON);
64      bind(BlobStore.class).to(S3BlobStore.class).in(Scopes.SINGLETON);
65      bindContext();
66      bind(BlobRequestSigner.class).to(S3BlobRequestSigner.class);
67      bindBucketLocationStrategy();
68   }
69 
70   protected void bindContext() {
71      bind(BlobStoreContext.class).to(new TypeLiteral<BlobStoreContextImpl<S3Client, S3AsyncClient>>() {
72      }).in(Scopes.SINGLETON);
73   }
74 
75   protected void bindBucketLocationStrategy() {
76      bind(new TypeLiteral<Function<BucketMetadata, Location>>() {
77      }).to(LocationFromBucketLocation.class);
78   }
79 
80   @Provides
81   @Singleton
82   protected Map<String, AccessControlList> bucketAcls(final S3Client client) {
83      return new MapMaker().expireAfterWrite(30, TimeUnit.SECONDS).makeComputingMap(
84               new Function<String, AccessControlList>() {
85                  public AccessControlList apply(String bucketName) {
86                     return client.getBucketACL(bucketName);
87                  }
88 
89                  @Override
90                  public String toString() {
91                     return "getBucketAcl()";
92                  }
93               });
94   }
95}

[all classes][org.jclouds.s3.blobstore.config]
EMMA 2.0.5312 (C) Vladimir Roubtsov