diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/config/EC2ComputeServiceContextModule.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/config/EC2ComputeServiceContextModule.java index 80e030dfee..cd086b9daa 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/config/EC2ComputeServiceContextModule.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/config/EC2ComputeServiceContextModule.java @@ -19,7 +19,6 @@ package org.jclouds.ec2.compute.config; import static com.google.common.collect.Iterables.toArray; -import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; import static org.jclouds.ec2.reference.EC2Constants.PROPERTY_EC2_AMI_OWNERS; import java.util.concurrent.ExecutionException; @@ -37,7 +36,6 @@ import org.jclouds.ec2.compute.domain.RegionAndName; import org.jclouds.ec2.compute.functions.RegionAndIdToImage; import org.jclouds.ec2.compute.suppliers.RegionAndNameToImageSupplier; import org.jclouds.rest.AuthorizationException; -import org.jclouds.rest.suppliers.MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier; import org.jclouds.rest.suppliers.SetAndThrowAuthorizationExceptionSupplier; import com.google.common.base.Splitter; @@ -69,7 +67,7 @@ public class EC2ComputeServiceContextModule extends BaseComputeServiceContextMod @Provides @Singleton protected Supplier> provideRegionAndNameToImageSupplierCache( - @Named(PROPERTY_SESSION_INTERVAL) long seconds, final RegionAndNameToImageSupplier supplier) { + final RegionAndNameToImageSupplier supplier) { return supplier; } diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/suppliers/RegionAndNameToImageSupplier.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/suppliers/RegionAndNameToImageSupplier.java index de599114fd..4f10c5d4e1 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/suppliers/RegionAndNameToImageSupplier.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/suppliers/RegionAndNameToImageSupplier.java @@ -18,7 +18,12 @@ */ package org.jclouds.ec2.compute.suppliers; +import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; + +import java.util.concurrent.TimeUnit; + import javax.inject.Inject; +import javax.inject.Named; import javax.inject.Singleton; import org.jclouds.compute.domain.Image; @@ -38,8 +43,9 @@ public class RegionAndNameToImageSupplier implements Supplier cache; @Inject - protected RegionAndNameToImageSupplier(CacheLoader regionAndIdToImage) { - cache = CacheBuilder.newBuilder().build(regionAndIdToImage); + protected RegionAndNameToImageSupplier(CacheLoader regionAndIdToImage, + @Named(PROPERTY_SESSION_INTERVAL) long expirationSecs) { + cache = CacheBuilder.newBuilder().expireAfterWrite(expirationSecs, TimeUnit.SECONDS).build(regionAndIdToImage); } @Override diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceContextModule.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceContextModule.java index 26140022d0..04d9ff956d 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceContextModule.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceContextModule.java @@ -18,13 +18,11 @@ */ package org.jclouds.aws.ec2.compute.config; -import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; import static org.jclouds.compute.domain.OsFamily.AMZN_LINUX; import java.util.concurrent.ExecutionException; import java.util.concurrent.atomic.AtomicReference; -import javax.inject.Named; import javax.inject.Singleton; import org.jclouds.aws.ec2.AWSEC2PropertiesBuilder; @@ -131,7 +129,7 @@ public class AWSEC2ComputeServiceContextModule extends BaseComputeServiceContext @Provides @Singleton protected Supplier> provideRegionAndNameToImageSupplierCache( - @Named(PROPERTY_SESSION_INTERVAL) long seconds, final RegionAndNameToImageSupplier supplier) { + final RegionAndNameToImageSupplier supplier) { return supplier; }