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

COVERAGE SUMMARY FOR SOURCE FILE [AzureStorageRestClientModule.java]

nameclass, %method, %block, %line, %
AzureStorageRestClientModule.java100% (2/2)100% (8/8)100% (73/73)100% (14/14)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AzureStorageRestClientModule100% (1/1)100% (6/6)100% (60/60)100% (13/13)
AzureStorageRestClientModule (Class, Class): void 100% (1/1)100% (5/5)100% (2/2)
bindErrorHandlers (): void 100% (1/1)100% (25/25)100% (4/4)
bindRetryHandlers (): void 100% (1/1)100% (9/9)100% (2/2)
configure (): void 100% (1/1)100% (8/8)100% (3/3)
provideTimeStamp (Supplier): String 100% (1/1)100% (4/4)100% (1/1)
provideTimeStampCache (long, DateService): Supplier 100% (1/1)100% (9/9)100% (1/1)
     
class AzureStorageRestClientModule$1100% (1/1)100% (2/2)100% (13/13)100% (2/2)
AzureStorageRestClientModule$1 (AzureStorageRestClientModule, DateService): void 100% (1/1)100% (9/9)100% (1/1)
get (): String 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.azure.storage.config;
20 
21import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
22 
23import java.util.concurrent.TimeUnit;
24 
25import javax.inject.Named;
26 
27import org.jclouds.azure.storage.handlers.AzureStorageClientErrorRetryHandler;
28import org.jclouds.azure.storage.handlers.ParseAzureStorageErrorFromXmlContent;
29import org.jclouds.date.DateService;
30import org.jclouds.date.TimeStamp;
31import org.jclouds.http.HttpErrorHandler;
32import org.jclouds.http.HttpRetryHandler;
33import org.jclouds.http.RequiresHttp;
34import org.jclouds.http.annotation.ClientError;
35import org.jclouds.http.annotation.Redirection;
36import org.jclouds.http.annotation.ServerError;
37import org.jclouds.rest.ConfiguresRestClient;
38import org.jclouds.rest.config.RestClientModule;
39 
40import com.google.common.base.Supplier;
41import com.google.common.base.Suppliers;
42import com.google.inject.Provides;
43 
44/**
45 * Configures the AzureStorage connection, including logging and http transport.
46 * 
47 * @author Adrian Cole
48 */
49@ConfiguresRestClient
50@RequiresHttp
51public class AzureStorageRestClientModule<S, A> extends RestClientModule<S, A> {
52 
53   public AzureStorageRestClientModule(Class<S> syncClientType, Class<A> asyncClientType) {
54      super(syncClientType, asyncClientType);
55   }
56 
57   @Provides
58   @TimeStamp
59   protected String provideTimeStamp(@TimeStamp Supplier<String> cache) {
60      return cache.get();
61   }
62 
63   /**
64    * borrowing concurrency code to ensure that caching takes place properly
65    */
66   @Provides
67   @TimeStamp
68   protected Supplier<String> provideTimeStampCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
69         final DateService dateService) {
70      return Suppliers.memoizeWithExpiration(new Supplier<String>() {
71         public String get() {
72            return dateService.rfc822DateFormat();
73         }
74      }, seconds, TimeUnit.SECONDS);
75   }
76 
77   @Override
78   protected void bindErrorHandlers() {
79      bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(ParseAzureStorageErrorFromXmlContent.class);
80      bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(ParseAzureStorageErrorFromXmlContent.class);
81      bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(ParseAzureStorageErrorFromXmlContent.class);
82   }
83 
84   @Override
85   protected void bindRetryHandlers() {
86      bind(HttpRetryHandler.class).annotatedWith(ClientError.class).to(AzureStorageClientErrorRetryHandler.class);
87   }
88 
89   @Override
90   protected void configure() {
91      install(new AzureStorageParserModule());
92      super.configure();
93   }
94 
95}

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