EMMA Coverage Report (generated Wed Oct 26 13:47:17 EDT 2011)
[all classes][org.jclouds.compute.config]

COVERAGE SUMMARY FOR SOURCE FILE [ComputeServiceAdapterContextModule.java]

nameclass, %method, %block, %line, %
ComputeServiceAdapterContextModule.java100% (5/5)95%  (18/19)97%  (121/125)95%  (19/20)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ComputeServiceAdapterContextModule$3100% (1/1)50%  (1/2)69%  (9/13)50%  (1/2)
get (): Iterable 0%   (0/1)0%   (0/4)0%   (0/1)
ComputeServiceAdapterContextModule$3 (ComputeServiceAdapterContextModule, Com... 100% (1/1)100% (9/9)100% (1/1)
     
class ComputeServiceAdapterContextModule100% (1/1)100% (12/12)100% (80/80)100% (17/17)
ComputeServiceAdapterContextModule (Class, Class): void 100% (1/1)100% (9/9)100% (4/4)
configure (): void 100% (1/1)100% (27/27)100% (3/3)
defineAddNodeWithTagStrategy (AdaptingComputeServiceStrategies): CreateNodeWi... 100% (1/1)100% (2/2)100% (1/1)
defineDestroyNodeStrategy (AdaptingComputeServiceStrategies): DestroyNodeStra... 100% (1/1)100% (2/2)100% (1/1)
defineGetNodeMetadataStrategy (AdaptingComputeServiceStrategies): GetNodeMeta... 100% (1/1)100% (2/2)100% (1/1)
defineListNodesStrategy (AdaptingComputeServiceStrategies): ListNodesStrategy 100% (1/1)100% (2/2)100% (1/1)
defineRebootNodeStrategy (AdaptingComputeServiceStrategies): RebootNodeStrategy 100% (1/1)100% (2/2)100% (1/1)
defineStartNodeStrategy (AdaptingComputeServiceStrategies): ResumeNodeStrategy 100% (1/1)100% (2/2)100% (1/1)
defineStopNodeStrategy (AdaptingComputeServiceStrategies): SuspendNodeStrategy 100% (1/1)100% (2/2)100% (1/1)
provideHardware (ComputeServiceAdapter, Function): Supplier 100% (1/1)100% (10/10)100% (1/1)
provideImages (ComputeServiceAdapter, Function): Supplier 100% (1/1)100% (10/10)100% (1/1)
provideLocations (ComputeServiceAdapter, Function): Supplier 100% (1/1)100% (10/10)100% (1/1)
     
class ComputeServiceAdapterContextModule$1100% (1/1)100% (1/1)100% (6/6)100% (1/1)
ComputeServiceAdapterContextModule$1 (ComputeServiceAdapterContextModule): void 100% (1/1)100% (6/6)100% (1/1)
     
class ComputeServiceAdapterContextModule$2100% (1/1)100% (2/2)100% (13/13)100% (2/2)
ComputeServiceAdapterContextModule$2 (ComputeServiceAdapterContextModule, Com... 100% (1/1)100% (9/9)100% (1/1)
get (): Iterable 100% (1/1)100% (4/4)100% (1/1)
     
class ComputeServiceAdapterContextModule$4100% (1/1)100% (2/2)100% (13/13)100% (2/2)
ComputeServiceAdapterContextModule$4 (ComputeServiceAdapterContextModule, Com... 100% (1/1)100% (9/9)100% (1/1)
get (): Iterable 100% (1/1)100% (4/4)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.compute.config;
20 
21import java.util.Set;
22 
23import javax.inject.Singleton;
24 
25import org.jclouds.collect.TransformingSetSupplier;
26import org.jclouds.compute.ComputeServiceAdapter;
27import org.jclouds.compute.ComputeServiceContext;
28import org.jclouds.compute.domain.Hardware;
29import org.jclouds.compute.domain.Image;
30import org.jclouds.compute.internal.ComputeServiceContextImpl;
31import org.jclouds.compute.strategy.CreateNodeWithGroupEncodedIntoName;
32import org.jclouds.compute.strategy.DestroyNodeStrategy;
33import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
34import org.jclouds.compute.strategy.ListNodesStrategy;
35import org.jclouds.compute.strategy.RebootNodeStrategy;
36import org.jclouds.compute.strategy.ResumeNodeStrategy;
37import org.jclouds.compute.strategy.SuspendNodeStrategy;
38import org.jclouds.compute.strategy.impl.AdaptingComputeServiceStrategies;
39import org.jclouds.domain.Location;
40 
41import com.google.common.base.Function;
42import com.google.common.base.Supplier;
43import com.google.inject.Provides;
44import com.google.inject.Scopes;
45import com.google.inject.TypeLiteral;
46import com.google.inject.util.Types;
47 
48/**
49 * 
50 * @author Adrian Cole
51 */
52public class ComputeServiceAdapterContextModule<S, A, N, H, I, L> extends BaseComputeServiceContextModule {
53 
54   private Class<A> asyncClientType;
55   private Class<S> syncClientType;
56 
57   public ComputeServiceAdapterContextModule(Class<S> syncClientType, Class<A> asyncClientType) {
58      this.syncClientType = syncClientType;
59      this.asyncClientType = asyncClientType;
60   }
61 
62   @SuppressWarnings( { "unchecked", "rawtypes" })
63   @Override
64   protected void configure() {
65      super.configure();
66      bind(new TypeLiteral<ComputeServiceContext>() {
67      }).to(
68               (TypeLiteral) TypeLiteral.get(Types.newParameterizedType(ComputeServiceContextImpl.class,
69                        syncClientType, asyncClientType))).in(Scopes.SINGLETON);
70   }
71 
72   @Provides
73   @Singleton
74   protected Supplier<Set<? extends Location>> provideLocations(final ComputeServiceAdapter<N, H, I, L> adapter,
75            Function<L, Location> transformer) {
76      return new TransformingSetSupplier<L, Location>(new Supplier<Iterable<L>>() {
77 
78         @Override
79         public Iterable<L> get() {
80            return adapter.listLocations();
81         }
82 
83      }, transformer);
84   }
85 
86   @Provides
87   @Singleton
88   protected Supplier<Set<? extends Hardware>> provideHardware(final ComputeServiceAdapter<N, H, I, L> adapter,
89            Function<H, Hardware> transformer) {
90      return new TransformingSetSupplier<H, Hardware>(new Supplier<Iterable<H>>() {
91 
92         @Override
93         public Iterable<H> get() {
94            return adapter.listHardwareProfiles();
95         }
96 
97      }, transformer);
98   }
99 
100   @Provides
101   @Singleton
102   protected Supplier<Set<? extends Image>> provideImages(final ComputeServiceAdapter<N, H, I, L> adapter,
103            Function<I, Image> transformer) {
104      return new TransformingSetSupplier<I, Image>(new Supplier<Iterable<I>>() {
105 
106         @Override
107         public Iterable<I> get() {
108            return adapter.listImages();
109         }
110 
111      }, transformer);
112   }
113 
114   @Provides
115   @Singleton
116   protected CreateNodeWithGroupEncodedIntoName defineAddNodeWithTagStrategy(AdaptingComputeServiceStrategies<N, H, I, L> in) {
117      return in;
118   }
119 
120   @Provides
121   @Singleton
122   protected DestroyNodeStrategy defineDestroyNodeStrategy(AdaptingComputeServiceStrategies<N, H, I, L> in) {
123      return in;
124   }
125 
126   @Provides
127   @Singleton
128   protected GetNodeMetadataStrategy defineGetNodeMetadataStrategy(AdaptingComputeServiceStrategies<N, H, I, L> in) {
129      return in;
130   }
131 
132   @Provides
133   @Singleton
134   protected ListNodesStrategy defineListNodesStrategy(AdaptingComputeServiceStrategies<N, H, I, L> in) {
135      return in;
136   }
137 
138   @Provides
139   @Singleton
140   protected RebootNodeStrategy defineRebootNodeStrategy(AdaptingComputeServiceStrategies<N, H, I, L> in) {
141      return in;
142   }
143 
144   @Provides
145   @Singleton
146   protected ResumeNodeStrategy defineStartNodeStrategy(AdaptingComputeServiceStrategies<N, H, I, L> in) {
147      return in;
148   }
149 
150   @Provides
151   @Singleton
152   protected SuspendNodeStrategy defineStopNodeStrategy(AdaptingComputeServiceStrategies<N, H, I, L> in) {
153      return in;
154   }
155}

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