mirror of https://github.com/apache/jclouds.git
centralized RestContext<S,A> binding
This commit is contained in:
parent
f570ec99e6
commit
f3f56463b4
|
@ -91,6 +91,9 @@ public abstract class BaseCloudLoadBalancersAsyncClientTest<T> extends RestClien
|
||||||
(TypeLiteral) TypeLiteral.get(Types.newParameterizedType(
|
(TypeLiteral) TypeLiteral.get(Types.newParameterizedType(
|
||||||
RestContextImpl.class, syncClientType, asyncClientType))).in(
|
RestContextImpl.class, syncClientType, asyncClientType))).in(
|
||||||
Scopes.SINGLETON);
|
Scopes.SINGLETON);
|
||||||
|
bind(TypeLiteral.get(Types.newParameterizedType(RestContext.class, syncClientType, asyncClientType))).to(
|
||||||
|
(TypeLiteral) TypeLiteral.get(Types.newParameterizedType(RestContextImpl.class, syncClientType,
|
||||||
|
asyncClientType))).in(Scopes.SINGLETON);
|
||||||
bindAsyncClient();
|
bindAsyncClient();
|
||||||
bindClient();
|
bindClient();
|
||||||
bindErrorHandlers();
|
bindErrorHandlers();
|
||||||
|
|
|
@ -186,9 +186,6 @@ public class CloudStackRestClientModule extends RestClientModule<CloudStackClien
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
bind(DateAdapter.class).to(CloudStackDateAdapter.class);
|
bind(DateAdapter.class).to(CloudStackDateAdapter.class);
|
||||||
bind(new TypeLiteral<RestContext<CloudStackClient, CloudStackAsyncClient>>() {
|
|
||||||
}).to(new TypeLiteral<RestContextImpl<CloudStackClient, CloudStackAsyncClient>>() {
|
|
||||||
});
|
|
||||||
bind(new TypeLiteral<RestContext<CloudStackDomainClient, CloudStackDomainAsyncClient>>() {
|
bind(new TypeLiteral<RestContext<CloudStackDomainClient, CloudStackDomainAsyncClient>>() {
|
||||||
}).to(new TypeLiteral<RestContextImpl<CloudStackDomainClient, CloudStackDomainAsyncClient>>() {
|
}).to(new TypeLiteral<RestContextImpl<CloudStackDomainClient, CloudStackDomainAsyncClient>>() {
|
||||||
});
|
});
|
||||||
|
|
|
@ -112,9 +112,6 @@ public class EC2ComputeServiceDependenciesModule extends AbstractModule {
|
||||||
bind(new TypeLiteral<ComputeServiceContext>() {
|
bind(new TypeLiteral<ComputeServiceContext>() {
|
||||||
}).to(new TypeLiteral<ComputeServiceContextImpl<EC2Client, EC2AsyncClient>>() {
|
}).to(new TypeLiteral<ComputeServiceContextImpl<EC2Client, EC2AsyncClient>>() {
|
||||||
}).in(Scopes.SINGLETON);
|
}).in(Scopes.SINGLETON);
|
||||||
bind(new TypeLiteral<RestContext<EC2Client, EC2AsyncClient>>() {
|
|
||||||
}).to(new TypeLiteral<RestContextImpl<EC2Client, EC2AsyncClient>>() {
|
|
||||||
}).in(Scopes.SINGLETON);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -21,7 +21,6 @@ package org.jclouds.s3.config;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.jclouds.javax.annotation.Nullable;
|
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
@ -30,10 +29,12 @@ import org.jclouds.aws.config.AWSRestClientModule;
|
||||||
import org.jclouds.date.DateService;
|
import org.jclouds.date.DateService;
|
||||||
import org.jclouds.date.TimeStamp;
|
import org.jclouds.date.TimeStamp;
|
||||||
import org.jclouds.http.HttpErrorHandler;
|
import org.jclouds.http.HttpErrorHandler;
|
||||||
|
import org.jclouds.http.HttpRetryHandler;
|
||||||
import org.jclouds.http.RequiresHttp;
|
import org.jclouds.http.RequiresHttp;
|
||||||
import org.jclouds.http.annotation.ClientError;
|
import org.jclouds.http.annotation.ClientError;
|
||||||
import org.jclouds.http.annotation.Redirection;
|
import org.jclouds.http.annotation.Redirection;
|
||||||
import org.jclouds.http.annotation.ServerError;
|
import org.jclouds.http.annotation.ServerError;
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
import org.jclouds.location.Region;
|
import org.jclouds.location.Region;
|
||||||
import org.jclouds.rest.ConfiguresRestClient;
|
import org.jclouds.rest.ConfiguresRestClient;
|
||||||
import org.jclouds.rest.RequestSigner;
|
import org.jclouds.rest.RequestSigner;
|
||||||
|
@ -42,6 +43,7 @@ import org.jclouds.s3.S3AsyncClient;
|
||||||
import org.jclouds.s3.S3Client;
|
import org.jclouds.s3.S3Client;
|
||||||
import org.jclouds.s3.filters.RequestAuthorizeSignature;
|
import org.jclouds.s3.filters.RequestAuthorizeSignature;
|
||||||
import org.jclouds.s3.handlers.ParseS3ErrorFromXmlContent;
|
import org.jclouds.s3.handlers.ParseS3ErrorFromXmlContent;
|
||||||
|
import org.jclouds.s3.handlers.S3RedirectionRetryHandler;
|
||||||
|
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.common.base.Suppliers;
|
import com.google.common.base.Suppliers;
|
||||||
|
@ -100,6 +102,11 @@ public class S3RestClientModule<S extends S3Client, A extends S3AsyncClient> ext
|
||||||
protected RequestSigner provideRequestSigner(RequestAuthorizeSignature in) {
|
protected RequestSigner provideRequestSigner(RequestAuthorizeSignature in) {
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void bindRetryHandlers() {
|
||||||
|
bind(HttpRetryHandler.class).annotatedWith(Redirection.class).to(S3RedirectionRetryHandler.class);
|
||||||
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@TimeStamp
|
@TimeStamp
|
||||||
|
|
|
@ -34,8 +34,6 @@ import org.jclouds.compute.domain.OperatingSystem;
|
||||||
import org.jclouds.compute.internal.ComputeServiceContextImpl;
|
import org.jclouds.compute.internal.ComputeServiceContextImpl;
|
||||||
import org.jclouds.compute.options.TemplateOptions;
|
import org.jclouds.compute.options.TemplateOptions;
|
||||||
import org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy;
|
import org.jclouds.compute.strategy.PopulateDefaultLoginCredentialsForImageStrategy;
|
||||||
import org.jclouds.rest.RestContext;
|
|
||||||
import org.jclouds.rest.internal.RestContextImpl;
|
|
||||||
import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudAsyncClient;
|
import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudAsyncClient;
|
||||||
import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudClient;
|
import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudClient;
|
||||||
import org.jclouds.trmk.vcloud_0_8.compute.TerremarkVCloudComputeService;
|
import org.jclouds.trmk.vcloud_0_8.compute.TerremarkVCloudComputeService;
|
||||||
|
@ -96,9 +94,6 @@ public class TerremarkVCloudComputeServiceContextModule extends BaseComputeServi
|
||||||
bind(new TypeLiteral<ComputeServiceContext>() {
|
bind(new TypeLiteral<ComputeServiceContext>() {
|
||||||
}).to(new TypeLiteral<ComputeServiceContextImpl<TerremarkVCloudClient, TerremarkVCloudAsyncClient>>() {
|
}).to(new TypeLiteral<ComputeServiceContextImpl<TerremarkVCloudClient, TerremarkVCloudAsyncClient>>() {
|
||||||
}).in(Scopes.SINGLETON);
|
}).in(Scopes.SINGLETON);
|
||||||
bind(new TypeLiteral<RestContext<TerremarkVCloudClient, TerremarkVCloudAsyncClient>>() {
|
|
||||||
}).to(new TypeLiteral<RestContextImpl<TerremarkVCloudClient, TerremarkVCloudAsyncClient>>() {
|
|
||||||
}).in(Scopes.SINGLETON);
|
|
||||||
bind(new TypeLiteral<Function<Org, Iterable<? extends Image>>>() {
|
bind(new TypeLiteral<Function<Org, Iterable<? extends Image>>>() {
|
||||||
}).to(new TypeLiteral<ImagesInVCloudExpressOrg>() {
|
}).to(new TypeLiteral<ImagesInVCloudExpressOrg>() {
|
||||||
});
|
});
|
||||||
|
|
|
@ -29,8 +29,8 @@ import org.jclouds.rest.ConfiguresRestClient;
|
||||||
import org.jclouds.rest.RestContext;
|
import org.jclouds.rest.RestContext;
|
||||||
import org.jclouds.rest.internal.RestContextImpl;
|
import org.jclouds.rest.internal.RestContextImpl;
|
||||||
|
|
||||||
import com.google.common.cache.LoadingCache;
|
|
||||||
import com.google.common.cache.CacheBuilder;
|
import com.google.common.cache.CacheBuilder;
|
||||||
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.inject.AbstractModule;
|
import com.google.inject.AbstractModule;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
|
@ -71,6 +71,9 @@ public class RestClientModule<S, A> extends AbstractModule {
|
||||||
(TypeLiteral) TypeLiteral.get(Types.newParameterizedType(
|
(TypeLiteral) TypeLiteral.get(Types.newParameterizedType(
|
||||||
RestContextImpl.class, syncClientType, asyncClientType))).in(
|
RestContextImpl.class, syncClientType, asyncClientType))).in(
|
||||||
Scopes.SINGLETON);
|
Scopes.SINGLETON);
|
||||||
|
bind(TypeLiteral.get(Types.newParameterizedType(RestContext.class, syncClientType, asyncClientType))).to(
|
||||||
|
(TypeLiteral) TypeLiteral.get(Types.newParameterizedType(RestContextImpl.class, syncClientType,
|
||||||
|
asyncClientType))).in(Scopes.SINGLETON);
|
||||||
bindAsyncClient();
|
bindAsyncClient();
|
||||||
bindClient();
|
bindClient();
|
||||||
bindErrorHandlers();
|
bindErrorHandlers();
|
||||||
|
|
|
@ -60,9 +60,6 @@ public class RimuHostingComputeServiceDependenciesModule extends AbstractModule
|
||||||
bind(new TypeLiteral<ComputeServiceContext>() {
|
bind(new TypeLiteral<ComputeServiceContext>() {
|
||||||
}).to(new TypeLiteral<ComputeServiceContextImpl<RimuHostingClient, RimuHostingAsyncClient>>() {
|
}).to(new TypeLiteral<ComputeServiceContextImpl<RimuHostingClient, RimuHostingAsyncClient>>() {
|
||||||
}).in(Scopes.SINGLETON);
|
}).in(Scopes.SINGLETON);
|
||||||
bind(new TypeLiteral<RestContext<RimuHostingClient, RimuHostingAsyncClient>>() {
|
|
||||||
}).to(new TypeLiteral<RestContextImpl<RimuHostingClient, RimuHostingAsyncClient>>() {
|
|
||||||
}).in(Scopes.SINGLETON);
|
|
||||||
bind(new TypeLiteral<Function<Server, Iterable<String>>>() {
|
bind(new TypeLiteral<Function<Server, Iterable<String>>>() {
|
||||||
}).to(ServerToPublicAddresses.class);
|
}).to(ServerToPublicAddresses.class);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue