EMMA Coverage Report (generated Fri Apr 27 15:03:37 EDT 2012)
[all classes][org.jclouds.ec2]

COVERAGE SUMMARY FOR SOURCE FILE [EC2ApiMetadata.java]

nameclass, %method, %block, %line, %
EC2ApiMetadata.java100% (3/3)100% (9/9)100% (108/108)100% (20/20)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class EC2ApiMetadata100% (1/1)100% (5/5)100% (61/61)100% (14/14)
<static initializer> 100% (1/1)100% (5/5)100% (1/1)
EC2ApiMetadata (): void 100% (1/1)100% (8/8)100% (2/2)
EC2ApiMetadata (EC2ApiMetadata$Builder): void 100% (1/1)100% (4/4)100% (2/2)
defaultProperties (): Properties 100% (1/1)100% (34/34)100% (8/8)
toBuilder (): EC2ApiMetadata$Builder 100% (1/1)100% (10/10)100% (1/1)
     
class EC2ApiMetadata$1100% (1/1)100% (1/1)100% (3/3)100% (1/1)
EC2ApiMetadata$1 (): void 100% (1/1)100% (3/3)100% (1/1)
     
class EC2ApiMetadata$Builder100% (1/1)100% (3/3)100% (44/44)100% (6/6)
EC2ApiMetadata$Builder (Class, Class): void 100% (1/1)100% (33/33)100% (3/3)
build (): ApiMetadata 100% (1/1)100% (5/5)100% (1/1)
fromApiMetadata (ApiMetadata): EC2ApiMetadata$Builder 100% (1/1)100% (6/6)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.ec2;
20 
21import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AUTH_TAG;
22import static org.jclouds.aws.reference.AWSConstants.PROPERTY_HEADER_TAG;
23import static org.jclouds.compute.config.ComputeServiceProperties.RESOURCENAME_DELIMITER;
24import static org.jclouds.ec2.reference.EC2Constants.PROPERTY_EC2_AMI_OWNERS;
25import static org.jclouds.ec2.reference.EC2Constants.PROPERTY_EC2_AUTO_ALLOCATE_ELASTIC_IPS;
26import static org.jclouds.ec2.reference.EC2Constants.PROPERTY_EC2_TIMEOUT_SECURITYGROUP_PRESENT;
27 
28import java.net.URI;
29import java.util.Properties;
30 
31import org.jclouds.apis.ApiMetadata;
32import org.jclouds.ec2.compute.EC2ComputeServiceContext;
33import org.jclouds.ec2.compute.config.EC2ComputeServiceContextModule;
34import org.jclouds.ec2.compute.config.EC2ResolveImagesModule;
35import org.jclouds.ec2.config.EC2RestClientModule;
36import org.jclouds.rest.RestContext;
37import org.jclouds.rest.internal.BaseRestApiMetadata;
38 
39import com.google.common.collect.ImmutableSet;
40import com.google.common.reflect.TypeToken;
41import com.google.inject.Module;
42 
43/**
44 * Implementation of {@link ApiMetadata} for Amazon's EC2 api.
45 * 
46 * <h3>note</h3>
47 * <p/>
48 * This class allows overriding of types {@code S}(client) and {@code A}
49 * (asyncClient), so that children can add additional methods not declared here,
50 * such as new features from AWS.
51 * <p/>
52 * 
53 * As this is a popular api, we also allow overrides for type {@code C}
54 * (context). This allows subtypes to add in new feature groups or extensions,
55 * not present in the base api. For example, you could make a subtype for
56 * context, that exposes admin operations.
57 * 
58 * @author Adrian Cole
59 */
60public class EC2ApiMetadata extends BaseRestApiMetadata {
61 
62   /** The serialVersionUID */
63   private static final long serialVersionUID = 4424763314988423886L;
64   
65   public static final TypeToken<RestContext<? extends EC2Client, ? extends EC2AsyncClient>> CONTEXT_TOKEN = new TypeToken<RestContext<? extends EC2Client, ? extends EC2AsyncClient>>() {
66      private static final long serialVersionUID = -5070937833892503232L;
67   };
68 
69   @Override
70   public Builder toBuilder() {
71      return (Builder) new Builder(getApi(), getAsyncApi()).fromApiMetadata(this);
72   }
73 
74   public EC2ApiMetadata() {
75      this(new Builder(EC2Client.class, EC2AsyncClient.class));
76   }
77 
78   protected EC2ApiMetadata(Builder builder) {
79      super(builder);
80   }
81 
82   public static Properties defaultProperties() {
83      Properties properties = BaseRestApiMetadata.defaultProperties();
84      properties.setProperty(PROPERTY_AUTH_TAG, "AWS");
85      properties.setProperty(PROPERTY_HEADER_TAG, "amz");
86      properties.setProperty(PROPERTY_EC2_AMI_OWNERS, "*");
87      properties.setProperty(PROPERTY_EC2_TIMEOUT_SECURITYGROUP_PRESENT, "500");
88      properties.setProperty(PROPERTY_EC2_AUTO_ALLOCATE_ELASTIC_IPS, "false");
89      properties.setProperty(RESOURCENAME_DELIMITER, "#");
90      return properties;
91   }
92 
93   public static class Builder
94         extends BaseRestApiMetadata.Builder {
95 
96      protected Builder(Class<?> syncClient, Class<?> asyncClient) {
97         super(syncClient, asyncClient);
98         id("ec2")
99         .name("Amazon Elastic Compute Cloud (EC2) API")
100         .identityName("Access Key ID")
101         .credentialName("Secret Access Key")
102         .defaultEndpoint("https://ec2.us-east-1.amazonaws.com")
103         .documentation(URI.create("http://docs.amazonwebservices.com/AWSEC2/latest/APIReference"))
104         .version(EC2AsyncClient.VERSION)
105         .defaultProperties(EC2ApiMetadata.defaultProperties())
106         .context(CONTEXT_TOKEN)
107         .view(EC2ComputeServiceContext.class)
108         .defaultModules(ImmutableSet.<Class<? extends Module>>of(EC2RestClientModule.class, EC2ResolveImagesModule.class, EC2ComputeServiceContextModule.class));
109      }
110 
111      @Override
112      public ApiMetadata build() {
113         return new EC2ApiMetadata(this);
114      }
115 
116      @Override
117      public Builder fromApiMetadata(ApiMetadata in) {
118         super.fromApiMetadata(in);
119         return this;
120      }
121 
122   }
123 
124}

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