EMMA Coverage Report (generated Wed Jun 22 19:47:49 EDT 2011)
[all classes][org.jclouds.byon.config]

COVERAGE SUMMARY FOR SOURCE FILE [YamlNodeStoreModule.java]

nameclass, %method, %block, %line, %
YamlNodeStoreModule.java100% (9/9)100% (14/14)100% (143/143)100% (18/18)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class YamlNodeStoreModule100% (1/1)100% (6/6)100% (95/95)100% (17/17)
<static initializer> 100% (1/1)100% (5/5)100% (1/1)
YamlNodeStoreModule (): void 100% (1/1)100% (4/4)100% (2/2)
YamlNodeStoreModule (Map): void 100% (1/1)100% (6/6)100% (3/3)
configure (): void 100% (1/1)100% (66/66)100% (9/9)
provideNodeStore (Map, Function, Function): Map 100% (1/1)100% (7/7)100% (1/1)
provideYamlStore (Map, Function, Function): Map 100% (1/1)100% (7/7)100% (1/1)
     
class YamlNodeStoreModule$1100% (1/1)100% (1/1)100% (6/6)100% (1/1)
YamlNodeStoreModule$1 (YamlNodeStoreModule): void 100% (1/1)100% (6/6)100% (1/1)
     
class YamlNodeStoreModule$2100% (1/1)100% (1/1)100% (6/6)100% (1/1)
YamlNodeStoreModule$2 (YamlNodeStoreModule): void 100% (1/1)100% (6/6)100% (1/1)
     
class YamlNodeStoreModule$3100% (1/1)100% (1/1)100% (6/6)100% (1/1)
YamlNodeStoreModule$3 (YamlNodeStoreModule): void 100% (1/1)100% (6/6)100% (1/1)
     
class YamlNodeStoreModule$4100% (1/1)100% (1/1)100% (6/6)100% (1/1)
YamlNodeStoreModule$4 (YamlNodeStoreModule): void 100% (1/1)100% (6/6)100% (1/1)
     
class YamlNodeStoreModule$5100% (1/1)100% (1/1)100% (6/6)100% (1/1)
YamlNodeStoreModule$5 (YamlNodeStoreModule): void 100% (1/1)100% (6/6)100% (1/1)
     
class YamlNodeStoreModule$6100% (1/1)100% (1/1)100% (6/6)100% (1/1)
YamlNodeStoreModule$6 (YamlNodeStoreModule): void 100% (1/1)100% (6/6)100% (1/1)
     
class YamlNodeStoreModule$7100% (1/1)100% (1/1)100% (6/6)100% (1/1)
YamlNodeStoreModule$7 (YamlNodeStoreModule): void 100% (1/1)100% (6/6)100% (1/1)
     
class YamlNodeStoreModule$8100% (1/1)100% (1/1)100% (6/6)100% (1/1)
YamlNodeStoreModule$8 (YamlNodeStoreModule): void 100% (1/1)100% (6/6)100% (1/1)

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.byon.config;
20 
21import java.io.InputStream;
22import java.util.Map;
23import java.util.concurrent.ConcurrentHashMap;
24 
25import javax.inject.Singleton;
26 
27import org.jclouds.byon.Node;
28import org.jclouds.byon.domain.YamlNode;
29import org.jclouds.collect.TransformingMap;
30import org.jclouds.io.CopyInputStreamInputSupplierMap;
31 
32import com.google.common.annotations.Beta;
33import com.google.common.base.Function;
34import com.google.common.io.InputSupplier;
35import com.google.inject.AbstractModule;
36import com.google.inject.Provides;
37import com.google.inject.TypeLiteral;
38 
39/**
40 * 
41 * @author Adrian Cole
42 */
43@ConfiguresNodeStore
44@Beta
45public class YamlNodeStoreModule extends AbstractModule {
46   private static final Map<String, InputSupplier<InputStream>> BACKING = new ConcurrentHashMap<String, InputSupplier<InputStream>>();
47   private final Map<String, InputStream> backing;
48 
49   public YamlNodeStoreModule(Map<String, InputStream> backing) {
50      this.backing = backing;
51   }
52 
53   public YamlNodeStoreModule() {
54      this(null);
55   }
56 
57   @Override
58   protected void configure() {
59      bind(new TypeLiteral<Function<YamlNode, InputStream>>() {
60      }).toInstance(org.jclouds.byon.domain.YamlNode.yamlNodeToInputStream);
61      bind(new TypeLiteral<Function<InputStream, YamlNode>>() {
62      }).toInstance(org.jclouds.byon.domain.YamlNode.inputStreamToYamlNode);
63      bind(new TypeLiteral<Function<Node, YamlNode>>() {
64      }).toInstance(org.jclouds.byon.domain.YamlNode.nodeToYamlNode);
65      bind(new TypeLiteral<Function<YamlNode, Node>>() {
66      }).toInstance(org.jclouds.byon.domain.YamlNode.toNode);
67      if (backing != null) {
68         bind(new TypeLiteral<Map<String, InputStream>>() {
69         }).toInstance(backing);
70      } else {
71         bind(new TypeLiteral<Map<String, InputSupplier<InputStream>>>() {
72         }).toInstance(BACKING);
73         bind(new TypeLiteral<Map<String, InputStream>>() {
74         }).to(new TypeLiteral<CopyInputStreamInputSupplierMap>() {
75         });
76      }
77   }
78 
79   @Provides
80   @Singleton
81   protected Map<String, Node> provideNodeStore(Map<String, YamlNode> backing,
82            Function<Node, YamlNode> yamlSerializer, Function<YamlNode, Node> yamlDeserializer) {
83      return new TransformingMap<String, YamlNode, Node>(backing, yamlDeserializer, yamlSerializer);
84   }
85 
86   @Provides
87   @Singleton
88   protected Map<String, YamlNode> provideYamlStore(Map<String, InputStream> backing,
89            Function<YamlNode, InputStream> yamlSerializer, Function<InputStream, YamlNode> yamlDeserializer) {
90      return new TransformingMap<String, InputStream, YamlNode>(backing, yamlDeserializer, yamlSerializer);
91   }
92}

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