centralized RestContext<S,A> binding

This commit is contained in:
Adrian Cole 2012-01-10 12:18:51 -08:00
parent f570ec99e6
commit f3f56463b4
7 changed files with 15 additions and 16 deletions

View File

@ -91,6 +91,9 @@ public abstract class BaseCloudLoadBalancersAsyncClientTest<T> extends RestClien
(TypeLiteral) TypeLiteral.get(Types.newParameterizedType(
RestContextImpl.class, syncClientType, asyncClientType))).in(
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();
bindClient();
bindErrorHandlers();

View File

@ -186,9 +186,6 @@ public class CloudStackRestClientModule extends RestClientModule<CloudStackClien
@Override
protected void configure() {
bind(DateAdapter.class).to(CloudStackDateAdapter.class);
bind(new TypeLiteral<RestContext<CloudStackClient, CloudStackAsyncClient>>() {
}).to(new TypeLiteral<RestContextImpl<CloudStackClient, CloudStackAsyncClient>>() {
});
bind(new TypeLiteral<RestContext<CloudStackDomainClient, CloudStackDomainAsyncClient>>() {
}).to(new TypeLiteral<RestContextImpl<CloudStackDomainClient, CloudStackDomainAsyncClient>>() {
});

View File

@ -112,9 +112,6 @@ public class EC2ComputeServiceDependenciesModule extends AbstractModule {
bind(new TypeLiteral<ComputeServiceContext>() {
}).to(new TypeLiteral<ComputeServiceContextImpl<EC2Client, EC2AsyncClient>>() {
}).in(Scopes.SINGLETON);
bind(new TypeLiteral<RestContext<EC2Client, EC2AsyncClient>>() {
}).to(new TypeLiteral<RestContextImpl<EC2Client, EC2AsyncClient>>() {
}).in(Scopes.SINGLETON);
}
/**

View File

@ -21,7 +21,6 @@ package org.jclouds.s3.config;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import org.jclouds.javax.annotation.Nullable;
import javax.inject.Named;
import javax.inject.Singleton;
@ -30,10 +29,12 @@ import org.jclouds.aws.config.AWSRestClientModule;
import org.jclouds.date.DateService;
import org.jclouds.date.TimeStamp;
import org.jclouds.http.HttpErrorHandler;
import org.jclouds.http.HttpRetryHandler;
import org.jclouds.http.RequiresHttp;
import org.jclouds.http.annotation.ClientError;
import org.jclouds.http.annotation.Redirection;
import org.jclouds.http.annotation.ServerError;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.location.Region;
import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.RequestSigner;
@ -42,6 +43,7 @@ import org.jclouds.s3.S3AsyncClient;
import org.jclouds.s3.S3Client;
import org.jclouds.s3.filters.RequestAuthorizeSignature;
import org.jclouds.s3.handlers.ParseS3ErrorFromXmlContent;
import org.jclouds.s3.handlers.S3RedirectionRetryHandler;
import com.google.common.base.Supplier;
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) {
return in;
}
@Override
protected void bindRetryHandlers() {
bind(HttpRetryHandler.class).annotatedWith(Redirection.class).to(S3RedirectionRetryHandler.class);
}
@Provides
@TimeStamp

View File

@ -34,8 +34,6 @@ import org.jclouds.compute.domain.OperatingSystem;
import org.jclouds.compute.internal.ComputeServiceContextImpl;
import org.jclouds.compute.options.TemplateOptions;
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.TerremarkVCloudClient;
import org.jclouds.trmk.vcloud_0_8.compute.TerremarkVCloudComputeService;
@ -96,9 +94,6 @@ public class TerremarkVCloudComputeServiceContextModule extends BaseComputeServi
bind(new TypeLiteral<ComputeServiceContext>() {
}).to(new TypeLiteral<ComputeServiceContextImpl<TerremarkVCloudClient, TerremarkVCloudAsyncClient>>() {
}).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>>>() {
}).to(new TypeLiteral<ImagesInVCloudExpressOrg>() {
});

View File

@ -29,8 +29,8 @@ import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.RestContext;
import org.jclouds.rest.internal.RestContextImpl;
import com.google.common.cache.LoadingCache;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.LoadingCache;
import com.google.common.collect.ImmutableMap;
import com.google.inject.AbstractModule;
import com.google.inject.Provides;
@ -71,6 +71,9 @@ public class RestClientModule<S, A> extends AbstractModule {
(TypeLiteral) TypeLiteral.get(Types.newParameterizedType(
RestContextImpl.class, syncClientType, asyncClientType))).in(
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();
bindClient();
bindErrorHandlers();

View File

@ -60,9 +60,6 @@ public class RimuHostingComputeServiceDependenciesModule extends AbstractModule
bind(new TypeLiteral<ComputeServiceContext>() {
}).to(new TypeLiteral<ComputeServiceContextImpl<RimuHostingClient, RimuHostingAsyncClient>>() {
}).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>>>() {
}).to(ServerToPublicAddresses.class);