mirror of https://github.com/apache/jclouds.git
Merge branch 'master' of github.com:jclouds/jclouds into 1.5.x
* 'master' of github.com:jclouds/jclouds: fix covariance/assignability in RestContext<? extends Client> subclasses Issue 891: ensure we run apt update when install jdk fails
This commit is contained in:
commit
3c948c0320
|
@ -50,9 +50,6 @@ import com.google.inject.Provides;
|
|||
*/
|
||||
@ConfiguresRestClient
|
||||
public class AtmosRestClientModule extends RestClientModule<AtmosClient, AtmosAsyncClient> {
|
||||
public AtmosRestClientModule() {
|
||||
super(AtmosClient.class, AtmosAsyncClient.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
|
|
|
@ -54,10 +54,6 @@ import com.google.inject.Provides;
|
|||
@ConfiguresRestClient
|
||||
public class CloudFilesRestClientModule extends RestClientModule<CloudFilesClient, CloudFilesAsyncClient> {
|
||||
|
||||
public CloudFilesRestClientModule() {
|
||||
super(CloudFilesClient.class, CloudFilesAsyncClient.class);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
CommonSwiftClient provideCommonSwiftClient(CloudFilesClient in) {
|
||||
|
|
|
@ -73,7 +73,7 @@ public class CloudLoadBalancersRestClientModule extends
|
|||
.build();
|
||||
|
||||
public CloudLoadBalancersRestClientModule() {
|
||||
super(CloudLoadBalancersClient.class, CloudLoadBalancersAsyncClient.class, DELEGATE_MAP);
|
||||
super(DELEGATE_MAP);
|
||||
}
|
||||
|
||||
protected void installLocations() {
|
||||
|
|
|
@ -54,10 +54,6 @@ import com.google.inject.Provides;
|
|||
@ConfiguresRestClient
|
||||
public class CloudServersRestClientModule extends RestClientModule<CloudServersClient, CloudServersAsyncClient> {
|
||||
|
||||
public CloudServersRestClientModule() {
|
||||
super(CloudServersClient.class, CloudServersAsyncClient.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(DateAdapter.class).to(Iso8601DateAdapter.class);
|
||||
|
|
|
@ -57,10 +57,6 @@ import com.google.inject.TypeLiteral;
|
|||
@ConfiguresRestClient
|
||||
public class CloudSigmaRestClientModule extends RestClientModule<CloudSigmaClient, CloudSigmaAsyncClient> {
|
||||
|
||||
public CloudSigmaRestClientModule() {
|
||||
super(CloudSigmaClient.class, CloudSigmaAsyncClient.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void bindErrorHandlers() {
|
||||
bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(CloudSigmaErrorHandler.class);
|
||||
|
|
|
@ -221,7 +221,7 @@ public class CloudStackRestClientModule extends RestClientModule<CloudStackClien
|
|||
}
|
||||
|
||||
public CloudStackRestClientModule() {
|
||||
super(CloudStackClient.class, CloudStackAsyncClient.class, DELEGATE_MAP);
|
||||
super(DELEGATE_MAP);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -30,8 +30,5 @@ import org.jclouds.rest.ConfiguresRestClient;
|
|||
*/
|
||||
@ConfiguresRestClient
|
||||
public class CloudWatchRestClientModule extends FormSigningRestClientModule<CloudWatchClient, CloudWatchAsyncClient> {
|
||||
public CloudWatchRestClientModule() {
|
||||
super(CloudWatchClient.class, CloudWatchAsyncClient.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -63,10 +63,6 @@ import com.google.inject.Provides;
|
|||
@ConfiguresRestClient
|
||||
public class DeltacloudRestClientModule extends RestClientModule<DeltacloudClient, DeltacloudAsyncClient> {
|
||||
|
||||
public DeltacloudRestClientModule() {
|
||||
super(DeltacloudClient.class, DeltacloudAsyncClient.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void bindErrorHandlers() {
|
||||
bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(DeltacloudErrorHandler.class);
|
||||
|
|
|
@ -62,7 +62,7 @@ public class EC2ApiMetadata extends BaseRestApiMetadata {
|
|||
/** The serialVersionUID */
|
||||
private static final long serialVersionUID = 4424763314988423886L;
|
||||
|
||||
public static final TypeToken<RestContext<EC2Client, EC2AsyncClient>> CONTEXT_TOKEN = new TypeToken<RestContext<EC2Client, EC2AsyncClient>>() {
|
||||
public static final TypeToken<RestContext<? extends EC2Client, ? extends EC2AsyncClient>> CONTEXT_TOKEN = new TypeToken<RestContext<? extends EC2Client, ? extends EC2AsyncClient>>() {
|
||||
private static final long serialVersionUID = -5070937833892503232L;
|
||||
};
|
||||
|
||||
|
@ -103,6 +103,7 @@ public class EC2ApiMetadata extends BaseRestApiMetadata {
|
|||
.documentation(URI.create("http://docs.amazonwebservices.com/AWSEC2/latest/APIReference"))
|
||||
.version(EC2AsyncClient.VERSION)
|
||||
.defaultProperties(EC2ApiMetadata.defaultProperties())
|
||||
.context(CONTEXT_TOKEN)
|
||||
.wrapper(EC2ComputeServiceContext.class)
|
||||
.defaultModules(ImmutableSet.<Class<? extends Module>>of(EC2RestClientModule.class, EC2ResolveImagesModule.class, EC2ComputeServiceContextModule.class));
|
||||
}
|
||||
|
|
|
@ -49,6 +49,7 @@ import org.jclouds.location.suppliers.derived.ZoneIdsFromRegionIdToZoneIdsValues
|
|||
import org.jclouds.rest.ConfiguresRestClient;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.inject.Scopes;
|
||||
|
||||
/**
|
||||
|
@ -59,7 +60,6 @@ import com.google.inject.Scopes;
|
|||
@ConfiguresRestClient
|
||||
public class EC2RestClientModule<S extends EC2Client, A extends EC2AsyncClient> extends
|
||||
WithZonesFormSigningRestClientModule<S, A> {
|
||||
|
||||
public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>> builder()//
|
||||
.put(AMIClient.class, AMIAsyncClient.class)//
|
||||
.put(ElasticIPAddressClient.class, ElasticIPAddressAsyncClient.class)//
|
||||
|
@ -73,13 +73,16 @@ public class EC2RestClientModule<S extends EC2Client, A extends EC2AsyncClient>
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
public EC2RestClientModule() {
|
||||
this((Class) EC2Client.class, (Class) EC2AsyncClient.class, DELEGATE_MAP);
|
||||
super((TypeToken) TypeToken.of(EC2Client.class), (TypeToken) TypeToken.of(EC2AsyncClient.class), DELEGATE_MAP);
|
||||
}
|
||||
|
||||
public EC2RestClientModule(Class<S> sync, Class<A> async, Map<Class<?>, Class<?>> delegateMap) {
|
||||
super(sync, async, delegateMap);
|
||||
protected EC2RestClientModule(TypeToken<S> syncClientType, TypeToken<A> asyncClientType,
|
||||
Map<Class<?>, Class<?>> sync2Async) {
|
||||
super(syncClientType, asyncClientType, sync2Async);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected void installLocations() {
|
||||
install(new LocationModule());
|
||||
|
|
|
@ -65,10 +65,6 @@ public abstract class BaseEC2AsyncClientTest<T> extends BaseAsyncClientTest<T> {
|
|||
@ConfiguresRestClient
|
||||
protected static class StubEC2RestClientModule extends EC2RestClientModule<EC2Client, EC2AsyncClient> {
|
||||
|
||||
public StubEC2RestClientModule() {
|
||||
super(EC2Client.class, EC2AsyncClient.class, DELEGATE_MAP);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
LoadingCache<RegionAndName, Image> provide(){
|
||||
|
|
|
@ -57,10 +57,6 @@ import com.google.inject.TypeLiteral;
|
|||
@ConfiguresRestClient
|
||||
public class ElasticStackRestClientModule extends RestClientModule<ElasticStackClient, ElasticStackAsyncClient> {
|
||||
|
||||
public ElasticStackRestClientModule() {
|
||||
super(ElasticStackClient.class, ElasticStackAsyncClient.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
super.configure();
|
||||
|
|
|
@ -51,7 +51,6 @@ public class NovaRestClientModule extends RestClientModule<NovaClient, NovaAsync
|
|||
private final OpenStackAuthenticationModule module;
|
||||
|
||||
public NovaRestClientModule(OpenStackAuthenticationModule module) {
|
||||
super(NovaClient.class, NovaAsyncClient.class);
|
||||
this.module = module;
|
||||
}
|
||||
|
||||
|
|
|
@ -41,10 +41,6 @@ import com.google.inject.Scopes;
|
|||
@ConfiguresRestClient
|
||||
public class NovaEC2RestClientModule extends EC2RestClientModule<EC2Client, EC2AsyncClient> {
|
||||
|
||||
public NovaEC2RestClientModule() {
|
||||
super(EC2Client.class, EC2AsyncClient.class, DELEGATE_MAP);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
super.configure();
|
||||
|
|
|
@ -78,7 +78,7 @@ public class NovaRestClientModule extends RestClientModule<NovaClient, NovaAsync
|
|||
.put(KeyPairClient.class, KeyPairAsyncClient.class).build();
|
||||
|
||||
public NovaRestClientModule() {
|
||||
super(NovaClient.class, NovaAsyncClient.class, DELEGATE_MAP);
|
||||
super(DELEGATE_MAP);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -65,7 +65,7 @@ public class S3ApiMetadata extends BaseRestApiMetadata {
|
|||
/** The serialVersionUID */
|
||||
private static final long serialVersionUID = 820062881469203616L;
|
||||
|
||||
public static final TypeToken<RestContext<S3Client, S3AsyncClient>> CONTEXT_TOKEN = new TypeToken<RestContext<S3Client, S3AsyncClient>>() {
|
||||
public static final TypeToken<RestContext<? extends S3Client,? extends S3AsyncClient>> CONTEXT_TOKEN = new TypeToken<RestContext<? extends S3Client,? extends S3AsyncClient>>() {
|
||||
private static final long serialVersionUID = -5070937833892503232L;
|
||||
};
|
||||
|
||||
|
@ -107,6 +107,7 @@ public class S3ApiMetadata extends BaseRestApiMetadata {
|
|||
.documentation(URI.create("http://docs.amazonwebservices.com/AmazonS3/latest/API"))
|
||||
.version(S3AsyncClient.VERSION)
|
||||
.defaultProperties(S3ApiMetadata.defaultProperties())
|
||||
.context(CONTEXT_TOKEN)
|
||||
.wrapper(TypeToken.of(S3BlobStoreContext.class))
|
||||
.defaultModules(ImmutableSet.<Class<? extends Module>>of(S3RestClientModule.class, S3BlobStoreContextModule.class));
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ import org.jclouds.s3.handlers.S3RedirectionRetryHandler;
|
|||
import com.google.common.base.Supplier;
|
||||
import com.google.common.base.Suppliers;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.inject.Provides;
|
||||
import com.google.inject.Scopes;
|
||||
|
||||
|
@ -59,11 +60,11 @@ public class S3RestClientModule<S extends S3Client, A extends S3AsyncClient> ext
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
public S3RestClientModule() {
|
||||
this((Class) S3Client.class, (Class) S3AsyncClient.class);
|
||||
this((TypeToken) TypeToken.of(S3Client.class), (TypeToken) TypeToken.of(S3AsyncClient.class));
|
||||
}
|
||||
|
||||
public S3RestClientModule(Class<S> sync, Class<A> async) {
|
||||
super(sync, async);
|
||||
protected S3RestClientModule(TypeToken<S> syncClientType, TypeToken<A> asyncClientType) {
|
||||
super(syncClientType, asyncClientType);
|
||||
}
|
||||
|
||||
@Provides
|
||||
|
@ -82,10 +83,10 @@ public class S3RestClientModule<S extends S3Client, A extends S3AsyncClient> ext
|
|||
|
||||
@Override
|
||||
protected void configure() {
|
||||
super.configure();
|
||||
install(new S3ObjectModule());
|
||||
install(new S3ParserModule());
|
||||
bind(RequestAuthorizeSignature.class).in(Scopes.SINGLETON);
|
||||
super.configure();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -481,10 +481,6 @@ public abstract class S3AsyncClientTest<T extends S3AsyncClient> extends BaseS3A
|
|||
@ConfiguresRestClient
|
||||
private static final class TestS3RestClientModule extends S3RestClientModule<S3Client, S3AsyncClient> {
|
||||
|
||||
public TestS3RestClientModule() {
|
||||
super(S3Client.class, S3AsyncClient.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String provideTimeStamp(@TimeStamp Supplier<String> cache) {
|
||||
return "2009-11-08T15:54:08.897Z";
|
||||
|
|
|
@ -118,10 +118,6 @@ public class S3BlobRequestSignerTest extends BaseS3AsyncClientTest<S3AsyncClient
|
|||
@ConfiguresRestClient
|
||||
private static final class TestS3RestClientModule extends S3RestClientModule<S3Client, S3AsyncClient> {
|
||||
|
||||
public TestS3RestClientModule() {
|
||||
super(S3Client.class, S3AsyncClient.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String provideTimeStamp(@TimeStamp Supplier<String> cache) {
|
||||
return "Thu, 05 Jun 2008 16:38:19 GMT";
|
||||
|
|
|
@ -40,10 +40,6 @@ public abstract class BaseS3ClientExpectTest extends BaseRestClientExpectTest<S3
|
|||
@ConfiguresRestClient
|
||||
private static final class TestS3RestClientModule extends S3RestClientModule<S3Client, S3AsyncClient> {
|
||||
|
||||
public TestS3RestClientModule() {
|
||||
super(S3Client.class, S3AsyncClient.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String provideTimeStamp(@TimeStamp Supplier<String> cache) {
|
||||
return CONSTANT_DATE;
|
||||
|
|
|
@ -50,13 +50,11 @@ public class BaseSwiftRestClientModule<S extends CommonSwiftClient, A extends Co
|
|||
RestClientModule<S, A> {
|
||||
private final OpenStackAuthenticationModule module;
|
||||
|
||||
public BaseSwiftRestClientModule(Class<S> syncClientType, Class<A> asyncClientType) {
|
||||
this(new OpenStackAuthenticationModule(), syncClientType, asyncClientType);
|
||||
public BaseSwiftRestClientModule() {
|
||||
this(new OpenStackAuthenticationModule());
|
||||
}
|
||||
|
||||
public BaseSwiftRestClientModule(OpenStackAuthenticationModule module, Class<S> syncClientType,
|
||||
Class<A> asyncClientType) {
|
||||
super(syncClientType, asyncClientType);
|
||||
public BaseSwiftRestClientModule(OpenStackAuthenticationModule module) {
|
||||
this.module = module;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,10 +35,6 @@ import com.google.inject.Provides;
|
|||
@ConfiguresRestClient
|
||||
public class SwiftRestClientModule extends BaseSwiftRestClientModule<SwiftClient, SwiftAsyncClient> {
|
||||
|
||||
public SwiftRestClientModule() {
|
||||
super(SwiftClient.class, SwiftAsyncClient.class);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
CommonSwiftClient provideCommonSwiftClient(SwiftClient in) {
|
||||
|
|
|
@ -67,7 +67,7 @@ public abstract class CommonSwiftClientTest extends BaseAsyncClientTest<SwiftAsy
|
|||
protected static class TestSwiftRestClientModule extends
|
||||
BaseSwiftRestClientModule<SwiftClient, SwiftAsyncClient> {
|
||||
private TestSwiftRestClientModule() {
|
||||
super(new TestOpenStackAuthenticationModule(), SwiftClient.class, SwiftAsyncClient.class);
|
||||
super(new TestOpenStackAuthenticationModule());
|
||||
}
|
||||
@Provides
|
||||
@Singleton
|
||||
|
|
|
@ -144,7 +144,7 @@ public class VCloudRestClientModule extends RestClientModule<VCloudClient, VClou
|
|||
.build();
|
||||
|
||||
public VCloudRestClientModule() {
|
||||
super(VCloudClient.class, VCloudAsyncClient.class, DELEGATE_MAP);
|
||||
super(DELEGATE_MAP);
|
||||
}
|
||||
|
||||
@Provides
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.jclouds.s3.S3Client;
|
|||
import org.jclouds.s3.config.S3RestClientModule;
|
||||
import org.jclouds.walrus.WalrusAsyncClient;
|
||||
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.inject.Provides;
|
||||
|
||||
/**
|
||||
|
@ -34,9 +35,8 @@ import com.google.inject.Provides;
|
|||
*/
|
||||
@ConfiguresRestClient
|
||||
public class WalrusRestClientModule extends S3RestClientModule<S3Client, WalrusAsyncClient> {
|
||||
|
||||
public WalrusRestClientModule() {
|
||||
super(S3Client.class, WalrusAsyncClient.class);
|
||||
super(TypeToken.of(S3Client.class), TypeToken.of(WalrusAsyncClient.class));
|
||||
}
|
||||
|
||||
@Provides
|
||||
|
|
|
@ -31,22 +31,32 @@ import org.jclouds.http.annotation.ServerError;
|
|||
import org.jclouds.rest.ConfiguresRestClient;
|
||||
import org.jclouds.rest.config.RestClientModule;
|
||||
|
||||
import com.google.common.reflect.TypeToken;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@ConfiguresRestClient
|
||||
public class AWSRestClientModule<S, A> extends RestClientModule<S, A> {
|
||||
public abstract class AWSRestClientModule<S, A> extends RestClientModule<S, A> {
|
||||
|
||||
public AWSRestClientModule(Class<S> syncClientType, Class<A> asyncClientType, Map<Class<?>, Class<?>> delegates) {
|
||||
super(syncClientType, asyncClientType, delegates);
|
||||
protected AWSRestClientModule(Map<Class<?>, Class<?>> delegates) {
|
||||
super(delegates);
|
||||
}
|
||||
|
||||
public AWSRestClientModule(Class<S> syncClientType, Class<A> asyncClientType) {
|
||||
protected AWSRestClientModule() {
|
||||
}
|
||||
|
||||
protected AWSRestClientModule(TypeToken<S> syncClientType, TypeToken<A> asyncClientType) {
|
||||
super(syncClientType, asyncClientType);
|
||||
}
|
||||
|
||||
protected AWSRestClientModule(TypeToken<S> syncClientType, TypeToken<A> asyncClientType,
|
||||
Map<Class<?>, Class<?>> sync2Async) {
|
||||
super(syncClientType, asyncClientType, sync2Async);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void bindErrorHandlers() {
|
||||
bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(ParseAWSErrorFromXmlContent.class);
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.jclouds.date.TimeStamp;
|
|||
import org.jclouds.rest.ConfiguresRestClient;
|
||||
import org.jclouds.rest.RequestSigner;
|
||||
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.inject.Provides;
|
||||
|
||||
/**
|
||||
|
@ -38,17 +39,24 @@ import com.google.inject.Provides;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
@ConfiguresRestClient
|
||||
public class FormSigningRestClientModule<S, A> extends AWSRestClientModule<S, A> {
|
||||
public abstract class FormSigningRestClientModule<S, A> extends AWSRestClientModule<S, A> {
|
||||
|
||||
public FormSigningRestClientModule(Class<S> syncClientType, Class<A> asyncClientType,
|
||||
Map<Class<?>, Class<?>> delegates) {
|
||||
super(syncClientType, asyncClientType, delegates);
|
||||
protected FormSigningRestClientModule(Map<Class<?>, Class<?>> delegates) {
|
||||
super(delegates);
|
||||
}
|
||||
|
||||
public FormSigningRestClientModule(Class<S> syncClientType, Class<A> asyncClientType) {
|
||||
protected FormSigningRestClientModule() {
|
||||
}
|
||||
|
||||
protected FormSigningRestClientModule(TypeToken<S> syncClientType, TypeToken<A> asyncClientType) {
|
||||
super(syncClientType, asyncClientType);
|
||||
}
|
||||
|
||||
protected FormSigningRestClientModule(TypeToken<S> syncClientType, TypeToken<A> asyncClientType,
|
||||
Map<Class<?>, Class<?>> sync2Async) {
|
||||
super(syncClientType, asyncClientType, sync2Async);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@TimeStamp
|
||||
protected String provideTimeStamp(final DateService dateService,
|
||||
|
|
|
@ -23,21 +23,29 @@ import java.util.Map;
|
|||
|
||||
import org.jclouds.rest.ConfiguresRestClient;
|
||||
|
||||
import com.google.common.reflect.TypeToken;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@ConfiguresRestClient
|
||||
public class WithZonesFormSigningRestClientModule<S, A> extends FormSigningRestClientModule<S, A> {
|
||||
|
||||
public WithZonesFormSigningRestClientModule(Class<S> syncClientType, Class<A> asyncClientType,
|
||||
Map<Class<?>, Class<?>> delegates) {
|
||||
super(syncClientType, asyncClientType, delegates);
|
||||
public abstract class WithZonesFormSigningRestClientModule<S, A> extends FormSigningRestClientModule<S, A> {
|
||||
protected WithZonesFormSigningRestClientModule(Map<Class<?>, Class<?>> delegates) {
|
||||
super(delegates);
|
||||
}
|
||||
|
||||
public WithZonesFormSigningRestClientModule(Class<S> syncClientType, Class<A> asyncClientType) {
|
||||
protected WithZonesFormSigningRestClientModule() {
|
||||
}
|
||||
|
||||
protected WithZonesFormSigningRestClientModule(TypeToken<S> syncClientType, TypeToken<A> asyncClientType) {
|
||||
super(syncClientType, asyncClientType);
|
||||
}
|
||||
|
||||
protected WithZonesFormSigningRestClientModule(TypeToken<S> syncClientType, TypeToken<A> asyncClientType,
|
||||
Map<Class<?>, Class<?>> sync2Async) {
|
||||
super(syncClientType, asyncClientType, sync2Async);
|
||||
}
|
||||
|
||||
}
|
|
@ -38,6 +38,7 @@ import org.jclouds.rest.config.RestClientModule;
|
|||
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.base.Suppliers;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.inject.Provides;
|
||||
|
||||
/**
|
||||
|
@ -47,8 +48,11 @@ import com.google.inject.Provides;
|
|||
*/
|
||||
@ConfiguresRestClient
|
||||
public class AzureStorageRestClientModule<S, A> extends RestClientModule<S, A> {
|
||||
protected AzureStorageRestClientModule() {
|
||||
|
||||
public AzureStorageRestClientModule(Class<S> syncClientType, Class<A> asyncClientType) {
|
||||
}
|
||||
|
||||
public AzureStorageRestClientModule(TypeToken<S> syncClientType, TypeToken<A> asyncClientType) {
|
||||
super(syncClientType, asyncClientType);
|
||||
}
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ import org.testng.annotations.DataProvider;
|
|||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Module;
|
||||
|
||||
|
@ -140,8 +141,9 @@ public class SharedKeyLiteAuthenticationTest {
|
|||
.credentials(ACCOUNT, "credential")
|
||||
.modules(
|
||||
ImmutableSet.<Module> of(new MockModule(), new NullLoggingModule(),
|
||||
new AzureStorageRestClientModule<IntegrationTestClient, IntegrationTestAsyncClient>(
|
||||
IntegrationTestClient.class, IntegrationTestAsyncClient.class))).buildInjector();
|
||||
new AzureStorageRestClientModule<IntegrationTestClient, IntegrationTestAsyncClient>(TypeToken
|
||||
.of(IntegrationTestClient.class), TypeToken.of(IntegrationTestAsyncClient.class))))
|
||||
.buildInjector();
|
||||
filter = injector.getInstance(SharedKeyLiteAuthentication.class);
|
||||
}
|
||||
}
|
|
@ -96,13 +96,11 @@ import com.google.inject.TypeLiteral;
|
|||
|
||||
public class TerremarkVCloudRestClientModule<S, A> extends RestClientModule<S, A> {
|
||||
|
||||
public TerremarkVCloudRestClientModule(Class<S> syncClientType, Class<A> asyncClientType) {
|
||||
super(syncClientType, asyncClientType);
|
||||
public TerremarkVCloudRestClientModule() {
|
||||
}
|
||||
|
||||
public TerremarkVCloudRestClientModule(Class<S> syncClientType, Class<A> asyncClientType,
|
||||
Map<Class<?>, Class<?>> delegateMap) {
|
||||
super(syncClientType, asyncClientType, delegateMap);
|
||||
public TerremarkVCloudRestClientModule(Map<Class<?>, Class<?>> delegateMap) {
|
||||
super(delegateMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -84,13 +84,13 @@ END_OF_JCLOUDS_SCRIPT
|
|||
exit 1
|
||||
}
|
||||
alias apt-get-install="apt-get install -f -y -qq --force-yes"
|
||||
alias apt-get-upgrade="(apt-get update -qq&&apt-get upgrade -y -qq)"
|
||||
alias apt-get-update="apt-get update -qq"
|
||||
|
||||
function ensure_cmd_or_install_package_apt(){
|
||||
local cmd=$1
|
||||
local pkg=$2
|
||||
|
||||
hash $cmd 2>/dev/null || apt-get-install $pkg || ( apt-get-upgrade && apt-get-install $pkg )
|
||||
hash $cmd 2>/dev/null || apt-get-install $pkg || ( apt-get-update && apt-get-install $pkg )
|
||||
}
|
||||
|
||||
function ensure_cmd_or_install_package_yum(){
|
||||
|
@ -155,7 +155,7 @@ END_OF_JCLOUDS_FILE
|
|||
function installOpenJDK() {
|
||||
if hash apt-get 2>/dev/null; then
|
||||
export JAVA_HOME=${JAVA_HOME:-/usr/lib/jvm/java-6-openjdk}
|
||||
test -d $JAVA_HOME || apt-get-install openjdk-6-jdk
|
||||
test -d $JAVA_HOME || apt-get-install openjdk-6-jdk || ( apt-get-update && apt-get-install openjdk-6-jdk )
|
||||
elif hash yum 2>/dev/null; then
|
||||
export pkg=java-1.6.0-openjdk-devel
|
||||
yum --nogpgcheck -y install $pkg &&
|
||||
|
|
|
@ -84,13 +84,13 @@ END_OF_JCLOUDS_SCRIPT
|
|||
exit 1
|
||||
}
|
||||
alias apt-get-install="apt-get install -f -y -qq --force-yes"
|
||||
alias apt-get-upgrade="(apt-get update -qq&&apt-get upgrade -y -qq)"
|
||||
alias apt-get-update="apt-get update -qq"
|
||||
|
||||
function ensure_cmd_or_install_package_apt(){
|
||||
local cmd=$1
|
||||
local pkg=$2
|
||||
|
||||
hash $cmd 2>/dev/null || apt-get-install $pkg || ( apt-get-upgrade && apt-get-install $pkg )
|
||||
hash $cmd 2>/dev/null || apt-get-install $pkg || ( apt-get-update && apt-get-install $pkg )
|
||||
}
|
||||
|
||||
function ensure_cmd_or_install_package_yum(){
|
||||
|
@ -155,7 +155,7 @@ END_OF_JCLOUDS_FILE
|
|||
function installOpenJDK() {
|
||||
if hash apt-get 2>/dev/null; then
|
||||
export JAVA_HOME=${JAVA_HOME:-/usr/lib/jvm/java-6-openjdk}
|
||||
test -d $JAVA_HOME || apt-get-install openjdk-6-jdk
|
||||
test -d $JAVA_HOME || apt-get-install openjdk-6-jdk || ( apt-get-update && apt-get-install openjdk-6-jdk )
|
||||
elif hash yum 2>/dev/null; then
|
||||
export pkg=java-1.6.0-openjdk-devel
|
||||
yum --nogpgcheck -y install $pkg &&
|
||||
|
|
|
@ -84,13 +84,13 @@ END_OF_JCLOUDS_SCRIPT
|
|||
exit 1
|
||||
}
|
||||
alias apt-get-install="apt-get install -f -y -qq --force-yes"
|
||||
alias apt-get-upgrade="(apt-get update -qq&&apt-get upgrade -y -qq)"
|
||||
alias apt-get-update="apt-get update -qq"
|
||||
|
||||
function ensure_cmd_or_install_package_apt(){
|
||||
local cmd=$1
|
||||
local pkg=$2
|
||||
|
||||
hash $cmd 2>/dev/null || apt-get-install $pkg || ( apt-get-upgrade && apt-get-install $pkg )
|
||||
hash $cmd 2>/dev/null || apt-get-install $pkg || ( apt-get-update && apt-get-install $pkg )
|
||||
}
|
||||
|
||||
function ensure_cmd_or_install_package_yum(){
|
||||
|
@ -155,7 +155,7 @@ END_OF_JCLOUDS_FILE
|
|||
function installOpenJDK() {
|
||||
if hash apt-get 2>/dev/null; then
|
||||
export JAVA_HOME=${JAVA_HOME:-/usr/lib/jvm/java-6-openjdk}
|
||||
test -d $JAVA_HOME || apt-get-install openjdk-6-jdk
|
||||
test -d $JAVA_HOME || apt-get-install openjdk-6-jdk || ( apt-get-update && apt-get-install openjdk-6-jdk )
|
||||
elif hash yum 2>/dev/null; then
|
||||
export pkg=java-1.6.0-openjdk-devel
|
||||
yum --nogpgcheck -y install $pkg &&
|
||||
|
|
|
@ -68,6 +68,8 @@ import org.jclouds.rest.config.BindPropertiesToAnnotations;
|
|||
import org.jclouds.rest.config.CredentialStoreModule;
|
||||
import org.jclouds.rest.config.RestClientModule;
|
||||
import org.jclouds.rest.config.RestModule;
|
||||
import org.jclouds.rest.internal.BaseRestApiMetadata;
|
||||
import org.jclouds.rest.internal.RestContextImpl;
|
||||
import org.nnsoft.guice.rocoto.Rocoto;
|
||||
import org.nnsoft.guice.rocoto.configuration.ConfigurationModule;
|
||||
|
||||
|
@ -93,6 +95,7 @@ import com.google.inject.Module;
|
|||
import com.google.inject.Provides;
|
||||
import com.google.inject.Stage;
|
||||
import com.google.inject.TypeLiteral;
|
||||
import com.google.inject.util.Types;
|
||||
|
||||
/**
|
||||
* Creates {@link RestContext} or {@link Injector} instances based on the most commonly requested
|
||||
|
@ -109,6 +112,37 @@ import com.google.inject.TypeLiteral;
|
|||
*/
|
||||
public final class ContextBuilder {
|
||||
|
||||
static class ResolveRestContextModule extends AbstractModule {
|
||||
private final RestApiMetadata restApiMetadata;
|
||||
|
||||
ResolveRestContextModule(RestApiMetadata restApiMetadata) {
|
||||
this.restApiMetadata = restApiMetadata;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
protected void configure() {
|
||||
if (restApiMetadata.getContext().getRawType().equals(RestContext.class)) {
|
||||
TypeToken concreteType = BaseRestApiMetadata.contextToken(TypeToken.of(restApiMetadata.getApi()), TypeToken
|
||||
.of(restApiMetadata.getAsyncApi()));
|
||||
// bind explicit type
|
||||
bind(TypeLiteral.get(concreteType.getType())).to(
|
||||
(TypeLiteral) TypeLiteral.get(Types.newParameterizedType(RestContextImpl.class, restApiMetadata
|
||||
.getApi(), restApiMetadata.getAsyncApi())));
|
||||
// bind potentially wildcard type
|
||||
if (!concreteType.equals(restApiMetadata.getContext())) {
|
||||
bind(TypeLiteral.get(restApiMetadata.getContext().getType())).to(
|
||||
(TypeLiteral) TypeLiteral.get(Types.newParameterizedType(RestContextImpl.class, restApiMetadata
|
||||
.getApi(), restApiMetadata.getAsyncApi())));
|
||||
}
|
||||
// bind w/o types
|
||||
bind(TypeLiteral.get(RestContext.class)).to(
|
||||
(TypeLiteral) TypeLiteral.get(Types.newParameterizedType(RestContextImpl.class, restApiMetadata
|
||||
.getApi(), restApiMetadata.getAsyncApi())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private final class BindDefaultContextQualifiedToProvider extends AbstractModule {
|
||||
@Override
|
||||
protected void configure() {
|
||||
|
@ -301,6 +335,7 @@ public final class ContextBuilder {
|
|||
Iterable<Module> defaultModules = ifSpecifiedByUserDontIncludeDefaultRestModule(restModuleSpecifiedByUser);
|
||||
Iterables.addAll(modules, defaultModules);
|
||||
addClientModuleIfNotPresent(modules);
|
||||
addRestContextBinding();
|
||||
addLoggingModuleIfNotPresent(modules);
|
||||
addHttpModuleIfNeededAndNotPresent(modules);
|
||||
addExecutorServiceIfNotPresent(modules);
|
||||
|
@ -314,6 +349,12 @@ public final class ContextBuilder {
|
|||
return returnVal;
|
||||
}
|
||||
|
||||
void addRestContextBinding() {
|
||||
if (apiMetadata instanceof RestApiMetadata) {
|
||||
modules.add(new ResolveRestContextModule(RestApiMetadata.class.cast(apiMetadata)));
|
||||
}
|
||||
}
|
||||
|
||||
private Iterable<Module> ifSpecifiedByUserDontIncludeDefaultRestModule(boolean restModuleSpecifiedByUser) {
|
||||
Iterable<Module> defaultModules = Iterables.transform(apiMetadata.getDefaultModules(),
|
||||
new Function<Class<? extends Module>, Module>() {
|
||||
|
@ -384,8 +425,8 @@ public final class ContextBuilder {
|
|||
protected void addClientModule(List<Module> modules) {
|
||||
// TODO: move this up
|
||||
if (apiMetadata instanceof RestApiMetadata) {
|
||||
final RestApiMetadata rest = RestApiMetadata.class.cast(apiMetadata);
|
||||
modules.add(new RestClientModule(rest.getApi(), rest.getAsyncApi()));
|
||||
RestApiMetadata rest = RestApiMetadata.class.cast(apiMetadata);
|
||||
modules.add(new RestClientModule(TypeToken.of(rest.getApi()), TypeToken.of(rest.getAsyncApi())));
|
||||
} else {
|
||||
modules.add(new RestModule());
|
||||
}
|
||||
|
|
|
@ -21,13 +21,10 @@ package org.jclouds.rest.config;
|
|||
import java.util.Map;
|
||||
|
||||
import org.jclouds.rest.ConfiguresRestClient;
|
||||
import org.jclouds.rest.RestContext;
|
||||
import org.jclouds.rest.internal.RestContextImpl;
|
||||
import org.jclouds.util.TypeTokens2;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.inject.Scopes;
|
||||
import com.google.inject.TypeLiteral;
|
||||
import com.google.inject.util.Types;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -35,50 +32,65 @@ import com.google.inject.util.Types;
|
|||
*/
|
||||
@ConfiguresRestClient
|
||||
public class RestClientModule<S, A> extends RestModule {
|
||||
protected final Class<A> asyncClientType;
|
||||
protected final Class<S> syncClientType;
|
||||
protected final TypeToken<S> syncClientType;
|
||||
protected final TypeToken<A> asyncClientType;
|
||||
|
||||
public RestClientModule(Class<S> syncClientType, Class<A> asyncClientType,
|
||||
Map<Class<?>, Class<?>> sync2Async) {
|
||||
/**
|
||||
* Note that this ctor requires that you instantiate w/resolved generic params. For example, via
|
||||
* a subclass of a bound type, or natural instantiation w/resolved type params.
|
||||
*/
|
||||
protected RestClientModule(Map<Class<?>, Class<?>> sync2Async) {
|
||||
super(sync2Async);
|
||||
this.asyncClientType = asyncClientType;
|
||||
this.syncClientType = syncClientType;
|
||||
this.syncClientType = TypeTokens2.checkBound(new TypeToken<S>(getClass()) {
|
||||
private static final long serialVersionUID = 7519656925453755752L;
|
||||
});
|
||||
this.asyncClientType = TypeTokens2.checkBound(new TypeToken<A>(getClass()) {
|
||||
private static final long serialVersionUID = -4420015967358511548L;
|
||||
});
|
||||
}
|
||||
|
||||
public RestClientModule(Class<S> syncClientType, Class<A> asyncClientType) {
|
||||
this(syncClientType, asyncClientType, ImmutableMap
|
||||
.<Class<?>, Class<?>> of(syncClientType, asyncClientType));
|
||||
/**
|
||||
* @see #RestClientModule(Map)
|
||||
*/
|
||||
protected RestClientModule() {
|
||||
this(ImmutableMap.<Class<?>, Class<?>> of());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #RestClientModule(TypeToken, TypeToken, Map)
|
||||
*/
|
||||
public RestClientModule(TypeToken<S> syncClientType, TypeToken<A> asyncClientType) {
|
||||
this(syncClientType, asyncClientType, ImmutableMap.<Class<?>, Class<?>> of());
|
||||
}
|
||||
|
||||
/**
|
||||
* only necessary when type params are not resolvable at runtime.
|
||||
*/
|
||||
public RestClientModule(TypeToken<S> syncClientType, TypeToken<A> asyncClientType, Map<Class<?>, Class<?>> sync2Async) {
|
||||
super(sync2Async);
|
||||
this.syncClientType = TypeTokens2.checkBound(syncClientType);
|
||||
this.asyncClientType = TypeTokens2.checkBound(asyncClientType);
|
||||
}
|
||||
|
||||
@SuppressWarnings( { "unchecked", "rawtypes" })
|
||||
@Override
|
||||
protected void configure() {
|
||||
super.configure();
|
||||
// Ensures the restcontext can be looked up without generic types.
|
||||
bind(new TypeLiteral<RestContext>() {
|
||||
}).to(
|
||||
(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();
|
||||
bindRetryHandlers();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* overrides this to change the default retry handlers for the http engine
|
||||
*
|
||||
* ex.
|
||||
*
|
||||
* <pre>
|
||||
* bind(HttpRetryHandler.class).annotatedWith(Redirection.class).to(
|
||||
* AWSRedirectionRetryHandler.class);
|
||||
* bind(HttpRetryHandler.class).annotatedWith(ClientError.class).to(
|
||||
* AWSClientErrorRetryHandler.class);
|
||||
* bind(HttpRetryHandler.class).annotatedWith(Redirection.class).to(AWSRedirectionRetryHandler.class);
|
||||
* bind(HttpRetryHandler.class).annotatedWith(ClientError.class).to(AWSClientErrorRetryHandler.class);
|
||||
* </pre>
|
||||
*
|
||||
*/
|
||||
|
@ -91,12 +103,9 @@ public class RestClientModule<S, A> extends RestModule {
|
|||
* ex.
|
||||
*
|
||||
* <pre>
|
||||
* bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(
|
||||
* ParseAWSErrorFromXmlContent.class);
|
||||
* bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(
|
||||
* ParseAWSErrorFromXmlContent.class);
|
||||
* bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(
|
||||
* ParseAWSErrorFromXmlContent.class);
|
||||
* bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(ParseAWSErrorFromXmlContent.class);
|
||||
* bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(ParseAWSErrorFromXmlContent.class);
|
||||
* bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(ParseAWSErrorFromXmlContent.class);
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
|
@ -105,12 +114,11 @@ public class RestClientModule<S, A> extends RestModule {
|
|||
}
|
||||
|
||||
protected void bindAsyncClient() {
|
||||
BinderUtils.bindAsyncClient(binder(), asyncClientType);
|
||||
BinderUtils.bindAsyncClient(binder(), asyncClientType.getRawType());
|
||||
}
|
||||
|
||||
protected void bindClient() {
|
||||
BinderUtils.bindClient(binder(), syncClientType, asyncClientType,
|
||||
sync2Async);
|
||||
BinderUtils.bindClient(binder(), syncClientType.getRawType(), asyncClientType.getRawType(), sync2Async);
|
||||
}
|
||||
|
||||
}
|
|
@ -67,6 +67,14 @@ public class BaseRestApiMetadata extends BaseApiMetadata implements RestApiMetad
|
|||
return props;
|
||||
}
|
||||
|
||||
public static <S, A> TypeToken<RestContext<S, A>> contextToken(TypeToken<S> apiToken, TypeToken<A> asyncApiToken) {
|
||||
return new TypeToken<RestContext<S, A>>() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
}.where(new TypeParameter<S>() {
|
||||
}, apiToken).where(new TypeParameter<A>() {
|
||||
}, asyncApiToken);
|
||||
}
|
||||
|
||||
public static class Builder extends BaseApiMetadata.Builder implements RestApiMetadata.Builder {
|
||||
protected Class<?> api;
|
||||
protected Class<?> asyncApi;
|
||||
|
@ -81,14 +89,6 @@ public class BaseRestApiMetadata extends BaseApiMetadata implements RestApiMetad
|
|||
.defaultProperties(BaseRestApiMetadata.defaultProperties());
|
||||
}
|
||||
|
||||
protected <S, A> TypeToken<RestContext<S, A>> contextToken(TypeToken<S> apiToken, TypeToken<A> asyncApiToken) {
|
||||
return new TypeToken<RestContext<S, A>>() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
}.where(new TypeParameter<S>() {
|
||||
}, apiToken).where(new TypeParameter<A>() {
|
||||
}, asyncApiToken);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.util;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
|
||||
import java.lang.reflect.TypeVariable;
|
||||
|
||||
import com.google.common.reflect.TypeToken;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class TypeTokens2 {
|
||||
/**
|
||||
* @throws IllegalStateException if the type is an instanceof {@link TypeVariable}
|
||||
*/
|
||||
public static <T> TypeToken<T> checkBound(TypeToken<T> type) throws IllegalStateException {
|
||||
checkState(!(type.getType() instanceof TypeVariable<?>),
|
||||
"unbound type variable: %s, use ctor that explicitly assigns this", type);
|
||||
return type;
|
||||
}
|
||||
}
|
|
@ -54,7 +54,7 @@ import com.google.inject.Key;
|
|||
import com.google.inject.TypeLiteral;
|
||||
import com.sun.jersey.api.uri.UriBuilderImpl;
|
||||
|
||||
@Test(groups = "unit")
|
||||
@Test(groups = "unit", testName = "BackoffLimitedRetryHandlerTest")
|
||||
public class BackoffLimitedRetryHandlerTest {
|
||||
|
||||
BackoffLimitedRetryHandler handler = new BackoffLimitedRetryHandler();
|
||||
|
|
|
@ -176,7 +176,7 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest {
|
|||
@ConfiguresRestClient
|
||||
protected static class CallerModule extends RestClientModule<Caller, AsyncCaller> {
|
||||
CallerModule() {
|
||||
super(Caller.class, AsyncCaller.class, ImmutableMap.<Class<?>, Class<?>> of(Callee.class, AsyncCallee.class, Callee2.class, AsyncCallee2.class));
|
||||
super(ImmutableMap.<Class<?>, Class<?>> of(Callee.class, AsyncCallee.class, Callee2.class, AsyncCallee2.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -30,8 +30,5 @@ import org.jclouds.rest.ConfiguresRestClient;
|
|||
*/
|
||||
@ConfiguresRestClient
|
||||
public class ELBRestClientModule extends FormSigningRestClientModule<ELBClient, ELBAsyncClient> {
|
||||
public ELBRestClientModule() {
|
||||
super(ELBClient.class, ELBAsyncClient.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ public class GleSYSRestClientModule extends RestClientModule<GleSYSClient, GleSY
|
|||
.build();
|
||||
|
||||
public GleSYSRestClientModule() {
|
||||
super(GleSYSClient.class, GleSYSAsyncClient.class, DELEGATE_MAP);
|
||||
super(DELEGATE_MAP);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -56,7 +56,7 @@ public class OpSourceServersRestClientModule extends
|
|||
.build();
|
||||
|
||||
public OpSourceServersRestClientModule() {
|
||||
super(OpSourceServersClient.class, OpSourceServersAsyncClient.class, DELEGATE_MAP);
|
||||
super(DELEGATE_MAP);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -147,7 +147,7 @@ public class VPDCRestClientModule extends RestClientModule<VPDCClient, VPDCAsync
|
|||
.build();
|
||||
|
||||
public VPDCRestClientModule() {
|
||||
super(VPDCClient.class, VPDCAsyncClient.class, DELEGATE_MAP);
|
||||
super(DELEGATE_MAP);
|
||||
}
|
||||
|
||||
@Singleton
|
||||
|
|
|
@ -152,7 +152,7 @@ public class VCloudDirectorRestClientModule extends RestClientModule<VCloudDirec
|
|||
}
|
||||
|
||||
public VCloudDirectorRestClientModule() {
|
||||
super(VCloudDirectorClient.class, VCloudDirectorAsyncClient.class, ADMIN_DELEGATE_MAP);
|
||||
super(ADMIN_DELEGATE_MAP);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -84,13 +84,13 @@ END_OF_JCLOUDS_SCRIPT
|
|||
exit 1
|
||||
}
|
||||
alias apt-get-install="apt-get install -f -y -qq --force-yes"
|
||||
alias apt-get-upgrade="(apt-get update -qq&&apt-get upgrade -y -qq)"
|
||||
alias apt-get-update="apt-get update -qq"
|
||||
|
||||
function ensure_cmd_or_install_package_apt(){
|
||||
local cmd=$1
|
||||
local pkg=$2
|
||||
|
||||
hash $cmd 2>/dev/null || apt-get-install $pkg || ( apt-get-upgrade && apt-get-install $pkg )
|
||||
hash $cmd 2>/dev/null || apt-get-install $pkg || ( apt-get-update && apt-get-install $pkg )
|
||||
}
|
||||
|
||||
function ensure_cmd_or_install_package_yum(){
|
||||
|
|
|
@ -82,6 +82,7 @@ public class AWSEC2ApiMetadata extends EC2ApiMetadata {
|
|||
.version(AWSEC2AsyncClient.VERSION)
|
||||
.name("Amazon-specific EC2 API")
|
||||
.wrapper(AWSEC2ComputeServiceContext.class)
|
||||
.context(CONTEXT_TOKEN)
|
||||
.defaultProperties(AWSEC2ApiMetadata.defaultProperties())
|
||||
.defaultModules(ImmutableSet.<Class<? extends Module>>of(AWSEC2RestClientModule.class, EC2ResolveImagesModule.class, AWSEC2ComputeServiceContextModule.class));
|
||||
}
|
||||
|
|
|
@ -64,6 +64,7 @@ import org.jclouds.ec2.services.WindowsClient;
|
|||
import org.jclouds.rest.ConfiguresRestClient;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.inject.Provides;
|
||||
|
||||
/**
|
||||
|
@ -90,7 +91,7 @@ public class AWSEC2RestClientModule extends EC2RestClientModule<AWSEC2Client, AW
|
|||
.build();
|
||||
|
||||
public AWSEC2RestClientModule() {
|
||||
super(AWSEC2Client.class, AWSEC2AsyncClient.class, DELEGATE_MAP);
|
||||
super(TypeToken.of(AWSEC2Client.class), TypeToken.of(AWSEC2AsyncClient.class), DELEGATE_MAP);
|
||||
}
|
||||
|
||||
@Singleton
|
||||
|
|
|
@ -28,11 +28,13 @@ import java.util.Properties;
|
|||
import java.util.Set;
|
||||
|
||||
import org.jclouds.aws.domain.Region;
|
||||
import org.jclouds.aws.ec2.AWSEC2ApiMetadata;
|
||||
import org.jclouds.aws.ec2.reference.AWSEC2Constants;
|
||||
import org.jclouds.compute.ComputeServiceContext;
|
||||
import org.jclouds.compute.domain.OsFamily;
|
||||
import org.jclouds.compute.domain.OsFamilyVersion64Bit;
|
||||
import org.jclouds.compute.domain.Template;
|
||||
import org.jclouds.ec2.EC2ApiMetadata;
|
||||
import org.jclouds.ec2.compute.EC2TemplateBuilderLiveTest;
|
||||
import org.jclouds.ec2.compute.predicates.EC2ImagePredicates;
|
||||
import org.jclouds.ec2.domain.InstanceType;
|
||||
|
@ -366,6 +368,12 @@ public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest {
|
|||
assertEquals(defaultTemplate.getImage().getId(), imageId);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAssignability() {
|
||||
context.unwrap(EC2ApiMetadata.CONTEXT_TOKEN);
|
||||
context.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Set<String> getIso3166Codes() {
|
||||
return ImmutableSet.<String> of("US-VA", "US-CA", "US-OR", "BR-SP", "IE", "SG", "JP-13");
|
||||
|
|
|
@ -73,6 +73,7 @@ public class AWSS3ApiMetadata extends S3ApiMetadata {
|
|||
id("aws-s3")
|
||||
.name("Amazon-specific S3 API")
|
||||
.defaultProperties(AWSS3ApiMetadata.defaultProperties())
|
||||
.context(CONTEXT_TOKEN)
|
||||
.wrapper(TypeToken.of(AWSS3BlobStoreContext.class))
|
||||
.defaultModules(ImmutableSet.<Class<? extends Module>>of(AWSS3RestClientModule.class, AWSS3BlobStoreContextModule.class));
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ import org.jclouds.s3.config.S3RestClientModule;
|
|||
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.base.Suppliers;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.inject.Provides;
|
||||
|
||||
/**
|
||||
|
@ -51,6 +52,10 @@ import com.google.inject.Provides;
|
|||
@ConfiguresRestClient
|
||||
public class AWSS3RestClientModule extends S3RestClientModule<AWSS3Client, AWSS3AsyncClient> {
|
||||
|
||||
public AWSS3RestClientModule() {
|
||||
super(TypeToken.of(AWSS3Client.class), TypeToken.of(AWSS3AsyncClient.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Supplier<String> defaultRegionForBucket(@Region Supplier<String> defaultRegion) {
|
||||
return Suppliers.ofInstance(US_STANDARD);
|
||||
|
@ -69,10 +74,6 @@ public class AWSS3RestClientModule extends S3RestClientModule<AWSS3Client, AWSS3
|
|||
return Suppliers.ofInstance(URI.create(endpoint));
|
||||
}
|
||||
|
||||
public AWSS3RestClientModule() {
|
||||
super(AWSS3Client.class, AWSS3AsyncClient.class);
|
||||
}
|
||||
|
||||
@Singleton
|
||||
@Provides
|
||||
S3Client provide(AWSS3Client in) {
|
||||
|
|
|
@ -36,10 +36,6 @@ import org.jclouds.rest.ConfiguresRestClient;
|
|||
@ConfiguresRestClient
|
||||
public class AzureBlobRestClientModule extends AzureStorageRestClientModule<AzureBlobClient, AzureBlobAsyncClient> {
|
||||
|
||||
public AzureBlobRestClientModule() {
|
||||
super(AzureBlobClient.class, AzureBlobAsyncClient.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
install(new AzureBlobModule());
|
||||
|
|
|
@ -71,7 +71,7 @@ public class GoGridRestClientModule extends RestClientModule<GoGridClient, GoGri
|
|||
.build();
|
||||
|
||||
public GoGridRestClientModule() {
|
||||
super(GoGridClient.class, GoGridAsyncClient.class, DELEGATE_MAP);
|
||||
super(DELEGATE_MAP);
|
||||
}
|
||||
|
||||
@Provides
|
||||
|
|
|
@ -67,7 +67,7 @@ public class HPCloudObjectStorageRestClientModule extends
|
|||
HPCloudCDNClient.class, HPCloudCDNAsyncClient.class).build();
|
||||
|
||||
public HPCloudObjectStorageRestClientModule() {
|
||||
super(HPCloudObjectStorageClient.class, HPCloudObjectStorageAsyncClient.class, DELEGATE_MAP);
|
||||
super(DELEGATE_MAP);
|
||||
}
|
||||
|
||||
protected void configure() {
|
||||
|
|
|
@ -48,10 +48,6 @@ import com.google.inject.Scopes;
|
|||
@ConfiguresRestClient
|
||||
public class RimuHostingRestClientModule extends RestClientModule<RimuHostingClient, RimuHostingAsyncClient> {
|
||||
|
||||
public RimuHostingRestClientModule() {
|
||||
super(RimuHostingClient.class, RimuHostingAsyncClient.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(DateAdapter.class).to(RimuIso8601DateAdapter.class);
|
||||
|
|
|
@ -35,10 +35,6 @@ import org.jclouds.slicehost.handlers.ParseSlicehostErrorFromHttpResponse;
|
|||
@ConfiguresRestClient
|
||||
public class SlicehostRestClientModule extends RestClientModule<SlicehostClient, SlicehostAsyncClient> {
|
||||
|
||||
public SlicehostRestClientModule() {
|
||||
super(SlicehostClient.class, SlicehostAsyncClient.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void bindErrorHandlers() {
|
||||
bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(ParseSlicehostErrorFromHttpResponse.class);
|
||||
|
|
|
@ -62,7 +62,7 @@ public class SoftLayerRestClientModule extends RestClientModule<SoftLayerClient,
|
|||
.build();
|
||||
|
||||
public SoftLayerRestClientModule() {
|
||||
super(SoftLayerClient.class, SoftLayerAsyncClient.class, DELEGATE_MAP);
|
||||
super(DELEGATE_MAP);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -61,7 +61,7 @@ public class TerremarkECloudRestClientModule extends
|
|||
.build();
|
||||
|
||||
public TerremarkECloudRestClientModule() {
|
||||
super(TerremarkECloudClient.class, TerremarkECloudAsyncClient.class, DELEGATE_MAP);
|
||||
super(DELEGATE_MAP);
|
||||
}
|
||||
|
||||
@Provides
|
||||
|
|
|
@ -39,10 +39,6 @@ import com.google.inject.Provides;
|
|||
public class TerremarkVCloudExpressRestClientModule extends
|
||||
TerremarkVCloudRestClientModule<TerremarkVCloudExpressClient, TerremarkVCloudExpressAsyncClient> {
|
||||
|
||||
public TerremarkVCloudExpressRestClientModule() {
|
||||
super(TerremarkVCloudExpressClient.class, TerremarkVCloudExpressAsyncClient.class);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
protected TerremarkVCloudAsyncClient provideVCloudAsyncClient(TerremarkVCloudExpressAsyncClient in) {
|
||||
|
|
|
@ -20,7 +20,7 @@ END_OF_JCLOUDS_FILE
|
|||
function installOpenJDK() {
|
||||
if hash apt-get 2>/dev/null; then
|
||||
export JAVA_HOME=${JAVA_HOME:-/usr/lib/jvm/java-6-openjdk}
|
||||
test -d $JAVA_HOME || apt-get-install openjdk-6-jdk
|
||||
test -d $JAVA_HOME || apt-get-install openjdk-6-jdk || ( apt-get-update && apt-get-install openjdk-6-jdk )
|
||||
elif hash yum 2>/dev/null; then
|
||||
export pkg=java-1.6.0-openjdk-devel
|
||||
yum --nogpgcheck -y install $pkg &&
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
alias apt-get-install="apt-get install -f -y -qq --force-yes"
|
||||
alias apt-get-upgrade="(apt-get update -qq&&apt-get upgrade -y -qq)"
|
||||
alias apt-get-update="apt-get update -qq"
|
||||
|
||||
function ensure_cmd_or_install_package_apt(){
|
||||
local cmd=$1
|
||||
local pkg=$2
|
||||
|
||||
hash $cmd 2>/dev/null || apt-get-install $pkg || ( apt-get-upgrade && apt-get-install $pkg )
|
||||
hash $cmd 2>/dev/null || apt-get-install $pkg || ( apt-get-update && apt-get-install $pkg )
|
||||
}
|
||||
|
||||
function ensure_cmd_or_install_package_yum(){
|
||||
|
|
|
@ -84,13 +84,13 @@ END_OF_JCLOUDS_SCRIPT
|
|||
exit 1
|
||||
}
|
||||
alias apt-get-install="apt-get install -f -y -qq --force-yes"
|
||||
alias apt-get-upgrade="(apt-get update -qq&&apt-get upgrade -y -qq)"
|
||||
alias apt-get-update="apt-get update -qq"
|
||||
|
||||
function ensure_cmd_or_install_package_apt(){
|
||||
local cmd=$1
|
||||
local pkg=$2
|
||||
|
||||
hash $cmd 2>/dev/null || apt-get-install $pkg || ( apt-get-upgrade && apt-get-install $pkg )
|
||||
hash $cmd 2>/dev/null || apt-get-install $pkg || ( apt-get-update && apt-get-install $pkg )
|
||||
}
|
||||
|
||||
function ensure_cmd_or_install_package_yum(){
|
||||
|
@ -155,7 +155,7 @@ END_OF_JCLOUDS_FILE
|
|||
function installOpenJDK() {
|
||||
if hash apt-get 2>/dev/null; then
|
||||
export JAVA_HOME=${JAVA_HOME:-/usr/lib/jvm/java-6-openjdk}
|
||||
test -d $JAVA_HOME || apt-get-install openjdk-6-jdk
|
||||
test -d $JAVA_HOME || apt-get-install openjdk-6-jdk || ( apt-get-update && apt-get-install openjdk-6-jdk )
|
||||
elif hash yum 2>/dev/null; then
|
||||
export pkg=java-1.6.0-openjdk-devel
|
||||
yum --nogpgcheck -y install $pkg &&
|
||||
|
|
Loading…
Reference in New Issue