JCLOUDS-962: Make all @Provider methods final

This commit is contained in:
Oliver Gondža 2015-07-17 07:05:19 +02:00 committed by Ignasi Barrera
parent 6cd716f1ea
commit edde721937
68 changed files with 321 additions and 192 deletions

View File

@ -45,7 +45,7 @@ public class AtmosBlobStoreContextModule extends AbstractModule {
@Provides
@Singleton
protected LoadingCache<String, Boolean> isPublic(final AtmosClient client) {
protected final LoadingCache<String, Boolean> isPublic(final AtmosClient client) {
return CacheBuilder.newBuilder().expireAfterWrite(30, TimeUnit.SECONDS).build(new CacheLoader<String, Boolean>() {
@Override

View File

@ -56,6 +56,10 @@ public class AtmosHttpApiModule extends HttpApiModule<AtmosClient> {
@Provides
@TimeStamp
protected final String guiceProvideTimeStamp(@TimeStamp Supplier<String> cache) {
return provideTimeStamp(cache);
}
protected String provideTimeStamp(@TimeStamp Supplier<String> cache) {
return cache.get();
}
@ -65,9 +69,10 @@ public class AtmosHttpApiModule extends HttpApiModule<AtmosClient> {
*/
@Provides
@TimeStamp
Supplier<String> provideTimeStampCache(@Named(Constants.PROPERTY_SESSION_INTERVAL) long seconds,
final Supplier<String> provideTimeStampCache(@Named(Constants.PROPERTY_SESSION_INTERVAL) long seconds,
final DateService dateService) {
return Suppliers.memoizeWithExpiration(new Supplier<String>() {
@Override
public String get() {
return dateService.rfc822DateFormat();
}
@ -76,7 +81,7 @@ public class AtmosHttpApiModule extends HttpApiModule<AtmosClient> {
@Provides
@TimeStamp
protected Long provideShareableUrlTimeout() {
protected final Long provideShareableUrlTimeout() {
return new Date().getTime() + TimeUnit.HOURS.toMillis(1);
}

View File

@ -39,7 +39,7 @@ public class AtmosObjectModule extends AbstractModule {
}
@Provides
AtmosObject provideAtmosObject(AtmosObject.Factory factory) {
final AtmosObject provideAtmosObject(AtmosObject.Factory factory) {
return factory.create((MutableContentMetadata) null);
}

View File

@ -81,14 +81,14 @@ public class YamlNodeStoreModule extends AbstractModule {
@Provides
@Singleton
protected LoadingCache<String, Node> provideNodeStore(Map<String, YamlNode> backing, Function<Node, YamlNode> yamlSerializer,
protected final LoadingCache<String, Node> provideNodeStore(Map<String, YamlNode> backing, Function<Node, YamlNode> yamlSerializer,
Function<YamlNode, Node> yamlDeserializer) {
return CacheBuilder.newBuilder().build(CacheLoader.from(Functions.forMap(new TransformingMap<String, YamlNode, Node>(backing, yamlDeserializer, yamlSerializer))));
}
@Provides
@Singleton
protected Map<String, YamlNode> provideYamlStore(@Named("yaml") Map<String, ByteSource> backing,
protected final Map<String, YamlNode> provideYamlStore(@Named("yaml") Map<String, ByteSource> backing,
Function<YamlNode, ByteSource> yamlSerializer, Function<ByteSource, YamlNode> yamlDeserializer) {
return new TransformingMap<String, ByteSource, YamlNode>(backing, yamlDeserializer, yamlSerializer);
}

View File

@ -75,6 +75,10 @@ public abstract class BaseChefHttpApiModule<S> extends HttpApiModule<S> {
@Provides
@TimeStamp
protected final String guiceProvideTimeStamp(@TimeStamp Supplier<String> cache) {
return provideTimeStamp(cache);
}
protected String provideTimeStamp(@TimeStamp Supplier<String> cache) {
return cache.get();
}
@ -84,7 +88,7 @@ public abstract class BaseChefHttpApiModule<S> extends HttpApiModule<S> {
*/
@Provides
@TimeStamp
Supplier<String> provideTimeStampCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds, final DateService dateService) {
final Supplier<String> provideTimeStampCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds, final DateService dateService) {
return memoizeWithExpiration(new Supplier<String>() {
@Override
public String get() {
@ -96,7 +100,7 @@ public abstract class BaseChefHttpApiModule<S> extends HttpApiModule<S> {
// TODO: potentially change this
@Provides
@Singleton
public Supplier<PrivateKey> supplyKey(final LoadingCache<Credentials, PrivateKey> keyCache,
public final Supplier<PrivateKey> supplyKey(final LoadingCache<Credentials, PrivateKey> keyCache,
@org.jclouds.location.Provider final Supplier<Credentials> creds) {
return compose(new Function<Credentials, PrivateKey>() {
@Override
@ -108,7 +112,7 @@ public abstract class BaseChefHttpApiModule<S> extends HttpApiModule<S> {
@Provides
@Singleton
LoadingCache<Credentials, PrivateKey> privateKeyCache(PrivateKeyForCredentials loader) {
final LoadingCache<Credentials, PrivateKey> privateKeyCache(PrivateKeyForCredentials loader) {
// throw out the private key related to old credentials
return CacheBuilder.newBuilder().maximumSize(2).build(loader);
}
@ -144,7 +148,7 @@ public abstract class BaseChefHttpApiModule<S> extends HttpApiModule<S> {
@Provides
@Singleton
@Validator
public Optional<String> provideValidatorName(Injector injector) {
public final Optional<String> provideValidatorName(Injector injector) {
// Named properties can not be injected as optional here, so let's use the
// injector to bypass it
Key<String> key = Key.get(String.class, Names.named(CHEF_VALIDATOR_NAME));
@ -158,7 +162,7 @@ public abstract class BaseChefHttpApiModule<S> extends HttpApiModule<S> {
@Provides
@Singleton
@Validator
public Optional<PrivateKey> provideValidatorCredential(Crypto crypto, Injector injector)
public final Optional<PrivateKey> provideValidatorCredential(Crypto crypto, Injector injector)
throws InvalidKeySpecException, IOException {
// Named properties can not be injected as optional here, so let's use the
// injector to bypass it
@ -175,13 +179,13 @@ public abstract class BaseChefHttpApiModule<S> extends HttpApiModule<S> {
@Provides
@Singleton
CacheLoader<String, BootstrapConfig> bootstrapConfigForGroup(BootstrapConfigForGroup bootstrapConfigForGroup) {
final CacheLoader<String, BootstrapConfig> bootstrapConfigForGroup(BootstrapConfigForGroup bootstrapConfigForGroup) {
return CacheLoader.from(bootstrapConfigForGroup);
}
@Provides
@Singleton
CacheLoader<String, Client> groupToClient(ClientForGroup clientForGroup) {
final CacheLoader<String, Client> groupToClient(ClientForGroup clientForGroup) {
return CacheLoader.from(clientForGroup);
}

View File

@ -45,7 +45,7 @@ public class ChefBootstrapModule extends AbstractModule {
@Provides
@Named("installChefGems")
@Singleton
Statement installChefGems(BootstrapProperties bootstrapProperties) {
final Statement installChefGems(BootstrapProperties bootstrapProperties) {
InstallRubyGems installRubyGems = InstallRubyGems.builder()
.version(bootstrapProperties.gemSystemVersion().orNull())
.updateSystem(bootstrapProperties.updateGemSystem(), bootstrapProperties.gemSystemVersion().orNull())
@ -60,7 +60,7 @@ public class ChefBootstrapModule extends AbstractModule {
@Provides
@Named("installChefOmnibus")
@Singleton
Statement installChefUsingOmnibus(BootstrapProperties bootstrapProperties) {
final Statement installChefUsingOmnibus(BootstrapProperties bootstrapProperties) {
return bootstrapProperties.chefVersion().isPresent() ?
new InstallChefUsingOmnibus(bootstrapProperties.chefVersion().get())
: new InstallChefUsingOmnibus();
@ -69,7 +69,7 @@ public class ChefBootstrapModule extends AbstractModule {
@Provides
@InstallChef
@Singleton
Statement installChef(BootstrapProperties bootstrapProperties, @Named("installChefGems") Statement installChefGems,
final Statement installChef(BootstrapProperties bootstrapProperties, @Named("installChefGems") Statement installChefGems,
@Named("installChefOmnibus") Statement installChefOmnibus) {
return bootstrapProperties.useOmnibus() ? installChefOmnibus : installChefGems;
}

View File

@ -283,7 +283,7 @@ public class ChefParserModule extends AbstractModule {
@Provides
@Singleton
public Map<Type, Object> provideCustomAdapterBindings(DataBagItemAdapter adapter, PrivateKeyAdapter privateAdapter,
public final Map<Type, Object> provideCustomAdapterBindings(DataBagItemAdapter adapter, PrivateKeyAdapter privateAdapter,
PublicKeyAdapter publicAdapter, X509CertificateAdapter certAdapter) {
return ImmutableMap.<Type, Object> of(DatabagItem.class, adapter, PrivateKey.class, privateAdapter,
PublicKey.class, publicAdapter, X509Certificate.class, certAdapter);

View File

@ -36,10 +36,15 @@ public class JMXOhaiModule extends OhaiModule {
@Provides
@Singleton
protected final RuntimeMXBean guiceProvideRuntimeMXBean() {
return provideRuntimeMXBean();
}
protected RuntimeMXBean provideRuntimeMXBean() {
return ManagementFactory.getRuntimeMXBean();
}
@Override
public MapBinder<String, Supplier<JsonBall>> bindOhai() {
MapBinder<String, Supplier<JsonBall>> mapBinder = super.bindOhai();
mapBinder.addBinding("uptime_seconds").to(UptimeSecondsSupplier.class);

View File

@ -59,13 +59,17 @@ public class OhaiModule extends AbstractModule {
@Provides
@Automatic
protected final Supplier<Map<String, JsonBall>> guiceProvideAutomatic(AutomaticSupplier in) {
return provideAutomatic(in);
}
protected Supplier<Map<String, JsonBall>> provideAutomatic(AutomaticSupplier in) {
return in;
}
@Provides
@Automatic
Multimap<String, Supplier<JsonBall>> provideAutomatic(MapSetToMultimap<String, Supplier<JsonBall>> converter,
final Multimap<String, Supplier<JsonBall>> provideAutomatic(MapSetToMultimap<String, Supplier<JsonBall>> converter,
@Automatic Map<String, Set<Supplier<JsonBall>>> input) {
return converter.apply(input);
@ -73,6 +77,10 @@ public class OhaiModule extends AbstractModule {
@Named("systemProperties")
@Provides
protected final Properties provideSystemProperties() {
return systemProperties();
}
protected Properties systemProperties() {
return System.getProperties();
}
@ -104,6 +112,10 @@ public class OhaiModule extends AbstractModule {
}
@Provides
protected final Long provideMillis() {
return millis();
}
protected Long millis() {
return System.currentTimeMillis();
}

View File

@ -156,7 +156,6 @@ public class CloudStackComputeServiceContextModule extends
install(new LocationsFromComputeServiceAdapterModule<VirtualMachine, ServiceOffering, Template, Zone>() {
});
}
@Override
protected TemplateOptions provideTemplateOptions(Injector injector, TemplateOptions options) {
@ -168,7 +167,7 @@ public class CloudStackComputeServiceContextModule extends
@Provides
@Singleton
@Memoized
public Supplier<Map<String, String>> listOSCategories(AtomicReference<AuthorizationException> authException, @Named(PROPERTY_SESSION_INTERVAL) long seconds,
public final Supplier<Map<String, String>> listOSCategories(AtomicReference<AuthorizationException> authException, @Named(PROPERTY_SESSION_INTERVAL) long seconds,
final CloudStackApi client) {
return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create(authException,
new Supplier<Map<String, String>>() {
@ -187,7 +186,7 @@ public class CloudStackComputeServiceContextModule extends
@Provides
@Singleton
@Memoized
public Supplier<Map<String, OSType>> listOSTypes(AtomicReference<AuthorizationException> authException, @Named(PROPERTY_SESSION_INTERVAL) long seconds,
public final Supplier<Map<String, OSType>> listOSTypes(AtomicReference<AuthorizationException> authException, @Named(PROPERTY_SESSION_INTERVAL) long seconds,
final CloudStackApi client) {
return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create(authException,
new Supplier<Map<String, OSType>>() {
@ -212,7 +211,7 @@ public class CloudStackComputeServiceContextModule extends
@Provides
@Singleton
@Memoized
public Supplier<Map<String, Network>> listNetworks(AtomicReference<AuthorizationException> authException, @Named(PROPERTY_SESSION_INTERVAL) long seconds,
public final Supplier<Map<String, Network>> listNetworks(AtomicReference<AuthorizationException> authException, @Named(PROPERTY_SESSION_INTERVAL) long seconds,
final NetworksForCurrentUser networksForCurrentUser) {
return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create(authException, networksForCurrentUser,
seconds, TimeUnit.SECONDS);
@ -221,7 +220,7 @@ public class CloudStackComputeServiceContextModule extends
@Provides
@Singleton
@Memoized
public Supplier<Map<String, Project>> listProjects(AtomicReference<AuthorizationException> authException, @Named(PROPERTY_SESSION_INTERVAL) long seconds,
public final Supplier<Map<String, Project>> listProjects(AtomicReference<AuthorizationException> authException, @Named(PROPERTY_SESSION_INTERVAL) long seconds,
final ProjectsForCurrentUser projectsForCurrentUser) {
return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create(authException, projectsForCurrentUser,
seconds, TimeUnit.SECONDS);
@ -230,7 +229,7 @@ public class CloudStackComputeServiceContextModule extends
@Provides
@Singleton
@Memoized
public Supplier<User> getCurrentUser(AtomicReference<AuthorizationException> authException, @Named(PROPERTY_SESSION_INTERVAL) long seconds,
public final Supplier<User> getCurrentUser(AtomicReference<AuthorizationException> authException, @Named(PROPERTY_SESSION_INTERVAL) long seconds,
final GetCurrentUser getCurrentUser) {
return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create(authException, getCurrentUser,
seconds, TimeUnit.SECONDS);
@ -238,27 +237,27 @@ public class CloudStackComputeServiceContextModule extends
@Provides
@Singleton
protected Predicate<String> jobComplete(JobComplete jobComplete) {
protected final Predicate<String> jobComplete(JobComplete jobComplete) {
return retry(jobComplete, 1200, 1, 5, SECONDS);
}
@Provides
@Singleton
protected LoadingCache<String, SshKeyPair> keyPairMap(
protected final LoadingCache<String, SshKeyPair> keyPairMap(
CacheLoader<String, SshKeyPair> in) {
return CacheBuilder.newBuilder().build(in);
}
@Provides
@Singleton
protected LoadingCache<ZoneAndName, SecurityGroup> securityGroupMap(
protected final LoadingCache<ZoneAndName, SecurityGroup> securityGroupMap(
CacheLoader<ZoneAndName, SecurityGroup> in) {
return CacheBuilder.newBuilder().build(in);
}
@Provides
@Singleton
protected LoadingCache<String, Set<IPForwardingRule>> getIPForwardingRulesByVirtualMachine(
protected final LoadingCache<String, Set<IPForwardingRule>> getIPForwardingRulesByVirtualMachine(
CacheLoader<String, Set<IPForwardingRule>> in) {
return CacheBuilder.newBuilder().build(in);
}
@ -266,14 +265,14 @@ public class CloudStackComputeServiceContextModule extends
@Provides
@Singleton
protected LoadingCache<String, Set<FirewallRule>> getFirewallRulesByVirtualMachine(
protected final LoadingCache<String, Set<FirewallRule>> getFirewallRulesByVirtualMachine(
CacheLoader<String, Set<FirewallRule>> getFirewallRules) {
return CacheBuilder.newBuilder().build(getFirewallRules);
}
@Provides
@Singleton
public Map<NetworkType, ? extends OptionsConverter> optionsConverters() {
public final Map<NetworkType, ? extends OptionsConverter> optionsConverters() {
return ImmutableMap.of(
NetworkType.ADVANCED, new AdvancedNetworkOptionsConverter(),
NetworkType.BASIC, new BasicNetworkOptionsConverter());

View File

@ -117,7 +117,7 @@ public class CloudStackHttpApiModule extends HttpApiModule<CloudStackApi> {
*/
@Provides
@Singleton
protected AuthenticationFilter authenticationFilterForCredentialType(CredentialType credentialType,
protected final AuthenticationFilter authenticationFilterForCredentialType(CredentialType credentialType,
AddSessionKeyAndJSessionIdToRequest addSessionKeyAndJSessionIdToRequest, QuerySigner querySigner) {
switch (credentialType) {
case PASSWORD_CREDENTIALS:
@ -132,7 +132,7 @@ public class CloudStackHttpApiModule extends HttpApiModule<CloudStackApi> {
// PROPERTY_SESSION_INTERVAL is default to 60 seconds
@Provides
@Singleton
protected LoadingCache<Credentials, LoginResponse> provideLoginResponseCache(
protected final LoadingCache<Credentials, LoginResponse> provideLoginResponseCache(
LoginWithPasswordCredentials getLoginResponse,
@Named(Constants.PROPERTY_SESSION_INTERVAL) int seconds) {
return CacheBuilder.newBuilder().expireAfterWrite(seconds, TimeUnit.SECONDS).build(getLoginResponse);
@ -142,7 +142,7 @@ public class CloudStackHttpApiModule extends HttpApiModule<CloudStackApi> {
// http://code.google.com/p/guava-libraries/issues/detail?id=872
@Provides
@Singleton
protected Supplier<LoginResponse> provideLoginResponseSupplier(final LoadingCache<Credentials, LoginResponse> cache,
protected final Supplier<LoginResponse> provideLoginResponseSupplier(final LoadingCache<Credentials, LoginResponse> cache,
@Provider final Supplier<Credentials> creds) {
return new Supplier<LoginResponse>() {
@Override

View File

@ -27,10 +27,12 @@ import java.util.concurrent.atomic.AtomicReference;
import javax.inject.Named;
import javax.inject.Singleton;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.config.BaseComputeServiceContextModule;
import org.jclouds.compute.domain.Image;
import org.jclouds.compute.extensions.ImageExtension;
import org.jclouds.compute.extensions.SecurityGroupExtension;
import org.jclouds.ec2.compute.EC2ComputeService;
import org.jclouds.ec2.compute.domain.RegionAndName;
import org.jclouds.ec2.compute.loaders.RegionAndIdToImage;
import org.jclouds.ec2.compute.suppliers.RegionAndNameToImageSupplier;
@ -63,11 +65,11 @@ public class EC2ComputeServiceContextModule extends BaseComputeServiceContextMod
install(new EC2BindComputeSuppliersByClass());
super.configure();
}
protected void installDependencies() {
install(new EC2ComputeServiceDependenciesModule());
}
@Override
protected boolean shouldEagerlyParseImages(Injector injector) {
// If no owners to query, then will never lookup all images
@ -90,13 +92,18 @@ public class EC2ComputeServiceContextModule extends BaseComputeServiceContextMod
@Provides
@Singleton
protected Supplier<LoadingCache<RegionAndName, ? extends Image>> provideRegionAndNameToImageSupplierCache(
protected final Supplier<LoadingCache<RegionAndName, ? extends Image>> provideRegionAndNameToImageSupplierCache(
final RegionAndNameToImageSupplier supplier) {
return supplier;
}
@Provides
@Singleton
protected final Supplier<CacheLoader<RegionAndName, Image>> guiceProvideRegionAndNameToImageSupplierCacheLoader(
final RegionAndIdToImage delegate) {
return provideRegionAndNameToImageSupplierCacheLoader(delegate);
}
protected Supplier<CacheLoader<RegionAndName, Image>> provideRegionAndNameToImageSupplierCacheLoader(
final RegionAndIdToImage delegate) {
return Suppliers.<CacheLoader<RegionAndName, Image>>ofInstance(new CacheLoader<RegionAndName, Image>() {
@ -116,19 +123,19 @@ public class EC2ComputeServiceContextModule extends BaseComputeServiceContextMod
};
return new SetAndThrowAuthorizationExceptionSupplier<Image>(rawSupplier, authException).get();
}
});
}
@Provides
@Singleton
@Named(PROPERTY_EC2_AMI_OWNERS)
String[] amiOwners(@Named(PROPERTY_EC2_AMI_OWNERS) String amiOwners) {
final String[] amiOwners(@Named(PROPERTY_EC2_AMI_OWNERS) String amiOwners) {
if (amiOwners.trim().equals(""))
return new String[] {};
return toArray(Splitter.on(',').split(amiOwners), String.class);
}
@Override
protected Optional<ImageExtension> provideImageExtension(Injector i) {
return Optional.of(i.getInstance(ImageExtension.class));

View File

@ -93,7 +93,7 @@ public class EC2ComputeServiceDependenciesModule extends AbstractModule {
@Singleton
@Provides
protected Map<InstanceState, NodeMetadata.Status> toPortableNodeStatus() {
protected final Map<InstanceState, NodeMetadata.Status> toPortableNodeStatus() {
return toPortableNodeStatus;
}
@ -106,7 +106,7 @@ public class EC2ComputeServiceDependenciesModule extends AbstractModule {
@Singleton
@Provides
protected Map<ImageState, Image.Status> toPortableImageStatus() {
protected final Map<ImageState, Image.Status> toPortableImageStatus() {
return toPortableImageStatus;
}
@ -146,7 +146,7 @@ public class EC2ComputeServiceDependenciesModule extends AbstractModule {
*/
@Provides
@Singleton
public Function<RunningInstance, NodeMetadata> bindNodeConverter(RunningInstanceToNodeMetadata baseConverter,
public final Function<RunningInstance, NodeMetadata> bindNodeConverter(RunningInstanceToNodeMetadata baseConverter,
AddElasticIpsToNodemetadata addElasticIpsToNodemetadata,
@Named(EC2Constants.PROPERTY_EC2_AUTO_ALLOCATE_ELASTIC_IPS) boolean autoAllocateElasticIps) {
if (!autoAllocateElasticIps)
@ -156,20 +156,20 @@ public class EC2ComputeServiceDependenciesModule extends AbstractModule {
@Provides
@Singleton
protected LoadingCache<RunningInstance, Optional<LoginCredentials>> credentialsMap(CacheLoader<RunningInstance, Optional<LoginCredentials>> in) {
protected final LoadingCache<RunningInstance, Optional<LoginCredentials>> credentialsMap(CacheLoader<RunningInstance, Optional<LoginCredentials>> in) {
return CacheBuilder.newBuilder().build(in);
}
@Provides
@Singleton
protected ConcurrentMap<RegionAndName, KeyPair> keypairMap(Injector i) {
protected final ConcurrentMap<RegionAndName, KeyPair> keypairMap(Injector i) {
return Maps.newConcurrentMap();
}
@Provides
@Singleton
@Named("SECURITY")
protected LoadingCache<RegionAndName, String> securityGroupMap(
protected final LoadingCache<RegionAndName, String> securityGroupMap(
@Named("SECURITY") CacheLoader<RegionAndName, String> in) {
return CacheBuilder.newBuilder().build(in);
}
@ -177,7 +177,7 @@ public class EC2ComputeServiceDependenciesModule extends AbstractModule {
@Provides
@Singleton
@Named("ELASTICIP")
protected LoadingCache<RegionAndName, String> instanceToElasticIp(
protected final LoadingCache<RegionAndName, String> instanceToElasticIp(
@Named("ELASTICIP") CacheLoader<RegionAndName, String> in) {
return CacheBuilder.newBuilder().build(in);
}
@ -185,7 +185,7 @@ public class EC2ComputeServiceDependenciesModule extends AbstractModule {
@Provides
@Singleton
@Named("SECURITY")
protected Predicate<RegionAndName> securityGroupEventualConsistencyDelay(SecurityGroupPresent in,
protected final Predicate<RegionAndName> securityGroupEventualConsistencyDelay(SecurityGroupPresent in,
@Named(PROPERTY_EC2_TIMEOUT_SECURITYGROUP_PRESENT) long msDelay) {
return retry(in, msDelay, 100l, MILLISECONDS);
}

View File

@ -101,7 +101,7 @@ public class ElasticStackComputeServiceContextModule extends
@Provides
@Singleton
protected LoadingCache<String, DriveInfo> cache(GetDrive getDrive) {
protected final LoadingCache<String, DriveInfo> cache(GetDrive getDrive) {
return CacheBuilder.newBuilder().build(getDrive);
}
@ -123,7 +123,7 @@ public class ElasticStackComputeServiceContextModule extends
@Singleton
@Provides
@Memoized
protected Supplier<Map<String, WellKnownImage>> provideImages(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
protected final Supplier<Map<String, WellKnownImage>> provideImages(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
@Memoized final Supplier<List<WellKnownImage>> wellKnownImageSupplier) throws IOException {
// The image map won't change. Memoize it during the session.
// This map can't be created directly as a singleton, as Guice needs it to construct the ElasticStackComputeServiceAdapter
@ -144,7 +144,7 @@ public class ElasticStackComputeServiceContextModule extends
@Singleton
@Provides
@Memoized
protected Supplier<List<WellKnownImage>> provideWellKnownImageSupplier(AtomicReference<AuthorizationException> authException,
protected final Supplier<List<WellKnownImage>> provideWellKnownImageSupplier(AtomicReference<AuthorizationException> authException,
@Named(PROPERTY_SESSION_INTERVAL) long seconds, WellKnownImageSupplier uncached)
throws IOException {
return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create(authException, uncached, seconds,
@ -153,7 +153,7 @@ public class ElasticStackComputeServiceContextModule extends
@Provides
@Singleton
protected Predicate<DriveInfo> supplyDriveUnclaimed(DriveClaimed driveClaimed, Timeouts timeouts) {
protected final Predicate<DriveInfo> supplyDriveUnclaimed(DriveClaimed driveClaimed, Timeouts timeouts) {
return retry(Predicates.not(driveClaimed), timeouts.nodeRunning, 1000, MILLISECONDS);
}
}

View File

@ -49,7 +49,7 @@ public class CinderHttpApiModule extends HttpApiModule<CinderApi> {
@Provides
@Singleton
public Multimap<URI, URI> aliases() {
public final Multimap<URI, URI> aliases() {
return ImmutableMultimap.<URI, URI>builder().build();
}

View File

@ -41,7 +41,7 @@ public class CinderParserModule extends AbstractModule {
@Provides
@Singleton
public Map<Type, Object> provideCustomAdapterBindings() {
public final Map<Type, Object> provideCustomAdapterBindings() {
return ImmutableMap.<Type, Object>of(
Snapshot.class, new SnapshotAdapter()
);

View File

@ -95,7 +95,7 @@ public class KeystoneAuthenticationModule extends AbstractModule {
@Provides
@Singleton
protected Supplier<URI> provideZoneIdToURISupplierForApiVersion(
protected final Supplier<URI> provideZoneIdToURISupplierForApiVersion(
@Named(KeystoneProperties.SERVICE_TYPE) String serviceType, @ApiVersion String apiVersion,
LocationIdToURIFromAccessForTypeAndVersion.Factory factory) {
return getLastValueInMap(factory.createForApiTypeAndVersion(serviceType, apiVersion));
@ -103,8 +103,9 @@ public class KeystoneAuthenticationModule extends AbstractModule {
@Provides
@Singleton
Function<Endpoint, String> provideProvider(@Provider final String provider) {
final Function<Endpoint, String> provideProvider(@Provider final String provider) {
return new Function<Endpoint, String>() {
@Override
public String apply(Endpoint in) {
return provider;
}
@ -125,21 +126,33 @@ public class KeystoneAuthenticationModule extends AbstractModule {
bind(LocationsSupplier.class).to(RegionToProvider.class).in(Scopes.SINGLETON);
}
// supply the region to id map from keystone, based on the servicetype and api version in
// config
@Provides
@Singleton
protected final RegionIdToURISupplier guiceProvideRegionIdToURISupplierForApiVersion(
@Named(KeystoneProperties.SERVICE_TYPE) String serviceType, @ApiVersion String apiVersion,
RegionIdToURISupplier.Factory factory) {
return provideRegionIdToURISupplierForApiVersion(serviceType, apiVersion, factory);
}
// supply the region to id map from keystone, based on the servicetype and api version in
// config
protected RegionIdToURISupplier provideRegionIdToURISupplierForApiVersion(
@Named(KeystoneProperties.SERVICE_TYPE) String serviceType, @ApiVersion String apiVersion,
RegionIdToURISupplier.Factory factory) {
return factory.createForApiTypeAndVersion(serviceType, apiVersion);
}
@Provides
@Singleton
protected final RegionIdToAdminURISupplier guiceProvideRegionIdToAdminURISupplierForApiVersion(
@Named(KeystoneProperties.SERVICE_TYPE) String serviceType, @ApiVersion String apiVersion,
RegionIdToAdminURISupplier.Factory factory) {
return provideRegionIdToAdminURISupplierForApiVersion(serviceType, apiVersion, factory);
}
// supply the region to id to AdminURL map from keystone, based on the servicetype and api
// version in
// config
@Provides
@Singleton
protected RegionIdToAdminURISupplier provideRegionIdToAdminURISupplierForApiVersion(
@Named(KeystoneProperties.SERVICE_TYPE) String serviceType, @ApiVersion String apiVersion,
RegionIdToAdminURISupplier.Factory factory) {
@ -167,7 +180,7 @@ public class KeystoneAuthenticationModule extends AbstractModule {
// config
@Provides
@Singleton
protected ZoneIdToURISupplier provideZoneIdToURISupplierForApiVersion(
protected final ZoneIdToURISupplier provideZoneIdToURISupplierForApiVersion(
@Named(KeystoneProperties.SERVICE_TYPE) String serviceType, @ApiVersion String apiVersion,
ZoneIdToURISupplier.Factory factory) {
return factory.createForApiTypeAndVersion(serviceType, apiVersion);
@ -186,9 +199,10 @@ public class KeystoneAuthenticationModule extends AbstractModule {
@Provides
@Singleton
@Authentication
protected Supplier<String> provideAuthenticationTokenCache(final Supplier<Access> supplier)
protected final Supplier<String> provideAuthenticationTokenCache(final Supplier<Access> supplier)
throws InterruptedException, ExecutionException, TimeoutException {
return new Supplier<String>() {
@Override
public String get() {
return supplier.get().getToken().getId();
}
@ -197,6 +211,10 @@ public class KeystoneAuthenticationModule extends AbstractModule {
@Provides
@Singleton
protected final Map<String, Function<Credentials, Access>> provideAuthenticationMethods(Injector i) {
return authenticationMethods(i);
}
protected Map<String, Function<Credentials, Access>> authenticationMethods(Injector i) {
Builder<Function<Credentials, Access>> fns = ImmutableSet.<Function<Credentials, Access>> builder();
fns.add(i.getInstance(AuthenticatePasswordCredentials.class));
@ -206,7 +224,7 @@ public class KeystoneAuthenticationModule extends AbstractModule {
@Provides
@Singleton
protected Function<Credentials, Access> authenticationMethodForCredentialType(
protected final Function<Credentials, Access> authenticationMethodForCredentialType(
@Named(KeystoneProperties.CREDENTIAL_TYPE) String credentialType,
Map<String, Function<Credentials, Access>> authenticationMethods) {
checkArgument(authenticationMethods.containsKey(credentialType), "credential type %s not in supported list: %s",
@ -218,7 +236,7 @@ public class KeystoneAuthenticationModule extends AbstractModule {
// PROPERTY_SESSION_INTERVAL is default to 60 seconds, but we have this here at 11 hours for now.
@Provides
@Singleton
public LoadingCache<Credentials, Access> provideAccessCache(Function<Credentials, Access> getAccess) {
public final LoadingCache<Credentials, Access> provideAccessCache(Function<Credentials, Access> getAccess) {
return CacheBuilder.newBuilder().expireAfterWrite(11, TimeUnit.HOURS).build(CacheLoader.from(getAccess));
}
@ -226,7 +244,7 @@ public class KeystoneAuthenticationModule extends AbstractModule {
// http://code.google.com/p/guava-libraries/issues/detail?id=872
@Provides
@Singleton
protected Supplier<Access> provideAccessSupplier(final LoadingCache<Credentials, Access> cache,
protected final Supplier<Access> provideAccessSupplier(final LoadingCache<Credentials, Access> cache,
@Provider final Supplier<Credentials> creds) {
return new Supplier<Access>() {
@Override

View File

@ -79,7 +79,7 @@ public class KeystoneHttpApiModule extends HttpApiModule<KeystoneApi> {
@Provides
@Singleton
@Identity
protected Supplier<URI> provideStorageUrl(final RegionIdToAdminURISupplier.Factory factory,
protected final Supplier<URI> provideStorageUrl(final RegionIdToAdminURISupplier.Factory factory,
@ApiVersion final String version, @Provider final Supplier<URI> providerURI) {
Supplier<URI> identityServiceForVersion = getLastValueInMap(factory.createForApiTypeAndVersion(
ServiceType.IDENTITY, version));
@ -105,7 +105,7 @@ public class KeystoneHttpApiModule extends HttpApiModule<KeystoneApi> {
@Provides
@Singleton
public LoadingCache<String, Set<? extends Extension>> provideExtensionsByRegion(final javax.inject.Provider<KeystoneApi> keystoneApi) {
public final LoadingCache<String, Set<? extends Extension>> provideExtensionsByRegion(final javax.inject.Provider<KeystoneApi> keystoneApi) {
return CacheBuilder.newBuilder().expireAfterWrite(23, TimeUnit.HOURS)
.build(CacheLoader.from(Suppliers.memoize(new Supplier<Set<? extends Extension>>() {
@Override

View File

@ -82,7 +82,7 @@ public class ProviderModuleExpectTest extends BaseRestApiExpectTest<ProviderModu
@Provides
@Singleton
@DNS
protected Supplier<URI> provideCDNUrl(RegionIdToURISupplier.Factory factory, @ApiVersion String apiVersion) {
protected final Supplier<URI> provideCDNUrl(RegionIdToURISupplier.Factory factory, @ApiVersion String apiVersion) {
return getLastValueInMap(factory.createForApiTypeAndVersion("dns", apiVersion));
}
}

View File

@ -174,14 +174,14 @@ public class NovaComputeServiceContextModule extends
@Provides
@Singleton
@Named("FLOATINGIP")
protected LoadingCache<RegionAndId, Iterable<? extends FloatingIP>> instanceToFloatingIps(
protected final LoadingCache<RegionAndId, Iterable<? extends FloatingIP>> instanceToFloatingIps(
@Named("FLOATINGIP") CacheLoader<RegionAndId, Iterable<? extends FloatingIP>> in) {
return CacheBuilder.newBuilder().build(in);
}
@Provides
@Singleton
protected LoadingCache<RegionAndName, SecurityGroupInRegion> securityGroupMap(
protected final LoadingCache<RegionAndName, SecurityGroupInRegion> securityGroupMap(
CacheLoader<RegionAndName, SecurityGroupInRegion> in) {
return CacheBuilder.newBuilder().build(in);
}
@ -195,7 +195,7 @@ public class NovaComputeServiceContextModule extends
@Provides
@Singleton
@Named("SECURITYGROUP_PRESENT")
protected Predicate<AtomicReference<RegionAndName>> securityGroupEventualConsistencyDelay(
protected final Predicate<AtomicReference<RegionAndName>> securityGroupEventualConsistencyDelay(
FindSecurityGroupWithNameAndReturnTrue in,
@Named(TIMEOUT_SECURITYGROUP_PRESENT) long msDelay) {
return retry(in, msDelay, 100l, MILLISECONDS);
@ -203,14 +203,14 @@ public class NovaComputeServiceContextModule extends
@Provides
@Singleton
protected LoadingCache<RegionAndName, KeyPair> keyPairMap(
protected final LoadingCache<RegionAndName, KeyPair> keyPairMap(
CacheLoader<RegionAndName, KeyPair> in) {
return CacheBuilder.newBuilder().build(in);
}
@Provides
@Singleton
protected Supplier<Map<String, Location>> createLocationIndexedById(
protected final Supplier<Map<String, Location>> createLocationIndexedById(
@Memoized Supplier<Set<? extends Location>> locations) {
return Suppliers.compose(new Function<Set<? extends Location>, Map<String, Location>>() {
@ -261,7 +261,7 @@ public class NovaComputeServiceContextModule extends
@Singleton
@Provides
protected Map<Server.Status, NodeMetadata.Status> toPortableNodeStatus() {
protected final Map<Server.Status, NodeMetadata.Status> toPortableNodeStatus() {
return toPortableNodeStatus;
}
@ -277,7 +277,7 @@ public class NovaComputeServiceContextModule extends
@Singleton
@Provides
protected Map<org.jclouds.openstack.nova.v2_0.domain.Image.Status, Image.Status> toPortableImageStatus() {
protected final Map<org.jclouds.openstack.nova.v2_0.domain.Image.Status, Image.Status> toPortableImageStatus() {
return toPortableImageStatus;
}

View File

@ -100,7 +100,7 @@ public class NovaHttpApiModule extends HttpApiModule<NovaApi> {
@Provides
@Singleton
public LoadingCache<String, Set<? extends Extension>> provideExtensionsByRegion(final Provider<NovaApi> novaApi) {
public final LoadingCache<String, Set<? extends Extension>> provideExtensionsByRegion(final Provider<NovaApi> novaApi) {
return CacheBuilder.newBuilder().expireAfterWrite(23, TimeUnit.HOURS)
.build(new CacheLoader<String, Set<? extends Extension>>() {
@Override

View File

@ -62,7 +62,7 @@ public class NovaParserModule extends AbstractModule {
@Provides
@Singleton
public Map<Type, Object> provideCustomAdapterBindings() {
public final Map<Type, Object> provideCustomAdapterBindings() {
return ImmutableMap.<Type, Object>of(
HostResourceUsage.class, new HostResourceUsageAdapter(),
ServerWithSecurityGroups.class, new ServerWithSecurityGroupsAdapter(),

View File

@ -44,7 +44,7 @@ public class SwiftBlobStoreContextModule extends AbstractModule {
}
@Provides
Function<String, BlobStore> blobStore(FactoryFunction in) {
final Function<String, BlobStore> blobStore(FactoryFunction in) {
return in;
}

View File

@ -55,7 +55,7 @@ public class TroveHttpApiModule extends HttpApiModule<TroveApi> {
@Provides
@Singleton
public Multimap<URI, URI> aliases() {
public final Multimap<URI, URI> aliases() {
return ImmutableMultimap.<URI, URI>builder().build();
}
@ -67,7 +67,7 @@ public class TroveHttpApiModule extends HttpApiModule<TroveApi> {
}
@Provides
Supplier<Optional<Tenant>> supplyTenant(Supplier<Access> access) {
final Supplier<Optional<Tenant>> supplyTenant(Supplier<Access> access) {
return Suppliers.compose(GetTenant.INSTANCE, access);
}

View File

@ -33,7 +33,7 @@ public class CloudIdentityAuthenticationApiModule extends AbstractModule {
}
@Provides
private AuthenticationApi provideAuthenticationApi(CloudIdentityAuthenticationApi in){
private AuthenticationApi provideAuthenticationApi(CloudIdentityAuthenticationApi in){
return in;
}
}

View File

@ -42,16 +42,20 @@ import com.google.inject.Provides;
public class Route53HttpApiModule extends AWSHttpApiModule<Route53Api> {
public Route53HttpApiModule() {
}
@Provides
@TimeStamp
protected final String guiceProvideTimeStamp(DateService dateService) {
return provideTimeStamp(dateService);
}
protected String provideTimeStamp(DateService dateService) {
return dateService.rfc1123DateFormat(new Date(System.currentTimeMillis()));
}
@Provides
@Singleton
RequestSigner provideRequestSigner(RestAuthentication in) {
final RequestSigner provideRequestSigner(RestAuthentication in) {
return in;
}

View File

@ -58,7 +58,7 @@ public class S3BlobStoreContextModule extends AbstractModule {
@Provides
@Singleton
protected LoadingCache<String, AccessControlList> bucketAcls(BackoffOnNotFoundWhenGetBucketACL loader) {
protected final LoadingCache<String, AccessControlList> bucketAcls(BackoffOnNotFoundWhenGetBucketACL loader) {
return CacheBuilder.newBuilder().expireAfterWrite(30, TimeUnit.SECONDS).build(loader);
}
}

View File

@ -80,6 +80,11 @@ public class S3HttpApiModule<S extends S3Client> extends AWSHttpApiModule<S> {
@Provides
@Bucket
@Singleton
protected final CacheLoader<String, Optional<String>> provideBucketToRegion(@Region Supplier<Set<String>> regionSupplier,
final S3Client client) {
return bucketToRegion(regionSupplier, client);
}
protected CacheLoader<String, Optional<String>> bucketToRegion(@Region Supplier<Set<String>> regionSupplier,
final S3Client client) {
Set<String> regions = regionSupplier.get();
@ -133,13 +138,17 @@ public class S3HttpApiModule<S extends S3Client> extends AWSHttpApiModule<S> {
@Provides
@Bucket
@Singleton
protected LoadingCache<String, Optional<String>> bucketToRegion(@Bucket CacheLoader<String, Optional<String>> loader) {
protected final LoadingCache<String, Optional<String>> bucketToRegion(@Bucket CacheLoader<String, Optional<String>> loader) {
return CacheBuilder.newBuilder().build(loader);
}
@Provides
@Bucket
@Singleton
protected final Supplier<String> provideDefaultRegionForBucket(@Region Supplier<String> defaultRegion) {
return defaultRegionForBucket(defaultRegion);
}
protected Supplier<String> defaultRegionForBucket(@Region Supplier<String> defaultRegion) {
return defaultRegion;
}
@ -147,7 +156,7 @@ public class S3HttpApiModule<S extends S3Client> extends AWSHttpApiModule<S> {
@Provides
@Singleton
@Bucket
protected Supplier<URI> provideBucketURI(@Bucket Supplier<String> defaultRegion,
protected final Supplier<URI> provideBucketURI(@Bucket Supplier<String> defaultRegion,
RegionToEndpointOrProviderIfNull regionToEndpoint) {
return Suppliers.compose(regionToEndpoint, defaultRegion);
}
@ -177,7 +186,7 @@ public class S3HttpApiModule<S extends S3Client> extends AWSHttpApiModule<S> {
@Provides
@Singleton
protected RequestSigner provideRequestSigner(RequestAuthorizeSignature in) {
protected final RequestSigner provideRequestSigner(RequestAuthorizeSignature in) {
return in;
}
@ -190,6 +199,10 @@ public class S3HttpApiModule<S extends S3Client> extends AWSHttpApiModule<S> {
@Provides
@TimeStamp
protected final String guiceProvideTimeStamp(@TimeStamp Supplier<String> cache) {
return provideTimeStamp(cache);
}
protected String provideTimeStamp(@TimeStamp Supplier<String> cache) {
return cache.get();
}
@ -200,9 +213,10 @@ public class S3HttpApiModule<S extends S3Client> extends AWSHttpApiModule<S> {
@Provides
@TimeStamp
@Singleton
protected Supplier<String> provideTimeStampCache(@Named(Constants.PROPERTY_SESSION_INTERVAL) long seconds,
protected final Supplier<String> provideTimeStampCache(@Named(Constants.PROPERTY_SESSION_INTERVAL) long seconds,
final DateService dateService) {
return Suppliers.memoizeWithExpiration(new Supplier<String>() {
@Override
public String get() {
return dateService.rfc822DateFormat();
}

View File

@ -53,7 +53,7 @@ public class S3ObjectModule extends AbstractModule {
}
@Provides
S3Object provideS3Object(S3Object.Factory factory) {
final S3Object provideS3Object(S3Object.Factory factory) {
return factory.create(null);
}

View File

@ -49,14 +49,14 @@ public abstract class AWSHttpApiModule<A> extends HttpApiModule<A> {
@Provides
@ClientError
@Singleton
protected Set<String> provideRetryableCodes() {
protected final Set<String> provideRetryableCodes() {
return ImmutableSet.of("RequestTimeout", "OperationAborted", "SignatureDoesNotMatch");
}
@Provides
@ServerError
@Singleton
protected Set<String> provideRetryableServerCodes() {
protected final Set<String> provideRetryableServerCodes() {
return ImmutableSet.of("RequestLimitExceeded", "InternalError");
}

View File

@ -45,13 +45,17 @@ public abstract class FormSigningHttpApiModule<A> extends AWSHttpApiModule<A> {
@Provides
@TimeStamp
protected final String guiceProvideTimeStamp(DateService dateService) {
return provideTimeStamp(dateService);
}
protected String provideTimeStamp(DateService dateService) {
return dateService.iso8601DateFormat(new Date(System.currentTimeMillis()));
}
@Provides
@Singleton
RequestSigner provideRequestSigner(FormSigner in) {
final RequestSigner provideRequestSigner(FormSigner in) {
if (in instanceof RequestSigner) {
return (RequestSigner) in;
}

View File

@ -64,6 +64,7 @@ public abstract class TemporaryUrlExtensionModule<A extends CommonSwiftClient> e
public static class SwiftKeystoneTemporaryUrlExtensionModule extends
TemporaryUrlExtensionModule<SwiftKeystoneClient> {
@Override
protected void bindTemporaryUrlKeyApi() {
bindHttpApi(binder(), KeystoneTemporaryUrlKeyApi.class);
bind(TemporaryUrlKeyApi.class).to(KeystoneTemporaryUrlKeyApi.class);
@ -79,6 +80,10 @@ public abstract class TemporaryUrlExtensionModule<A extends CommonSwiftClient> e
@Provides
@TimeStamp
protected final Long guiceUnixEpochTimestampProvider() {
return unixEpochTimestampProvider();
}
protected Long unixEpochTimestampProvider() {
return System.currentTimeMillis() / 1000; /* convert to seconds */
}

View File

@ -66,7 +66,7 @@ public class SwiftHttpApiModule<S extends CommonSwiftClient> extends HttpApiModu
@Provides
@Singleton
@Storage
protected Supplier<URI> provideStorageUrl(URIFromAuthenticationResponseForService.Factory factory) {
protected final Supplier<URI> provideStorageUrl(URIFromAuthenticationResponseForService.Factory factory) {
return factory.create(AuthHeaders.STORAGE_URL);
}
}
@ -75,7 +75,7 @@ public class SwiftHttpApiModule<S extends CommonSwiftClient> extends HttpApiModu
@Provides
@Singleton
@Storage
protected Supplier<URI> provideStorageUrl(RegionIdToURISupplier.Factory factory,
protected final Supplier<URI> provideStorageUrl(RegionIdToURISupplier.Factory factory,
@ApiVersion String apiVersion,
@Named(LocationConstants.PROPERTY_REGION) String region) {

View File

@ -54,7 +54,7 @@ public class SwiftObjectModule extends AbstractModule {
}
@Provides
SwiftObject provideSwiftObject(SwiftObject.Factory factory) {
final SwiftObject provideSwiftObject(SwiftObject.Factory factory) {
return factory.create(null);
}

View File

@ -52,7 +52,7 @@ public class BlobStoreObjectModule extends AbstractModule {
}
@Provides
Blob provideBlob(Blob.Factory factory) {
final Blob provideBlob(Blob.Factory factory) {
return factory.create(null);
}

View File

@ -59,15 +59,21 @@ public class OpenStackAuthenticationModule extends AbstractModule {
bind(HttpRetryHandler.class).annotatedWith(ClientError.class).to(RetryOnRenew.class);
}
/**
* borrowing concurrency code to ensure that caching takes place properly
*/
@Provides
@Singleton
@Authentication
protected final Supplier<String> guiceProvideAuthenticationTokenCache(final Supplier<AuthenticationResponse> supplier)
throws InterruptedException, ExecutionException, TimeoutException {
return provideAuthenticationTokenCache(supplier);
}
/**
* borrowing concurrency code to ensure that caching takes place properly
*/
protected Supplier<String> provideAuthenticationTokenCache(final Supplier<AuthenticationResponse> supplier)
throws InterruptedException, ExecutionException, TimeoutException {
return new Supplier<String>() {
@Override
public String get() {
return supplier.get().getAuthToken();
}
@ -97,14 +103,14 @@ public class OpenStackAuthenticationModule extends AbstractModule {
@Provides
@Singleton
public LoadingCache<Credentials, AuthenticationResponse> provideAuthenticationResponseCache(
public final LoadingCache<Credentials, AuthenticationResponse> provideAuthenticationResponseCache(
GetAuthenticationResponse getAuthenticationResponse) {
return CacheBuilder.newBuilder().expireAfterWrite(23, TimeUnit.HOURS).build(getAuthenticationResponse);
}
@Provides
@Singleton
protected Supplier<AuthenticationResponse> provideAuthenticationResponseSupplier(
protected final Supplier<AuthenticationResponse> provideAuthenticationResponseSupplier(
final LoadingCache<Credentials, AuthenticationResponse> cache, @Provider final Supplier<Credentials> creds) {
return new Supplier<AuthenticationResponse>() {
@Override
@ -117,8 +123,13 @@ public class OpenStackAuthenticationModule extends AbstractModule {
@Provides
@Singleton
@TimeStamp
protected final Supplier<Date> guiceProvideCacheBusterDate() {
return provideCacheBusterDate();
}
protected Supplier<Date> provideCacheBusterDate() {
return memoizeWithExpiration(new Supplier<Date>() {
@Override
public Date get() {
return new Date();
}

View File

@ -67,7 +67,7 @@ public class AuthenticationServiceModule extends AbstractModule {
@Provides
@Singleton
@Authentication
protected Supplier<String> provideAuthenticationTokenCache(final Supplier<Auth> supplier)
protected final Supplier<String> provideAuthenticationTokenCache(final Supplier<Auth> supplier)
throws InterruptedException, ExecutionException, TimeoutException {
return new Supplier<String>() {
public String get() {
@ -99,14 +99,14 @@ public class AuthenticationServiceModule extends AbstractModule {
@Provides
@Singleton
protected LoadingCache<Credentials, Auth> provideAuthCache(GetAuth getAuth,
protected final LoadingCache<Credentials, Auth> provideAuthCache(GetAuth getAuth,
@Named(PROPERTY_SESSION_INTERVAL) long sessionInterval) {
return CacheBuilder.newBuilder().expireAfterWrite(sessionInterval, TimeUnit.SECONDS).build(getAuth);
}
@Provides
@Singleton
protected Supplier<Auth> provideAuthSupplier(final LoadingCache<Credentials, Auth> cache,
protected final Supplier<Auth> provideAuthSupplier(final LoadingCache<Credentials, Auth> cache,
@Provider final Supplier<Credentials> creds) {
return new Supplier<Auth>() {
@Override

View File

@ -168,7 +168,7 @@ public abstract class BaseComputeServiceContextModule extends AbstractModule {
@Provides
@Singleton
public Map<OsFamily, Map<String, String>> provideOsVersionMap(ComputeServiceConstants.ReferenceData data, Json json) {
public final Map<OsFamily, Map<String, String>> provideOsVersionMap(ComputeServiceConstants.ReferenceData data, Json json) {
return json.fromJson(data.osVersionMapJson, new TypeLiteral<Map<OsFamily, Map<String, String>>>() {
}.getType());
}
@ -178,7 +178,7 @@ public abstract class BaseComputeServiceContextModule extends AbstractModule {
*/
@Provides
@Named("DEFAULT")
protected TemplateBuilder provideTemplateOptionallyFromProperties(Injector injector, TemplateBuilder template,
protected final TemplateBuilder provideTemplateOptionallyFromProperties(Injector injector, TemplateBuilder template,
@Provider String provider, ValueOfConfigurationKeyOrNull config) {
String templateString = config.apply(provider + ".template");
if (templateString == null)
@ -198,6 +198,10 @@ public abstract class BaseComputeServiceContextModule extends AbstractModule {
@Provides
@Singleton
protected final Map<OsFamily, LoginCredentials> provideOsFamilyToCredentials(Injector injector) {
return osFamilyToCredentials(injector);
}
protected Map<OsFamily, LoginCredentials> osFamilyToCredentials(Injector injector) {
return ImmutableMap.of(OsFamily.WINDOWS, LoginCredentials.builder().user("Administrator").build());
}
@ -207,13 +211,17 @@ public abstract class BaseComputeServiceContextModule extends AbstractModule {
*/
@Provides
@Named("DEFAULT")
protected final TemplateOptions guiceProvideTemplateOptions(Injector injector, TemplateOptions options) {
return provideTemplateOptions(injector, options);
}
protected TemplateOptions provideTemplateOptions(Injector injector, TemplateOptions options) {
return options;
}
@Provides
@Singleton
protected Supplier<Map<String, ? extends Image>> provideImageMap(@Memoized Supplier<Set<? extends Image>> images) {
protected final Supplier<Map<String, ? extends Image>> provideImageMap(@Memoized Supplier<Set<? extends Image>> images) {
return Suppliers.compose(new Function<Set<? extends Image>, Map<String, ? extends Image>>() {
@Override
@ -234,7 +242,7 @@ public abstract class BaseComputeServiceContextModule extends AbstractModule {
@Provides
@Singleton
@Named("imageCache")
protected Supplier<Set<? extends Image>> supplyImageCache(AtomicReference<AuthorizationException> authException, @Named(PROPERTY_SESSION_INTERVAL) long seconds,
protected final Supplier<Set<? extends Image>> supplyImageCache(AtomicReference<AuthorizationException> authException, @Named(PROPERTY_SESSION_INTERVAL) long seconds,
final Supplier<Set<? extends Image>> imageSupplier, Injector injector) {
if (shouldEagerlyParseImages(injector)) {
return supplyImageCache(authException, seconds, imageSupplier);
@ -263,7 +271,7 @@ public abstract class BaseComputeServiceContextModule extends AbstractModule {
@Provides
@Singleton
protected Supplier<Map<String, ? extends Hardware>> provideSizeMap(@Memoized Supplier<Set<? extends Hardware>> sizes) {
protected final Supplier<Map<String, ? extends Hardware>> provideSizeMap(@Memoized Supplier<Set<? extends Hardware>> sizes) {
return Suppliers.compose(new Function<Set<? extends Hardware>, Map<String, ? extends Hardware>>() {
@Override
@ -284,7 +292,7 @@ public abstract class BaseComputeServiceContextModule extends AbstractModule {
@Provides
@Singleton
@Memoized
protected Supplier<Set<? extends Hardware>> supplySizeCache(AtomicReference<AuthorizationException> authException, @Named(PROPERTY_SESSION_INTERVAL) long seconds,
protected final Supplier<Set<? extends Hardware>> supplySizeCache(AtomicReference<AuthorizationException> authException, @Named(PROPERTY_SESSION_INTERVAL) long seconds,
final Supplier<Set<? extends Hardware>> hardwareSupplier) {
return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create(authException, hardwareSupplier,
seconds, TimeUnit.SECONDS);
@ -292,7 +300,7 @@ public abstract class BaseComputeServiceContextModule extends AbstractModule {
@Provides
@Singleton
protected Function<ComputeMetadata, String> indexer() {
protected final Function<ComputeMetadata, String> indexer() {
return new Function<ComputeMetadata, String>() {
@Override
public String apply(ComputeMetadata from) {
@ -304,7 +312,7 @@ public abstract class BaseComputeServiceContextModule extends AbstractModule {
@Provides
@Singleton
public final Optional<ImageExtension> guiceProvideImageExtension(Injector i) {
return provideImageExtension(i);
return provideImageExtension(i);
}
protected Optional<ImageExtension> provideImageExtension(Injector i) {
@ -313,8 +321,8 @@ public abstract class BaseComputeServiceContextModule extends AbstractModule {
@Provides
@Singleton
protected Optional<SecurityGroupExtension> guiceProvideSecurityGroupExtension(Injector i)
return provideSecurityGroupExtension(i);
protected final Optional<SecurityGroupExtension> guiceProvideSecurityGroupExtension(Injector i) {
return provideSecurityGroupExtension(i);
}
protected Optional<SecurityGroupExtension> provideSecurityGroupExtension(Injector i) {

View File

@ -76,7 +76,7 @@ public class ComputeServiceAdapterContextModule<N, H, I, L> extends BaseComputeS
@Provides
@Singleton
protected LocationsSupplier supplyLocationsFromComputeServiceAdapter(
protected final LocationsSupplier supplyLocationsFromComputeServiceAdapter(
final ComputeServiceAdapter<N, H, I, L> adapter, final Function<L, Location> transformer) {
return new LocationsSupplier() {
@Override
@ -93,7 +93,7 @@ public class ComputeServiceAdapterContextModule<N, H, I, L> extends BaseComputeS
@Provides
@Singleton
protected Supplier<Set<? extends Hardware>> provideHardware(final ComputeServiceAdapter<N, H, I, L> adapter,
protected final Supplier<Set<? extends Hardware>> provideHardware(final ComputeServiceAdapter<N, H, I, L> adapter,
final Function<H, Hardware> transformer) {
return new Supplier<Set<? extends Hardware>>() {
@Override
@ -113,7 +113,7 @@ public class ComputeServiceAdapterContextModule<N, H, I, L> extends BaseComputeS
@Provides
@Singleton
protected Supplier<Set<? extends Image>> provideImages(final ComputeServiceAdapter<N, H, I, L> adapter,
protected final Supplier<Set<? extends Image>> provideImages(final ComputeServiceAdapter<N, H, I, L> adapter,
final Function<I, Image> transformer, final AddDefaultCredentialsToImage addDefaultCredentialsToImage) {
return new Supplier<Set<? extends Image>>() {
@Override
@ -152,50 +152,50 @@ public class ComputeServiceAdapterContextModule<N, H, I, L> extends BaseComputeS
@Provides
@Singleton
protected CreateNodeWithGroupEncodedIntoName defineAddNodeWithTagStrategy(
protected final CreateNodeWithGroupEncodedIntoName defineAddNodeWithTagStrategy(
AdaptingComputeServiceStrategies<N, H, I, L> in) {
return in;
}
@Provides
@Singleton
protected DestroyNodeStrategy defineDestroyNodeStrategy(AdaptingComputeServiceStrategies<N, H, I, L> in) {
protected final DestroyNodeStrategy defineDestroyNodeStrategy(AdaptingComputeServiceStrategies<N, H, I, L> in) {
return in;
}
@Provides
@Singleton
protected GetNodeMetadataStrategy defineGetNodeMetadataStrategy(AdaptingComputeServiceStrategies<N, H, I, L> in) {
protected final GetNodeMetadataStrategy defineGetNodeMetadataStrategy(AdaptingComputeServiceStrategies<N, H, I, L> in) {
return in;
}
@Provides
@Singleton
protected GetImageStrategy defineGetImageStrategy(AdaptingComputeServiceStrategies<N, H, I, L> in) {
protected final GetImageStrategy defineGetImageStrategy(AdaptingComputeServiceStrategies<N, H, I, L> in) {
return in;
}
@Provides
@Singleton
protected ListNodesStrategy defineListNodesStrategy(AdaptingComputeServiceStrategies<N, H, I, L> in) {
protected final ListNodesStrategy defineListNodesStrategy(AdaptingComputeServiceStrategies<N, H, I, L> in) {
return in;
}
@Provides
@Singleton
protected RebootNodeStrategy defineRebootNodeStrategy(AdaptingComputeServiceStrategies<N, H, I, L> in) {
protected final RebootNodeStrategy defineRebootNodeStrategy(AdaptingComputeServiceStrategies<N, H, I, L> in) {
return in;
}
@Provides
@Singleton
protected ResumeNodeStrategy defineStartNodeStrategy(AdaptingComputeServiceStrategies<N, H, I, L> in) {
protected final ResumeNodeStrategy defineStartNodeStrategy(AdaptingComputeServiceStrategies<N, H, I, L> in) {
return in;
}
@Provides
@Singleton
protected SuspendNodeStrategy defineStopNodeStrategy(AdaptingComputeServiceStrategies<N, H, I, L> in) {
protected final SuspendNodeStrategy defineStopNodeStrategy(AdaptingComputeServiceStrategies<N, H, I, L> in) {
return in;
}
}

View File

@ -54,6 +54,11 @@ public class ComputeServiceTimeoutsModule extends AbstractModule {
@Provides
@Singleton
@Named(TIMEOUT_NODE_RUNNING)
protected final Predicate<AtomicReference<NodeMetadata>> provideNodeRunning(AtomicNodeRunning statusRunning, Timeouts timeouts,
PollPeriod period) {
return nodeRunning(statusRunning, timeouts, period);
}
protected Predicate<AtomicReference<NodeMetadata>> nodeRunning(AtomicNodeRunning statusRunning, Timeouts timeouts,
PollPeriod period) {
return timeouts.nodeRunning == 0 ? statusRunning : RetryablePredicateGuardingNull.create(statusRunning,
@ -63,6 +68,11 @@ public class ComputeServiceTimeoutsModule extends AbstractModule {
@Provides
@Singleton
@Named(TIMEOUT_NODE_TERMINATED)
protected final Predicate<AtomicReference<NodeMetadata>> provideServerTerminated(AtomicNodeTerminated statusTerminated,
Timeouts timeouts, PollPeriod period) {
return serverTerminated(statusTerminated, timeouts, period);
}
protected Predicate<AtomicReference<NodeMetadata>> serverTerminated(AtomicNodeTerminated statusTerminated,
Timeouts timeouts, PollPeriod period) {
return timeouts.nodeTerminated == 0 ? statusTerminated : retry(statusTerminated, timeouts.nodeTerminated,
@ -72,6 +82,11 @@ public class ComputeServiceTimeoutsModule extends AbstractModule {
@Provides
@Singleton
@Named(TIMEOUT_NODE_SUSPENDED)
protected final Predicate<AtomicReference<NodeMetadata>> provideserverSuspended(AtomicNodeSuspended statusSuspended,
Timeouts timeouts, PollPeriod period) {
return serverSuspended(statusSuspended, timeouts, period);
}
protected Predicate<AtomicReference<NodeMetadata>> serverSuspended(AtomicNodeSuspended statusSuspended,
Timeouts timeouts, PollPeriod period) {
return timeouts.nodeSuspended == 0 ? statusSuspended : RetryablePredicateGuardingNull.create(statusSuspended,
@ -81,6 +96,10 @@ public class ComputeServiceTimeoutsModule extends AbstractModule {
@Provides
@Singleton
@Named(TIMEOUT_SCRIPT_COMPLETE)
protected final Predicate<CommandUsingClient> provideRunScriptRunning(ScriptStatusReturnsZero statusRunning, Timeouts timeouts) {
return runScriptRunning(statusRunning, timeouts);
}
protected Predicate<CommandUsingClient> runScriptRunning(ScriptStatusReturnsZero statusRunning, Timeouts timeouts) {
return timeouts.scriptComplete == 0 ? not(statusRunning) : retry(not(statusRunning), timeouts.scriptComplete);
}
@ -88,7 +107,7 @@ public class ComputeServiceTimeoutsModule extends AbstractModule {
@Provides
@Singleton
@Named(TIMEOUT_IMAGE_AVAILABLE)
protected Predicate<AtomicReference<Image>> imageAvailable(AtomicImageAvailable statusAvailable, Timeouts timeouts,
protected final Predicate<AtomicReference<Image>> imageAvailable(AtomicImageAvailable statusAvailable, Timeouts timeouts,
PollPeriod period) {
return timeouts.imageAvailable == 0 ? statusAvailable : retry(statusAvailable, timeouts.imageAvailable,
period.pollInitialPeriod, period.pollMaxPeriod);
@ -97,7 +116,7 @@ public class ComputeServiceTimeoutsModule extends AbstractModule {
@Provides
@Singleton
@Named(TIMEOUT_IMAGE_DELETED)
protected Predicate<AtomicReference<Image>> serverDeleted(AtomicImageDeleted statusDeleted, Timeouts timeouts,
protected final Predicate<AtomicReference<Image>> serverDeleted(AtomicImageDeleted statusDeleted, Timeouts timeouts,
PollPeriod period) {
return timeouts.imageDeleted == 0 ? statusDeleted : retry(statusDeleted, timeouts.imageDeleted,
period.pollInitialPeriod, period.pollMaxPeriod);

View File

@ -72,7 +72,7 @@ public class StubComputeServiceDependenciesModule extends AbstractModule {
@Provides
@Singleton
protected ConcurrentMap<String, NodeMetadata> provideNodesForIdentity(@Provider Supplier<Credentials> creds)
protected final ConcurrentMap<String, NodeMetadata> provideNodesForIdentity(@Provider Supplier<Credentials> creds)
throws ExecutionException {
return backing.get(creds.get().identity);
}
@ -89,7 +89,7 @@ public class StubComputeServiceDependenciesModule extends AbstractModule {
@Provides
@Singleton
protected ConcurrentMap<String, SecurityGroup> provideGroups(@Provider Supplier<Credentials> creds)
protected final ConcurrentMap<String, SecurityGroup> provideGroups(@Provider Supplier<Credentials> creds)
throws ExecutionException {
return groupBacking.get(creds.get().identity);
}
@ -106,7 +106,7 @@ public class StubComputeServiceDependenciesModule extends AbstractModule {
@Provides
@Singleton
protected Multimap<String, SecurityGroup> provideGroupsForNode(@Provider Supplier<Credentials> creds)
protected final Multimap<String, SecurityGroup> provideGroupsForNode(@Provider Supplier<Credentials> creds)
throws ExecutionException {
return groupsForNodeBacking.get(creds.get().identity);
}
@ -123,7 +123,7 @@ public class StubComputeServiceDependenciesModule extends AbstractModule {
@Provides
@Named("NODE_ID")
protected Integer provideNodeIdForIdentity(@Provider Supplier<Credentials> creds) throws ExecutionException {
protected final Integer provideNodeIdForIdentity(@Provider Supplier<Credentials> creds) throws ExecutionException {
return nodeIds.get(creds.get().identity).incrementAndGet();
}
@ -139,34 +139,34 @@ public class StubComputeServiceDependenciesModule extends AbstractModule {
@Provides
@Named("GROUP_ID")
protected Integer provideGroupIdForIdentity(@Provider Supplier<Credentials> creds) throws ExecutionException {
protected final Integer provideGroupIdForIdentity(@Provider Supplier<Credentials> creds) throws ExecutionException {
return groupIds.get(creds.get().identity).incrementAndGet();
}
@Singleton
@Provides
@Named("PUBLIC_IP_PREFIX")
String publicIpPrefix() {
final String publicIpPrefix() {
return "144.175.1.";
}
@Singleton
@Provides
@Named("PRIVATE_IP_PREFIX")
String privateIpPrefix() {
final String privateIpPrefix() {
return "10.1.1.";
}
@Singleton
@Provides
@Named("PASSWORD_PREFIX")
String passwordPrefix() {
final String passwordPrefix() {
return "password";
}
@Singleton
@Provides
SocketOpen socketOpen(StubSocketOpen in) {
final SocketOpen socketOpen(StubSocketOpen in) {
return in;
}

View File

@ -112,14 +112,14 @@ public class ExecutorServiceModule extends AbstractModule {
@Provides
@Singleton
TimeLimiter timeLimiter(@Named(PROPERTY_USER_THREADS) ListeningExecutorService userExecutor) {
final TimeLimiter timeLimiter(@Named(PROPERTY_USER_THREADS) ListeningExecutorService userExecutor) {
return new SimpleTimeLimiter(userExecutor);
}
@Provides
@Singleton
@Named(PROPERTY_USER_THREADS)
ListeningExecutorService provideListeningUserExecutorService(@Named(PROPERTY_USER_THREADS) int count, Closer closer) { // NO_UCD
final ListeningExecutorService provideListeningUserExecutorService(@Named(PROPERTY_USER_THREADS) int count, Closer closer) { // NO_UCD
if (userExecutorFromConstructor != null)
return userExecutorFromConstructor;
return shutdownOnClose(WithSubmissionTrace.wrap(newThreadPoolNamed("user thread %d", count)), closer);
@ -128,7 +128,7 @@ public class ExecutorServiceModule extends AbstractModule {
@Provides
@Singleton
@Named(PROPERTY_USER_THREADS)
ExecutorService provideUserExecutorService(@Named(PROPERTY_USER_THREADS) ListeningExecutorService in) { // NO_UCD
final ExecutorService provideUserExecutorService(@Named(PROPERTY_USER_THREADS) ListeningExecutorService in) { // NO_UCD
return in;
}

View File

@ -48,7 +48,7 @@ public class ScheduledExecutorServiceModule extends AbstractModule {
@Provides
@Singleton
@Named(PROPERTY_SCHEDULER_THREADS)
ListeningScheduledExecutorService provideListeningScheduledExecutorService(
final ListeningScheduledExecutorService provideListeningScheduledExecutorService(
@Named(PROPERTY_SCHEDULER_THREADS) int count, Closer closer) {
return shutdownOnClose(WithSubmissionTrace.wrap(newScheduledThreadPoolNamed("scheduler thread %d", count)),
closer);
@ -57,7 +57,7 @@ public class ScheduledExecutorServiceModule extends AbstractModule {
@Provides
@Singleton
@Named(PROPERTY_SCHEDULER_THREADS)
ScheduledExecutorService provideScheduledExecutor(
final ScheduledExecutorService provideScheduledExecutor(
@Named(PROPERTY_SCHEDULER_THREADS) ListeningScheduledExecutorService in) {
return in;
}

View File

@ -50,7 +50,7 @@ public class EventBusModule extends AbstractModule {
*/
@Provides
@Singleton
AsyncEventBus provideAsyncEventBus(@Named(PROPERTY_USER_THREADS) ListeningExecutorService userExecutor,
final AsyncEventBus provideAsyncEventBus(@Named(PROPERTY_USER_THREADS) ListeningExecutorService userExecutor,
DeadEventLoggingHandler deadEventsHandler) {// NO_UCD
AsyncEventBus asyncBus = new AsyncEventBus("jclouds-async-event-bus", userExecutor);
asyncBus.register(deadEventsHandler);
@ -62,7 +62,7 @@ public class EventBusModule extends AbstractModule {
*/
@Provides
@Singleton
EventBus provideSyncEventBus(DeadEventLoggingHandler deadEventsHandler) { // NO_UCD
final EventBus provideSyncEventBus(DeadEventLoggingHandler deadEventsHandler) { // NO_UCD
EventBus syncBus = new EventBus("jclouds-sync-event-bus");
syncBus.register(deadEventsHandler);
return syncBus;

View File

@ -68,7 +68,7 @@ public class SaxParserModule extends AbstractModule {
@Provides
@Singleton
SAXParserFactory provideSAXParserFactory() {
final SAXParserFactory provideSAXParserFactory() {
SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setNamespaceAware(false);
factory.setValidating(false);

View File

@ -87,7 +87,7 @@ public class GsonModule extends AbstractModule {
@SuppressWarnings("rawtypes")
@Provides
@Singleton
Gson provideGson(TypeAdapter<JsonBall> jsonAdapter, DateAdapter adapter, ByteListAdapter byteListAdapter,
final Gson provideGson(TypeAdapter<JsonBall> jsonAdapter, DateAdapter adapter, ByteListAdapter byteListAdapter,
ByteArrayAdapter byteArrayAdapter, PropertiesAdapter propertiesAdapter, JsonAdapterBindings bindings,
CredentialsAdapterFactory credentialsAdapterFactory, OptionalTypeAdapterFactory optional,
SetTypeAdapterFactory set, ImmutableSetTypeAdapterFactory immutableSet, MapTypeAdapterFactory map,
@ -165,7 +165,7 @@ public class GsonModule extends AbstractModule {
@Provides
@Singleton
protected TypeAdapter<JsonBall> provideJsonBallAdapter(NullHackJsonBallAdapter in) {
protected final TypeAdapter<JsonBall> provideJsonBallAdapter(NullHackJsonBallAdapter in) {
return in;
}

View File

@ -75,7 +75,7 @@ public class LocationModule extends AbstractModule {
@Provides
@Singleton
@Iso3166
protected Supplier<Map<String, Supplier<Set<String>>>> isoCodesSupplier(
protected final Supplier<Map<String, Supplier<Set<String>>>> isoCodesSupplier(
AtomicReference<AuthorizationException> authException, @Named(PROPERTY_SESSION_INTERVAL) long seconds,
LocationIdToIso3166CodesSupplier uncached) {
return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create(authException, uncached, seconds,
@ -85,7 +85,7 @@ public class LocationModule extends AbstractModule {
@Provides
@Singleton
@Provider
protected Supplier<URI> provideProvider(AtomicReference<AuthorizationException> authException,
protected final Supplier<URI> provideProvider(AtomicReference<AuthorizationException> authException,
@Named(PROPERTY_SESSION_INTERVAL) long seconds, ProviderURISupplier uncached) {
return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create(authException, uncached, seconds,
TimeUnit.SECONDS);
@ -93,7 +93,7 @@ public class LocationModule extends AbstractModule {
@Provides
@Singleton
protected Supplier<Location> implicitLocationSupplier(AtomicReference<AuthorizationException> authException,
protected final Supplier<Location> implicitLocationSupplier(AtomicReference<AuthorizationException> authException,
@Named(PROPERTY_SESSION_INTERVAL) long seconds, ImplicitLocationSupplier uncached) {
return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create(authException, uncached, seconds,
TimeUnit.SECONDS);
@ -103,7 +103,7 @@ public class LocationModule extends AbstractModule {
@Singleton
// TODO: we should eventually get rid of memoized as an annotation, as it is confusing
@Memoized
protected Supplier<Set<? extends Location>> memoizedLocationsSupplier(
protected final Supplier<Set<? extends Location>> memoizedLocationsSupplier(
AtomicReference<AuthorizationException> authException, @Named(PROPERTY_SESSION_INTERVAL) long seconds,
LocationsSupplier uncached) {
return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create(authException, uncached, seconds,
@ -113,7 +113,7 @@ public class LocationModule extends AbstractModule {
@Provides
@Singleton
@Region
protected Supplier<Set<String>> regionIdsSupplier(AtomicReference<AuthorizationException> authException,
protected final Supplier<Set<String>> regionIdsSupplier(AtomicReference<AuthorizationException> authException,
@Named(PROPERTY_SESSION_INTERVAL) long seconds, RegionIdFilter filter, RegionIdsSupplier uncached) {
return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create(authException,
Suppliers.compose(new FilterStrings(filter), uncached), seconds, TimeUnit.SECONDS);
@ -122,7 +122,7 @@ public class LocationModule extends AbstractModule {
@Provides
@Singleton
@Zone
protected Supplier<Set<String>> zoneIdsSupplier(
protected final Supplier<Set<String>> zoneIdsSupplier(
AtomicReference<AuthorizationException> authException, @Named(PROPERTY_SESSION_INTERVAL) long seconds,
ZoneIdFilter filter, ZoneIdsSupplier uncached) {
return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create(authException,
@ -152,7 +152,7 @@ public class LocationModule extends AbstractModule {
@Provides
@Singleton
@Region
protected Supplier<Map<String, Supplier<URI>>> regionIdToURISupplier(
protected final Supplier<Map<String, Supplier<URI>>> regionIdToURISupplier(
AtomicReference<AuthorizationException> authException, @Named(PROPERTY_SESSION_INTERVAL) long seconds,
RegionIdToURISupplier uncached) {
return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create(authException, uncached, seconds,
@ -162,7 +162,7 @@ public class LocationModule extends AbstractModule {
@Provides
@Singleton
@Region
protected Supplier<String> implicitRegionIdSupplier(AtomicReference<AuthorizationException> authException,
protected final Supplier<String> implicitRegionIdSupplier(AtomicReference<AuthorizationException> authException,
@Named(PROPERTY_SESSION_INTERVAL) long seconds, ImplicitRegionIdSupplier uncached) {
return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create(authException, uncached, seconds,
TimeUnit.SECONDS);
@ -172,7 +172,7 @@ public class LocationModule extends AbstractModule {
@Provides
@Singleton
@Zone
protected Supplier<Map<String, Supplier<Set<String>>>> regionIdToZoneIdsSupplier(
protected final Supplier<Map<String, Supplier<Set<String>>>> regionIdToZoneIdsSupplier(
AtomicReference<AuthorizationException> authException, @Named(PROPERTY_SESSION_INTERVAL) long seconds,
RegionIdToZoneIdsSupplier uncached) {
return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create(authException, uncached, seconds,
@ -182,7 +182,7 @@ public class LocationModule extends AbstractModule {
@Provides
@Singleton
@Zone
protected Supplier<Map<String, Supplier<URI>>> zoneIdToURISupplier(
protected final Supplier<Map<String, Supplier<URI>>> zoneIdToURISupplier(
AtomicReference<AuthorizationException> authException, @Named(PROPERTY_SESSION_INTERVAL) long seconds,
ZoneIdToURISupplier uncached) {
return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create(authException, uncached, seconds,

View File

@ -38,7 +38,7 @@ public abstract class LoggingModule extends AbstractModule {
@Provides
@Singleton
public final Logger.LoggerFactory provideLoggerFactory() {
return createLoggerFactory();
return createLoggerFactory();
}
public abstract Logger.LoggerFactory createLoggerFactory();

View File

@ -104,7 +104,7 @@ public class CredentialStoreModule extends AbstractModule {
@Provides
@Singleton
protected Map<String, Credentials> provideCredentialStore(Map<String, ByteSource> backing,
protected final Map<String, Credentials> provideCredentialStore(Map<String, ByteSource> backing,
Function<Credentials, ByteSource> credentialsSerializer,
Function<ByteSource, Credentials> credentialsDeserializer) {
return new TransformingMap<String, ByteSource, Credentials>(backing, credentialsDeserializer,

View File

@ -74,7 +74,7 @@ public class ApacheHCHttpCommandExecutorServiceModule extends AbstractModule {
@Singleton
@Provides
HttpParams newBasicHttpParams(HttpUtils utils) {
final HttpParams newBasicHttpParams(HttpUtils utils) {
BasicHttpParams params = new BasicHttpParams();
params.setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, 8 * 1024).setBooleanParameter(
@ -102,14 +102,14 @@ public class ApacheHCHttpCommandExecutorServiceModule extends AbstractModule {
@Singleton
@Provides
X509HostnameVerifier newHostnameVerifier(HttpUtils utils) {
final X509HostnameVerifier newHostnameVerifier(HttpUtils utils) {
return utils.relaxHostname() ? SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER
: SSLSocketFactory.STRICT_HOSTNAME_VERIFIER;
}
@Singleton
@Provides
SSLContext newSSLContext(HttpUtils utils, @Named("untrusted") Supplier<SSLContext> untrustedSSLContextProvider)
final SSLContext newSSLContext(HttpUtils utils, @Named("untrusted") Supplier<SSLContext> untrustedSSLContextProvider)
throws NoSuchAlgorithmException, KeyManagementException {
if (utils.trustAllCerts())
return untrustedSSLContextProvider.get();
@ -121,7 +121,7 @@ public class ApacheHCHttpCommandExecutorServiceModule extends AbstractModule {
@Singleton
@Provides
ClientConnectionManager newClientConnectionManager(HttpParams params, X509HostnameVerifier verifier,
final ClientConnectionManager newClientConnectionManager(HttpParams params, X509HostnameVerifier verifier,
SSLContext context, Closer closer) throws NoSuchAlgorithmException, KeyManagementException {
SchemeRegistry schemeRegistry = new SchemeRegistry();
@ -143,7 +143,7 @@ public class ApacheHCHttpCommandExecutorServiceModule extends AbstractModule {
@Provides
@Singleton
HttpClient newDefaultHttpClient(ProxyConfig config, BasicHttpParams params, ClientConnectionManager cm) {
final HttpClient newDefaultHttpClient(ProxyConfig config, BasicHttpParams params, ClientConnectionManager cm) {
DefaultHttpClient client = new DefaultHttpClient(cm, params);
if (config.useSystem()) {
ProxySelectorRoutePlanner routePlanner = new ProxySelectorRoutePlanner(client.getConnectionManager()

View File

@ -99,7 +99,7 @@ public class CurrentRequestExecutorServiceModule extends AbstractModule {
@Provides
@Singleton
@Named(Constants.PROPERTY_USER_THREADS)
protected ListeningExecutorService userExecutor() {
protected final ListeningExecutorService userExecutor() {
return memoizedCurrentRequestExecutorService.get();
}
}

View File

@ -80,7 +80,7 @@ public class GoogleAppEngineConfigurationModule extends AbstractModule {
}
@Provides
protected URLFetchService provideURLFetchService() {
protected final URLFetchService provideURLFetchService() {
return URLFetchServiceFactory.getURLFetchService();
}
}

View File

@ -124,6 +124,11 @@ public class AWSEC2ComputeServiceContextModule extends BaseComputeServiceContext
// duplicates EC2ComputeServiceContextModule; but that's easiest thing to do with guice; could extract to common util
@Provides
@Singleton
protected final Supplier<CacheLoader<RegionAndName, Image>> guiceProvideRegionAndNameToImageSupplierCacheLoader(
final RegionAndIdToImage delegate) {
return provideRegionAndNameToImageSupplierCacheLoader(delegate);
}
protected Supplier<CacheLoader<RegionAndName, Image>> provideRegionAndNameToImageSupplierCacheLoader(
final RegionAndIdToImage delegate) {
return Suppliers.<CacheLoader<RegionAndName, Image>>ofInstance(new CacheLoader<RegionAndName, Image>() {
@ -149,7 +154,7 @@ public class AWSEC2ComputeServiceContextModule extends BaseComputeServiceContext
@Provides
@Singleton
protected Supplier<LoadingCache<RegionAndName, ? extends Image>> provideRegionAndNameToImageSupplierCache(
protected final Supplier<LoadingCache<RegionAndName, ? extends Image>> provideRegionAndNameToImageSupplierCache(
final RegionAndNameToImageSupplier supplier) {
return supplier;
}

View File

@ -119,7 +119,7 @@ public class AWSEC2ComputeServiceDependenciesModule extends EC2ComputeServiceDep
@Provides
@Singleton
@ImageQuery
protected Map<String, String> imageQuery(ValueOfConfigurationKeyOrNull config) {
protected final Map<String, String> imageQuery(ValueOfConfigurationKeyOrNull config) {
String amiQuery = Strings.emptyToNull(config.apply(PROPERTY_EC2_AMI_QUERY));
String owners = config.apply(PROPERTY_EC2_AMI_OWNERS);
if ("".equals(owners)) {
@ -147,28 +147,28 @@ public class AWSEC2ComputeServiceDependenciesModule extends EC2ComputeServiceDep
@Provides
@Singleton
@Named("AVAILABLE")
protected Predicate<PlacementGroup> placementGroupAvailable(PlacementGroupAvailable available) {
protected final Predicate<PlacementGroup> placementGroupAvailable(PlacementGroupAvailable available) {
return retry(available, 60, 1, SECONDS);
}
@Provides
@Singleton
@Named("DELETED")
protected Predicate<PlacementGroup> placementGroupDeleted(PlacementGroupDeleted deleted) {
protected final Predicate<PlacementGroup> placementGroupDeleted(PlacementGroupDeleted deleted) {
return retry(deleted, 60, 1, SECONDS);
}
@Provides
@Singleton
@Named("PLACEMENT")
protected LoadingCache<RegionAndName, String> placementGroupMap(CreatePlacementGroupIfNeeded in) {
protected final LoadingCache<RegionAndName, String> placementGroupMap(CreatePlacementGroupIfNeeded in) {
return CacheBuilder.newBuilder().build(in);
}
@Provides
@ClusterCompute
@Singleton
protected Set<String> provideClusterComputeIds() {
protected final Set<String> provideClusterComputeIds() {
return Sets.newLinkedHashSet();
}

View File

@ -57,25 +57,25 @@ public class AWSEC2HttpApiModule extends BaseEC2HttpApiModule<AWSEC2Api> {
@Singleton
@Provides
EC2Api provide(AWSEC2Api in) {
final EC2Api provide(AWSEC2Api in) {
return in;
}
@Singleton
@Provides
InstanceApi getInstanceApi(AWSEC2Api in) {
final InstanceApi getInstanceApi(AWSEC2Api in) {
return in.getInstanceApi().get();
}
@Singleton
@Provides
SecurityGroupApi getSecurityGroupApi(AWSEC2Api in) {
final SecurityGroupApi getSecurityGroupApi(AWSEC2Api in) {
return in.getSecurityGroupApi().get();
}
@Singleton
@Provides
AMIApi getAMIApi(AWSEC2Api in) {
final AMIApi getAMIApi(AWSEC2Api in) {
return in.getAMIApi().get();
}

View File

@ -63,7 +63,7 @@ public class AWSS3HttpApiModule extends S3HttpApiModule<AWSS3Client> {
@Singleton
@Provides
S3Client provide(AWSS3Client in) {
final S3Client provide(AWSS3Client in) {
return in;
}
}

View File

@ -46,7 +46,7 @@ public class AzureBlobStoreContextModule extends AbstractModule {
@Provides
@Singleton
protected LoadingCache<String, PublicAccess> containerAcls(final AzureBlobClient client) {
protected final LoadingCache<String, PublicAccess> containerAcls(final AzureBlobClient client) {
return CacheBuilder.newBuilder().expireAfterWrite(30, TimeUnit.SECONDS).build(
new CacheLoader<String, PublicAccess>() {
@Override

View File

@ -17,8 +17,6 @@
package org.jclouds.azureblob.config;
import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
import static org.jclouds.json.config.GsonModule.DateAdapter;
import static org.jclouds.json.config.GsonModule.Iso8601DateAdapter;
import java.util.concurrent.TimeUnit;
@ -34,6 +32,8 @@ import org.jclouds.http.HttpRetryHandler;
import org.jclouds.http.annotation.ClientError;
import org.jclouds.http.annotation.Redirection;
import org.jclouds.http.annotation.ServerError;
import org.jclouds.json.config.GsonModule.DateAdapter;
import org.jclouds.json.config.GsonModule.Iso8601DateAdapter;
import org.jclouds.rest.ConfiguresHttpApi;
import org.jclouds.rest.config.HttpApiModule;
@ -56,6 +56,10 @@ public class AzureBlobHttpApiModule extends HttpApiModule<AzureBlobClient> {
@Provides
@TimeStamp
protected final String guiceProvideTimeStamp(@TimeStamp Supplier<String> cache) {
return provideTimeStamp(cache);
}
protected String provideTimeStamp(@TimeStamp Supplier<String> cache) {
return cache.get();
}
@ -68,6 +72,7 @@ public class AzureBlobHttpApiModule extends HttpApiModule<AzureBlobClient> {
protected Supplier<String> provideTimeStampCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
final DateService dateService) {
return Suppliers.memoizeWithExpiration(new Supplier<String>() {
@Override
public String get() {
return dateService.rfc822DateFormat();
}

View File

@ -54,7 +54,7 @@ public class AzureBlobModule extends AbstractModule {
}
@Provides
AzureBlob provideAzureBlob(AzureBlob.Factory factory) {
final AzureBlob provideAzureBlob(AzureBlob.Factory factory) {
return factory.create(null);
}

View File

@ -51,7 +51,7 @@ public class DynECTParserModule extends AbstractModule {
@Provides
@Singleton
public Map<Type, Object> provideCustomAdapterBindings() {
public final Map<Type, Object> provideCustomAdapterBindings() {
return new ImmutableMap.Builder<Type, Object>()
.put(SessionCredentials.class, new SessionCredentialsTypeAdapter())
.put(GeoRegionGroup.class, new GeoRegionGroupTypeAdapter())

View File

@ -35,7 +35,7 @@ public class GleSYSParserModule extends AbstractModule {
@Provides
@Singleton
public Map<Type, Object> provideCustomAdapterBindings() {
public final Map<Type, Object> provideCustomAdapterBindings() {
return ImmutableMap.<Type, Object>of(Server.State.class, new GleSYSTypeAdapters.ServerStateAdapter(),
GleSYSBoolean.class, new GleSYSTypeAdapters.GleSYSBooleanAdapter());
}

View File

@ -92,7 +92,7 @@ public class GoGridComputeServiceContextModule extends
@Singleton
@Provides
Map<ServerState, Status> toPortableNodeStatus() {
final Map<ServerState, Status> toPortableNodeStatus() {
return toPortableNodeStatus;
}
@ -106,7 +106,7 @@ public class GoGridComputeServiceContextModule extends
@Singleton
@Provides
Map<ServerImageState, Image.Status> toPortableImageStatus() {
final Map<ServerImageState, Image.Status> toPortableImageStatus() {
return toPortableImageStatus;
}
@ -121,7 +121,7 @@ public class GoGridComputeServiceContextModule extends
*/
@Singleton
@Provides
Function<Hardware, String> provideSizeToRam() {
final Function<Hardware, String> provideSizeToRam() {
return new Function<Hardware, String>() {
@Override
public String apply(Hardware hardware) {

View File

@ -47,6 +47,10 @@ public class GoGridHttpApiModule extends HttpApiModule<GoGridApi> {
@Provides
@TimeStamp
protected final Long guiceProvideTimeStamp(@TimeStamp Supplier<Long> cache) {
return provideTimeStamp(cache);
}
protected Long provideTimeStamp(@TimeStamp Supplier<Long> cache) {
return cache.get();
}
@ -56,8 +60,9 @@ public class GoGridHttpApiModule extends HttpApiModule<GoGridApi> {
*/
@Provides
@TimeStamp
Supplier<Long> provideTimeStampCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds) {
final Supplier<Long> provideTimeStampCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds) {
return Suppliers.memoizeWithExpiration(new Supplier<Long>() {
@Override
public Long get() {
return System.currentTimeMillis() / 1000;
}

View File

@ -47,7 +47,7 @@ public class GoGridParserModule extends AbstractModule {
@Provides
@Singleton
public Map<Type, Object> provideCustomAdapterBindings() {
public final Map<Type, Object> provideCustomAdapterBindings() {
Map<Type, Object> bindings = Maps.newHashMap();
bindings.put(ObjectType.class, new CustomDeserializers.ObjectTypeAdapter());
bindings.put(LoadBalancerOs.class, new CustomDeserializers.LoadBalancerOsAdapter());

View File

@ -16,8 +16,6 @@
*/
package org.jclouds.googlecomputeengine.config;
import static org.jclouds.googlecomputeengine.domain.Firewall.Rule;
import java.lang.reflect.Type;
import java.util.Map;
import java.util.Set;
@ -26,6 +24,7 @@ import javax.inject.Singleton;
import org.jclouds.googlecloud.config.ListPageAdapterFactory;
import org.jclouds.googlecomputeengine.domain.Firewall;
import org.jclouds.googlecomputeengine.domain.Firewall.Rule;
import org.jclouds.googlecomputeengine.options.FirewallOptions;
import org.jclouds.googlecomputeengine.options.RouteOptions;
import org.jclouds.json.config.GsonModule;

View File

@ -85,7 +85,7 @@ public class HPCloudObjectStorageBlobStoreContextModule extends SwiftBlobStoreCo
@Provides
@Singleton
protected LoadingCache<String, URI> cdnContainer(GetCDNMetadata loader) {
protected final LoadingCache<String, URI> cdnContainer(GetCDNMetadata loader) {
return CacheBuilder.newBuilder().expireAfterWrite(30, TimeUnit.SECONDS).build(loader);
}

View File

@ -68,7 +68,7 @@ public class HPCloudObjectStorageHttpApiModule extends SwiftHttpApiModule<HPClou
@Singleton
@HPExtensionCDN
@Nullable
protected Supplier<URI> provideCDNUrl(RegionIdToURISupplier.Factory factory,
protected final Supplier<URI> provideCDNUrl(RegionIdToURISupplier.Factory factory,
@ApiVersion String apiVersion,
@Named(LocationConstants.PROPERTY_REGION) String region) {
@ -81,7 +81,7 @@ public class HPCloudObjectStorageHttpApiModule extends SwiftHttpApiModule<HPClou
@Singleton
@Storage
@Nullable
protected Supplier<URI> provideStorageUrl(RegionIdToURISupplier.Factory factory,
protected final Supplier<URI> provideStorageUrl(RegionIdToURISupplier.Factory factory,
@ApiVersion String apiVersion,
@Named(LocationConstants.PROPERTY_REGION) String region) {

View File

@ -79,7 +79,7 @@ public class SoftLayerComputeServiceContextModule extends
@Provides
@Singleton
@Memoized
public Supplier<ContainerVirtualGuestConfiguration> getCreateObjectOptions(
public final Supplier<ContainerVirtualGuestConfiguration> getCreateObjectOptions(
AtomicReference<AuthorizationException> authException, @Named(PROPERTY_SESSION_INTERVAL) long seconds,
final SoftLayerApi api) {
return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create(authException,