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

COVERAGE SUMMARY FOR SOURCE FILE [EC2ComputeServiceContextModule.java]

nameclass, %method, %block, %line, %
EC2ComputeServiceContextModule.java50%  (1/2)43%  (3/7)37%  (24/65)57%  (8/14)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class EC2ComputeServiceContextModule$10%   (0/1)0%   (0/2)0%   (0/13)0%   (0/2)
EC2ComputeServiceContextModule$1 (EC2ComputeServiceContextModule, RegionAndNa... 0%   (0/1)0%   (0/9)0%   (0/1)
get (): Cache 0%   (0/1)0%   (0/4)0%   (0/1)
     
class EC2ComputeServiceContextModule100% (1/1)60%  (3/5)46%  (24/52)67%  (8/12)
amiOwners (String): String [] 0%   (0/1)0%   (0/16)0%   (0/3)
provideRegionAndNameToImageSupplierCache (long, RegionAndNameToImageSupplier)... 0%   (0/1)0%   (0/12)0%   (0/1)
EC2ComputeServiceContextModule (): void 100% (1/1)100% (3/3)100% (1/1)
configure (): void 100% (1/1)100% (15/15)100% (5/5)
installDependencies (): void 100% (1/1)100% (6/6)100% (2/2)

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.ec2.compute.config;
20 
21import static com.google.common.collect.Iterables.toArray;
22import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
23import static org.jclouds.ec2.reference.EC2Constants.PROPERTY_EC2_AMI_OWNERS;
24 
25import javax.inject.Named;
26import javax.inject.Singleton;
27 
28import org.jclouds.compute.ComputeServiceContext;
29import org.jclouds.compute.config.BaseComputeServiceContextModule;
30import org.jclouds.compute.domain.Image;
31import org.jclouds.ec2.compute.EC2ComputeService;
32import org.jclouds.ec2.compute.domain.RegionAndName;
33import org.jclouds.ec2.compute.suppliers.RegionAndNameToImageSupplier;
34import org.jclouds.rest.suppliers.MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier;
35 
36import com.google.common.base.Splitter;
37import com.google.common.base.Supplier;
38import com.google.common.cache.Cache;
39import com.google.inject.Provides;
40 
41/**
42 * Configures the {@link ComputeServiceContext}; requires {@link EC2ComputeService} bound.
43 * 
44 * @author Adrian Cole
45 */
46public class EC2ComputeServiceContextModule extends BaseComputeServiceContextModule {
47   @Override
48   protected void configure() {
49      installDependencies();
50      install(new EC2BindComputeStrategiesByClass());
51      install(new EC2BindComputeSuppliersByClass());
52      super.configure();
53   }
54   
55   protected void installDependencies(){
56      install(new EC2ComputeServiceDependenciesModule());
57   }
58 
59   @Provides
60   @Singleton
61   protected Supplier<Cache<RegionAndName, ? extends Image>> provideRegionAndNameToImageSupplierCache(
62            @Named(PROPERTY_SESSION_INTERVAL) long seconds, final RegionAndNameToImageSupplier supplier) {
63      return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Cache<RegionAndName, ? extends Image>>(
64               authException, seconds, new Supplier<Cache<RegionAndName, ? extends Image>>() {
65                  @Override
66                  public Cache<RegionAndName, ? extends Image> get() {
67                     return supplier.get();
68                  }
69               });
70   }
71 
72   @Provides
73   @Singleton
74   @Named(PROPERTY_EC2_AMI_OWNERS)
75   String[] amiOwners(@Named(PROPERTY_EC2_AMI_OWNERS) String amiOwners) {
76      if (amiOwners.trim().equals(""))
77         return new String[] {};
78      return toArray(Splitter.on(',').split(amiOwners), String.class);
79   }
80 
81}
82 

[all classes][org.jclouds.ec2.compute.config]
EMMA 2.0.5312 (C) Vladimir Roubtsov