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

COVERAGE SUMMARY FOR SOURCE FILE [BlobStoreContextFactory.java]

nameclass, %method, %block, %line, %
BlobStoreContextFactory.java100% (1/1)36%  (4/11)25%  (28/113)33%  (8/24)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class BlobStoreContextFactory100% (1/1)36%  (4/11)25%  (28/113)33%  (8/24)
BlobStoreContextFactory (Properties): void 0%   (0/1)0%   (0/7)0%   (0/2)
createContext (RestContextSpec): BlobStoreContext 0%   (0/1)0%   (0/9)0%   (0/2)
createContext (RestContextSpec, Properties): BlobStoreContext 0%   (0/1)0%   (0/10)0%   (0/2)
createContext (String, Iterable, Properties): BlobStoreContext 0%   (0/1)0%   (0/13)0%   (0/2)
createContext (String, Properties): BlobStoreContext 0%   (0/1)0%   (0/12)0%   (0/2)
createContext (String, String, String, Iterable): BlobStoreContext 0%   (0/1)0%   (0/14)0%   (0/2)
createContext (String, String, String, Iterable, Properties): BlobStoreContext 0%   (0/1)0%   (0/15)0%   (0/2)
buildContextUnwrappingExceptions (BlobStoreContextBuilder): BlobStoreContext 100% (1/1)38%  (3/8)33%  (1/3)
BlobStoreContextFactory (): void 100% (1/1)100% (6/6)100% (2/2)
BlobStoreContextFactory (RestContextFactory): void 100% (1/1)100% (6/6)100% (3/3)
createContext (String, String, String): BlobStoreContext 100% (1/1)100% (13/13)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.blobstore;
20 
21import static org.jclouds.rest.RestContextFactory.createContextBuilder;
22import static org.jclouds.util.Throwables2.propagateAuthorizationOrOriginalException;
23 
24import java.util.Properties;
25 
26import org.jclouds.javax.annotation.Nullable;
27 
28import org.jclouds.rest.RestContextFactory;
29import org.jclouds.rest.RestContextSpec;
30 
31import com.google.inject.Module;
32 
33/**
34 * Helper class to instantiate {@code BlobStoreContext} instances.
35 * 
36 * @author Adrian Cole
37 */
38public class BlobStoreContextFactory {
39 
40   private final RestContextFactory contextFactory;
41 
42   /**
43    * Initializes with the default properties built-in to jclouds. This is
44    * typically stored in the classpath resource {@code rest.properties}
45    * 
46    * @see RestContextFactory#getPropertiesFromResource
47    */
48   public BlobStoreContextFactory() {
49      this(new RestContextFactory());
50   }
51 
52   /**
53    * Finds definitions in the specified properties.
54    */
55   public BlobStoreContextFactory(Properties properties) {
56      this(new RestContextFactory(properties));
57   }
58 
59   /**
60    * 
61    * Uses the supplied RestContextFactory to create {@link BlobStoreContext}s
62    */
63   public BlobStoreContextFactory(RestContextFactory restContextFactory) {
64      this.contextFactory = restContextFactory;
65   }
66 
67   public static <S, A> BlobStoreContext buildContextUnwrappingExceptions(BlobStoreContextBuilder<S, A> builder) {
68      try {
69         return builder.buildBlobStoreContext();
70      } catch (Exception e) {
71         return propagateAuthorizationOrOriginalException(e);
72      }
73   }
74 
75   /**
76    * @see RestContextFactory#createContextBuilder(String, String, String)
77    */
78   public BlobStoreContext createContext(String provider, String identity, String credential) {
79      BlobStoreContextBuilder<?, ?> builder = BlobStoreContextBuilder.class.cast(contextFactory.createContextBuilder(
80            provider, identity, credential));
81      return buildContextUnwrappingExceptions(builder);
82   }
83 
84   /**
85    * @see RestContextFactory#createContextBuilder(String, Properties)
86    */
87   public BlobStoreContext createContext(String provider, Properties overrides) {
88      BlobStoreContextBuilder<?, ?> builder = BlobStoreContextBuilder.class.cast(contextFactory.createContextBuilder(
89            provider, overrides));
90      return buildContextUnwrappingExceptions(builder);
91   }
92 
93   /**
94    * @see RestContextFactory#createContextBuilder(String, Iterable)
95    */
96   public BlobStoreContext createContext(String provider, Iterable<? extends Module> modules, Properties overrides) {
97      BlobStoreContextBuilder<?, ?> builder = BlobStoreContextBuilder.class.cast(contextFactory.createContextBuilder(
98            provider, modules, overrides));
99      return buildContextUnwrappingExceptions(builder);
100 
101   }
102 
103   /**
104    * @see RestContextFactory#createContextBuilder(String, String,String,
105    *      Iterable)
106    */
107   public BlobStoreContext createContext(String provider, @Nullable String identity, @Nullable String credential,
108         Iterable<? extends Module> modules) {
109      BlobStoreContextBuilder<?, ?> builder = BlobStoreContextBuilder.class.cast(contextFactory.createContextBuilder(
110            provider, identity, credential, modules));
111      return buildContextUnwrappingExceptions(builder);
112   }
113 
114   /**
115    * @see RestContextFactory#createContextBuilder(String, String,String,
116    *      Iterable, Properties)
117    */
118   public BlobStoreContext createContext(String provider, @Nullable String identity, @Nullable String credential,
119         Iterable<? extends Module> modules, Properties overrides) {
120      BlobStoreContextBuilder<?, ?> builder = BlobStoreContextBuilder.class.cast(contextFactory.createContextBuilder(
121            provider, identity, credential, modules, overrides));
122      return buildContextUnwrappingExceptions(builder);
123   }
124 
125   /**
126    * @see RestContextFactory#createContextBuilder(RestContextSpec)
127    */
128   public <S, A> BlobStoreContext createContext(RestContextSpec<S, A> contextSpec) {
129      BlobStoreContextBuilder<?, ?> builder = BlobStoreContextBuilder.class.cast(createContextBuilder(contextSpec));
130      return buildContextUnwrappingExceptions(builder);
131 
132   }
133 
134   /**
135    * @see RestContextFactory#createContextBuilder(RestContextSpec, Properties)
136    */
137   public <S, A> BlobStoreContext createContext(RestContextSpec<S, A> contextSpec, Properties overrides) {
138      BlobStoreContextBuilder<?, ?> builder = BlobStoreContextBuilder.class.cast(createContextBuilder(contextSpec,
139            overrides));
140      return buildContextUnwrappingExceptions(builder);
141   }
142}

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