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

COVERAGE SUMMARY FOR SOURCE FILE [BaseVCloudExpressRestClientModule.java]

nameclass, %method, %block, %line, %
BaseVCloudExpressRestClientModule.java75%  (3/4)56%  (5/9)43%  (37/87)50%  (7/14)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class BaseVCloudExpressRestClientModule$30%   (0/1)0%   (0/3)0%   (0/38)0%   (0/6)
<static initializer> 0%   (0/1)0%   (0/8)0%   (0/1)
BaseVCloudExpressRestClientModule$3 (BaseVCloudExpressRestClientModule, VClou... 0%   (0/1)0%   (0/9)0%   (0/1)
get (): VCloudSession 0%   (0/1)0%   (0/21)0%   (0/5)
     
class BaseVCloudExpressRestClientModule100% (1/1)75%  (3/4)68%  (25/37)86%  (6/7)
provideVCloudTokenCache (long, VCloudExpressLoginAsyncClient): Supplier 0%   (0/1)0%   (0/12)0%   (0/1)
BaseVCloudExpressRestClientModule (Class, Class): void 100% (1/1)100% (5/5)100% (2/2)
configure (): void 100% (1/1)100% (15/15)100% (3/3)
provideVCloudLogin (AsyncClientFactory): VCloudExpressLoginAsyncClient 100% (1/1)100% (5/5)100% (1/1)
     
class BaseVCloudExpressRestClientModule$1100% (1/1)100% (1/1)100% (6/6)100% (1/1)
BaseVCloudExpressRestClientModule$1 (BaseVCloudExpressRestClientModule): void 100% (1/1)100% (6/6)100% (1/1)
     
class BaseVCloudExpressRestClientModule$2100% (1/1)100% (1/1)100% (6/6)100% (1/1)
BaseVCloudExpressRestClientModule$2 (BaseVCloudExpressRestClientModule): 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.vcloud.config;
20 
21import static com.google.common.base.Throwables.propagate;
22import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
23 
24import java.util.concurrent.TimeUnit;
25 
26import javax.inject.Named;
27import javax.inject.Singleton;
28 
29import org.jclouds.http.RequiresHttp;
30import org.jclouds.rest.AsyncClientFactory;
31import org.jclouds.rest.ConfiguresRestClient;
32import org.jclouds.rest.suppliers.MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier;
33import org.jclouds.vcloud.VCloudExpressAsyncClient;
34import org.jclouds.vcloud.VCloudExpressClient;
35import org.jclouds.vcloud.VCloudExpressLoginAsyncClient;
36import org.jclouds.vcloud.domain.CatalogItem;
37import org.jclouds.vcloud.domain.VCloudExpressVAppTemplate;
38import org.jclouds.vcloud.domain.VCloudSession;
39import org.jclouds.vcloud.functions.VCloudExpressVAppTemplatesForCatalogItems;
40 
41import com.google.common.base.Function;
42import com.google.common.base.Supplier;
43import com.google.inject.Provides;
44import com.google.inject.TypeLiteral;
45 
46 
47/**
48 * Configures the VCloud authentication service connection, including logging
49 * and http transport.
50 * 
51 * @author Adrian Cole
52 */
53@RequiresHttp
54@ConfiguresRestClient
55public abstract class BaseVCloudExpressRestClientModule<S extends VCloudExpressClient, A extends VCloudExpressAsyncClient>
56      extends CommonVCloudRestClientModule<S, A> {
57 
58   public BaseVCloudExpressRestClientModule(Class<S> syncClientType, Class<A> asyncClientType) {
59      super(syncClientType, asyncClientType);
60   }
61 
62   @Override
63   protected void configure() {
64      bind(new TypeLiteral<Function<Iterable<? extends CatalogItem>, Iterable<? extends VCloudExpressVAppTemplate>>>() {
65      }).to(new TypeLiteral<VCloudExpressVAppTemplatesForCatalogItems>() {
66      });
67      super.configure();
68   }
69 
70   @Provides
71   @Singleton
72   protected VCloudExpressLoginAsyncClient provideVCloudLogin(AsyncClientFactory factory) {
73      return factory.create(VCloudExpressLoginAsyncClient.class);
74   }
75 
76   @Provides
77   @Singleton
78   protected Supplier<VCloudSession> provideVCloudTokenCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
79         final VCloudExpressLoginAsyncClient login) {
80      return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier<VCloudSession>(authException, seconds,
81            new Supplier<VCloudSession>() {
82 
83               @Override
84               public VCloudSession get() {
85                  try {
86                     return login.login().get(10, TimeUnit.SECONDS);
87                  } catch (Exception e) {
88                     propagate(e);
89                     assert false : e;
90                     return null;
91                  }
92               }
93 
94            });
95   }
96 
97}

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