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

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