java.util.Mapcom.google.common.cache.Cache



Project jclouds/jclouds in file ...uds.aws.ec2.compute.AWSEC2TemplateBuilderImpl.java (2011-09-22)
@@ -18,7 +18,6 @@
  */
 package org.jclouds.aws.ec2.compute;
 
-import java.util.Map;
 import java.util.Set;
 
 import javax.inject.Inject;
@@ -35,6 +34,7 @@ import org.jclouds.ec2.compute.domain.RegionAndName;
 import org.jclouds.ec2.compute.internal.EC2TemplateBuilderImpl;
 
 import com.google.common.base.Supplier;
+import com.google.common.cache.Cache;
 
 /**
  * 
@@ -46,7 +46,7 @@ public class AWSEC2TemplateBuilderImpl extends EC2TemplateBuilderImpl {
    protected AWSEC2TemplateBuilderImpl(@Memoized Supplier<Set<? extends Location>> locations,
          @Memoized Supplier<Set<? extends Image>> images, @Memoized Supplier<Set<? extends Hardware>> sizes,
          Supplier<Location> defaultLocation, @Named("DEFAULT") Provider<TemplateOptions> optionsProvider,
-         @Named("DEFAULT") Provider<TemplateBuilder> defaultTemplateProvider, Map<RegionAndName, Image> imageMap) {
+         @Named("DEFAULT") Provider<TemplateBuilder> defaultTemplateProvider, Supplier<Cache<RegionAndName, ? extends Image>> imageMap) {
       super(locations, images, sizes, defaultLocation, optionsProvider, defaultTemplateProvider, imageMap);
    }
 
Project jclouds/legacy-jclouds in file ...uds.aws.ec2.compute.AWSEC2TemplateBuilderImpl.java (2011-09-22)
@@ -18,7 +18,6 @@
  */
 package org.jclouds.aws.ec2.compute;
 
-import java.util.Map;
 import java.util.Set;
 
 import javax.inject.Inject;
@@ -35,6 +34,7 @@ import org.jclouds.ec2.compute.domain.RegionAndName;
 import org.jclouds.ec2.compute.internal.EC2TemplateBuilderImpl;
 
 import com.google.common.base.Supplier;
+import com.google.common.cache.Cache;
 
 /**
  * 
@@ -46,7 +46,7 @@ public class AWSEC2TemplateBuilderImpl extends EC2TemplateBuilderImpl {
    protected AWSEC2TemplateBuilderImpl(@Memoized Supplier<Set<? extends Location>> locations,
          @Memoized Supplier<Set<? extends Image>> images, @Memoized Supplier<Set<? extends Hardware>> sizes,
          Supplier<Location> defaultLocation, @Named("DEFAULT") Provider<TemplateOptions> optionsProvider,
-         @Named("DEFAULT") Provider<TemplateBuilder> defaultTemplateProvider, Map<RegionAndName, Image> imageMap) {
+         @Named("DEFAULT") Provider<TemplateBuilder> defaultTemplateProvider, Supplier<Cache<RegionAndName, ? extends Image>> imageMap) {
       super(locations, images, sizes, defaultLocation, optionsProvider, defaultTemplateProvider, imageMap);
    }
 
Project jclouds/jclouds in file ...clouds.tools.ant.taskdefs.compute.ComputeTask.java (2011-09-22)
@@ -25,9 +25,6 @@ import static org.jclouds.tools.ant.taskdefs.compute.ComputeTaskUtils.ipOrEmptyS
 
 import java.io.IOException;
 import java.net.URI;
-import java.util.Map;
-
-import org.jclouds.javax.annotation.Nullable;
 
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Project;
@@ -43,10 +40,12 @@ import org.jclouds.compute.domain.Template;
 import org.jclouds.compute.predicates.NodePredicates;
 import org.jclouds.domain.Location;
 import org.jclouds.http.HttpUtils;
+import org.jclouds.javax.annotation.Nullable;
 import org.jclouds.util.CredentialUtils;
 
 import com.google.common.base.CaseFormat;
 import com.google.common.base.Splitter;
+import com.google.common.cache.Cache;
 import com.google.common.collect.Iterables;
 import com.google.inject.Provider;
 
@@ -56,7 +55,7 @@ import com.google.inject.Provider;
  */
 public class ComputeTask extends Task {
 
-   private final Map<URI, ComputeServiceContext> computeMap;
+   private final Cache<URI, ComputeServiceContext> computeMap;
    private String provider;
    private String actions;
    private NodeElement nodeElement;
@@ -72,7 +71,7 @@ public class ComputeTask extends Task {
       }
    };
 
-   public ComputeTask(@Nullable Map<URI, ComputeServiceContext> computeMap) {
+   public ComputeTask(@Nullable Cache<URI, ComputeServiceContext> computeMap) {
       this.computeMap = computeMap != null ? computeMap : buildComputeMap(projectProvider);
    }
 
@@ -88,7 +87,7 @@ public class ComputeTask extends Task {
     * makes a connection to the compute service and invokes
     */
    public void execute() throws BuildException {
-      ComputeServiceContext context = computeMap.get(HttpUtils.createUri(provider));
+      ComputeServiceContext context = computeMap.getUnchecked(HttpUtils.createUri(provider));
 
       try {
          for (String action : Splitter.on(',').split(actions)) {
Project jclouds/jclouds in file ...clouds.ec2.compute.suppliers.EC2ImageSupplier.java (2011-09-22)
@@ -18,16 +18,16 @@
  */
 package org.jclouds.ec2.compute.suppliers;
 
-import java.util.Map;
 import java.util.Set;
 
 import javax.inject.Inject;
 import javax.inject.Singleton;
 
-import org.jclouds.ec2.compute.domain.RegionAndName;
 import org.jclouds.compute.domain.Image;
+import org.jclouds.ec2.compute.domain.RegionAndName;
 
 import com.google.common.base.Supplier;
+import com.google.common.cache.Cache;
 import com.google.common.collect.Sets;
 
 /**
@@ -36,16 +36,16 @@ import com.google.common.collect.Sets;
  */
 @Singleton
 public class EC2ImageSupplier implements Supplier<Set<? extends Image>> {
-   private final Supplier<Map<RegionAndName, ? extends Image>> map;
+   private final Supplier<Cache<RegionAndName, ? extends Image>> map;
 
    @Inject
-   EC2ImageSupplier(Supplier<Map<RegionAndName, ? extends Image>> map) {
+   EC2ImageSupplier(Supplier<Cache<RegionAndName, ? extends Image>> map) {
       this.map = map;
    }
 
    @Override
    public Set<? extends Image> get() {
-      return Sets.newLinkedHashSet(map.get().values());
+      return Sets.newLinkedHashSet(map.get().asMap().values());
    }
 
 }
Project jclouds/legacy-jclouds in file ...clouds.tools.ant.taskdefs.compute.ComputeTask.java (2011-09-22)
@@ -25,9 +25,6 @@ import static org.jclouds.tools.ant.taskdefs.compute.ComputeTaskUtils.ipOrEmptyS
 
 import java.io.IOException;
 import java.net.URI;
-import java.util.Map;
-
-import org.jclouds.javax.annotation.Nullable;
 
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Project;
@@ -43,10 +40,12 @@ import org.jclouds.compute.domain.Template;
 import org.jclouds.compute.predicates.NodePredicates;
 import org.jclouds.domain.Location;
 import org.jclouds.http.HttpUtils;
+import org.jclouds.javax.annotation.Nullable;
 import org.jclouds.util.CredentialUtils;
 
 import com.google.common.base.CaseFormat;
 import com.google.common.base.Splitter;
+import com.google.common.cache.Cache;
 import com.google.common.collect.Iterables;
 import com.google.inject.Provider;
 
@@ -56,7 +55,7 @@ import com.google.inject.Provider;
  */
 public class ComputeTask extends Task {
 
-   private final Map<URI, ComputeServiceContext> computeMap;
+   private final Cache<URI, ComputeServiceContext> computeMap;
    private String provider;
    private String actions;
    private NodeElement nodeElement;
@@ -72,7 +71,7 @@ public class ComputeTask extends Task {
       }
    };
 
-   public ComputeTask(@Nullable Map<URI, ComputeServiceContext> computeMap) {
+   public ComputeTask(@Nullable Cache<URI, ComputeServiceContext> computeMap) {
       this.computeMap = computeMap != null ? computeMap : buildComputeMap(projectProvider);
    }
 
@@ -88,7 +87,7 @@ public class ComputeTask extends Task {
     * makes a connection to the compute service and invokes
     */
    public void execute() throws BuildException {
-      ComputeServiceContext context = computeMap.get(HttpUtils.createUri(provider));
+      ComputeServiceContext context = computeMap.getUnchecked(HttpUtils.createUri(provider));
 
       try {
          for (String action : Splitter.on(',').split(actions)) {