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

COVERAGE SUMMARY FOR SOURCE FILE [AtmosRestClientModule.java]

nameclass, %method, %block, %line, %
AtmosRestClientModule.java100% (2/2)67%  (6/9)80%  (70/88)81%  (13/16)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AtmosRestClientModule$1100% (1/1)50%  (1/2)69%  (9/13)50%  (1/2)
get (): String 0%   (0/1)0%   (0/4)0%   (0/1)
AtmosRestClientModule$1 (AtmosRestClientModule, DateService): void 100% (1/1)100% (9/9)100% (1/1)
     
class AtmosRestClientModule100% (1/1)71%  (5/7)81%  (61/75)87%  (13/15)
provideShareableUrlTimeout (): Long 0%   (0/1)0%   (0/10)0%   (0/1)
provideTimeStamp (Supplier): String 0%   (0/1)0%   (0/4)0%   (0/1)
AtmosRestClientModule (): 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% (13/13)100% (4/4)
provideTimeStampCache (long, DateService): Supplier 100% (1/1)100% (9/9)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.atmos.config;
20 
21import java.util.Date;
22import java.util.concurrent.TimeUnit;
23 
24import javax.inject.Named;
25 
26import org.jclouds.Constants;
27import org.jclouds.atmos.AtmosAsyncClient;
28import org.jclouds.atmos.AtmosClient;
29import org.jclouds.atmos.handlers.AtmosClientErrorRetryHandler;
30import org.jclouds.atmos.handlers.ParseAtmosErrorFromXmlContent;
31import org.jclouds.date.DateService;
32import org.jclouds.date.TimeStamp;
33import org.jclouds.http.HttpErrorHandler;
34import org.jclouds.http.HttpRetryHandler;
35import org.jclouds.http.RequiresHttp;
36import org.jclouds.http.annotation.ClientError;
37import org.jclouds.http.annotation.Redirection;
38import org.jclouds.http.annotation.ServerError;
39import org.jclouds.rest.ConfiguresRestClient;
40import org.jclouds.rest.config.RestClientModule;
41 
42import com.google.common.base.Supplier;
43import com.google.common.base.Suppliers;
44import com.google.inject.Provides;
45 
46/**
47 * Configures the EMC Atmos Online Storage authentication service connection, including logging and
48 * http transport.
49 * 
50 * @author Adrian Cole
51 */
52@ConfiguresRestClient
53@RequiresHttp
54public class AtmosRestClientModule extends RestClientModule<AtmosClient, AtmosAsyncClient> {
55   public AtmosRestClientModule() {
56      super(AtmosClient.class, AtmosAsyncClient.class);
57   }
58 
59   @Override
60   protected void configure() {
61      install(new AtmosParserModule());
62      install(new AtmosObjectModule());
63      super.configure();
64   }
65 
66   @Provides
67   @TimeStamp
68   protected String provideTimeStamp(@TimeStamp Supplier<String> cache) {
69      return cache.get();
70   }
71 
72   /**
73    * borrowing concurrency code to ensure that caching takes place properly
74    */
75   @Provides
76   @TimeStamp
77   Supplier<String> provideTimeStampCache(@Named(Constants.PROPERTY_SESSION_INTERVAL) long seconds,
78            final DateService dateService) {
79      return Suppliers.memoizeWithExpiration(new Supplier<String>() {
80         public String get() {
81            return dateService.rfc822DateFormat();
82         }
83      }, seconds, TimeUnit.SECONDS);
84   }
85 
86   @Provides
87   @TimeStamp
88   protected Long provideShareableUrlTimeout() {
89      return new Date().getTime() + TimeUnit.HOURS.toMillis(1);
90   }
91 
92   @Override
93   protected void bindErrorHandlers() {
94      bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(ParseAtmosErrorFromXmlContent.class);
95      bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(ParseAtmosErrorFromXmlContent.class);
96      bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(ParseAtmosErrorFromXmlContent.class);
97   }
98 
99   @Override
100   protected void bindRetryHandlers() {
101      bind(HttpRetryHandler.class).annotatedWith(ClientError.class).to(AtmosClientErrorRetryHandler.class);
102   }
103 
104}

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