From 0b59dea0733e75ec94435b233a2635513afe8867 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Mon, 16 Apr 2012 00:44:20 -0700 Subject: [PATCH] removed ContextBuilder subclasses; added unwrap; undid generic params --- .../org/jclouds/atmos/AtmosApiMetadata.java | 35 +- .../jclouds/atmos/AtmosContextBuilder.java | 72 ---- .../binders/BindUserMetadataToHeaders.java | 2 +- .../atmos/blobstore/AtmosAsyncBlobStore.java | 2 +- .../atmos/blobstore/AtmosBlobStore.java | 2 +- .../config/AtmosBlobStoreContextModule.java | 6 - .../functions/ObjectToBlobMetadata.java | 2 +- .../atmos/config/AtmosRestClientModule.java | 2 - .../jclouds/atmos/filters/SignRequest.java | 2 +- .../ParseUserMetadataFromHeaders.java | 2 +- .../jclouds/atmos/AtmosAsyncClientTest.java | 6 +- .../jclouds/atmos/AtmosClientLiveTest.java | 2 +- .../blobstore/AtmosBlobRequestSignerTest.java | 6 +- .../config/AtmosBlobStoreModuleTest.java | 6 +- .../atmos/filters/SignRequestTest.java | 10 +- .../atmos/functions/AtmosObjectNameTest.java | 2 +- .../org/jclouds/byon/BYONApiMetadata.java | 28 +- .../BYONComputeServiceContextBuilder.java | 71 ---- .../BYONComputeServiceContextModule.java | 20 +- .../org/jclouds/byon/domain/YamlNode.java | 2 +- .../internal/BYONComputeServiceAdapter.java | 2 +- .../byon/BYONComputeServiceLiveTest.java | 11 +- .../jclouds/byon/BYONComputeServiceTest.java | 55 ++- .../cloudfiles/CloudFilesApiMetadata.java | 33 +- .../cloudfiles/CloudFilesContextBuilder.java | 72 ---- .../blobstore/CloudFilesAsyncBlobStore.java | 2 +- .../blobstore/CloudFilesBlobStore.java | 2 +- .../config/CloudFilesRestClientModule.java | 2 - .../cloudfiles/CloudFilesClientLiveTest.java | 2 +- .../CloudLoadBalancersApiMetadata.java | 35 +- .../CloudLoadBalancersContextBuilder.java | 57 ---- .../CloudLoadBalancersRestClientModule.java | 2 - .../cloudloadbalancers/functions/LB.java | 2 +- .../features/LoadBalancerAsyncClientTest.java | 2 +- .../features/LoadBalancerClientLiveTest.java | 4 +- .../features/NodeAsyncClientTest.java | 2 +- .../features/NodeClientLiveTest.java | 8 +- .../functions/UnwrapLoadBalancerTest.java | 2 +- .../functions/UnwrapLoadBalancersTest.java | 2 +- ...BaseCloudLoadBalancersAsyncClientTest.java | 4 +- .../BaseCloudLoadBalancersClientLiveTest.java | 17 +- .../cloudservers/CloudServersApiMetadata.java | 33 +- .../CloudServersContextBuilder.java | 57 ---- ...oudServersComputeServiceContextModule.java | 10 +- .../config/CloudServersRestClientModule.java | 2 - .../CloudServersAsyncClientTest.java | 6 +- .../CloudServersClientLiveTest.java | 5 +- .../CloudServersComputeServiceLiveTest.java | 7 +- .../BaseCloudServersRestClientExpectTest.java | 6 +- .../cloudsigma/CloudSigmaApiMetadata.java | 32 +- .../cloudsigma/CloudSigmaContextBuilder.java | 57 ---- ...CloudSigmaComputeServiceContextModule.java | 10 +- .../functions/PreinstalledDiskToImage.java | 2 +- .../config/CloudSigmaRestClientModule.java | 4 +- .../cloudsigma/functions/MapToDevices.java | 2 +- .../cloudsigma/CloudSigmaAsyncClientTest.java | 2 +- .../cloudsigma/CloudSigmaClientLiveTest.java | 7 +- .../CloudSigmaComputeServiceLiveTest.java | 7 +- .../cloudstack/CloudStackApiMetadata.java | 33 +- .../jclouds/cloudstack/CloudStackContext.java | 3 +- .../cloudstack/CloudStackContextBuilder.java | 63 ---- ...ecurityGroupPairsToIndexedQueryParams.java | 2 +- ...CloudStackComputeServiceContextModule.java | 10 +- .../functions/TemplateToOperatingSystem.java | 2 +- .../CloudStackComputeServiceAdapter.java | 2 +- .../config/CloudStackParserModule.java | 2 +- .../config/CloudStackProperties.java | 1 - .../config/CloudStackRestClientModule.java | 2 - .../cloudstack/domain/NetworkService.java | 4 +- .../features/LoadBalancerAsyncClient.java | 2 +- .../features/LoadBalancerClient.java | 2 +- .../CreatePortForwardingRulesForIP.java | 2 +- .../ParseIdToNameFromHttpResponse.java | 2 +- .../functions/ParseTypedAsyncJob.java | 4 +- .../internal/CloudStackContextImpl.java | 27 +- .../cloudstack/predicates/UserPredicates.java | 2 +- .../jclouds/cloudstack/util/ApiKeyPairs.java | 8 +- ...oudStackComputeServiceAdapterLiveTest.java | 4 +- .../CloudStackComputeServiceLiveTest.java | 12 +- .../BaseCloudStackAsyncClientTest.java | 6 +- .../BaseCloudStackClientLiveTest.java | 9 +- .../BaseCloudStackRestClientExpectTest.java | 2 +- .../features/GlobalUserClientLiveTest.java | 2 +- .../features/GuestOSClientLiveTest.java | 2 +- .../features/LoadBalancerClientLiveTest.java | 4 +- .../cloudstack/filters/QuerySignerTest.java | 2 +- .../ParseAsyncJobFromHttpResponseTest.java | 6 +- .../parse/ListAccountsResponseTest.java | 2 +- .../predicates/JobCompleteTest.java | 2 +- .../cloudwatch/CloudWatchApiMetadata.java | 55 ++- .../cloudwatch/CloudWatchContextBuilder.java | 64 ---- .../config/CloudWatchRestClientModule.java | 2 - .../cloudwatch/CloudWatchApiMetadataTest.java | 11 +- .../cloudwatch/CloudWatchAsyncClientTest.java | 7 +- .../cloudwatch/CloudWatchClientLiveTest.java | 9 +- .../deltacloud/DeltacloudApiMetadata.java | 56 ++-- .../deltacloud/DeltacloudAsyncClient.java | 2 +- .../jclouds/deltacloud/DeltacloudClient.java | 2 +- .../deltacloud/DeltacloudContextBuilder.java | 57 ---- ...DeltacloudComputeServiceContextModule.java | 11 +- .../DeltacloudComputeServiceAdapter.java | 2 +- .../config/DeltacloudRestClientModule.java | 2 - .../xml/HardwarePropertyHandler.java | 2 +- .../deltacloud/xml/InstanceHandler.java | 2 +- .../deltacloud/xml/InstanceStatesHandler.java | 4 +- .../deltacloud/DeltacloudAsyncClientTest.java | 6 +- .../ReadOnlyDeltacloudClientLiveTest.java | 9 +- .../DeltacloudComputeServiceLiveTest.java | 13 +- .../DeltacloudTemplateBuilderLiveTest.java | 7 +- ...DeltacloudRedirectionRetryHandlerTest.java | 4 +- .../deltacloud/xml/InstanceHandlerTest.java | 2 +- .../xml/InstanceStatesHandlerTest.java | 4 +- .../java/org/jclouds/ec2/EC2ApiMetadata.java | 67 ++-- .../org/jclouds/ec2/EC2ContextBuilder.java | 77 ----- .../ec2/compute/EC2ComputeService.java | 2 +- .../ec2/compute/EC2ComputeServiceContext.java | 4 +- .../EC2ComputeServiceDependenciesModule.java | 9 - .../EC2ComputeServiceContextImpl.java | 16 +- .../ec2/config/EC2RestClientModule.java | 7 +- ...icationArchitecturesEC2ClientLiveTest.java | 5 +- .../jclouds/ec2/EBSBootEC2ClientLiveTest.java | 7 +- .../org/jclouds/ec2/EC2ApiMetadataTest.java | 1 - .../compute/EC2ComputeServiceLiveTest.java | 18 +- .../compute/EC2TemplateBuilderLiveTest.java | 6 +- .../compute/TestCanRecreateGroupLiveTest.java | 4 +- ...ailabilityZoneAndRegionClientLiveTest.java | 10 +- .../ec2/services/BaseEC2AsyncClientTest.java | 7 +- .../ElasticBlockStoreClientLiveTest.java | 10 +- .../ElasticIPAddressClientLiveTest.java | 8 +- .../ec2/services/InstanceClientLiveTest.java | 8 +- .../ec2/services/KeyPairClientLiveTest.java | 8 +- .../services/SecurityGroupClientLiveTest.java | 8 +- .../ec2/services/WindowsClientLiveTest.java | 8 +- .../elasticstack/ElasticStackApiMetadata.java | 31 +- .../ElasticStackContextBuilder.java | 57 ---- ...asticStackComputeServiceContextModule.java | 12 +- .../config/ElasticStackRestClientModule.java | 4 +- .../elasticstack/functions/MapToDevices.java | 2 +- .../ElasticStackAsyncClientTest.java | 2 +- .../ElasticStackClientLiveTest.java | 5 +- .../ElasticStackComputeServiceLiveTest.java | 7 +- .../eucalyptus/EucalyptusApiMetadata.java | 12 +- .../EucalyptusComputeServiceLiveTest.java | 6 +- .../filesystem/FilesystemApiMetadata.java | 30 +- .../filesystem/FilesystemAsyncBlobStore.java | 4 +- .../FilesystemBlobStoreContextBuilder.java | 59 ---- .../FilesystemBlobStoreContextModule.java | 24 +- .../config/FilesystemBlobStoreModule.java | 45 --- .../FilesystemAsyncBlobStoreTest.java | 10 +- .../openstack/nova/NovaApiMetadata.java | 35 +- .../openstack/nova/NovaContextBuilder.java | 57 ---- .../NovaComputeServiceContextModule.java | 10 +- .../nova/config/NovaRestClientModule.java | 2 - .../nova/options/CreateServerOptions.java | 2 +- .../openstack/nova/NovaAsyncClientTest.java | 8 +- .../openstack/nova/NovaClientLiveTest.java | 5 +- .../compute/NovaComputeServiceLiveTest.java | 6 +- .../nova/ec2/NovaEC2ApiMetadata.java | 25 +- .../nova/ec2/NovaEC2ContextBuilder.java | 58 ---- .../ec2/config/NovaEC2RestClientModule.java | 2 - .../NovaEC2ComputeServiceLiveTest.java | 5 +- apis/openstack-nova/pom.xml | 2 + .../openstack/nova/v1_1/NovaApiMetadata.java | 35 +- .../nova/v1_1/NovaContextBuilder.java | 57 ---- .../BindSecurityGroupRuleToJsonPayload.java | 2 +- .../nova/v1_1/compute/NovaComputeService.java | 2 +- .../NovaComputeServiceContextModule.java | 10 +- .../compute/options/NovaTemplateOptions.java | 2 +- .../v1_1/config/NovaRestClientModule.java | 2 - .../openstack/nova/v1_1/domain/Server.java | 2 +- .../v1_1/domain/zonescoped/ZoneAndName.java | 2 +- .../ParseImageIdFromLocationHeader.java | 3 +- .../v1_1/options/CreateServerOptions.java | 4 +- .../NovaComputeServiceAdapterExpectTest.java | 2 +- .../compute/NovaComputeServiceExpectTest.java | 2 +- .../compute/NovaComputeServiceLiveTest.java | 18 +- .../loaders/CreateUniqueKeyPairTest.java | 1 - .../CreateSecurityGroupIfNeededTest.java | 2 +- .../v1_1/internal/BaseNovaClientLiveTest.java | 19 +- ...seNovaComputeServiceContextExpectTest.java | 3 +- .../BaseNovaComputeServiceExpectTest.java | 2 +- .../v1_1/parse/ParseCreatedServerTest.java | 2 +- .../nova/v1_1/parse/ParseFlavorListTest.java | 2 +- .../nova/v1_1/parse/ParseImageListTest.java | 2 +- .../nova/v1_1/parse/ParseImageTest.java | 2 +- .../nova/v1_1/parse/ParseServerListTest.java | 2 +- .../nova/v1_1/parse/ParseServerTest.java | 2 +- .../ParseServerWithInternetAddressesTest.java | 2 +- ...kShouldRerouteToPublicBlockExpectTest.java | 2 +- .../java/org/jclouds/s3/S3ApiMetadata.java | 64 ++-- .../java/org/jclouds/s3/S3ContextBuilder.java | 67 ---- .../s3/blobstore/S3AsyncBlobStore.java | 2 +- .../org/jclouds/s3/blobstore/S3BlobStore.java | 2 +- .../s3/blobstore/S3BlobStoreContext.java | 4 +- .../config/S3BlobStoreContextModule.java | 10 +- .../internal/S3BlobStoreContextImpl.java | 25 +- .../jclouds/s3/config/S3RestClientModule.java | 12 +- .../org/jclouds/s3/S3ApiMetadataTest.java | 1 - .../org/jclouds/s3/S3AsyncClientTest.java | 10 +- .../java/org/jclouds/s3/S3ClientLiveTest.java | 12 +- .../s3/blobstore/S3BlobRequestSignerTest.java | 2 - .../s3/internal/BaseS3AsyncClientTest.java | 1 - .../s3/internal/BaseS3ClientExpectTest.java | 5 +- .../jclouds/s3/services/BucketsLiveTest.java | 13 +- .../openstack/swift/SwiftApiMetadata.java | 35 +- .../openstack/swift/SwiftContextBuilder.java | 72 ---- .../swift/blobstore/SwiftAsyncBlobStore.java | 2 +- .../swift/blobstore/SwiftBlobStore.java | 2 +- .../config/SwiftBlobStoreContextModule.java | 7 - .../config/BaseSwiftRestClientModule.java | 2 - .../swift/config/SwiftRestClientModule.java | 2 - .../swift/CommonSwiftClientTest.java | 34 +- .../openstack/swift/SwiftApiMetadataTest.java | 18 + .../openstack/swift/SwiftClientLiveTest.java | 2 +- .../BindSwiftObjectMetadataToRequestTest.java | 10 +- .../blobstore/SwiftBlobRequestSignerTest.java | 11 +- .../org/jclouds/vcloud/VCloudApiMetadata.java | 33 +- .../jclouds/vcloud/VCloudContextBuilder.java | 57 ---- .../VCloudComputeServiceContextModule.java | 10 +- .../vcloud/config/VCloudRestClientModule.java | 2 - .../jclouds/vcloud/VCloudApiMetadataTest.java | 7 +- .../vcloud/VCloudSessionRefreshLiveTest.java | 3 +- .../vcloud/VCloudVersionsAsyncClientTest.java | 2 +- .../BindCloneVAppParamsToXmlPayloadTest.java | 6 +- ...oneVAppTemplateParamsToXmlPayloadTest.java | 4 +- .../BaseVCloudComputeServiceExpectTest.java | 2 +- .../compute/VCloudComputeServiceLiveTest.java | 7 +- .../features/CatalogClientLiveTest.java | 5 +- .../vcloud/features/VmClientLiveTest.java | 6 +- .../internal/BaseVCloudAsyncClientTest.java | 6 +- .../internal/BaseVCloudClientLiveTest.java | 9 +- .../internal/VCloudLoginAsyncClientTest.java | 2 +- .../org/jclouds/walrus/WalrusApiMetadata.java | 19 +- .../jclouds/walrus/WalrusContextBuilder.java | 56 ---- .../walrus/config/WalrusRestClientModule.java | 2 - .../jclouds/walrus/WalrusClientLiveTest.java | 3 +- .../main/clojure/org/jclouds/blobstore2.clj | 7 +- .../org/jclouds/blobstore/AsyncBlobStore.java | 2 +- .../java/org/jclouds/blobstore/BlobStore.java | 2 +- .../blobstore/BlobStoreApiMetadata.java | 20 -- .../jclouds/blobstore/BlobStoreContext.java | 14 +- .../blobstore/BlobStoreContextBuilder.java | 63 ---- .../blobstore/BlobStoreContextFactory.java | 32 +- .../blobstore/TransientApiMetadata.java | 39 +-- .../blobstore/TransientAsyncBlobStore.java | 2 +- .../TransientBlobStoreContextBuilder.java | 55 --- .../TransientBlobStoreContextModule.java | 12 +- .../config/TransientBlobStoreModule.java | 40 --- .../internal/BaseAsyncBlobStore.java | 6 +- .../blobstore/internal/BaseBlobStore.java | 6 +- .../internal/BaseBlobStoreApiMetadata.java | 65 ---- .../internal/BlobStoreContextImpl.java | 55 +-- .../org/jclouds/blobstore/BlobStoresTest.java | 11 +- .../TransientBlobRequestSignerTest.java | 2 +- .../binders/BindBlobToMultipartFormTest.java | 4 +- ...ndUserMetadataToHeadersWithPrefixTest.java | 4 +- .../blobstore/functions/BlobNameTest.java | 6 +- .../internal/BaseBlobMapIntegrationTest.java | 4 +- .../BaseBlobStoreIntegrationTest.java | 22 +- .../BaseInputStreamMapIntegrationTest.java | 4 +- .../internal/BaseMapIntegrationTest.java | 4 +- .../internal/BaseServiceIntegrationTest.java | 3 +- .../blobstore/internal/BaseBlobMapTest.java | 6 +- .../BaseBlobStoreApiMetadataTest.java | 37 +- .../internal/BiggerThanPageSizeTest.java | 5 +- .../aws/config/AWSRestClientModule.java | 2 - .../config/FormSigningRestClientModule.java | 2 - .../WithZonesFormSigningRestClientModule.java | 2 - .../java/org/jclouds/aws/util/AWSUtils.java | 2 +- .../jclouds/aws/filters/FormSignerTest.java | 2 +- .../storage/AzureStorageContextBuilder.java | 64 ---- .../config/AzureStorageRestClientModule.java | 2 - .../filters/SharedKeyLiteAuthentication.java | 2 +- .../SharedKeyLiteAuthenticationTest.java | 2 +- .../config/OpenStackAuthenticationModule.java | 2 - .../config/AuthenticationServiceModule.java | 2 - .../config/KeystoneAuthenticationModule.java | 2 - .../OpenStackAuthAsyncClientTest.java | 2 +- .../TerremarkVCloudContextBuilder.java | 71 ---- .../TerremarkVCloudPropertiesBuilder.java | 67 ---- .../BindVAppConfigurationToXmlPayload.java | 4 +- .../TerremarkVCloudComputeService.java | 1 - ...markVCloudComputeServiceContextModule.java | 9 - .../TerremarkVCloudRestClientModule.java | 8 +- .../internal/TerremarkVCloudApiMetadata.java | 45 +-- .../vcloud_0_8/TerremarkClientLiveTest.java | 39 ++- .../BindCloneVAppParamsToXmlPayloadTest.java | 6 +- ...ateVAppTemplateParamsToXmlPayloadTest.java | 5 +- ...BindNodeConfigurationToXmlPayloadTest.java | 5 +- ...BindVAppConfigurationToXmlPayloadTest.java | 7 +- .../VAppTemplatesInOrgsLiveTest.java | 6 +- .../internal/BaseTerremarkClientLiveTest.java | 14 +- .../TerremarkVCloudLoginAsyncClientTest.java | 2 +- ...erremarkVCloudVersionsAsyncClientTest.java | 2 +- .../xml/CatalogItemHandlerTest.java | 8 +- .../trmk/vcloud_0_8/xml/OrgHandlerTest.java | 8 +- .../src/main/clojure/org/jclouds/compute2.clj | 7 +- .../org/jclouds/compute/ComputeService.java | 2 +- .../compute/ComputeServiceApiMetadata.java | 38 --- .../compute/ComputeServiceContext.java | 14 +- .../compute/ComputeServiceContextBuilder.java | 95 ------ .../compute/ComputeServiceContextFactory.java | 32 +- .../org/jclouds/compute/RunScriptData.java | 2 +- ...tandaloneComputeServiceContextBuilder.java | 50 --- .../ComputeServiceAdapterContextModule.java | 25 +- .../config/ComputeServiceTimeoutsModule.java | 2 +- ...iveComputeServiceAdapterContextModule.java | 9 +- .../StandaloneComputeServiceClientModule.java | 41 --- .../compute/internal/BaseComputeService.java | 6 +- .../BaseComputeServiceApiMetadata.java | 63 ---- .../internal/ComputeServiceContextImpl.java | 66 ++-- .../compute/options/RunScriptOptions.java | 2 +- .../jclouds/compute/stub/StubApiMetadata.java | 23 +- .../config/StubComputeServiceAdapter.java | 4 +- .../StubComputeServiceContextModule.java | 19 +- .../StubComputeServiceContextBuilder.java | 54 --- .../compute/util/ComputeServiceUtils.java | 2 +- .../org/jclouds/ovf/xml/EnvelopeHandler.java | 2 +- .../VirtualSystemSettingDataHandlerTest.java | 2 +- .../StubComputeServiceIntegrationTest.java | 5 +- .../StubTemplateBuilderIntegrationTest.java | 7 +- .../config/ComputeServicePropertiesTest.java | 6 +- .../BaseComputeServiceApiMetadataTest.java | 17 +- .../BaseComputeServiceContextLiveTest.java | 12 +- .../internal/BaseComputeServiceLiveTest.java | 8 +- .../internal/BaseTemplateBuilderLiveTest.java | 13 +- .../predicates/ImagePredicatesTest.java | 5 +- .../{rest/internal => }/ContextBuilder.java | 317 ++++++++++-------- .../java/org/jclouds/PropertiesBuilder.java | 288 ---------------- core/src/main/java/org/jclouds/Wrapper.java | 65 ++++ .../java/org/jclouds/apis/ApiMetadata.java | 106 +++--- .../java/org/jclouds/apis/ApiPredicates.java | 107 +++--- .../main/java/org/jclouds/apis/ApiType.java | 46 --- core/src/main/java/org/jclouds/apis/Apis.java | 137 +++----- .../apis/internal/BaseApiMetadata.java | 265 +++++++-------- .../jclouds/concurrent/DynamicExecutors.java | 2 +- .../jclouds/encryption/internal/Base64.java | 8 +- .../org/jclouds/internal/BaseWrapper.java | 97 ++++++ .../location/config/LocationModule.java | 6 + .../providers/AnonymousProviderMetadata.java | 39 +-- .../jclouds/providers/ProviderMetadata.java | 40 +-- .../jclouds/providers/ProviderPredicates.java | 141 ++++---- .../java/org/jclouds/providers/Providers.java | 157 ++++----- .../internal/BaseProviderMetadata.java | 91 ++--- .../rest/AnonymousRestApiMetadata.java | 33 +- .../main/java/org/jclouds/rest/Providers.java | 11 +- .../org/jclouds/rest/RestApiMetadata.java | 25 +- .../org/jclouds/rest/RestContextBuilder.java | 40 --- .../org/jclouds/rest/RestContextFactory.java | 13 +- .../rest/config/AsyncClientProvider.java | 4 +- .../org/jclouds/rest/config/BinderUtils.java | 4 +- .../jclouds/rest/config/ClientProvider.java | 6 +- .../jclouds/rest/config/RestClientModule.java | 51 +-- .../org/jclouds/rest/config/RestModule.java | 40 ++- .../rest/internal/BaseRestApiMetadata.java | 112 +++++-- core/src/main/resources/rest.properties | 244 -------------- .../internal => }/ContextBuilderTest.java | 37 +- .../test/java/org/jclouds/apis/ApisTest.java | 18 +- .../test/java/org/jclouds/apis/Balancer.java | 24 +- .../BaseContextLiveTest.java | 27 +- .../java/org/jclouds/apis/Compute.java} | 29 +- .../apis/JcloudsTestBlobStoreApiMetadata.java | 16 +- .../apis/JcloudsTestComputeApiMetadata.java | 16 +- ...loudsTestYetAnotherComputeApiMetadata.java | 16 +- .../test/java/org/jclouds/apis/Storage.java | 24 +- .../apis/internal/BaseApiMetadataTest.java | 25 +- .../java/org/jclouds/http/BaseJettyTest.java | 8 +- .../http/HttpPropertiesBuilderTest.java | 49 --- .../http/IntegrationTestClientExpectTest.java | 2 +- .../handlers/RedirectionRetryHandlerTest.java | 31 +- .../org/jclouds/internal/BaseWrapperTest.java | 79 +++++ .../JcloudsTestBlobStoreProviderMetadata.java | 14 +- .../JcloudsTestComputeProviderMetadata.java | 14 +- ...TestYetAnotherComputeProviderMetadata.java | 14 +- .../org/jclouds/providers/ProvidersTest.java | 52 +-- .../internal/BaseProviderMetadataTest.java | 31 +- .../jclouds/rest/InputParamValidatorTest.java | 2 +- .../rest/internal/BaseAsyncClientTest.java | 10 +- .../internal/BaseRestApiMetadataTest.java | 12 +- .../internal/BaseRestClientExpectTest.java | 92 ++--- .../internal/RestAnnotationProcessorTest.java | 3 +- .../java/org/jclouds/util/PatternsTest.java | 8 +- ...oogleAppEngineConfigurationModuleTest.java | 4 +- .../aws/elb/AWSELBProviderMetadata.java | 16 +- .../aws/elb/AWSELBAsyncClientTest.java | 2 +- .../jclouds/aws/elb/AWSELBProviderTest.java | 4 +- .../AWSELBLoadBalancerServiceLiveTest.java | 4 +- .../CarrenzaVCloudDirectorContextBuilder.java | 59 ---- ...arrenzaVCloudDirectorProviderMetadata.java | 23 +- ...udDirectorComputeServiceContextModule.java | 9 +- ...arrenzaVCloudDirectorRestClientModule.java | 2 - .../org/jclouds/dmtf/ovf/SectionType.java | 1 - .../java/org/jclouds/elb/ELBApiMetadata.java | 57 ++-- .../org/jclouds/elb/ELBContextBuilder.java | 67 ---- .../org/jclouds/elb/ELBPropertiesBuilder.java | 51 --- .../elb/config/ELBRestClientModule.java | 2 - .../org/jclouds/elb/ELBApiMetadataTest.java | 1 - .../org/jclouds/elb/ELBAsyncClientTest.java | 6 +- .../org/jclouds/elb/ELBClientLiveTest.java | 30 +- .../ELBLoadBalancerServiceLiveTest.java | 7 +- .../org/jclouds/glesys/GleSYSApiMetadata.java | 31 +- .../jclouds/glesys/GleSYSContextBuilder.java | 57 ---- .../glesys/GleSYSProviderMetadata.java | 17 +- .../compute/GleSYSComputeServiceAdapter.java | 2 +- .../GleSYSComputeServiceContextModule.java | 11 +- .../compute/functions/OSTemplateToImage.java | 2 +- .../glesys/config/GleSYSRestClientModule.java | 2 - .../compute/GleSYSComputeServiceLiveTest.java | 7 +- .../compute/GleSYSExperimentExpectTest.java | 2 +- .../compute/GleSYSExperimentLiveTest.java | 14 +- .../GleSYSTemplateBuilderLiveTest.java | 7 +- .../functions/ServerSpecToHardwareTest.java | 2 +- .../BaseGleSYSComputeServiceExpectTest.java | 6 +- .../features/ArchiveClientExpectTest.java | 2 +- .../features/DomainClientExpectTest.java | 2 +- .../features/EmailClientExpectTest.java | 2 +- .../features/ServerClientExpectTest.java | 2 +- .../internal/BaseGleSYSAsyncClientTest.java | 2 +- .../internal/BaseGleSYSClientLiveTest.java | 7 +- .../servers/OpSourceServersApiMetadata.java | 27 +- .../OpSourceServersContextBuilder.java | 56 ---- .../OpSourceServersRestClientModule.java | 2 - .../BaseOpSourceServersClientLiveTest.java | 21 +- ...seOpSourceServersRestClientExpectTest.java | 2 +- .../jclouds/savvis/vpdc/VPDCApiMetadata.java | 35 +- .../savvis/vpdc/VPDCContextBuilder.java | 57 ---- .../savvis/vpdc/VPDCPropertiesBuilder.java | 50 --- .../savvis/vpdc/VPDCProviderMetadata.java | 17 +- .../VPDCComputeServiceContextModule.java | 8 +- .../vpdc/config/VPDCRestClientModule.java | 2 + .../VPDCComputeServiceLiveTestDisabled.java | 7 +- .../compute/VPDCTemplateBuilderLiveTest.java | 6 +- .../features/BaseVPDCAsyncClientTest.java | 4 +- .../vpdc/features/BaseVPDCClientLiveTest.java | 5 +- .../v1_5/VCloudDirectorApiMetadata.java | 27 +- .../v1_5/VCloudDirectorContextBuilder.java | 62 ---- .../v1_5/VCloudDirectorPropertiesBuilder.java | 69 ---- .../VCloudDirectorRestClientModule.java | 2 - .../director/v1_5/HttpClientLiveTest.java | 2 + .../v1_5/VCloudDirectorApiMetadataTest.java | 12 +- .../admin/AdminCatalogClientLiveTest.java | 6 - .../BaseVCloudDirectorClientLiveTest.java | 15 +- .../internal/VCloudDirectorTestSession.java | 4 +- .../v1_5/login/SessionClientExpectTest.java | 2 +- .../v1_5/login/SessionClientLiveTest.java | 14 +- .../virtualbox/VirtualBoxApiMetadata.java | 35 +- .../virtualbox/VirtualBoxContextBuilder.java | 80 ----- .../config/DefaultCacheNodeStoreModule.java | 83 ++--- ...VirtualBoxComputeServiceContextModule.java | 16 +- .../BaseVirtualBoxClientLiveTest.java | 8 +- .../virtualbox/VirtualBoxApiMetadataTest.java | 7 +- .../compute/VirtualBoxExperimentLiveTest.java | 7 +- .../functions/CreateAndInstallVmLiveTest.java | 1 - ...ieveActiveBridgedInterfacesExpectTest.java | 3 - .../loadbalancer/LoadBalancerService.java | 2 +- .../LoadBalancerServiceApiMetadata.java | 20 -- .../LoadBalancerServiceContext.java | 14 +- .../LoadBalancerServiceContextBuilder.java | 65 ---- .../LoadBalancerServiceContextFactory.java | 32 +- .../internal/BaseLoadBalancerService.java | 6 +- .../BaseLoadBalancerServiceApiMetadata.java | 63 ---- ...BaseLoadBalancerServiceContextBuilder.java | 39 --- .../LoadBalancerServiceContextImpl.java | 44 +-- .../BaseLoadBalancerServiceLiveTest.java | 21 +- ...aseLoadBalancerServiceApiMetadataTest.java | 35 +- .../AWSCloudWatchProviderMetadata.java | 17 +- .../cloudwatch/AWSCloudWatchProviderTest.java | 4 +- .../jclouds/aws/ec2/AWSEC2ApiMetadata.java | 26 +- .../jclouds/aws/ec2/AWSEC2ContextBuilder.java | 96 ------ .../aws/ec2/AWSEC2ProviderMetadata.java | 9 +- .../BindLaunchSpecificationToFormParams.java | 2 +- .../aws/ec2/compute/AWSEC2ComputeService.java | 2 +- .../compute/AWSEC2ComputeServiceContext.java | 4 +- .../AWSEC2ComputeServiceContextModule.java | 9 +- ...WSEC2ComputeServiceDependenciesModule.java | 51 ++- .../aws/ec2/compute/config/ImageQuery.java | 20 +- .../AWSEC2ComputeServiceContextImpl.java | 15 +- .../suppliers/AWSEC2ImageSupplier.java | 19 +- .../ec2/compute/suppliers/CallForImages.java | 2 +- .../ec2/config/AWSEC2RestClientModule.java | 2 - .../aws/ec2/AWSEC2ContextBuilderTest.java | 32 +- .../compute/AWSEC2ComputeServiceLiveTest.java | 18 +- .../AWSEC2TemplateBuilderLiveTest.java | 10 +- .../aws/ec2/services/AMIClientLiveTest.java | 18 +- .../ec2/services/AWSAMIClientLiveTest.java | 12 +- .../services/AWSInstanceClientLiveTest.java | 10 +- .../services/AWSKeyPairClientLiveTest.java | 11 +- .../AWSSecurityGroupClientLiveTest.java | 5 +- .../services/BaseAWSEC2AsyncClientTest.java | 4 +- .../services/MonitoringClientLiveTest.java | 8 +- .../PlacementGroupClientLiveTest.java | 7 +- .../services/SpotInstanceClientLiveTest.java | 7 +- .../aws/ec2/services/TagClientLiveTest.java | 14 +- .../org/jclouds/aws/s3/AWSS3ApiMetadata.java | 25 +- .../jclouds/aws/s3/AWSS3ContextBuilder.java | 60 ---- .../jclouds/aws/s3/AWSS3ProviderMetadata.java | 12 +- .../aws/s3/blobstore/AWSS3AsyncBlobStore.java | 10 +- .../aws/s3/blobstore/AWSS3BlobStore.java | 8 +- .../s3/blobstore/AWSS3BlobStoreContext.java | 4 +- .../config/AWSS3BlobStoreContextModule.java | 11 - .../internal/AWSS3BlobStoreContextImpl.java | 24 +- .../ParallelMultipartUploadStrategy.java | 6 +- .../SequentialMultipartUploadStrategy.java | 6 +- .../aws/s3/config/AWSS3RestClientModule.java | 2 - .../jclouds/aws/s3/AWSS3AsyncClientTest.java | 7 +- .../jclouds/aws/s3/AWSS3ClientLiveTest.java | 6 +- ...SequentialMultipartUploadStrategyTest.java | 12 +- .../internal/BaseAWSS3ClientExpectTest.java | 6 +- .../azureblob/AzureBlobApiMetadata.java | 49 +-- .../azureblob/AzureBlobContextBuilder.java | 76 ----- .../azureblob/AzureBlobProviderMetadata.java | 12 +- .../BindAzureBlobMetadataToRequest.java | 2 +- .../blobstore/AzureAsyncBlobStore.java | 2 +- .../azureblob/blobstore/AzureBlobStore.java | 2 +- .../config/AzureBlobStoreContextModule.java | 6 - .../config/AzureBlobRestClientModule.java | 2 - .../azureblob/AzureBlobClientLiveTest.java | 10 +- .../blobstore/AzureBlobRequestSignerTest.java | 4 +- .../config/AzureBlobStoreModuleTest.java | 4 +- .../BluelockVCloudZone01ContextBuilder.java | 72 ---- .../BluelockVCloudZone01ProviderMetadata.java | 23 +- ...ckVCloudZone01TemplateBuilderLiveTest.java | 7 +- .../CloudFilesUKProviderMetadata.java | 14 +- .../CloudFilesUKClientLiveTest.java | 3 +- .../CloudFilesUSProviderMetadata.java | 14 +- .../CloudLoadBalancersUKProviderMetadata.java | 11 +- .../CloudLoadBalancersUSProviderMetadata.java | 11 +- .../CloudOneStorageProviderMetadata.java | 11 +- .../CloudServersUKProviderMetadata.java | 14 +- ...CloudServersUKTemplateBuilderLiveTest.java | 7 +- .../CloudServersUSProviderMetadata.java | 14 +- ...CloudServersUSTemplateBuilderLiveTest.java | 7 +- .../CloudSigmaLasVegasProviderMetadata.java | 9 +- ...dSigmaLasVegasTemplateBuilderLiveTest.java | 2 +- .../CloudSigmaZurichProviderMetadata.java | 9 +- ...oudSigmaZurichTemplateBuilderLiveTest.java | 2 +- ...cHostsPeer1LosAngelesProviderMetadata.java | 11 +- ...eer1LosAngelesTemplateBuilderLiveTest.java | 2 +- ...HostsBlueSquareLondonProviderMetadata.java | 11 +- ...ueSquareLondonTemplateBuilderLiveTest.java | 2 +- ...asticHostsPeer1LondonProviderMetadata.java | 11 +- ...stsPeer1LondonTemplateBuilderLiveTest.java | 2 +- ...cHostsPeer1SanAntonioProviderMetadata.java | 19 +- ...eer1SanAntonioTemplateBuilderLiveTest.java | 7 +- ...sticHostsPeer1TorontoProviderMetadata.java | 18 +- ...tsPeer1TorontoTemplateBuilderLiveTest.java | 7 +- .../EucalyptusPartnerCloudContextBuilder.java | 52 --- ...lyptusPartnerCloudEC2ProviderMetadata.java | 23 +- ...loudEucalyptusTemplateBuilderLiveTest.java | 6 +- ...alyptusPartnerCloudS3ProviderMetadata.java | 14 +- ...Go2CloudJohannesburg1ProviderMetadata.java | 20 +- ...dJohannesburg1TemplateBuilderLiveTest.java | 7 +- .../org/jclouds/gogrid/GoGridApiMetadata.java | 33 +- .../jclouds/gogrid/GoGridContextBuilder.java | 57 ---- .../gogrid/GoGridProviderMetadata.java | 17 +- .../gogrid/compute/GoGridComputeService.java | 2 +- .../GoGridComputeServiceContextModule.java | 7 +- .../gogrid/config/GoGridRestClientModule.java | 2 - .../gogrid/GoGridLiveTestDisabled.java | 12 +- .../compute/GoGridComputeServiceLiveTest.java | 7 +- .../GoGridTemplateBuilderLiveTest.java | 7 +- .../services/BaseGoGridAsyncClientTest.java | 6 +- .../services/BaseGoGridClientLiveTest.java | 7 +- .../BaseGoGridRestClientExpectTest.java | 6 +- ...nHouseDataElementVCloudContextBuilder.java | 57 ---- ...ouseDataElementVCloudProviderMetadata.java | 24 +- ...ouseDataElementVCloudRestClientModule.java | 34 -- ...aElementVCloudTemplateBuilderLiveTest.java | 7 +- .../compute/HPCloudComputeContextBuilder.java | 53 --- .../HPCloudComputeProviderMetadata.java | 32 +- ...HPCloudComputeTemplateBuilderLiveTest.java | 6 +- .../HPCloudObjectStorageApiMetadata.java | 39 ++- .../HPCloudObjectStorageContextBuilder.java | 72 ---- .../HPCloudObjectStorageProviderMetadata.java | 15 +- .../HPCloudObjectStorageAsyncBlobStore.java | 2 +- .../HPCloudObjectStorageBlobStore.java | 2 +- .../HPCloudObjectStorageRestClientModule.java | 2 - .../HPCloudObjectStorageClientLiveTest.java | 2 +- .../HPCloudObjectStorageExpectTest.java | 2 +- .../NinefoldComputeProviderMetadata.java | 16 +- ...inefoldComputeTemplateBuilderLiveTest.java | 7 +- .../NinefoldStorageProviderMetadata.java | 14 +- .../OpenHostingEast1ProviderMetadata.java | 16 +- ...enHostingEast1TemplateBuilderLiveTest.java | 7 +- .../miro/RimuHostingApiMetadata.java | 35 +- .../miro/RimuHostingContextBuilder.java | 57 ---- .../miro/RimuHostingProviderMetadata.java | 17 +- ...stingComputeServiceDependenciesModule.java | 9 - .../config/RimuHostingRestClientModule.java | 2 - .../location/RimuHostingLocationSupplier.java | 2 +- .../miro/RimuHostingAsyncClientTest.java | 2 +- .../miro/RimuHostingClientLiveTest.java | 5 +- .../RimuHostingComputeServiceLiveTest.java | 7 +- .../RimuHostingTemplateBuilderLiveTest.java | 7 +- .../ServerloveManchesterProviderMetadata.java | 16 +- ...loveManchesterTemplateBuilderLiveTest.java | 7 +- .../SkaliCloudMalaysiaProviderMetadata.java | 16 +- ...iCloudMalaysiaTemplateBuilderLiveTest.java | 5 +- .../slicehost/SlicehostApiMetadata.java | 32 +- .../slicehost/SlicehostContextBuilder.java | 57 ---- .../slicehost/SlicehostProviderMetadata.java | 12 +- .../SlicehostComputeServiceContextModule.java | 10 +- .../config/SlicehostRestClientModule.java | 2 - .../slicehost/SlicehostAsyncClientTest.java | 2 +- .../slicehost/SlicehostClientLiveTest.java | 5 +- .../SlicehostComputeServiceLiveTest.java | 7 +- .../SlicehostTemplateBuilderLiveTest.java | 7 +- .../softlayer/SoftLayerApiMetadata.java | 34 +- .../softlayer/SoftLayerContextBuilder.java | 57 ---- .../softlayer/SoftLayerProviderMetadata.java | 17 +- .../SoftLayerComputeServiceContextModule.java | 10 +- .../config/SoftLayerRestClientModule.java | 2 - .../SoftLayerComputeServiceLiveTest.java | 13 +- .../compute/SoftLayerExperimentLiveTest.java | 14 +- .../SoftLayerTemplateBuilderLiveTest.java | 18 +- .../BaseSoftLayerAsyncClientTest.java | 2 +- .../features/BaseSoftLayerClientLiveTest.java | 7 +- .../StratoGenVCloudMyCloudContextBuilder.java | 57 ---- ...tratoGenVCloudMyCloudProviderMetadata.java | 24 +- ...nVCloudMyCloudTemplateBuilderLiveTest.java | 7 +- .../SynapticStorageProviderMetadata.java | 14 +- .../ecloud/TerremarkECloudApiMetadata.java | 29 +- .../ecloud/TerremarkECloudContextBuilder.java | 76 ----- .../TerremarkECloudProviderMetadata.java | 12 +- .../TerremarkECloudRestClientModule.java | 2 - .../BaseTerremarkECloudAsyncClientTest.java | 6 +- .../BaseTerremarkECloudClientLiveTest.java | 3 +- ...TerremarkECloudComputeServiceLiveTest.java | 7 +- ...erremarkECloudTemplateBuilderLiveTest.java | 7 +- .../DataCenterOperationsClientLiveTest.java | 6 +- .../features/TagOperationsClientLiveTest.java | 6 +- .../trmk/ecloud/xml/ECloudOrgHandlerTest.java | 8 +- .../xml/TagNameToUsageCountHandlerTest.java | 8 +- .../TerremarkVCloudExpressApiMetadata.java | 26 +- .../TerremarkVCloudExpressContextBuilder.java | 76 ----- ...rremarkVCloudExpressPropertiesBuilder.java | 52 --- ...erremarkVCloudExpressProviderMetadata.java | 12 +- ...erremarkVCloudExpressRestClientModule.java | 2 - .../InternetServiceLiveTest.java | 5 +- ...TerremarkVCloudExpressAsyncClientTest.java | 6 +- ...rkVCloudExpressComputeServiceLiveTest.java | 7 +- ...kVCloudExpressTemplateBuilderLiveTest.java | 7 +- .../nova/TryStackNovaContextBuilder.java | 53 --- .../nova/TryStackNovaProviderMetadata.java | 26 +- .../TryStackNovaTemplateBuilderLiveTest.java | 6 +- .../DunkelVCloudDirectorContextBuilder.java | 10 +- ...DunkelVCloudDirectorPropertiesBuilder.java | 8 - .../DunkelVCloudDirectorProviderMetadata.java | 7 - ...udDirectorComputeServiceContextModule.java | 9 - .../DunkelVCloudDirectorRestClientModule.java | 4 - .../vcd/DunkelVCloudDirectorProviderTest.java | 5 +- ...lVCloudDirectorComputeServiceLiveTest.java | 2 - ...VCloudDirectorTemplateBuilderLiveTest.java | 14 - .../ServerManagerApiMetadata.java | 21 +- ...erManagerComputeServiceContextBuilder.java | 57 ---- ...verManagerComputeServiceContextModule.java | 7 +- ...nagerComputeServiceContextBuilderTest.java | 32 +- .../ServerManagerComputeServiceLiveTest.java | 5 +- .../ServerManagerExperimentLiveTest.java | 11 +- 659 files changed, 3814 insertions(+), 8641 deletions(-) delete mode 100644 apis/atmos/src/main/java/org/jclouds/atmos/AtmosContextBuilder.java delete mode 100644 apis/byon/src/main/java/org/jclouds/byon/BYONComputeServiceContextBuilder.java delete mode 100644 apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesContextBuilder.java delete mode 100644 apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersContextBuilder.java delete mode 100644 apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersContextBuilder.java delete mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaContextBuilder.java delete mode 100644 apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackContextBuilder.java delete mode 100644 apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/CloudWatchContextBuilder.java delete mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudContextBuilder.java delete mode 100644 apis/ec2/src/main/java/org/jclouds/ec2/EC2ContextBuilder.java delete mode 100644 apis/elasticstack/src/main/java/org/jclouds/elasticstack/ElasticStackContextBuilder.java delete mode 100644 apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemBlobStoreContextBuilder.java delete mode 100644 apis/filesystem/src/main/java/org/jclouds/filesystem/config/FilesystemBlobStoreModule.java delete mode 100644 apis/nova/src/main/java/org/jclouds/openstack/nova/NovaContextBuilder.java delete mode 100644 apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/NovaEC2ContextBuilder.java delete mode 100644 apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaContextBuilder.java delete mode 100644 apis/s3/src/main/java/org/jclouds/s3/S3ContextBuilder.java delete mode 100644 apis/swift/src/main/java/org/jclouds/openstack/swift/SwiftContextBuilder.java delete mode 100644 apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudContextBuilder.java delete mode 100644 apis/walrus/src/main/java/org/jclouds/walrus/WalrusContextBuilder.java delete mode 100644 blobstore/src/main/java/org/jclouds/blobstore/BlobStoreApiMetadata.java delete mode 100644 blobstore/src/main/java/org/jclouds/blobstore/BlobStoreContextBuilder.java delete mode 100644 blobstore/src/main/java/org/jclouds/blobstore/TransientBlobStoreContextBuilder.java delete mode 100644 blobstore/src/main/java/org/jclouds/blobstore/config/TransientBlobStoreModule.java delete mode 100644 blobstore/src/main/java/org/jclouds/blobstore/internal/BaseBlobStoreApiMetadata.java delete mode 100644 common/azure/src/main/java/org/jclouds/azure/storage/AzureStorageContextBuilder.java delete mode 100644 common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/TerremarkVCloudContextBuilder.java delete mode 100644 common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/TerremarkVCloudPropertiesBuilder.java delete mode 100644 compute/src/main/java/org/jclouds/compute/ComputeServiceApiMetadata.java delete mode 100644 compute/src/main/java/org/jclouds/compute/ComputeServiceContextBuilder.java delete mode 100644 compute/src/main/java/org/jclouds/compute/StandaloneComputeServiceContextBuilder.java delete mode 100644 compute/src/main/java/org/jclouds/compute/config/StandaloneComputeServiceClientModule.java delete mode 100644 compute/src/main/java/org/jclouds/compute/internal/BaseComputeServiceApiMetadata.java delete mode 100644 compute/src/main/java/org/jclouds/compute/stub/internal/StubComputeServiceContextBuilder.java rename core/src/main/java/org/jclouds/{rest/internal => }/ContextBuilder.java (62%) delete mode 100644 core/src/main/java/org/jclouds/PropertiesBuilder.java create mode 100644 core/src/main/java/org/jclouds/Wrapper.java delete mode 100644 core/src/main/java/org/jclouds/apis/ApiType.java create mode 100644 core/src/main/java/org/jclouds/internal/BaseWrapper.java delete mode 100644 core/src/main/java/org/jclouds/rest/RestContextBuilder.java delete mode 100644 core/src/main/resources/rest.properties rename core/src/test/java/org/jclouds/{rest/internal => }/ContextBuilderTest.java (83%) rename providers/bluelock-vcloud-zone01/src/main/java/org/jclouds/bluelock/vcloud/zone01/config/BluelockVCloudZone01RestClientModule.java => core/src/test/java/org/jclouds/apis/Balancer.java (64%) rename core/src/test/java/org/jclouds/{rest/internal => apis}/BaseContextLiveTest.java (86%) rename core/src/{main/java/org/jclouds/rest/BackedByRestContext.java => test/java/org/jclouds/apis/Compute.java} (68%) rename providers/stratogen-vcloud-mycloud/src/main/java/org/jclouds/stratogen/vcloud/mycloud/config/StratoGenVCloudMyCloudRestClientModule.java => core/src/test/java/org/jclouds/apis/Storage.java (64%) delete mode 100644 core/src/test/java/org/jclouds/http/HttpPropertiesBuilderTest.java create mode 100644 core/src/test/java/org/jclouds/internal/BaseWrapperTest.java rename core/src/test/java/org/jclouds/{apis => rest}/internal/BaseRestApiMetadataTest.java (79%) delete mode 100644 labs/carrenza-vcloud-director/src/main/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorContextBuilder.java delete mode 100644 labs/elb/src/main/java/org/jclouds/elb/ELBContextBuilder.java delete mode 100644 labs/elb/src/main/java/org/jclouds/elb/ELBPropertiesBuilder.java delete mode 100644 labs/glesys/src/main/java/org/jclouds/glesys/GleSYSContextBuilder.java delete mode 100644 labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/OpSourceServersContextBuilder.java delete mode 100644 labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCContextBuilder.java delete mode 100644 labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCPropertiesBuilder.java delete mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorContextBuilder.java delete mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorPropertiesBuilder.java delete mode 100644 labs/virtualbox/src/main/java/org/jclouds/virtualbox/VirtualBoxContextBuilder.java rename apis/nova/src/main/java/org/jclouds/openstack/nova/NovaPropertiesBuilder.java => labs/virtualbox/src/main/java/org/jclouds/virtualbox/config/DefaultCacheNodeStoreModule.java (50%) delete mode 100644 loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerServiceApiMetadata.java delete mode 100644 loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerServiceContextBuilder.java delete mode 100644 loadbalancer/src/main/java/org/jclouds/loadbalancer/internal/BaseLoadBalancerServiceApiMetadata.java delete mode 100644 loadbalancer/src/main/java/org/jclouds/loadbalancer/internal/BaseLoadBalancerServiceContextBuilder.java delete mode 100644 providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2ContextBuilder.java rename core/src/main/java/org/jclouds/http/RequiresHttp.java => providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/config/ImageQuery.java (71%) delete mode 100644 providers/aws-s3/src/main/java/org/jclouds/aws/s3/AWSS3ContextBuilder.java delete mode 100644 providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobContextBuilder.java delete mode 100644 providers/bluelock-vcloud-zone01/src/main/java/org/jclouds/bluelock/vcloud/zone01/BluelockVCloudZone01ContextBuilder.java delete mode 100644 providers/eucalyptus-partnercloud-ec2/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudContextBuilder.java delete mode 100644 providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridContextBuilder.java delete mode 100644 providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudContextBuilder.java delete mode 100644 providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/config/GreenHouseDataElementVCloudRestClientModule.java delete mode 100644 providers/hpcloud-compute/src/main/java/org/jclouds/hpcloud/compute/HPCloudComputeContextBuilder.java delete mode 100644 providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageContextBuilder.java delete mode 100644 providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingContextBuilder.java delete mode 100644 providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostContextBuilder.java delete mode 100644 providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerContextBuilder.java delete mode 100644 providers/stratogen-vcloud-mycloud/src/main/java/org/jclouds/stratogen/vcloud/mycloud/StratoGenVCloudMyCloudContextBuilder.java delete mode 100644 providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/TerremarkECloudContextBuilder.java delete mode 100644 providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressContextBuilder.java delete mode 100644 providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressPropertiesBuilder.java delete mode 100644 providers/trystack-nova/src/main/java/org/jclouds/trystack/nova/TryStackNovaContextBuilder.java delete mode 100644 skeletons/standalone-compute/src/main/java/org/jclouds/servermanager/compute/ServerManagerComputeServiceContextBuilder.java diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/AtmosApiMetadata.java b/apis/atmos/src/main/java/org/jclouds/atmos/AtmosApiMetadata.java index 1dd282eff9..c4f6f01201 100644 --- a/apis/atmos/src/main/java/org/jclouds/atmos/AtmosApiMetadata.java +++ b/apis/atmos/src/main/java/org/jclouds/atmos/AtmosApiMetadata.java @@ -25,19 +25,31 @@ import java.net.URI; import java.util.Properties; import org.jclouds.apis.ApiMetadata; +import org.jclouds.atmos.blobstore.config.AtmosBlobStoreContextModule; +import org.jclouds.atmos.config.AtmosRestClientModule; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.internal.BaseBlobStoreApiMetadata; +import org.jclouds.rest.RestContext; +import org.jclouds.rest.internal.BaseRestApiMetadata; +import com.google.common.collect.ImmutableSet; import com.google.common.reflect.TypeToken; +import com.google.inject.Module; /** * Implementation of {@link ApiMetadata} for Rackspace Cloud Files API * * @author Adrian Cole */ -public class AtmosApiMetadata - extends - BaseBlobStoreApiMetadata, AtmosApiMetadata> { +public class AtmosApiMetadata extends BaseRestApiMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 8067252472547486854L; + + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; + + private static Builder builder() { return new Builder(); } @@ -55,17 +67,16 @@ public class AtmosApiMetadata super(builder); } - protected static Properties defaultProperties() { - Properties properties = BaseBlobStoreApiMetadata.Builder.defaultProperties(); + public static Properties defaultProperties() { + Properties properties = BaseRestApiMetadata.defaultProperties(); properties.setProperty(PROPERTY_REGIONS, "DEFAULT"); properties.setProperty(PROPERTY_USER_METADATA_PREFIX, "X-Object-Meta-"); return properties; } - public static class Builder - extends - BaseBlobStoreApiMetadata.Builder, AtmosApiMetadata> { + public static class Builder extends BaseRestApiMetadata.Builder { protected Builder() { + super(AtmosClient.class, AtmosAsyncClient.class); id("atmos") .name("EMC's Atmos API") .identityName("Subtenant ID (UID)") @@ -73,9 +84,9 @@ public class AtmosApiMetadata .documentation(URI.create("https://community.emc.com/docs/DOC-10508")) .version("1.4.0") .defaultEndpoint("https://accesspoint.atmosonline.com") - .contextBuilder(TypeToken.of(AtmosContextBuilder.class)) .defaultProperties(AtmosApiMetadata.defaultProperties()) - .javaApi(AtmosClient.class, AtmosAsyncClient.class); + .wrapper(TypeToken.of(BlobStoreContext.class)) + .defaultModules(ImmutableSet.>of(AtmosRestClientModule.class, AtmosBlobStoreContextModule.class)); } @Override @@ -84,7 +95,7 @@ public class AtmosApiMetadata } @Override - public Builder fromApiMetadata(AtmosApiMetadata in) { + public Builder fromApiMetadata(ApiMetadata in) { super.fromApiMetadata(in); return this; } diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/AtmosContextBuilder.java b/apis/atmos/src/main/java/org/jclouds/atmos/AtmosContextBuilder.java deleted file mode 100644 index 6856023dee..0000000000 --- a/apis/atmos/src/main/java/org/jclouds/atmos/AtmosContextBuilder.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * 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.atmos; - -import java.util.List; - -import org.jclouds.atmos.blobstore.config.AtmosBlobStoreContextModule; -import org.jclouds.atmos.config.AtmosRestClientModule; -import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextBuilder; -import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; -import org.jclouds.logging.jdk.config.JDKLoggingModule; -import org.jclouds.providers.ProviderMetadata; - -import com.google.inject.Injector; -import com.google.inject.Module; - -/** - * Creates {@link AtmosStoreContext} or {@link Injector} instances based on - * the most commonly requested arguments. - *

- * Note that Threadsafe objects will be bound as singletons to the Injector or - * Context provided. - *

- *

- * If no Modules are specified, the default - * {@link JDKLoggingModule logging} and - * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be - * installed. - * - * @author Adrian Cole, Andrew Newdigate - * @see AtmosStoreContext - */ -public class AtmosContextBuilder - extends - BlobStoreContextBuilder, AtmosApiMetadata> { - - public AtmosContextBuilder( - ProviderMetadata, AtmosApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public AtmosContextBuilder(AtmosApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new AtmosBlobStoreContextModule()); - } - - @Override - protected void addClientModule(List modules) { - modules.add(new AtmosRestClientModule()); - } -} diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/binders/BindUserMetadataToHeaders.java b/apis/atmos/src/main/java/org/jclouds/atmos/binders/BindUserMetadataToHeaders.java index 670466d589..982ef6b5d6 100644 --- a/apis/atmos/src/main/java/org/jclouds/atmos/binders/BindUserMetadataToHeaders.java +++ b/apis/atmos/src/main/java/org/jclouds/atmos/binders/BindUserMetadataToHeaders.java @@ -33,8 +33,8 @@ import org.jclouds.rest.Binder; import com.google.common.base.Function; import com.google.common.base.Joiner; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMap.Builder; import com.google.common.collect.Multimaps; +import com.google.common.collect.ImmutableMap.Builder; /** * @author Adrian Cole diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosAsyncBlobStore.java b/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosAsyncBlobStore.java index 7c5db767a6..18c1b084be 100644 --- a/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosAsyncBlobStore.java +++ b/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosAsyncBlobStore.java @@ -85,7 +85,7 @@ public class AtmosAsyncBlobStore extends BaseAsyncBlobStore { private final LoadingCache isPublic; @Inject - AtmosAsyncBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, + AtmosAsyncBlobStore(BlobStoreContext context, BlobUtils blobUtils, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService service, Supplier defaultLocation, @Memoized Supplier> locations, AtmosAsyncClient async, AtmosClient sync, ObjectToBlob object2Blob, ObjectToBlobMetadata object2BlobMd, BlobToObject blob2Object, diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosBlobStore.java b/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosBlobStore.java index 5dafd49b28..4ba8c4b63b 100644 --- a/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosBlobStore.java +++ b/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosBlobStore.java @@ -73,7 +73,7 @@ public class AtmosBlobStore extends BaseBlobStore { private final LoadingCache isPublic; @Inject - AtmosBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, Supplier defaultLocation, + AtmosBlobStore(BlobStoreContext context, BlobUtils blobUtils, Supplier defaultLocation, @Memoized Supplier> locations, AtmosClient sync, ObjectToBlob object2Blob, ObjectToBlobMetadata object2BlobMd, BlobToObject blob2Object, BlobStoreListOptionsToListOptions container2ContainerListOptions, diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/config/AtmosBlobStoreContextModule.java b/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/config/AtmosBlobStoreContextModule.java index d9e84e51e7..5ca4c57d49 100644 --- a/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/config/AtmosBlobStoreContextModule.java +++ b/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/config/AtmosBlobStoreContextModule.java @@ -22,7 +22,6 @@ import java.util.concurrent.TimeUnit; import javax.inject.Singleton; -import org.jclouds.atmos.AtmosAsyncClient; import org.jclouds.atmos.AtmosClient; import org.jclouds.atmos.blobstore.AtmosAsyncBlobStore; import org.jclouds.atmos.blobstore.AtmosBlobRequestSigner; @@ -31,10 +30,8 @@ import org.jclouds.atmos.blobstore.strategy.FindMD5InUserMetadata; import org.jclouds.blobstore.AsyncBlobStore; import org.jclouds.blobstore.BlobRequestSigner; import org.jclouds.blobstore.BlobStore; -import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.blobstore.attr.ConsistencyModel; import org.jclouds.blobstore.config.BlobStoreMapModule; -import org.jclouds.blobstore.internal.BlobStoreContextImpl; import org.jclouds.blobstore.strategy.ContainsValueInListStrategy; import com.google.common.cache.CacheBuilder; @@ -43,7 +40,6 @@ import com.google.common.cache.LoadingCache; import com.google.inject.AbstractModule; import com.google.inject.Provides; import com.google.inject.Scopes; -import com.google.inject.TypeLiteral; /** * Configures the {@link AtmosBlobStoreContext}; requires {@link AtmosAsyncBlobStore} bound. @@ -58,8 +54,6 @@ public class AtmosBlobStoreContextModule extends AbstractModule { bind(ConsistencyModel.class).toInstance(ConsistencyModel.EVENTUAL); bind(AsyncBlobStore.class).to(AtmosAsyncBlobStore.class).in(Scopes.SINGLETON); bind(BlobStore.class).to(AtmosBlobStore.class).in(Scopes.SINGLETON); - bind(BlobStoreContext.class).to(new TypeLiteral>() { - }).in(Scopes.SINGLETON); bind(ContainsValueInListStrategy.class).to(FindMD5InUserMetadata.class); bind(BlobRequestSigner.class).to(AtmosBlobRequestSigner.class); } diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/functions/ObjectToBlobMetadata.java b/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/functions/ObjectToBlobMetadata.java index 5f1f772933..6338fff02b 100644 --- a/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/functions/ObjectToBlobMetadata.java +++ b/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/functions/ObjectToBlobMetadata.java @@ -19,8 +19,8 @@ package org.jclouds.atmos.blobstore.functions; import java.util.Map; -import java.util.Map.Entry; import java.util.Set; +import java.util.Map.Entry; import javax.inject.Inject; import javax.inject.Singleton; diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/config/AtmosRestClientModule.java b/apis/atmos/src/main/java/org/jclouds/atmos/config/AtmosRestClientModule.java index b36f1c8d03..b9d52d486c 100644 --- a/apis/atmos/src/main/java/org/jclouds/atmos/config/AtmosRestClientModule.java +++ b/apis/atmos/src/main/java/org/jclouds/atmos/config/AtmosRestClientModule.java @@ -32,7 +32,6 @@ 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; @@ -50,7 +49,6 @@ import com.google.inject.Provides; * @author Adrian Cole */ @ConfiguresRestClient -@RequiresHttp public class AtmosRestClientModule extends RestClientModule { public AtmosRestClientModule() { super(AtmosClient.class, AtmosAsyncClient.class); diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/filters/SignRequest.java b/apis/atmos/src/main/java/org/jclouds/atmos/filters/SignRequest.java index 568a1e50fd..94be6d2c57 100644 --- a/apis/atmos/src/main/java/org/jclouds/atmos/filters/SignRequest.java +++ b/apis/atmos/src/main/java/org/jclouds/atmos/filters/SignRequest.java @@ -51,8 +51,8 @@ import org.jclouds.util.Strings2; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Strings; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMap.Builder; import com.google.common.collect.Multimaps; +import com.google.common.collect.ImmutableMap.Builder; /** * Signs the EMC Atmos Online Storage request. diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/functions/ParseUserMetadataFromHeaders.java b/apis/atmos/src/main/java/org/jclouds/atmos/functions/ParseUserMetadataFromHeaders.java index de352521d2..c726f2e8b3 100644 --- a/apis/atmos/src/main/java/org/jclouds/atmos/functions/ParseUserMetadataFromHeaders.java +++ b/apis/atmos/src/main/java/org/jclouds/atmos/functions/ParseUserMetadataFromHeaders.java @@ -33,9 +33,9 @@ import com.google.common.base.Function; import com.google.common.base.Predicate; import com.google.common.base.Splitter; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMap.Builder; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Maps; +import com.google.common.collect.ImmutableMap.Builder; /** * @author Adrian Cole diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/AtmosAsyncClientTest.java b/apis/atmos/src/test/java/org/jclouds/atmos/AtmosAsyncClientTest.java index 6722aeffc4..878e0e7e8f 100644 --- a/apis/atmos/src/test/java/org/jclouds/atmos/AtmosAsyncClientTest.java +++ b/apis/atmos/src/test/java/org/jclouds/atmos/AtmosAsyncClientTest.java @@ -42,7 +42,6 @@ import org.jclouds.blobstore.functions.ThrowContainerNotFoundOn404; import org.jclouds.blobstore.functions.ThrowKeyNotFoundOn404; import org.jclouds.date.TimeStamp; import org.jclouds.http.HttpRequest; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.functions.ParseURIFromListOrLocationHeaderIf20x; import org.jclouds.http.functions.ReleasePayloadAndReturn; import org.jclouds.http.options.GetOptions; @@ -320,8 +319,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest return new TestAtmosRestClientModule(); } - @RequiresHttp - @ConfiguresRestClient + @ConfiguresRestClient private static final class TestAtmosRestClientModule extends AtmosRestClientModule { @Override protected void configure() { @@ -337,7 +335,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest protected String provider = "atmos"; @Override - public ApiMetadata createApiMetadata() { + public ApiMetadata createApiMetadata() { return new AtmosApiMetadata(); } diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/AtmosClientLiveTest.java b/apis/atmos/src/test/java/org/jclouds/atmos/AtmosClientLiveTest.java index 6d02a88be8..fc9adafdb9 100644 --- a/apis/atmos/src/test/java/org/jclouds/atmos/AtmosClientLiveTest.java +++ b/apis/atmos/src/test/java/org/jclouds/atmos/AtmosClientLiveTest.java @@ -57,7 +57,7 @@ import com.google.common.collect.Sets; public class AtmosClientLiveTest extends BaseBlobStoreIntegrationTest { public AtmosClient getApi() { - return (AtmosClient) context.getProviderSpecificContext().getApi(); + return context.unwrap(AtmosApiMetadata.CONTEXT_TOKEN).getApi(); } private static final class HeadMatches implements Runnable { diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/AtmosBlobRequestSignerTest.java b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/AtmosBlobRequestSignerTest.java index c4f2d593be..79555eae05 100644 --- a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/AtmosBlobRequestSignerTest.java +++ b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/AtmosBlobRequestSignerTest.java @@ -32,7 +32,6 @@ import org.jclouds.blobstore.domain.Blob; import org.jclouds.blobstore.domain.Blob.Factory; import org.jclouds.date.TimeStamp; import org.jclouds.http.HttpRequest; -import org.jclouds.http.RequiresHttp; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.internal.BaseAsyncClientTest; import org.jclouds.rest.internal.RestAnnotationProcessor; @@ -128,8 +127,7 @@ public class AtmosBlobRequestSignerTest extends BaseAsyncClientTest createApiMetadata() { + public ApiMetadata createApiMetadata() { return new AtmosApiMetadata(); } diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/config/AtmosBlobStoreModuleTest.java b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/config/AtmosBlobStoreModuleTest.java index ccf9a5c840..6b40259d08 100644 --- a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/config/AtmosBlobStoreModuleTest.java +++ b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/config/AtmosBlobStoreModuleTest.java @@ -20,10 +20,10 @@ package org.jclouds.atmos.blobstore.config; import static org.testng.Assert.assertEquals; +import org.jclouds.ContextBuilder; import org.jclouds.atmos.AtmosApiMetadata; import org.jclouds.atmos.blobstore.strategy.FindMD5InUserMetadata; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextBuilder; import org.jclouds.blobstore.internal.BlobStoreContextImpl; import org.jclouds.blobstore.strategy.ContainsValueInListStrategy; import org.jclouds.logging.config.NullLoggingModule; @@ -41,7 +41,7 @@ import com.google.inject.Module; public class AtmosBlobStoreModuleTest { Injector createInjector() { - return BlobStoreContextBuilder + return ContextBuilder .newBuilder(new AtmosApiMetadata()) .credentials("uid", "key") .modules( @@ -53,7 +53,7 @@ public class AtmosBlobStoreModuleTest { void testContextImpl() { Injector injector = createInjector(); - BlobStoreContext handler = injector.getInstance(BlobStoreContext.class); + BlobStoreContext handler = injector.getInstance(BlobStoreContext.class); assertEquals(handler.getClass(), BlobStoreContextImpl.class); ContainsValueInListStrategy valueList = injector .getInstance(ContainsValueInListStrategy.class); diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/filters/SignRequestTest.java b/apis/atmos/src/test/java/org/jclouds/atmos/filters/SignRequestTest.java index dc07a557d8..903cba2de1 100644 --- a/apis/atmos/src/test/java/org/jclouds/atmos/filters/SignRequestTest.java +++ b/apis/atmos/src/test/java/org/jclouds/atmos/filters/SignRequestTest.java @@ -28,12 +28,11 @@ import java.security.NoSuchAlgorithmException; import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.MediaType; +import org.jclouds.ContextBuilder; import org.jclouds.atmos.config.AtmosRestClientModule; import org.jclouds.atmos.reference.AtmosHeaders; -import org.jclouds.blobstore.BlobStoreContextBuilder; import org.jclouds.date.TimeStamp; import org.jclouds.http.HttpRequest; -import org.jclouds.http.RequiresHttp; import org.jclouds.logging.config.NullLoggingModule; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.internal.BaseRestClientTest.MockModule; @@ -43,9 +42,9 @@ import org.testng.annotations.Test; import com.google.common.base.Supplier; import com.google.common.collect.ImmutableMultimap; -import com.google.common.collect.ImmutableMultimap.Builder; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Multimap; +import com.google.common.collect.ImmutableMultimap.Builder; import com.google.inject.Injector; import com.google.inject.Module; @@ -97,7 +96,7 @@ public class SignRequestTest { @BeforeClass protected void createFilter() { - Injector injector = BlobStoreContextBuilder + Injector injector = ContextBuilder .newBuilder("atmos") .credentials(UID, KEY) .modules( @@ -108,8 +107,7 @@ public class SignRequestTest { } - @RequiresHttp - @ConfiguresRestClient + @ConfiguresRestClient private static final class TestAtmosRestClientModule extends AtmosRestClientModule { @Override diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/functions/AtmosObjectNameTest.java b/apis/atmos/src/test/java/org/jclouds/atmos/functions/AtmosObjectNameTest.java index b1690107fe..1f9a5a56e1 100644 --- a/apis/atmos/src/test/java/org/jclouds/atmos/functions/AtmosObjectNameTest.java +++ b/apis/atmos/src/test/java/org/jclouds/atmos/functions/AtmosObjectNameTest.java @@ -23,9 +23,9 @@ import static org.testng.Assert.assertEquals; import java.io.File; import org.jclouds.atmos.domain.AtmosObject; -import org.jclouds.atmos.domain.AtmosObject.Factory; import org.jclouds.atmos.domain.SystemMetadata; import org.jclouds.atmos.domain.UserMetadata; +import org.jclouds.atmos.domain.AtmosObject.Factory; import org.testng.annotations.Test; import com.google.inject.Guice; diff --git a/apis/byon/src/main/java/org/jclouds/byon/BYONApiMetadata.java b/apis/byon/src/main/java/org/jclouds/byon/BYONApiMetadata.java index a094713c0b..1aa7293702 100644 --- a/apis/byon/src/main/java/org/jclouds/byon/BYONApiMetadata.java +++ b/apis/byon/src/main/java/org/jclouds/byon/BYONApiMetadata.java @@ -19,15 +19,16 @@ package org.jclouds.byon; import java.net.URI; -import java.util.Properties; import org.jclouds.JcloudsVersion; import org.jclouds.apis.ApiMetadata; +import org.jclouds.apis.internal.BaseApiMetadata; +import org.jclouds.byon.config.BYONComputeServiceContextModule; +import org.jclouds.byon.config.YamlNodeStoreModule; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; -import com.google.common.base.Supplier; -import com.google.common.reflect.TypeToken; +import com.google.common.collect.ImmutableSet; +import com.google.inject.Module; /** * Implementation of {@link ApiMetadata} for jclouds BYON API @@ -39,8 +40,10 @@ import com.google.common.reflect.TypeToken; * * @author Adrian Cole */ -@SuppressWarnings("rawtypes") -public class BYONApiMetadata extends BaseComputeServiceApiMetadata, BYONApiMetadata> { +public class BYONApiMetadata extends BaseApiMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = -4059125995177393819L; @Override public Builder toBuilder() { @@ -55,11 +58,7 @@ public class BYONApiMetadata extends BaseComputeServiceApiMetadata, BYONApiMetadata> { + public static class Builder extends BaseApiMetadata.Builder { protected Builder() { id("byon") @@ -71,9 +70,8 @@ public class BYONApiMetadata extends BaseComputeServiceApiMetadata>of(YamlNodeStoreModule.class, BYONComputeServiceContextModule.class)); } @Override @@ -82,7 +80,7 @@ public class BYONApiMetadata extends BaseComputeServiceApiMetadata, BYONApiMetadata> { - - public BYONComputeServiceContextBuilder( - ProviderMetadata, BYONApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public BYONComputeServiceContextBuilder(BYONApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new BYONComputeServiceContextModule()); - addNodeStoreModuleIfNotPresent(modules); - } - - protected void addNodeStoreModuleIfNotPresent(List modules) { - if (!Iterables.any(modules, new Predicate() { - public boolean apply(Module input) { - return input.getClass().isAnnotationPresent(ConfiguresNodeStore.class); - } - - })) { - addNodeStoreModule(modules); - } - } - - protected void addNodeStoreModule(List modules) { - modules.add(new YamlNodeStoreModule()); - } -} diff --git a/apis/byon/src/main/java/org/jclouds/byon/config/BYONComputeServiceContextModule.java b/apis/byon/src/main/java/org/jclouds/byon/config/BYONComputeServiceContextModule.java index f00b3db1e7..8168e645f3 100644 --- a/apis/byon/src/main/java/org/jclouds/byon/config/BYONComputeServiceContextModule.java +++ b/apis/byon/src/main/java/org/jclouds/byon/config/BYONComputeServiceContextModule.java @@ -21,9 +21,6 @@ package org.jclouds.byon.config; import java.io.InputStream; import java.net.URI; -import javax.inject.Singleton; - -import org.jclouds.byon.Node; import org.jclouds.byon.internal.BYONComputeServiceAdapter; import org.jclouds.byon.suppliers.SupplyFromProviderURIOrNodesProperty; import org.jclouds.compute.config.JCloudsNativeComputeServiceAdapterContextModule; @@ -36,27 +33,17 @@ import org.jclouds.location.Provider; import com.google.common.base.Function; import com.google.common.base.Supplier; -import com.google.common.cache.LoadingCache; -import com.google.inject.Provides; import com.google.inject.TypeLiteral; /** * * @author Adrian Cole */ -@SuppressWarnings("unchecked") @SingleThreaded -public class BYONComputeServiceContextModule extends - JCloudsNativeComputeServiceAdapterContextModule { +public class BYONComputeServiceContextModule extends JCloudsNativeComputeServiceAdapterContextModule { public BYONComputeServiceContextModule() { - super(Supplier.class, Supplier.class, BYONComputeServiceAdapter.class); - } - - @Provides - @Singleton - Supplier provideApi(Supplier> in) { - return in; + super(BYONComputeServiceAdapter.class); } @Override @@ -68,6 +55,7 @@ public class BYONComputeServiceContextModule extends }).annotatedWith(Provider.class).to(SupplyFromProviderURIOrNodesProperty.class); bind(new TypeLiteral>() { }).to(SupplyFromProviderURIOrNodesProperty.class); - install(new LocationsFromComputeServiceAdapterModule(){}); + install(new LocationsFromComputeServiceAdapterModule() { + }); } } diff --git a/apis/byon/src/main/java/org/jclouds/byon/domain/YamlNode.java b/apis/byon/src/main/java/org/jclouds/byon/domain/YamlNode.java index b8b8615f56..318fc515ac 100644 --- a/apis/byon/src/main/java/org/jclouds/byon/domain/YamlNode.java +++ b/apis/byon/src/main/java/org/jclouds/byon/domain/YamlNode.java @@ -33,9 +33,9 @@ import org.yaml.snakeyaml.constructor.Constructor; import com.google.common.base.Function; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMap.Builder; import com.google.common.collect.Lists; import com.google.common.collect.Maps; +import com.google.common.collect.ImmutableMap.Builder; import com.google.common.io.Closeables; /** diff --git a/apis/byon/src/main/java/org/jclouds/byon/internal/BYONComputeServiceAdapter.java b/apis/byon/src/main/java/org/jclouds/byon/internal/BYONComputeServiceAdapter.java index 6ae9ecdd4a..19837550e7 100644 --- a/apis/byon/src/main/java/org/jclouds/byon/internal/BYONComputeServiceAdapter.java +++ b/apis/byon/src/main/java/org/jclouds/byon/internal/BYONComputeServiceAdapter.java @@ -42,8 +42,8 @@ import com.google.common.base.Predicates; import com.google.common.base.Supplier; import com.google.common.cache.LoadingCache; import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSet.Builder; import com.google.common.collect.Iterables; +import com.google.common.collect.ImmutableSet.Builder; import com.google.common.util.concurrent.UncheckedExecutionException; /** diff --git a/apis/byon/src/test/java/org/jclouds/byon/BYONComputeServiceLiveTest.java b/apis/byon/src/test/java/org/jclouds/byon/BYONComputeServiceLiveTest.java index 4668ad7a45..588c5e6a41 100644 --- a/apis/byon/src/test/java/org/jclouds/byon/BYONComputeServiceLiveTest.java +++ b/apis/byon/src/test/java/org/jclouds/byon/BYONComputeServiceLiveTest.java @@ -24,14 +24,14 @@ import static org.jclouds.scriptbuilder.domain.Statements.exec; import java.io.FileNotFoundException; import java.io.IOException; import java.util.Map; -import java.util.Map.Entry; import java.util.Properties; +import java.util.Map.Entry; +import org.jclouds.ContextBuilder; import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.logging.log4j.config.Log4JLoggingModule; -import org.jclouds.rest.internal.ContextBuilder; import org.jclouds.scriptbuilder.domain.OsFamily; import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.AfterClass; @@ -49,7 +49,7 @@ import com.google.inject.Module; @Test(groups = "live") public class BYONComputeServiceLiveTest { - private ComputeServiceContext context; + private ComputeServiceContext context; @BeforeClass(groups = "live") public void setup() throws FileNotFoundException, IOException { @@ -72,8 +72,9 @@ public class BYONComputeServiceLiveTest { .append("\n"); contextProperties.setProperty("byon.nodes", nodes.toString()); - context = ContextBuilder.newBuilder(new BYONApiMetadata()).overrides(contextProperties) - .modules(ImmutableSet. of(new SshjSshClientModule(), new Log4JLoggingModule())).build(); + context = ContextBuilder.newBuilder(new BYONApiMetadata()).overrides(contextProperties).modules( + ImmutableSet. of(new SshjSshClientModule(), new Log4JLoggingModule())).build( + ComputeServiceContext.class); } public void testCanRunCommandAsCurrentUser() throws Exception { diff --git a/apis/byon/src/test/java/org/jclouds/byon/BYONComputeServiceTest.java b/apis/byon/src/test/java/org/jclouds/byon/BYONComputeServiceTest.java index 258e837e5a..9a6b4077cd 100644 --- a/apis/byon/src/test/java/org/jclouds/byon/BYONComputeServiceTest.java +++ b/apis/byon/src/test/java/org/jclouds/byon/BYONComputeServiceTest.java @@ -23,16 +23,14 @@ import static org.jclouds.byon.functions.NodeToNodeMetadataTest.expectedProvider import static org.jclouds.byon.functions.NodeToNodeMetadataTest.zoneCalled; import static org.testng.Assert.assertEquals; -import java.net.URI; - +import org.jclouds.ContextBuilder; +import org.jclouds.byon.config.BYONComputeServiceContextModule; import org.jclouds.byon.config.CacheNodeStoreModule; import org.jclouds.byon.functions.NodesFromYamlTest; import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.domain.Location; import org.jclouds.domain.LoginCredentials; -import org.jclouds.providers.AnonymousProviderMetadata; -import org.jclouds.rest.internal.ContextBuilder; import org.testng.annotations.Test; import com.google.common.base.Supplier; @@ -40,7 +38,9 @@ import com.google.common.cache.LoadingCache; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; +import com.google.inject.Key; import com.google.inject.Module; +import com.google.inject.TypeLiteral; /** * @@ -51,36 +51,31 @@ public class BYONComputeServiceTest { @Test public void testNodesParseNodeMap() throws Exception { - assertNodesParse( - "foo", - ImmutableSet. of(new CacheNodeStoreModule(ImmutableMap. of( - NodesFromYamlTest.TEST1.getId(), NodesFromYamlTest.TEST1)))); + assertNodesParse("foo", ContextBuilder.newBuilder( + new BYONApiMetadata().toBuilder().defaultModule(BYONComputeServiceContextModule.class).build()) + .endpoint("foo").modules( + ImmutableSet. of(new CacheNodeStoreModule(ImmutableMap. of( + NodesFromYamlTest.TEST1.getId(), NodesFromYamlTest.TEST1)))).build( + ComputeServiceContext.class)); } @Test public void testNodesParseWithFileUrl() throws Exception { - assertNodesParse("file://" + getClass().getResource("/test1.yaml").getPath(), ImmutableSet. of()); + assertNodesParse("file://" + getClass().getResource("/test1.yaml").getPath(), ContextBuilder.newBuilder(new BYONApiMetadata()).endpoint( + "file://" + getClass().getResource("/test1.yaml").getPath()).build(ComputeServiceContext.class)); } @Test public void testNodesParseWithClasspathUrl() throws Exception { - assertNodesParse("classpath:///test1.yaml", ImmutableSet. of()); + assertNodesParse("classpath:///test1.yaml", ContextBuilder.newBuilder(new BYONApiMetadata()).endpoint( + "classpath:///test1.yaml").build(ComputeServiceContext.class)); } - private void assertNodesParse(String endpoint, Iterable modules) { - ComputeServiceContext context = null; + private void assertNodesParse(String endpoint, ComputeServiceContext context) { try { Location providerLocation = expectedProviderLocationFromResource(endpoint); - context = ContextBuilder.newBuilder( - AnonymousProviderMetadata.forApiWithEndpoint(new BYONApiMetadata(), endpoint)) - .modules(modules).build(); - - assertEquals(context.getProviderSpecificContext().getEndpoint(), URI.create(endpoint)); - - @SuppressWarnings("unchecked") - Supplier> supplier = (Supplier>) context.getProviderSpecificContext() - .getApi(); + Supplier> supplier = supplier(context); assertEquals(supplier.get().size(), context.getComputeService().listNodes().size()); assertEquals(supplier.get().asMap(), @@ -96,17 +91,12 @@ public class BYONComputeServiceTest { } public void testNodesWithLocations() { - ComputeServiceContext context = null; + ComputeServiceContext context = null; try { String endpoint = "file://" + getClass().getResource("/test_location.yaml").getPath(); - context = ContextBuilder.newBuilder( - AnonymousProviderMetadata.forApiWithEndpoint(new BYONApiMetadata(), endpoint)).build(); + context = ContextBuilder.newBuilder(new BYONApiMetadata()).endpoint(endpoint).build(ComputeServiceContext.class); - assertEquals(context.getProviderSpecificContext().getEndpoint(), URI.create(endpoint)); - - @SuppressWarnings("unchecked") - Supplier> supplier = (Supplier>) context.getProviderSpecificContext() - .getApi(); + Supplier> supplier = supplier(context); assertEquals(supplier.get().size(), context.getComputeService().listNodes().size()); assertEquals(supplier.get().asMap(), ImmutableMap. of(NodesFromYamlTest.TEST2.getId(), @@ -143,4 +133,11 @@ public class BYONComputeServiceTest { context.close(); } } + + private Supplier> supplier(ComputeServiceContext context) { + Supplier> supplier = context.utils().injector().getInstance( + Key.get(new TypeLiteral>>() { + })); + return supplier; + } } diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesApiMetadata.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesApiMetadata.java index 5d7cf50a69..85bbdd6fd0 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesApiMetadata.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesApiMetadata.java @@ -26,19 +26,29 @@ import java.util.Properties; import org.jclouds.apis.ApiMetadata; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.internal.BaseBlobStoreApiMetadata; +import org.jclouds.cloudfiles.blobstore.config.CloudFilesBlobStoreContextModule; +import org.jclouds.cloudfiles.config.CloudFilesRestClientModule; import org.jclouds.openstack.OpenStackAuthAsyncClient; +import org.jclouds.rest.RestContext; +import org.jclouds.rest.internal.BaseRestApiMetadata; +import com.google.common.collect.ImmutableSet; import com.google.common.reflect.TypeToken; +import com.google.inject.Module; /** * Implementation of {@link ApiMetadata} for Rackspace Cloud Files API * * @author Adrian Cole */ -public class CloudFilesApiMetadata - extends - BaseBlobStoreApiMetadata, CloudFilesApiMetadata> { +public class CloudFilesApiMetadata extends BaseRestApiMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = 820062881469203616L; + + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; + private static Builder builder() { return new Builder(); } @@ -56,26 +66,25 @@ public class CloudFilesApiMetadata super(builder); } - protected static Properties defaultProperties() { - Properties properties = BaseBlobStoreApiMetadata.Builder.defaultProperties(); + public static Properties defaultProperties() { + Properties properties = BaseRestApiMetadata.defaultProperties(); properties.setProperty(PROPERTY_REGIONS, "DEFAULT"); properties.setProperty(PROPERTY_USER_METADATA_PREFIX, "X-Object-Meta-"); return properties; } - public static class Builder - extends - BaseBlobStoreApiMetadata.Builder, CloudFilesApiMetadata> { + public static class Builder extends BaseRestApiMetadata.Builder { protected Builder() { + super(CloudFilesClient.class, CloudFilesAsyncClient.class); id("cloudfiles") .name("Rackspace Cloud Files API") .identityName("Username") .credentialName("API Key") .documentation(URI.create("http://docs.rackspacecloud.com/files/api/v1/cfdevguide_d5/content/ch01.html")) .version(OpenStackAuthAsyncClient.VERSION) - .contextBuilder(TypeToken.of(CloudFilesContextBuilder.class)) .defaultProperties(CloudFilesApiMetadata.defaultProperties()) - .javaApi(CloudFilesClient.class, CloudFilesAsyncClient.class); + .wrapper(TypeToken.of(BlobStoreContext.class)) + .defaultModules(ImmutableSet.>of(CloudFilesRestClientModule.class, CloudFilesBlobStoreContextModule.class)); } @Override @@ -84,7 +93,7 @@ public class CloudFilesApiMetadata } @Override - public Builder fromApiMetadata(CloudFilesApiMetadata in) { + public Builder fromApiMetadata(ApiMetadata in) { super.fromApiMetadata(in); return this; } diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesContextBuilder.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesContextBuilder.java deleted file mode 100644 index 84f966e358..0000000000 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesContextBuilder.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * 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.cloudfiles; - -import java.util.List; - -import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextBuilder; -import org.jclouds.cloudfiles.blobstore.config.CloudFilesBlobStoreContextModule; -import org.jclouds.cloudfiles.config.CloudFilesRestClientModule; -import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; -import org.jclouds.logging.jdk.config.JDKLoggingModule; -import org.jclouds.providers.ProviderMetadata; - -import com.google.inject.Injector; -import com.google.inject.Module; - -/** - * Creates {@link CloudFilesStoreContext} or {@link Injector} instances based on - * the most commonly requested arguments. - *

- * Note that Threadsafe objects will be bound as singletons to the Injector or - * Context provided. - *

- *

- * If no Modules are specified, the default - * {@link JDKLoggingModule logging} and - * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be - * installed. - * - * @author Adrian Cole, Andrew Newdigate - * @see CloudFilesStoreContext - */ -public class CloudFilesContextBuilder - extends - BlobStoreContextBuilder, CloudFilesApiMetadata> { - - public CloudFilesContextBuilder( - ProviderMetadata, CloudFilesApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public CloudFilesContextBuilder(CloudFilesApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new CloudFilesBlobStoreContextModule()); - } - - @Override - protected void addClientModule(List modules) { - modules.add(new CloudFilesRestClientModule()); - } -} diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/CloudFilesAsyncBlobStore.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/CloudFilesAsyncBlobStore.java index af064f61c1..34b61b03de 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/CloudFilesAsyncBlobStore.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/CloudFilesAsyncBlobStore.java @@ -59,7 +59,7 @@ public class CloudFilesAsyncBlobStore extends SwiftAsyncBlobStore { private final EnableCDNAndCache enableCDNAndCache; @Inject - protected CloudFilesAsyncBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, + protected CloudFilesAsyncBlobStore(BlobStoreContext context, BlobUtils blobUtils, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService service, Supplier defaultLocation, @Memoized Supplier> locations, CloudFilesClient sync, CloudFilesAsyncClient async, ContainerToResourceMetadata container2ResourceMd, diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/CloudFilesBlobStore.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/CloudFilesBlobStore.java index d7309f99bc..42be6d884c 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/CloudFilesBlobStore.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/CloudFilesBlobStore.java @@ -53,7 +53,7 @@ public class CloudFilesBlobStore extends SwiftBlobStore { private EnableCDNAndCache enableCDNAndCache; @Inject - protected CloudFilesBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, Supplier defaultLocation, + protected CloudFilesBlobStore(BlobStoreContext context, BlobUtils blobUtils, Supplier defaultLocation, @Memoized Supplier> locations, CommonSwiftClient sync, ContainerToResourceMetadata container2ResourceMd, BlobStoreListContainerOptionsToListContainerOptions container2ContainerListOptions, diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/config/CloudFilesRestClientModule.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/config/CloudFilesRestClientModule.java index f665b01ad1..cdbc74dea9 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/config/CloudFilesRestClientModule.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/config/CloudFilesRestClientModule.java @@ -28,7 +28,6 @@ import org.jclouds.cloudfiles.CDNManagement; import org.jclouds.cloudfiles.CloudFilesAsyncClient; import org.jclouds.cloudfiles.CloudFilesClient; import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.ServerError; @@ -53,7 +52,6 @@ import com.google.inject.Provides; * @author Adrian Cole */ @ConfiguresRestClient -@RequiresHttp public class CloudFilesRestClientModule extends RestClientModule { public CloudFilesRestClientModule() { diff --git a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/CloudFilesClientLiveTest.java b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/CloudFilesClientLiveTest.java index 91bd107f73..e7b382059f 100644 --- a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/CloudFilesClientLiveTest.java +++ b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/CloudFilesClientLiveTest.java @@ -47,7 +47,7 @@ public class CloudFilesClientLiveTest extends CommonSwiftClientLiveTest, CloudLoadBalancersApiMetadata> { +public class CloudLoadBalancersApiMetadata extends BaseRestApiMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 6725672099385580694L; + + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; + @Override public Builder toBuilder() { @@ -51,16 +61,15 @@ public class CloudLoadBalancersApiMetadata super(builder); } - protected static Properties defaultProperties() { - Properties properties = BaseLoadBalancerServiceApiMetadata.Builder.defaultProperties(); + public static Properties defaultProperties() { + Properties properties = BaseRestApiMetadata.defaultProperties(); return properties; } - public static class Builder - extends - BaseLoadBalancerServiceApiMetadata.Builder, CloudLoadBalancersApiMetadata> { + public static class Builder extends BaseRestApiMetadata.Builder { protected Builder() { + super(CloudLoadBalancersClient.class, CloudLoadBalancersAsyncClient.class); id("cloudloadbalancers") .name("Rackspace Cloud Load Balancers API") .identityName("Username") @@ -68,9 +77,9 @@ public class CloudLoadBalancersApiMetadata .documentation(URI.create("http://docs.rackspacecloud.com/loadbalancers/api/v1.0/clb-devguide/content/ch01.html")) .version(OpenStackAuthAsyncClient.VERSION) .defaultEndpoint("https://auth.api.rackspacecloud.com") - .javaApi(CloudLoadBalancersClient.class, CloudLoadBalancersAsyncClient.class) .defaultProperties(CloudLoadBalancersApiMetadata.defaultProperties()) - .contextBuilder(TypeToken.of(CloudLoadBalancersContextBuilder.class)); + .wrapper(TypeToken.of(LoadBalancerServiceContext.class)) + .defaultModules(ImmutableSet.>of(CloudLoadBalancersRestClientModule.class, CloudLoadBalancersLoadBalancerContextModule.class)); } @Override @@ -79,7 +88,7 @@ public class CloudLoadBalancersApiMetadata } @Override - public Builder fromApiMetadata(CloudLoadBalancersApiMetadata in) { + public Builder fromApiMetadata(ApiMetadata in) { super.fromApiMetadata(in); return this; } diff --git a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersContextBuilder.java b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersContextBuilder.java deleted file mode 100644 index 2e4c8e7827..0000000000 --- a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersContextBuilder.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * 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.cloudloadbalancers; - -import java.util.List; - -import org.jclouds.cloudloadbalancers.config.CloudLoadBalancersRestClientModule; -import org.jclouds.cloudloadbalancers.loadbalancer.config.CloudLoadBalancersLoadBalancerContextModule; -import org.jclouds.loadbalancer.LoadBalancerServiceContext; -import org.jclouds.loadbalancer.LoadBalancerServiceContextBuilder; -import org.jclouds.providers.ProviderMetadata; - -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class CloudLoadBalancersContextBuilder - extends - LoadBalancerServiceContextBuilder, CloudLoadBalancersApiMetadata> { - - public CloudLoadBalancersContextBuilder( - ProviderMetadata, CloudLoadBalancersApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public CloudLoadBalancersContextBuilder(CloudLoadBalancersApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new CloudLoadBalancersLoadBalancerContextModule()); - } - - protected void addClientModule(List modules) { - modules.add(new CloudLoadBalancersRestClientModule()); - } - -} \ No newline at end of file diff --git a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/config/CloudLoadBalancersRestClientModule.java b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/config/CloudLoadBalancersRestClientModule.java index 58b1681999..bd9e8ce2b2 100644 --- a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/config/CloudLoadBalancersRestClientModule.java +++ b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/config/CloudLoadBalancersRestClientModule.java @@ -37,7 +37,6 @@ import org.jclouds.cloudloadbalancers.handlers.ParseCloudLoadBalancersErrorFromH import org.jclouds.cloudloadbalancers.location.RegionUrisFromPropertiesAndAccountIDPathSuffix; import org.jclouds.cloudloadbalancers.reference.RackspaceConstants; import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.ServerError; @@ -64,7 +63,6 @@ import com.google.inject.assistedinject.FactoryModuleBuilder; * * @author Adrian Cole */ -@RequiresHttp @ConfiguresRestClient public class CloudLoadBalancersRestClientModule extends RestClientModule { diff --git a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/functions/LB.java b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/functions/LB.java index 213eea8d48..658a2134e5 100644 --- a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/functions/LB.java +++ b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/functions/LB.java @@ -22,9 +22,9 @@ import java.util.Date; import java.util.Map; import java.util.Set; -import org.jclouds.cloudloadbalancers.domain.LoadBalancer.Status; import org.jclouds.cloudloadbalancers.domain.Node; import org.jclouds.cloudloadbalancers.domain.VirtualIP; +import org.jclouds.cloudloadbalancers.domain.LoadBalancer.Status; import org.jclouds.cloudloadbalancers.domain.internal.BaseLoadBalancer; import com.google.common.collect.Maps; diff --git a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/LoadBalancerAsyncClientTest.java b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/LoadBalancerAsyncClientTest.java index bacd9bb7f5..23c35038fd 100644 --- a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/LoadBalancerAsyncClientTest.java +++ b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/LoadBalancerAsyncClientTest.java @@ -22,8 +22,8 @@ import java.io.IOException; import java.lang.reflect.Method; import org.jclouds.cloudloadbalancers.domain.LoadBalancerAttributes; -import org.jclouds.cloudloadbalancers.domain.LoadBalancerAttributes.Builder; import org.jclouds.cloudloadbalancers.domain.LoadBalancerRequest; +import org.jclouds.cloudloadbalancers.domain.LoadBalancerAttributes.Builder; import org.jclouds.cloudloadbalancers.domain.VirtualIP.Type; import org.jclouds.cloudloadbalancers.functions.UnwrapLoadBalancer; import org.jclouds.cloudloadbalancers.functions.UnwrapLoadBalancers; diff --git a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/LoadBalancerClientLiveTest.java b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/LoadBalancerClientLiveTest.java index b95b023667..2b672161cb 100644 --- a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/LoadBalancerClientLiveTest.java +++ b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/LoadBalancerClientLiveTest.java @@ -53,12 +53,12 @@ public class LoadBalancerClientLiveTest extends BaseCloudLoadBalancersClientLive } @Override - protected void tearDown() { + protected void tearDownContext() { for (LoadBalancer lb : lbs) { client.getLoadBalancerClient(lb.getRegion()).removeLoadBalancer(lb.getId()); assert loadBalancerDeleted.apply(lb) : lb; } - super.tearDown(); + super.tearDownContext(); } public void testCreateLoadBalancer() throws Exception { diff --git a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/NodeAsyncClientTest.java b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/NodeAsyncClientTest.java index b0702d5d7e..fb09722a1b 100644 --- a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/NodeAsyncClientTest.java +++ b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/NodeAsyncClientTest.java @@ -24,8 +24,8 @@ import java.util.Collections; import java.util.Set; import org.jclouds.cloudloadbalancers.domain.NodeAttributes; -import org.jclouds.cloudloadbalancers.domain.NodeAttributes.Builder; import org.jclouds.cloudloadbalancers.domain.NodeRequest; +import org.jclouds.cloudloadbalancers.domain.NodeAttributes.Builder; import org.jclouds.cloudloadbalancers.domain.internal.BaseNode.Condition; import org.jclouds.cloudloadbalancers.internal.BaseCloudLoadBalancersAsyncClientTest; import org.jclouds.http.HttpRequest; diff --git a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/NodeClientLiveTest.java b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/NodeClientLiveTest.java index e722442f85..64bfa9611e 100644 --- a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/NodeClientLiveTest.java +++ b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/NodeClientLiveTest.java @@ -26,16 +26,16 @@ import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Map; -import java.util.Map.Entry; import java.util.Set; +import java.util.Map.Entry; import java.util.logging.Logger; import org.jclouds.cloudloadbalancers.domain.LoadBalancer; -import org.jclouds.cloudloadbalancers.domain.LoadBalancer.Status; import org.jclouds.cloudloadbalancers.domain.LoadBalancerRequest; import org.jclouds.cloudloadbalancers.domain.Node; import org.jclouds.cloudloadbalancers.domain.NodeAttributes; import org.jclouds.cloudloadbalancers.domain.NodeRequest; +import org.jclouds.cloudloadbalancers.domain.LoadBalancer.Status; import org.jclouds.cloudloadbalancers.domain.VirtualIP.Type; import org.jclouds.cloudloadbalancers.internal.BaseCloudLoadBalancersClientLiveTest; import org.testng.annotations.AfterGroups; @@ -137,7 +137,7 @@ public class NodeClientLiveTest extends BaseCloudLoadBalancersClientLiveTest { @Override @AfterGroups(groups = "live") - protected void tearDown() { + protected void tearDownContext() { for (Entry> entry : nodes.entrySet()) { LoadBalancer lb = entry.getKey(); LoadBalancerClient lbClient = client.getLoadBalancerClient(lb.getRegion()); @@ -147,6 +147,6 @@ public class NodeClientLiveTest extends BaseCloudLoadBalancersClientLiveTest { } assert loadBalancerDeleted.apply(lb) : lb; } - super.tearDown(); + super.tearDownContext(); } } diff --git a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/functions/UnwrapLoadBalancerTest.java b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/functions/UnwrapLoadBalancerTest.java index 0fc4fb0bff..521aa3a0ef 100644 --- a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/functions/UnwrapLoadBalancerTest.java +++ b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/functions/UnwrapLoadBalancerTest.java @@ -19,9 +19,9 @@ package org.jclouds.cloudloadbalancers.functions; import org.jclouds.cloudloadbalancers.domain.LoadBalancer; -import org.jclouds.cloudloadbalancers.domain.LoadBalancer.Status; import org.jclouds.cloudloadbalancers.domain.Node; import org.jclouds.cloudloadbalancers.domain.VirtualIP; +import org.jclouds.cloudloadbalancers.domain.LoadBalancer.Status; import org.jclouds.cloudloadbalancers.domain.VirtualIP.IPVersion; import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.http.HttpResponse; diff --git a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/functions/UnwrapLoadBalancersTest.java b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/functions/UnwrapLoadBalancersTest.java index b6fc178223..95b1e0d848 100644 --- a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/functions/UnwrapLoadBalancersTest.java +++ b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/functions/UnwrapLoadBalancersTest.java @@ -21,8 +21,8 @@ package org.jclouds.cloudloadbalancers.functions; import java.util.Set; import org.jclouds.cloudloadbalancers.domain.LoadBalancer; -import org.jclouds.cloudloadbalancers.domain.LoadBalancer.Status; import org.jclouds.cloudloadbalancers.domain.VirtualIP; +import org.jclouds.cloudloadbalancers.domain.LoadBalancer.Status; import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.http.HttpResponse; import org.jclouds.json.BaseSetParserTest; diff --git a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/internal/BaseCloudLoadBalancersAsyncClientTest.java b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/internal/BaseCloudLoadBalancersAsyncClientTest.java index 3ddb2f6e45..d0ed3c0283 100644 --- a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/internal/BaseCloudLoadBalancersAsyncClientTest.java +++ b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/internal/BaseCloudLoadBalancersAsyncClientTest.java @@ -38,7 +38,6 @@ import org.jclouds.cloudloadbalancers.config.CloudLoadBalancersRestClientModule; import org.jclouds.cloudloadbalancers.reference.Region; import org.jclouds.domain.Credentials; import org.jclouds.http.HttpRequest; -import org.jclouds.http.RequiresHttp; import org.jclouds.internal.ClassMethodArgs; import org.jclouds.location.config.LocationModule; import org.jclouds.openstack.filters.AuthenticateRequest; @@ -71,7 +70,6 @@ public abstract class BaseCloudLoadBalancersAsyncClientTest extends BaseAsync } @ConfiguresRestClient - @RequiresHttp protected static class TestCloudLoadBalancersRestClientModule extends CloudLoadBalancersRestClientModule { @Override protected void installLocations() { @@ -127,7 +125,7 @@ public abstract class BaseCloudLoadBalancersAsyncClientTest extends BaseAsync } @Override - protected ApiMetadata createApiMetadata() { + protected ApiMetadata createApiMetadata() { return new CloudLoadBalancersApiMetadata(); } diff --git a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/internal/BaseCloudLoadBalancersClientLiveTest.java b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/internal/BaseCloudLoadBalancersClientLiveTest.java index fc178ac0f7..201a5b363a 100644 --- a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/internal/BaseCloudLoadBalancersClientLiveTest.java +++ b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/internal/BaseCloudLoadBalancersClientLiveTest.java @@ -20,6 +20,7 @@ package org.jclouds.cloudloadbalancers.internal; import java.util.concurrent.TimeUnit; +import org.jclouds.apis.BaseContextLiveTest; import org.jclouds.cloudloadbalancers.CloudLoadBalancersAsyncClient; import org.jclouds.cloudloadbalancers.CloudLoadBalancersClient; import org.jclouds.cloudloadbalancers.domain.LoadBalancer; @@ -30,11 +31,10 @@ import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.net.IPSocket; import org.jclouds.predicates.RetryablePredicate; import org.jclouds.rest.RestContext; -import org.jclouds.rest.internal.BaseContextLiveTest; -import org.testng.annotations.AfterGroups; import org.testng.annotations.BeforeGroups; import com.google.common.base.Predicate; +import com.google.common.reflect.TypeToken; import com.google.inject.Guice; import com.google.inject.Injector; @@ -42,9 +42,7 @@ import com.google.inject.Injector; * * @author Adrian Cole */ -public class BaseCloudLoadBalancersClientLiveTest - extends - BaseContextLiveTest> { +public class BaseCloudLoadBalancersClientLiveTest extends BaseContextLiveTest { public BaseCloudLoadBalancersClientLiveTest() { provider = "cloudloadbalancers"; @@ -63,7 +61,7 @@ public class BaseCloudLoadBalancersClientLiveTest @Override public void setupContext() { super.setupContext(); - lbContext = context.getProviderSpecificContext(); + lbContext = context.unwrap(); client = lbContext.getApi(); @@ -76,10 +74,9 @@ public class BaseCloudLoadBalancersClientLiveTest injector.injectMembers(loadBalancerDeleted); } - @AfterGroups(groups = "live") - protected void tearDown() { - if (lbContext != null) - lbContext.close(); + @Override + protected TypeToken contextType() { + return TypeToken.of(LoadBalancerServiceContext.class); } } diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersApiMetadata.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersApiMetadata.java index 7ab3010dec..208fb51b30 100644 --- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersApiMetadata.java +++ b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersApiMetadata.java @@ -22,20 +22,30 @@ import java.net.URI; import java.util.Properties; import org.jclouds.apis.ApiMetadata; +import org.jclouds.cloudservers.compute.config.CloudServersComputeServiceContextModule; +import org.jclouds.cloudservers.config.CloudServersRestClientModule; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; import org.jclouds.openstack.OpenStackAuthAsyncClient; +import org.jclouds.rest.RestContext; +import org.jclouds.rest.internal.BaseRestApiMetadata; +import com.google.common.collect.ImmutableSet; import com.google.common.reflect.TypeToken; +import com.google.inject.Module; /** * Implementation of {@link ApiMetadata} for CloudServers 1.0 API * * @author Adrian Cole */ -public class CloudServersApiMetadata - extends - BaseComputeServiceApiMetadata, CloudServersApiMetadata> { +public class CloudServersApiMetadata extends BaseRestApiMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 6725672099385580694L; + + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; @Override public Builder toBuilder() { @@ -50,16 +60,15 @@ public class CloudServersApiMetadata super(builder); } - protected static Properties defaultProperties() { - Properties properties = BaseComputeServiceApiMetadata.Builder.defaultProperties(); + public static Properties defaultProperties() { + Properties properties = BaseRestApiMetadata.defaultProperties(); return properties; } - public static class Builder - extends - BaseComputeServiceApiMetadata.Builder, CloudServersApiMetadata> { + public static class Builder extends BaseRestApiMetadata.Builder { protected Builder() { + super(CloudServersClient.class, CloudServersAsyncClient.class); id("cloudservers") .name("Rackspace Cloud Servers API") .identityName("Username") @@ -67,9 +76,9 @@ public class CloudServersApiMetadata .documentation(URI.create("http://docs.rackspacecloud.com/servers/api/v1.0/cs-devguide/content/ch01.html")) .version(OpenStackAuthAsyncClient.VERSION) .defaultEndpoint("https://auth.api.rackspacecloud.com") - .javaApi(CloudServersClient.class, CloudServersAsyncClient.class) .defaultProperties(CloudServersApiMetadata.defaultProperties()) - .contextBuilder(TypeToken.of(CloudServersContextBuilder.class)); + .wrapper(TypeToken.of(ComputeServiceContext.class)) + .defaultModules(ImmutableSet.>of(CloudServersRestClientModule.class, CloudServersComputeServiceContextModule.class)); } @Override @@ -78,7 +87,7 @@ public class CloudServersApiMetadata } @Override - public Builder fromApiMetadata(CloudServersApiMetadata in) { + public Builder fromApiMetadata(ApiMetadata in) { super.fromApiMetadata(in); return this; } diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersContextBuilder.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersContextBuilder.java deleted file mode 100644 index 52e43a7d3a..0000000000 --- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersContextBuilder.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * 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.cloudservers; - -import java.util.List; - -import org.jclouds.cloudservers.compute.config.CloudServersComputeServiceContextModule; -import org.jclouds.cloudservers.config.CloudServersRestClientModule; -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextBuilder; -import org.jclouds.providers.ProviderMetadata; - -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class CloudServersContextBuilder - extends - ComputeServiceContextBuilder, CloudServersApiMetadata> { - - public CloudServersContextBuilder( - ProviderMetadata, CloudServersApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public CloudServersContextBuilder(CloudServersApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new CloudServersComputeServiceContextModule()); - } - - protected void addClientModule(List modules) { - modules.add(new CloudServersRestClientModule()); - } - -} \ No newline at end of file diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/config/CloudServersComputeServiceContextModule.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/config/CloudServersComputeServiceContextModule.java index d7065b96dc..9747eca77f 100644 --- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/config/CloudServersComputeServiceContextModule.java +++ b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/config/CloudServersComputeServiceContextModule.java @@ -22,8 +22,6 @@ import java.util.Map; import javax.inject.Singleton; -import org.jclouds.cloudservers.CloudServersAsyncClient; -import org.jclouds.cloudservers.CloudServersClient; import org.jclouds.cloudservers.compute.functions.CloudServersImageToImage; import org.jclouds.cloudservers.compute.functions.CloudServersImageToOperatingSystem; import org.jclouds.cloudservers.compute.functions.FlavorToHardware; @@ -55,12 +53,8 @@ import com.google.inject.TypeLiteral; * * @author Adrian Cole */ -public class CloudServersComputeServiceContextModule - extends - ComputeServiceAdapterContextModule { - public CloudServersComputeServiceContextModule() { - super(CloudServersClient.class, CloudServersAsyncClient.class); - } +public class CloudServersComputeServiceContextModule extends + ComputeServiceAdapterContextModule { @SuppressWarnings("unchecked") @Override diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/config/CloudServersRestClientModule.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/config/CloudServersRestClientModule.java index dcc000ec92..13f267c7c5 100644 --- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/config/CloudServersRestClientModule.java +++ b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/config/CloudServersRestClientModule.java @@ -32,7 +32,6 @@ import org.jclouds.cloudservers.CloudServersClient; import org.jclouds.cloudservers.handlers.ParseCloudServersErrorFromHttpResponse; import org.jclouds.date.TimeStamp; import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.ServerError; @@ -53,7 +52,6 @@ import com.google.inject.Provides; * @author Adrian Cole */ @ConfiguresRestClient -@RequiresHttp public class CloudServersRestClientModule extends RestClientModule { public CloudServersRestClientModule() { diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersAsyncClientTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersAsyncClientTest.java index 829b7a8cef..e630ff6ed6 100644 --- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersAsyncClientTest.java +++ b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersAsyncClientTest.java @@ -50,7 +50,6 @@ import org.jclouds.cloudservers.options.ListOptions; import org.jclouds.cloudservers.options.RebuildServerOptions; import org.jclouds.domain.Credentials; import org.jclouds.http.HttpRequest; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.functions.ReleasePayloadAndReturn; import org.jclouds.http.functions.ReturnFalseOn404; import org.jclouds.http.functions.ReturnTrueIf2xx; @@ -890,8 +889,7 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest createApiMetadata() { + protected ApiMetadata createApiMetadata() { return new CloudServersApiMetadata(); } diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersClientLiveTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersClientLiveTest.java index 3618a2c58e..d1f0cc47e9 100644 --- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersClientLiveTest.java +++ b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersClientLiveTest.java @@ -44,7 +44,6 @@ import org.jclouds.cloudservers.domain.ServerStatus; import org.jclouds.cloudservers.domain.SharedIpGroup; import org.jclouds.cloudservers.domain.WeeklyBackup; import org.jclouds.cloudservers.options.RebuildServerOptions; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.domain.LoginCredentials; @@ -72,9 +71,7 @@ import com.google.inject.Injector; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "CloudServersClientLiveTest") -public class CloudServersClientLiveTest - extends - BaseComputeServiceContextLiveTest> { +public class CloudServersClientLiveTest extends BaseComputeServiceContextLiveTest { public CloudServersClientLiveTest() { provider = "cloudservers"; diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/CloudServersComputeServiceLiveTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/CloudServersComputeServiceLiveTest.java index d7af173018..9aa6c7671d 100644 --- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/CloudServersComputeServiceLiveTest.java +++ b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/CloudServersComputeServiceLiveTest.java @@ -22,9 +22,6 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; -import org.jclouds.cloudservers.CloudServersAsyncClient; -import org.jclouds.cloudservers.CloudServersClient; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.internal.BaseComputeServiceLiveTest; import org.jclouds.domain.LocationScope; @@ -40,9 +37,7 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", enabled = true, singleThreaded = true, testName = "CloudServersComputeServiceLiveTest") -public class CloudServersComputeServiceLiveTest - extends - BaseComputeServiceLiveTest> { +public class CloudServersComputeServiceLiveTest extends BaseComputeServiceLiveTest { public CloudServersComputeServiceLiveTest() { provider = "cloudservers"; diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/internal/BaseCloudServersRestClientExpectTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/internal/BaseCloudServersRestClientExpectTest.java index 71cc584289..f6018a9707 100644 --- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/internal/BaseCloudServersRestClientExpectTest.java +++ b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/internal/BaseCloudServersRestClientExpectTest.java @@ -28,7 +28,6 @@ import org.jclouds.cloudservers.CloudServersApiMetadata; import org.jclouds.cloudservers.CloudServersClient; import org.jclouds.cloudservers.config.CloudServersRestClientModule; import org.jclouds.date.internal.SimpleDateFormatDateService; -import org.jclouds.http.RequiresHttp; import org.jclouds.openstack.filters.AddTimestampQuery; import org.jclouds.openstack.keystone.v1_1.config.AuthenticationServiceModule; import org.jclouds.openstack.keystone.v1_1.internal.BaseKeystoneRestClientExpectTest; @@ -49,7 +48,7 @@ public class BaseCloudServersRestClientExpectTest extends BaseKeystoneRestClient } @Override - protected ApiMetadata createApiMetadata() { + protected ApiMetadata createApiMetadata() { return new CloudServersApiMetadata(); } @@ -81,8 +80,7 @@ public class BaseCloudServersRestClientExpectTest extends BaseKeystoneRestClient } @ConfiguresRestClient - @RequiresHttp - protected static class TestCloudServersRestClientModule extends CloudServersRestClientModule { + protected static class TestCloudServersRestClientModule extends CloudServersRestClientModule { @Override public Supplier provideCacheBusterDate() { diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaApiMetadata.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaApiMetadata.java index 96cfb3893a..28be12c28c 100644 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaApiMetadata.java +++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaApiMetadata.java @@ -24,20 +24,29 @@ import java.net.URI; import java.util.Properties; import org.jclouds.apis.ApiMetadata; +import org.jclouds.cloudsigma.compute.config.CloudSigmaComputeServiceContextModule; +import org.jclouds.cloudsigma.config.CloudSigmaRestClientModule; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; +import org.jclouds.rest.RestContext; +import org.jclouds.rest.internal.BaseRestApiMetadata; +import com.google.common.collect.ImmutableSet; import com.google.common.reflect.TypeToken; +import com.google.inject.Module; /** * Implementation of {@link ApiMetadata} for the Cloud Sigma API * * @author Adrian Cole */ -public class CloudSigmaApiMetadata - extends - BaseComputeServiceApiMetadata, CloudSigmaApiMetadata> { +public class CloudSigmaApiMetadata extends BaseRestApiMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = 6725672099385580694L; + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; + @Override public Builder toBuilder() { return new Builder().fromApiMetadata(this); @@ -51,8 +60,8 @@ public class CloudSigmaApiMetadata super(builder); } - protected static Properties defaultProperties() { - Properties properties = BaseComputeServiceApiMetadata.Builder.defaultProperties(); + public static Properties defaultProperties() { + Properties properties = BaseRestApiMetadata.defaultProperties(); properties.setProperty(PROPERTY_VNC_PASSWORD, "IL9vs34d"); // passwords are set post-boot, so auth failures are possible // from a race condition applying the password set script @@ -61,11 +70,10 @@ public class CloudSigmaApiMetadata return properties; } - public static class Builder - extends - BaseComputeServiceApiMetadata.Builder, CloudSigmaApiMetadata> { + public static class Builder extends BaseRestApiMetadata.Builder { protected Builder() { + super(CloudSigmaClient.class, CloudSigmaAsyncClient.class); id("cloudsigma") .name("CloudSigma API") .identityName("Email") @@ -74,8 +82,8 @@ public class CloudSigmaApiMetadata .version("1.0") .defaultEndpoint("https://api.cloudsigma.com") .defaultProperties(CloudSigmaApiMetadata.defaultProperties()) - .javaApi(CloudSigmaClient.class, CloudSigmaAsyncClient.class) - .contextBuilder(TypeToken.of(CloudSigmaContextBuilder.class)); + .wrapper(TypeToken.of(ComputeServiceContext.class)) + .defaultModules(ImmutableSet.>of(CloudSigmaRestClientModule.class, CloudSigmaComputeServiceContextModule.class)); } @Override @@ -84,7 +92,7 @@ public class CloudSigmaApiMetadata } @Override - public Builder fromApiMetadata(CloudSigmaApiMetadata in) { + public Builder fromApiMetadata(ApiMetadata in) { super.fromApiMetadata(in); return this; } diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaContextBuilder.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaContextBuilder.java deleted file mode 100644 index 222e790707..0000000000 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaContextBuilder.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * 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.cloudsigma; - -import java.util.List; - -import org.jclouds.cloudsigma.compute.config.CloudSigmaComputeServiceContextModule; -import org.jclouds.cloudsigma.config.CloudSigmaRestClientModule; -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextBuilder; -import org.jclouds.providers.ProviderMetadata; - -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class CloudSigmaContextBuilder - extends - ComputeServiceContextBuilder, CloudSigmaApiMetadata> { - - public CloudSigmaContextBuilder( - ProviderMetadata, CloudSigmaApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public CloudSigmaContextBuilder(CloudSigmaApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new CloudSigmaComputeServiceContextModule()); - } - - protected void addClientModule(List modules) { - modules.add(new CloudSigmaRestClientModule()); - } - -} diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/config/CloudSigmaComputeServiceContextModule.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/config/CloudSigmaComputeServiceContextModule.java index 6d596eaffd..51afbb8c76 100644 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/config/CloudSigmaComputeServiceContextModule.java +++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/config/CloudSigmaComputeServiceContextModule.java @@ -23,7 +23,6 @@ import java.util.concurrent.TimeUnit; import javax.inject.Inject; import javax.inject.Singleton; -import org.jclouds.cloudsigma.CloudSigmaAsyncClient; import org.jclouds.cloudsigma.CloudSigmaClient; import org.jclouds.cloudsigma.compute.CloudSigmaComputeServiceAdapter; import org.jclouds.cloudsigma.compute.CloudSigmaTemplateBuilderImpl; @@ -68,13 +67,8 @@ import com.google.inject.TypeLiteral; * * @author Adrian Cole */ -public class CloudSigmaComputeServiceContextModule - extends - ComputeServiceAdapterContextModule { - - public CloudSigmaComputeServiceContextModule() { - super(CloudSigmaClient.class, CloudSigmaAsyncClient.class); - } +public class CloudSigmaComputeServiceContextModule extends + ComputeServiceAdapterContextModule { @Override protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) { diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/functions/PreinstalledDiskToImage.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/functions/PreinstalledDiskToImage.java index 5439b5d0ad..356fc1bec9 100644 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/functions/PreinstalledDiskToImage.java +++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/functions/PreinstalledDiskToImage.java @@ -25,8 +25,8 @@ import org.jclouds.cloudsigma.domain.DriveInfo; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.ImageBuilder; import org.jclouds.compute.domain.OperatingSystem; -import org.jclouds.compute.domain.OperatingSystem.Builder; import org.jclouds.compute.domain.OsFamilyVersion64Bit; +import org.jclouds.compute.domain.OperatingSystem.Builder; import org.jclouds.domain.Location; import com.google.common.base.Function; diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/config/CloudSigmaRestClientModule.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/config/CloudSigmaRestClientModule.java index b933c221e3..ce17878825 100644 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/config/CloudSigmaRestClientModule.java +++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/config/CloudSigmaRestClientModule.java @@ -33,14 +33,13 @@ import org.jclouds.cloudsigma.domain.ServerMetrics; import org.jclouds.cloudsigma.functions.BaseDriveToMap; import org.jclouds.cloudsigma.functions.DriveDataToMap; import org.jclouds.cloudsigma.functions.MapToDevices; -import org.jclouds.cloudsigma.functions.MapToDevices.DeviceToId; import org.jclouds.cloudsigma.functions.MapToDriveMetrics; import org.jclouds.cloudsigma.functions.MapToNICs; import org.jclouds.cloudsigma.functions.MapToServerMetrics; import org.jclouds.cloudsigma.functions.ServerToMap; +import org.jclouds.cloudsigma.functions.MapToDevices.DeviceToId; import org.jclouds.cloudsigma.handlers.CloudSigmaErrorHandler; import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.ServerError; @@ -55,7 +54,6 @@ import com.google.inject.TypeLiteral; * * @author Adrian Cole */ -@RequiresHttp @ConfiguresRestClient public class CloudSigmaRestClientModule extends RestClientModule { diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToDevices.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToDevices.java index 709786f360..a0a6b11fef 100644 --- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToDevices.java +++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/functions/MapToDevices.java @@ -31,8 +31,8 @@ import org.jclouds.cloudsigma.domain.SCSIDevice; import com.google.common.base.Function; import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSet.Builder; import com.google.common.collect.Maps; +import com.google.common.collect.ImmutableSet.Builder; /** * diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaAsyncClientTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaAsyncClientTest.java index d7fafbaf17..7b0312d639 100644 --- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaAsyncClientTest.java +++ b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaAsyncClientTest.java @@ -648,7 +648,7 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest createApiMetadata() { + protected ApiMetadata createApiMetadata() { return new CloudSigmaApiMetadata(); } diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaClientLiveTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaClientLiveTest.java index 874a59309e..48f8c98bb7 100644 --- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaClientLiveTest.java +++ b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaClientLiveTest.java @@ -43,7 +43,6 @@ import org.jclouds.cloudsigma.domain.VLANInfo; import org.jclouds.cloudsigma.options.CloneDriveOptions; import org.jclouds.cloudsigma.predicates.DriveClaimed; import org.jclouds.cloudsigma.util.Servers; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.domain.LoginCredentials; @@ -71,9 +70,7 @@ import com.google.inject.Guice; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "CloudSigmaClientLiveTest") -public class CloudSigmaClientLiveTest - extends - BaseComputeServiceContextLiveTest> { +public class CloudSigmaClientLiveTest extends BaseComputeServiceContextLiveTest { public CloudSigmaClientLiveTest() { provider = "cloudsigma"; @@ -92,7 +89,7 @@ public class CloudSigmaClientLiveTest @Override public void setupContext() { super.setupContext(); - cloudSigmaContext = context.getProviderSpecificContext(); + cloudSigmaContext = context.unwrap(); client = cloudSigmaContext.getApi(); driveNotClaimed = new RetryablePredicate(Predicates.not(new DriveClaimed(client)), maxDriveImageTime, diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceLiveTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceLiveTest.java index 7022468935..bbedf65bdc 100644 --- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceLiveTest.java +++ b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceLiveTest.java @@ -18,9 +18,6 @@ */ package org.jclouds.cloudsigma.compute; -import org.jclouds.cloudsigma.CloudSigmaAsyncClient; -import org.jclouds.cloudsigma.CloudSigmaClient; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.internal.BaseComputeServiceLiveTest; @@ -34,9 +31,7 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live") -public class CloudSigmaComputeServiceLiveTest - extends - BaseComputeServiceLiveTest> { +public class CloudSigmaComputeServiceLiveTest extends BaseComputeServiceLiveTest { public CloudSigmaComputeServiceLiveTest() { provider = "cloudsigma"; diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackApiMetadata.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackApiMetadata.java index 80f97b45cf..ac6981292f 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackApiMetadata.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackApiMetadata.java @@ -22,9 +22,14 @@ import java.net.URI; import java.util.Properties; import org.jclouds.apis.ApiMetadata; -import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; +import org.jclouds.cloudstack.compute.config.CloudStackComputeServiceContextModule; +import org.jclouds.cloudstack.config.CloudStackRestClientModule; +import org.jclouds.rest.RestContext; +import org.jclouds.rest.internal.BaseRestApiMetadata; +import com.google.common.collect.ImmutableSet; import com.google.common.reflect.TypeToken; +import com.google.inject.Module; /** * Implementation of {@link ApiMetadata} for Citrix/Apache CloudStack api. @@ -43,9 +48,15 @@ import com.google.common.reflect.TypeToken; * * @author Adrian Cole */ -public class CloudStackApiMetadata extends BaseComputeServiceApiMetadata -{ - +public class CloudStackApiMetadata extends BaseRestApiMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = -3936131452958663245L; + + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; + @Override public Builder toBuilder() { return new Builder().fromApiMetadata(this); @@ -59,17 +70,18 @@ public class CloudStackApiMetadata extends BaseComputeServiceApiMetadata { + extends BaseRestApiMetadata.Builder { protected Builder() { + super(CloudStackClient.class, CloudStackAsyncClient.class); id("cloudstack") .name("Citrix CloudStack API") .identityName("API Key") @@ -77,10 +89,9 @@ public class CloudStackApiMetadata extends BaseComputeServiceApiMetadata>of(CloudStackRestClientModule.class, CloudStackComputeServiceContextModule.class)); } @Override @@ -89,7 +100,7 @@ public class CloudStackApiMetadata extends BaseComputeServiceApiMetadata { +public interface CloudStackContext extends ComputeServiceContext { + @SuppressWarnings("unchecked") @Override RestContext getProviderSpecificContext(); diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackContextBuilder.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackContextBuilder.java deleted file mode 100644 index 904972e5ac..0000000000 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackContextBuilder.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * 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.cloudstack; - -import java.util.List; -import java.util.Properties; - -import org.jclouds.cloudstack.compute.config.CloudStackComputeServiceContextModule; -import org.jclouds.cloudstack.config.CloudStackRestClientModule; -import org.jclouds.compute.ComputeServiceContextBuilder; -import org.jclouds.providers.ProviderMetadata; - -import com.google.common.annotations.VisibleForTesting; -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class CloudStackContextBuilder extends - ComputeServiceContextBuilder { - - public CloudStackContextBuilder( - ProviderMetadata providerMetadata) { - super(providerMetadata); - } - - public CloudStackContextBuilder(CloudStackApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addClientModule(List modules) { - modules.add(new CloudStackRestClientModule()); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new CloudStackComputeServiceContextModule()); - } - - @VisibleForTesting - public Properties getOverrides() { - return overrides; - } - -} diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/binders/BindAccountSecurityGroupPairsToIndexedQueryParams.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/binders/BindAccountSecurityGroupPairsToIndexedQueryParams.java index 3427a394cb..8b3b1b72e2 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/binders/BindAccountSecurityGroupPairsToIndexedQueryParams.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/binders/BindAccountSecurityGroupPairsToIndexedQueryParams.java @@ -33,8 +33,8 @@ import org.jclouds.http.utils.ModifyRequest; import org.jclouds.rest.Binder; import com.google.common.collect.ImmutableMultimap; -import com.google.common.collect.ImmutableMultimap.Builder; import com.google.common.collect.Multimap; +import com.google.common.collect.ImmutableMultimap.Builder; /** * diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/config/CloudStackComputeServiceContextModule.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/config/CloudStackComputeServiceContextModule.java index f008bfe2ed..23af639fe9 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/config/CloudStackComputeServiceContextModule.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/config/CloudStackComputeServiceContextModule.java @@ -30,7 +30,6 @@ import javax.inject.Inject; import javax.inject.Named; import javax.inject.Singleton; -import org.jclouds.cloudstack.CloudStackAsyncClient; import org.jclouds.cloudstack.CloudStackClient; import org.jclouds.cloudstack.compute.functions.ServiceOfferingToHardware; import org.jclouds.cloudstack.compute.functions.TemplateToImage; @@ -87,13 +86,8 @@ import com.google.inject.assistedinject.FactoryModuleBuilder; * * @author Adrian Cole */ -public class CloudStackComputeServiceContextModule - extends - ComputeServiceAdapterContextModule { - - public CloudStackComputeServiceContextModule() { - super(CloudStackClient.class, CloudStackAsyncClient.class); - } +public class CloudStackComputeServiceContextModule extends + ComputeServiceAdapterContextModule { @Override protected void configure() { diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/functions/TemplateToOperatingSystem.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/functions/TemplateToOperatingSystem.java index 6880782594..6c63d78e54 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/functions/TemplateToOperatingSystem.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/functions/TemplateToOperatingSystem.java @@ -33,8 +33,8 @@ import org.jclouds.cloudstack.domain.OSType; import org.jclouds.cloudstack.domain.Template; import org.jclouds.collect.Memoized; import org.jclouds.compute.domain.OperatingSystem; -import org.jclouds.compute.domain.OperatingSystem.Builder; import org.jclouds.compute.domain.OsFamily; +import org.jclouds.compute.domain.OperatingSystem.Builder; import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.compute.util.ComputeServiceUtils; import org.jclouds.logging.Logger; diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/strategy/CloudStackComputeServiceAdapter.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/strategy/CloudStackComputeServiceAdapter.java index 2179d4fb36..c7225110b5 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/strategy/CloudStackComputeServiceAdapter.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/strategy/CloudStackComputeServiceAdapter.java @@ -63,8 +63,8 @@ import com.google.common.base.Supplier; import com.google.common.base.Throwables; import com.google.common.cache.LoadingCache; import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSet.Builder; import com.google.common.collect.Sets; +import com.google.common.collect.ImmutableSet.Builder; import com.google.common.primitives.Ints; /** diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackParserModule.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackParserModule.java index 065662b09a..91bd2075a4 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackParserModule.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackParserModule.java @@ -27,11 +27,11 @@ import java.util.Set; import javax.inject.Singleton; import org.jclouds.cloudstack.domain.Account; -import org.jclouds.cloudstack.domain.Account.State; import org.jclouds.cloudstack.domain.FirewallRule; import org.jclouds.cloudstack.domain.LoadBalancerRule; import org.jclouds.cloudstack.domain.PortForwardingRule; import org.jclouds.cloudstack.domain.User; +import org.jclouds.cloudstack.domain.Account.State; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Sets; diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackProperties.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackProperties.java index 4508246b79..3f937c56ce 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackProperties.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackProperties.java @@ -18,7 +18,6 @@ */ package org.jclouds.cloudstack.config; -import org.jclouds.compute.ComputeServiceContextBuilder; /** * Configuration properties and constants used in CloudStack connections. diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackRestClientModule.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackRestClientModule.java index e4e7336a7f..a5b63e1d09 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackRestClientModule.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackRestClientModule.java @@ -123,7 +123,6 @@ import org.jclouds.concurrent.RetryOnTimeOutExceptionFunction; import org.jclouds.domain.Credentials; 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; @@ -155,7 +154,6 @@ import com.google.inject.name.Named; * * @author Adrian Cole */ -@RequiresHttp @ConfiguresRestClient public class CloudStackRestClientModule extends RestClientModule { diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/NetworkService.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/NetworkService.java index a3d8306359..39c910507b 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/NetworkService.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/NetworkService.java @@ -21,13 +21,13 @@ package org.jclouds.cloudstack.domain; import static com.google.common.base.Preconditions.checkNotNull; import java.util.Map; -import java.util.Map.Entry; import java.util.SortedSet; +import java.util.Map.Entry; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMap.Builder; import com.google.common.collect.ImmutableSortedMap; import com.google.common.collect.ImmutableSortedSet; +import com.google.common.collect.ImmutableMap.Builder; import com.google.gson.annotations.SerializedName; /** diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/LoadBalancerAsyncClient.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/LoadBalancerAsyncClient.java index 670e2698fb..eeb36a23a7 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/LoadBalancerAsyncClient.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/LoadBalancerAsyncClient.java @@ -26,8 +26,8 @@ import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import org.jclouds.cloudstack.domain.LoadBalancerRule; -import org.jclouds.cloudstack.domain.LoadBalancerRule.Algorithm; import org.jclouds.cloudstack.domain.VirtualMachine; +import org.jclouds.cloudstack.domain.LoadBalancerRule.Algorithm; import org.jclouds.cloudstack.filters.AuthenticationFilter; import org.jclouds.cloudstack.options.CreateLoadBalancerRuleOptions; import org.jclouds.cloudstack.options.ListLoadBalancerRulesOptions; diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/LoadBalancerClient.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/LoadBalancerClient.java index ab20d2e2e0..c80e3d59d7 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/LoadBalancerClient.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/LoadBalancerClient.java @@ -22,8 +22,8 @@ import java.util.Set; import java.util.concurrent.TimeUnit; import org.jclouds.cloudstack.domain.LoadBalancerRule; -import org.jclouds.cloudstack.domain.LoadBalancerRule.Algorithm; import org.jclouds.cloudstack.domain.VirtualMachine; +import org.jclouds.cloudstack.domain.LoadBalancerRule.Algorithm; import org.jclouds.cloudstack.options.CreateLoadBalancerRuleOptions; import org.jclouds.cloudstack.options.ListLoadBalancerRulesOptions; import org.jclouds.cloudstack.options.UpdateLoadBalancerRuleOptions; diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/functions/CreatePortForwardingRulesForIP.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/functions/CreatePortForwardingRulesForIP.java index 572ef7ede2..8153196602 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/functions/CreatePortForwardingRulesForIP.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/functions/CreatePortForwardingRulesForIP.java @@ -38,8 +38,8 @@ import org.jclouds.logging.Logger; import com.google.common.cache.LoadingCache; import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSet.Builder; import com.google.common.collect.Iterables; +import com.google.common.collect.ImmutableSet.Builder; /** * diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/functions/ParseIdToNameFromHttpResponse.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/functions/ParseIdToNameFromHttpResponse.java index ec9a209a3a..fdd1aa8718 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/functions/ParseIdToNameFromHttpResponse.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/functions/ParseIdToNameFromHttpResponse.java @@ -30,8 +30,8 @@ import org.jclouds.http.functions.ParseFirstJsonValueNamed; import org.jclouds.json.internal.GsonWrapper; import com.google.common.base.Function; -import com.google.common.collect.ImmutableMap.Builder; import com.google.common.collect.ImmutableSortedMap; +import com.google.common.collect.ImmutableMap.Builder; import com.google.inject.Inject; import com.google.inject.TypeLiteral; diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/functions/ParseTypedAsyncJob.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/functions/ParseTypedAsyncJob.java index 7f1ba7d325..50e63eb1ab 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/functions/ParseTypedAsyncJob.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/functions/ParseTypedAsyncJob.java @@ -29,9 +29,7 @@ import javax.inject.Singleton; import org.jclouds.cloudstack.domain.Account; import org.jclouds.cloudstack.domain.AsyncJob; -import org.jclouds.cloudstack.domain.AsyncJob.Builder; import org.jclouds.cloudstack.domain.AsyncJobError; -import org.jclouds.cloudstack.domain.AsyncJobError.ErrorCode; import org.jclouds.cloudstack.domain.FirewallRule; import org.jclouds.cloudstack.domain.IPForwardingRule; import org.jclouds.cloudstack.domain.LoadBalancerRule; @@ -45,6 +43,8 @@ import org.jclouds.cloudstack.domain.TemplateExtraction; import org.jclouds.cloudstack.domain.User; import org.jclouds.cloudstack.domain.VirtualMachine; import org.jclouds.cloudstack.domain.Volume; +import org.jclouds.cloudstack.domain.AsyncJob.Builder; +import org.jclouds.cloudstack.domain.AsyncJobError.ErrorCode; import org.jclouds.domain.JsonBall; import org.jclouds.json.Json; import org.jclouds.logging.Logger; diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/internal/CloudStackContextImpl.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/internal/CloudStackContextImpl.java index 2be7231dd2..3267f9d56b 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/internal/CloudStackContextImpl.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/internal/CloudStackContextImpl.java @@ -18,6 +18,7 @@ */ package org.jclouds.cloudstack.internal; +import java.io.Closeable; import java.util.Map; import javax.inject.Inject; @@ -34,34 +35,34 @@ import org.jclouds.compute.ComputeService; import org.jclouds.compute.Utils; import org.jclouds.compute.internal.ComputeServiceContextImpl; import org.jclouds.domain.Credentials; +import org.jclouds.location.Provider; import org.jclouds.rest.RestContext; +import com.google.common.reflect.TypeToken; + /** * @author Adrian Cole */ @Singleton -public class CloudStackContextImpl extends ComputeServiceContextImpl implements - CloudStackContext { - private final RestContext providerSpecificContext; +public class CloudStackContextImpl extends ComputeServiceContextImpl implements CloudStackContext { private final RestContext domainContext; private final RestContext globalContext; @Inject - public CloudStackContextImpl(ComputeService computeService, Map credentialStore, Utils utils, - RestContext providerSpecificContext, - RestContext domainContext, - RestContext globalContext) { - super(computeService, credentialStore, utils, providerSpecificContext); - this.providerSpecificContext=providerSpecificContext; + public CloudStackContextImpl(@Provider Closeable wrapped, @Provider TypeToken wrappedType, + ComputeService computeService, Map credentialStore, Utils utils, + RestContext domainContext, + RestContext globalContext) { + super(wrapped, wrappedType, computeService, credentialStore, utils); this.domainContext = domainContext; this.globalContext = globalContext; } - + @Override - public RestContext getProviderSpecificContext() { - return providerSpecificContext; + public RestContext getProviderSpecificContext() { + return unwrap(); } - + @Override public RestContext getDomainContext() { return domainContext; diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/predicates/UserPredicates.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/predicates/UserPredicates.java index 52dc210313..ce3e1bfa95 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/predicates/UserPredicates.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/predicates/UserPredicates.java @@ -21,8 +21,8 @@ package org.jclouds.cloudstack.predicates; import static com.google.common.base.Preconditions.checkNotNull; import org.jclouds.cloudstack.domain.Account; -import org.jclouds.cloudstack.domain.Account.Type; import org.jclouds.cloudstack.domain.User; +import org.jclouds.cloudstack.domain.Account.Type; import com.google.common.base.Predicate; diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/util/ApiKeyPairs.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/util/ApiKeyPairs.java index 1683fd9524..d5bd2bd5da 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/util/ApiKeyPairs.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/util/ApiKeyPairs.java @@ -26,13 +26,13 @@ import java.util.Properties; import java.util.Set; import org.jclouds.Constants; +import org.jclouds.ContextBuilder; import org.jclouds.cloudstack.CloudStackApiMetadata; import org.jclouds.cloudstack.CloudStackClient; import org.jclouds.cloudstack.CloudStackContext; import org.jclouds.cloudstack.domain.Account; import org.jclouds.cloudstack.domain.ApiKeyPair; import org.jclouds.cloudstack.domain.User; -import org.jclouds.compute.ComputeServiceContextBuilder; /** * @author Andrei Savu @@ -62,12 +62,12 @@ public class ApiKeyPairs { overrides.put(Constants.PROPERTY_RELAX_HOSTNAME, "true"); overrides.put("jclouds.cloudstack.credential-type", "passwordCredentials"); - context = ComputeServiceContextBuilder.newBuilder(new CloudStackApiMetadata()) + context = ContextBuilder.newBuilder(new CloudStackApiMetadata()) .endpoint(checkNotNull(endpoint, "endpoint").toASCIIString()) .credentials(String.format("%s/%s", checkNotNull(domain, "domain"), checkNotNull(username, "username")), password) - .overrides(overrides).build(); + .overrides(overrides).build(CloudStackContext.class); - CloudStackClient client = CloudStackClient.class.cast(context.getProviderSpecificContext().getApi()); + CloudStackClient client = context.getProviderSpecificContext().getApi(); Set listOfAccounts = client.getAccountClient().listAccounts(); domain = (domain.equals("") || domain.equals("/")) ? "ROOT" : domain; diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/compute/CloudStackComputeServiceAdapterLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/compute/CloudStackComputeServiceAdapterLiveTest.java index 8dad16187e..0da85d8081 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/compute/CloudStackComputeServiceAdapterLiveTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/compute/CloudStackComputeServiceAdapterLiveTest.java @@ -53,8 +53,8 @@ import org.jclouds.cloudstack.suppliers.GetCurrentUser; import org.jclouds.cloudstack.suppliers.NetworksForCurrentUser; import org.jclouds.cloudstack.suppliers.ZoneIdToZoneSupplier; import org.jclouds.collect.Memoized; -import org.jclouds.compute.ComputeServiceAdapter.NodeAndInitialCredentials; import org.jclouds.compute.ComputeTestUtils; +import org.jclouds.compute.ComputeServiceAdapter.NodeAndInitialCredentials; import org.jclouds.compute.domain.Template; import org.jclouds.compute.functions.DefaultCredentialsFromImageOrOverridingCredentials; import org.jclouds.compute.strategy.PrioritizeCredentialsFromTemplate; @@ -102,7 +102,7 @@ public class CloudStackComputeServiceAdapterLiveTest extends BaseCloudStackClien @Override protected void configure() { bindProperties(binder(), setupProperties()); - bind(String.class).annotatedWith(Identity.class).toInstance(context.getProviderSpecificContext().getIdentity()); + bind(String.class).annotatedWith(Identity.class).toInstance(identity); bind(new TypeLiteral>() { }).annotatedWith(Memoized.class).to(GetCurrentUser.class).in(Scopes.SINGLETON); bind(new TypeLiteral>>() { diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/compute/CloudStackComputeServiceLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/compute/CloudStackComputeServiceLiveTest.java index a0ae087295..a112d37849 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/compute/CloudStackComputeServiceLiveTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/compute/CloudStackComputeServiceLiveTest.java @@ -18,12 +18,8 @@ */ package org.jclouds.cloudstack.compute; -import org.jclouds.cloudstack.CloudStackAsyncClient; -import org.jclouds.cloudstack.CloudStackClient; -import org.jclouds.cloudstack.CloudStackContext; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.internal.BaseComputeServiceLiveTest; -import org.jclouds.rest.RestContext; import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.Test; @@ -37,8 +33,7 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", enabled = true, singleThreaded = true) -public class CloudStackComputeServiceLiveTest extends - BaseComputeServiceLiveTest { +public class CloudStackComputeServiceLiveTest extends BaseComputeServiceLiveTest { public CloudStackComputeServiceLiveTest() { provider = "cloudstack"; } @@ -48,11 +43,6 @@ public class CloudStackComputeServiceLiveTest extends return new SshjSshClientModule(); } - public void testAssignability() throws Exception { - @SuppressWarnings("unused") - RestContext tmContext = context.getProviderSpecificContext(); - } - // cloudstack does not support metadata @Override protected void checkUserMetadataInNodeEquals(NodeMetadata node, ImmutableMap userMetadata) { diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/BaseCloudStackAsyncClientTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/BaseCloudStackAsyncClientTest.java index 66ca388819..6be2724084 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/BaseCloudStackAsyncClientTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/BaseCloudStackAsyncClientTest.java @@ -24,7 +24,6 @@ import org.jclouds.cloudstack.CloudStackApiMetadata; import org.jclouds.cloudstack.config.CloudStackRestClientModule; import org.jclouds.cloudstack.filters.QuerySigner; import org.jclouds.http.HttpRequest; -import org.jclouds.http.RequiresHttp; import org.jclouds.providers.AnonymousProviderMetadata; import org.jclouds.providers.ProviderMetadata; import org.jclouds.rest.ConfiguresRestClient; @@ -37,8 +36,7 @@ import com.google.inject.Module; */ public abstract class BaseCloudStackAsyncClientTest extends BaseAsyncClientTest { - @RequiresHttp - @ConfiguresRestClient + @ConfiguresRestClient public static class CloudStackRestClientModuleExtension extends CloudStackRestClientModule { } @@ -55,7 +53,7 @@ public abstract class BaseCloudStackAsyncClientTest extends BaseAsyncClientTe } @Override - protected ProviderMetadata createProviderMetadata() { + protected ProviderMetadata createProviderMetadata() { return AnonymousProviderMetadata.forApiWithEndpoint(new CloudStackApiMetadata(), "http://localhost:8080/client/api"); } diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/BaseCloudStackClientLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/BaseCloudStackClientLiveTest.java index db2510239e..d202c58841 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/BaseCloudStackClientLiveTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/BaseCloudStackClientLiveTest.java @@ -73,8 +73,7 @@ import com.google.inject.Module; * * @author Adrian Cole */ -public class BaseCloudStackClientLiveTest extends - BaseComputeServiceContextLiveTest { +public class BaseCloudStackClientLiveTest extends BaseComputeServiceContextLiveTest { protected String domainAdminIdentity; protected String domainAdminCredential; protected String globalAdminIdentity; @@ -195,13 +194,13 @@ public class BaseCloudStackClientLiveTest extends public void setupContext() { super.setupContext(); computeClient = context.getComputeService(); - cloudStackContext = context.getProviderSpecificContext(); + cloudStackContext = context.unwrap(); client = cloudStackContext.getApi(); user = verifyCurrentUserIsOfType(cloudStackContext, Account.Type.USER); domainAdminEnabled = setupDomainAdminProperties() != null; if (domainAdminEnabled) { - domainAdminComputeContext = createContext(setupDomainAdminProperties(), setupModules()); + domainAdminComputeContext = createContext(setupDomainAdminProperties(), setupModules()).unwrap(); domainAdminContext = domainAdminComputeContext.getDomainContext(); domainAdminClient = domainAdminContext.getApi(); domainAdminUser = verifyCurrentUserIsOfType(domainAdminContext, Account.Type.DOMAIN_ADMIN); @@ -210,7 +209,7 @@ public class BaseCloudStackClientLiveTest extends globalAdminEnabled = setupGlobalAdminProperties() != null; if (globalAdminEnabled) { - globalAdminComputeContext = createContext(setupGlobalAdminProperties(), setupModules()); + globalAdminComputeContext = createContext(setupGlobalAdminProperties(), setupModules()).unwrap(); globalAdminContext = globalAdminComputeContext.getGlobalContext(); globalAdminClient = globalAdminContext.getApi(); globalAdminUser = verifyCurrentUserIsOfType(globalAdminContext, Account.Type.ADMIN); diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/BaseCloudStackRestClientExpectTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/BaseCloudStackRestClientExpectTest.java index 5686229973..a2e027d082 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/BaseCloudStackRestClientExpectTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/BaseCloudStackRestClientExpectTest.java @@ -47,7 +47,7 @@ public abstract class BaseCloudStackRestClientExpectTest extends BaseRestClie } @Override - protected ApiMetadata createApiMetadata() { + protected ApiMetadata createApiMetadata() { return new CloudStackApiMetadata(); } diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalUserClientLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalUserClientLiveTest.java index e3b3a1cb58..fbc3166f7d 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalUserClientLiveTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalUserClientLiveTest.java @@ -83,7 +83,7 @@ public class GlobalUserClientLiveTest extends BaseCloudStackClientLiveTest { } private void checkAuthAsUser(ApiKeyPair keyPair) { - ComputeServiceContext context = createContext(credentialsAsProperties(keyPair), setupModules()); + ComputeServiceContext context = createContext(credentialsAsProperties(keyPair), setupModules()); CloudStackClient client = CloudStackClient.class.cast(context.getProviderSpecificContext().getApi()); Set accounts = client.getAccountClient().listAccounts(); diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GuestOSClientLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GuestOSClientLiveTest.java index 2a65eb3e48..57f3f9c405 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GuestOSClientLiveTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GuestOSClientLiveTest.java @@ -23,8 +23,8 @@ import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; import java.util.Map; -import java.util.Map.Entry; import java.util.Set; +import java.util.Map.Entry; import org.jclouds.cloudstack.domain.OSType; import org.jclouds.cloudstack.options.ListOSTypesOptions; diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/LoadBalancerClientLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/LoadBalancerClientLiveTest.java index 759579c4f4..441a0d8b8a 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/LoadBalancerClientLiveTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/LoadBalancerClientLiveTest.java @@ -35,11 +35,11 @@ import javax.annotation.Nullable; import org.jclouds.cloudstack.domain.AsyncJob; import org.jclouds.cloudstack.domain.JobResult; import org.jclouds.cloudstack.domain.LoadBalancerRule; -import org.jclouds.cloudstack.domain.LoadBalancerRule.Algorithm; -import org.jclouds.cloudstack.domain.LoadBalancerRule.State; import org.jclouds.cloudstack.domain.Network; import org.jclouds.cloudstack.domain.PublicIPAddress; import org.jclouds.cloudstack.domain.VirtualMachine; +import org.jclouds.cloudstack.domain.LoadBalancerRule.Algorithm; +import org.jclouds.cloudstack.domain.LoadBalancerRule.State; import org.jclouds.cloudstack.predicates.LoadBalancerRuleActive; import org.jclouds.net.IPSocket; import org.jclouds.predicates.RetryablePredicate; diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/filters/QuerySignerTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/filters/QuerySignerTest.java index 25fd9ae0c9..2c4bea015d 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/filters/QuerySignerTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/filters/QuerySignerTest.java @@ -22,13 +22,13 @@ import static org.testng.Assert.assertEquals; import java.net.URI; +import org.jclouds.ContextBuilder; import org.jclouds.http.HttpRequest; import org.jclouds.http.IntegrationTestAsyncClient; import org.jclouds.http.IntegrationTestClient; import org.jclouds.logging.config.NullLoggingModule; import org.jclouds.providers.AnonymousProviderMetadata; import org.jclouds.rest.internal.BaseRestClientTest.MockModule; -import org.jclouds.rest.internal.ContextBuilder; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/functions/ParseAsyncJobFromHttpResponseTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/functions/ParseAsyncJobFromHttpResponseTest.java index 27957ba85f..4b912b2389 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/functions/ParseAsyncJobFromHttpResponseTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/functions/ParseAsyncJobFromHttpResponseTest.java @@ -24,14 +24,14 @@ import static org.testng.Assert.assertTrue; import java.io.InputStream; import org.jclouds.cloudstack.domain.AsyncJob; -import org.jclouds.cloudstack.domain.AsyncJob.ResultCode; -import org.jclouds.cloudstack.domain.AsyncJob.Status; import org.jclouds.cloudstack.domain.AsyncJobError; -import org.jclouds.cloudstack.domain.AsyncJobError.ErrorCode; import org.jclouds.cloudstack.domain.IPForwardingRule; import org.jclouds.cloudstack.domain.PublicIPAddress; import org.jclouds.cloudstack.domain.Template; import org.jclouds.cloudstack.domain.TemplateExtraction; +import org.jclouds.cloudstack.domain.AsyncJob.ResultCode; +import org.jclouds.cloudstack.domain.AsyncJob.Status; +import org.jclouds.cloudstack.domain.AsyncJobError.ErrorCode; import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.domain.JsonBall; import org.jclouds.http.HttpResponse; diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListAccountsResponseTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListAccountsResponseTest.java index 2b585c4ea8..d323a0b88c 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListAccountsResponseTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/parse/ListAccountsResponseTest.java @@ -22,9 +22,9 @@ import java.util.Set; import org.jclouds.cloudstack.config.CloudStackParserModule; import org.jclouds.cloudstack.domain.Account; +import org.jclouds.cloudstack.domain.User; import org.jclouds.cloudstack.domain.Account.State; import org.jclouds.cloudstack.domain.Account.Type; -import org.jclouds.cloudstack.domain.User; import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.json.BaseSetParserTest; import org.jclouds.json.config.GsonModule; diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/predicates/JobCompleteTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/predicates/JobCompleteTest.java index 53310e5e0a..a4ef0a60db 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/predicates/JobCompleteTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/predicates/JobCompleteTest.java @@ -28,9 +28,9 @@ import static org.testng.Assert.fail; import org.jclouds.cloudstack.AsyncJobException; import org.jclouds.cloudstack.CloudStackClient; import org.jclouds.cloudstack.domain.AsyncJob; +import org.jclouds.cloudstack.domain.AsyncJobError; import org.jclouds.cloudstack.domain.AsyncJob.ResultCode; import org.jclouds.cloudstack.domain.AsyncJob.Status; -import org.jclouds.cloudstack.domain.AsyncJobError; import org.jclouds.cloudstack.domain.AsyncJobError.ErrorCode; import org.jclouds.cloudstack.features.AsyncJobClient; import org.testng.annotations.BeforeMethod; diff --git a/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/CloudWatchApiMetadata.java b/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/CloudWatchApiMetadata.java index 51fb3b648d..d40bd4ee25 100644 --- a/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/CloudWatchApiMetadata.java +++ b/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/CloudWatchApiMetadata.java @@ -25,73 +25,68 @@ import java.net.URI; import java.util.Properties; import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.internal.BaseApiMetadata; +import org.jclouds.cloudwatch.config.CloudWatchRestClientModule; import org.jclouds.rest.RestContext; import org.jclouds.rest.internal.BaseRestApiMetadata; +import com.google.common.reflect.TypeToken; + /** * Implementation of {@link ApiMetadata} for Amazon's CloudWatch api. * - *

note

- *

- * This class allows overriding of types {@code S}(client) and {@code A}(asyncClient), so that - * children can add additional methods not declared here, such as new features - * from AWS. - *

- * - * This class is not setup to allow a different context than {@link RestContext} - * . By doing so, it reduces the type complexity. - * * @author Adrian Cole */ -public class CloudWatchApiMetadata extends - BaseRestApiMetadata, CloudWatchApiMetadata> { +public class CloudWatchApiMetadata extends BaseRestApiMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 3450830053589179249L; + + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; @Override - public Builder toBuilder() { - return new Builder(getApi(), getAsyncApi()).fromApiMetadata(this); + public Builder toBuilder() { + return new Builder(getApi(), getAsyncApi()).fromApiMetadata(this); } public CloudWatchApiMetadata() { - this(new Builder(CloudWatchClient.class, CloudWatchAsyncClient.class)); + this(new Builder(CloudWatchClient.class, CloudWatchAsyncClient.class)); } - @SuppressWarnings("unchecked") - protected CloudWatchApiMetadata(Builder builder) { + protected CloudWatchApiMetadata(Builder builder) { super(Builder.class.cast(builder)); } - protected static Properties defaultProperties() { - Properties properties = BaseApiMetadata.Builder.defaultProperties(); + public static Properties defaultProperties() { + Properties properties = BaseRestApiMetadata.defaultProperties(); properties.setProperty(PROPERTY_AUTH_TAG, "AWS"); properties.setProperty(PROPERTY_HEADER_TAG, "amz"); return properties; } - public static class Builder extends - BaseRestApiMetadata.Builder, CloudWatchApiMetadata> { + public static class Builder extends BaseRestApiMetadata.Builder { - protected Builder(Class client, Class asyncClient) { + protected Builder(Class client, Class asyncClient) { super(client, asyncClient); id("cloudwatch") - .type(ApiType.MONITOR) .name("Amazon CloudWatch Api") .identityName("Access Key ID") .credentialName("Secret Access Key") .version(CloudWatchAsyncClient.VERSION) - .defaultProperties(CloudWatchApiMetadata.defaultProperties()) + .documentation(URI.create("http://docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference/")) .defaultEndpoint("https://monitoring.us-east-1.amazonaws.com") - .documentation(URI.create("http://docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference/")); + .defaultProperties(CloudWatchApiMetadata.defaultProperties()) + .defaultModule(CloudWatchRestClientModule.class); } @Override - public CloudWatchApiMetadata build() { - return new CloudWatchApiMetadata(this); + public CloudWatchApiMetadata build() { + return new CloudWatchApiMetadata(this); } @Override - public Builder fromApiMetadata(CloudWatchApiMetadata in) { + public Builder fromApiMetadata(ApiMetadata in) { super.fromApiMetadata(in); return this; } diff --git a/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/CloudWatchContextBuilder.java b/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/CloudWatchContextBuilder.java deleted file mode 100644 index 7d60ccef2b..0000000000 --- a/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/CloudWatchContextBuilder.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * 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.cloudwatch; - -import java.util.List; - -import org.jclouds.cloudwatch.config.CloudWatchRestClientModule; -import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; -import org.jclouds.logging.jdk.config.JDKLoggingModule; -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.rest.RestContext; -import org.jclouds.rest.RestContextBuilder; - -import com.google.inject.Injector; -import com.google.inject.Module; - -/** - * Creates {@link MonitoringContext} or {@link Injector} instances based on the - * most commonly requested arguments. - *

- * Note that Threadsafe objects will be bound as singletons to the Injector or - * Context provided. - *

- *

- * If no Modules are specified, the default - * {@link JDKLoggingModule logging} and - * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be - * installed. - * - * @author Adrian Cole - * @see MonitoringContext - */ -public class CloudWatchContextBuilder - extends RestContextBuilder, CloudWatchApiMetadata> { - - public CloudWatchContextBuilder(ProviderMetadata, CloudWatchApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public CloudWatchContextBuilder(CloudWatchApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addClientModule(List modules) { - modules.add(new CloudWatchRestClientModule()); - } -} diff --git a/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/config/CloudWatchRestClientModule.java b/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/config/CloudWatchRestClientModule.java index 5bddf2e30f..ebede447d3 100644 --- a/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/config/CloudWatchRestClientModule.java +++ b/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/config/CloudWatchRestClientModule.java @@ -21,7 +21,6 @@ package org.jclouds.cloudwatch.config; import org.jclouds.aws.config.FormSigningRestClientModule; import org.jclouds.cloudwatch.CloudWatchAsyncClient; import org.jclouds.cloudwatch.CloudWatchClient; -import org.jclouds.http.RequiresHttp; import org.jclouds.rest.ConfiguresRestClient; /** @@ -29,7 +28,6 @@ import org.jclouds.rest.ConfiguresRestClient; * * @author Adrian Cole */ -@RequiresHttp @ConfiguresRestClient public class CloudWatchRestClientModule extends FormSigningRestClientModule { public CloudWatchRestClientModule() { diff --git a/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchApiMetadataTest.java b/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchApiMetadataTest.java index 0321386289..ad68f537f7 100644 --- a/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchApiMetadataTest.java +++ b/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchApiMetadataTest.java @@ -18,19 +18,22 @@ */ package org.jclouds.cloudwatch; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.internal.BaseRestApiMetadataTest; +import org.jclouds.Wrapper; +import org.jclouds.rest.internal.BaseRestApiMetadataTest; import org.testng.annotations.Test; +import com.google.common.collect.ImmutableSet; +import com.google.common.reflect.TypeToken; + /** * * @author Adrian Cole */ -@SuppressWarnings("rawtypes") @Test(groups = "unit", testName = "CloudWatchApiMetadataTest") public class CloudWatchApiMetadataTest extends BaseRestApiMetadataTest { + // no monitoring abstraction, yet public CloudWatchApiMetadataTest() { - super(new CloudWatchApiMetadata(), ApiType.MONITOR); + super(new CloudWatchApiMetadata(), ImmutableSet.> of()); } } diff --git a/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchAsyncClientTest.java b/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchAsyncClientTest.java index 193b032682..690c7092fc 100644 --- a/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchAsyncClientTest.java +++ b/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchAsyncClientTest.java @@ -39,7 +39,6 @@ import org.jclouds.cloudwatch.options.GetMetricStatisticsOptions; import org.jclouds.cloudwatch.xml.GetMetricStatisticsResponseHandler; import org.jclouds.date.DateService; import org.jclouds.http.HttpRequest; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.functions.ParseSax; import org.jclouds.location.config.LocationModule; import org.jclouds.location.suppliers.RegionIdToURISupplier; @@ -91,8 +90,7 @@ public class CloudWatchAsyncClientTest extends BaseAsyncClientTest createApiMetadata() { + public ApiMetadata createApiMetadata() { return new CloudWatchApiMetadata(); } diff --git a/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchClientLiveTest.java b/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchClientLiveTest.java index 7bf1a80563..5109d92c4f 100644 --- a/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchClientLiveTest.java +++ b/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchClientLiveTest.java @@ -24,15 +24,17 @@ import java.util.Calendar; import java.util.Date; import java.util.Set; +import org.jclouds.apis.BaseContextLiveTest; import org.jclouds.cloudwatch.domain.Datapoint; import org.jclouds.cloudwatch.domain.Statistics; import org.jclouds.cloudwatch.domain.Unit; import org.jclouds.cloudwatch.options.GetMetricStatisticsOptions; import org.jclouds.rest.RestContext; -import org.jclouds.rest.internal.BaseContextLiveTest; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import com.google.common.reflect.TypeToken; + /** * Tests behavior of {@code CloudWatchClient} * @@ -67,4 +69,9 @@ public class CloudWatchClientLiveTest extends BaseContextLiveTest> contextType() { + return CloudWatchApiMetadata.CONTEXT_TOKEN; + } } diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudApiMetadata.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudApiMetadata.java index f84a352a8f..8908404e72 100644 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudApiMetadata.java +++ b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudApiMetadata.java @@ -23,16 +23,28 @@ import java.util.Properties; import org.jclouds.apis.ApiMetadata; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; +import org.jclouds.deltacloud.compute.config.DeltacloudComputeServiceContextModule; +import org.jclouds.deltacloud.config.DeltacloudRestClientModule; +import org.jclouds.rest.RestContext; +import org.jclouds.rest.internal.BaseRestApiMetadata; +import com.google.common.collect.ImmutableSet; import com.google.common.reflect.TypeToken; +import com.google.inject.Module; /** * Implementation of {@link ApiMetadata} for Apache Deltacloud API * * @author Adrian Cole */ -public class DeltacloudApiMetadata extends BaseComputeServiceApiMetadata, DeltacloudApiMetadata> { +public class DeltacloudApiMetadata extends BaseRestApiMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 6725672099385580694L; + + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; @Override public Builder toBuilder() { @@ -47,13 +59,14 @@ public class DeltacloudApiMetadata extends BaseComputeServiceApiMetadata, DeltacloudApiMetadata> { + public static class Builder extends BaseRestApiMetadata.Builder { protected Builder() { + super(DeltacloudClient.class, DeltacloudAsyncClient.class); id("deltacloud") .name("Apache Deltacloud API") .identityName("Username") @@ -61,21 +74,22 @@ public class DeltacloudApiMetadata extends BaseComputeServiceApiMetadata>of(DeltacloudRestClientModule.class, DeltacloudComputeServiceContextModule.class)); } - } \ No newline at end of file + @Override + public DeltacloudApiMetadata build() { + return new DeltacloudApiMetadata(this); + } + + @Override + public Builder fromApiMetadata(ApiMetadata in) { + super.fromApiMetadata(in); + return this; + } + + } + +} \ No newline at end of file diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudAsyncClient.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudAsyncClient.java index 83c6ab4ef9..3c672c145e 100644 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudAsyncClient.java +++ b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudAsyncClient.java @@ -36,9 +36,9 @@ import org.jclouds.deltacloud.domain.DeltacloudCollection; import org.jclouds.deltacloud.domain.HardwareProfile; import org.jclouds.deltacloud.domain.Image; import org.jclouds.deltacloud.domain.Instance; -import org.jclouds.deltacloud.domain.Instance.State; import org.jclouds.deltacloud.domain.Realm; import org.jclouds.deltacloud.domain.Transition; +import org.jclouds.deltacloud.domain.Instance.State; import org.jclouds.deltacloud.functions.ReturnVoidOnRedirectedDelete; import org.jclouds.deltacloud.options.CreateInstanceOptions; import org.jclouds.deltacloud.xml.DeltacloudCollectionsHandler; diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudClient.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudClient.java index 96ab9b62b5..39f4da8db7 100644 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudClient.java +++ b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudClient.java @@ -27,9 +27,9 @@ import org.jclouds.deltacloud.domain.DeltacloudCollection; import org.jclouds.deltacloud.domain.HardwareProfile; import org.jclouds.deltacloud.domain.Image; import org.jclouds.deltacloud.domain.Instance; -import org.jclouds.deltacloud.domain.Instance.State; import org.jclouds.deltacloud.domain.Realm; import org.jclouds.deltacloud.domain.Transition; +import org.jclouds.deltacloud.domain.Instance.State; import org.jclouds.deltacloud.options.CreateInstanceOptions; import org.jclouds.http.HttpRequest; diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudContextBuilder.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudContextBuilder.java deleted file mode 100644 index b37769c36e..0000000000 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudContextBuilder.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * 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.deltacloud; - -import java.util.List; - -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextBuilder; -import org.jclouds.deltacloud.compute.config.DeltacloudComputeServiceContextModule; -import org.jclouds.deltacloud.config.DeltacloudRestClientModule; -import org.jclouds.providers.ProviderMetadata; - -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class DeltacloudContextBuilder - extends - ComputeServiceContextBuilder, DeltacloudApiMetadata> { - - public DeltacloudContextBuilder( - ProviderMetadata, DeltacloudApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public DeltacloudContextBuilder(DeltacloudApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new DeltacloudComputeServiceContextModule()); - } - - protected void addClientModule(List modules) { - modules.add(new DeltacloudRestClientModule()); - } - -} diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/compute/config/DeltacloudComputeServiceContextModule.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/compute/config/DeltacloudComputeServiceContextModule.java index fe11997826..34d21cb1af 100644 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/compute/config/DeltacloudComputeServiceContextModule.java +++ b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/compute/config/DeltacloudComputeServiceContextModule.java @@ -21,8 +21,6 @@ package org.jclouds.deltacloud.compute.config; import org.jclouds.compute.ComputeServiceAdapter; import org.jclouds.compute.config.ComputeServiceAdapterContextModule; import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.deltacloud.DeltacloudAsyncClient; -import org.jclouds.deltacloud.DeltacloudClient; import org.jclouds.deltacloud.compute.functions.DeltacloudImageToImage; import org.jclouds.deltacloud.compute.functions.HardwareProfileToHardware; import org.jclouds.deltacloud.compute.functions.InstanceToNodeMetadata; @@ -40,13 +38,8 @@ import com.google.inject.TypeLiteral; * * @author Adrian Cole */ -public class DeltacloudComputeServiceContextModule - extends - ComputeServiceAdapterContextModule { - - public DeltacloudComputeServiceContextModule() { - super(DeltacloudClient.class, DeltacloudAsyncClient.class); - } +public class DeltacloudComputeServiceContextModule extends + ComputeServiceAdapterContextModule { @Override protected void configure() { diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/compute/strategy/DeltacloudComputeServiceAdapter.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/compute/strategy/DeltacloudComputeServiceAdapter.java index 0e304deaf6..0a6349a02d 100644 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/compute/strategy/DeltacloudComputeServiceAdapter.java +++ b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/compute/strategy/DeltacloudComputeServiceAdapter.java @@ -35,11 +35,11 @@ import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.deltacloud.DeltacloudClient; import org.jclouds.deltacloud.domain.HardwareProfile; import org.jclouds.deltacloud.domain.Instance; -import org.jclouds.deltacloud.domain.Instance.State; import org.jclouds.deltacloud.domain.PasswordAuthentication; import org.jclouds.deltacloud.domain.Realm; import org.jclouds.deltacloud.domain.Transition; import org.jclouds.deltacloud.domain.TransitionOnAction; +import org.jclouds.deltacloud.domain.Instance.State; import org.jclouds.deltacloud.options.CreateInstanceOptions; import org.jclouds.deltacloud.predicates.InstanceFinished; import org.jclouds.deltacloud.predicates.InstanceRunning; diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/config/DeltacloudRestClientModule.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/config/DeltacloudRestClientModule.java index bbd43b2a69..8a1664db3d 100644 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/config/DeltacloudRestClientModule.java +++ b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/config/DeltacloudRestClientModule.java @@ -40,7 +40,6 @@ import org.jclouds.deltacloud.handlers.DeltacloudErrorHandler; import org.jclouds.deltacloud.handlers.DeltacloudRedirectionRetryHandler; 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; @@ -61,7 +60,6 @@ import com.google.inject.Provides; * * @author Adrian Cole */ -@RequiresHttp @ConfiguresRestClient public class DeltacloudRestClientModule extends RestClientModule { diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/HardwarePropertyHandler.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/HardwarePropertyHandler.java index cf83cdfce5..c7c392e82f 100644 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/HardwarePropertyHandler.java +++ b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/HardwarePropertyHandler.java @@ -27,8 +27,8 @@ import org.jclouds.deltacloud.domain.EnumHardwareProperty; import org.jclouds.deltacloud.domain.FixedHardwareProperty; import org.jclouds.deltacloud.domain.HardwareParameter; import org.jclouds.deltacloud.domain.HardwareProperty; -import org.jclouds.deltacloud.domain.HardwareProperty.Kind; import org.jclouds.deltacloud.domain.RangeHardwareProperty; +import org.jclouds.deltacloud.domain.HardwareProperty.Kind; import org.jclouds.http.functions.ParseSax; import org.jclouds.javax.annotation.Nullable; import org.jclouds.util.SaxUtils; diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/InstanceHandler.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/InstanceHandler.java index 98ecc44514..6309f9816d 100644 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/InstanceHandler.java +++ b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/InstanceHandler.java @@ -27,9 +27,9 @@ import java.util.Set; import javax.annotation.Resource; import org.jclouds.deltacloud.domain.Instance; -import org.jclouds.deltacloud.domain.Instance.Authentication; import org.jclouds.deltacloud.domain.KeyAuthentication; import org.jclouds.deltacloud.domain.PasswordAuthentication; +import org.jclouds.deltacloud.domain.Instance.Authentication; import org.jclouds.domain.LoginCredentials; import org.jclouds.domain.LoginCredentials.Builder; import org.jclouds.http.HttpRequest; diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/InstanceStatesHandler.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/InstanceStatesHandler.java index ae31df317a..3be3d3fcbc 100644 --- a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/InstanceStatesHandler.java +++ b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/xml/InstanceStatesHandler.java @@ -22,11 +22,11 @@ import java.util.Map; import javax.annotation.Resource; -import org.jclouds.deltacloud.domain.Instance.Action; -import org.jclouds.deltacloud.domain.Instance.State; import org.jclouds.deltacloud.domain.Transition; import org.jclouds.deltacloud.domain.TransitionAutomatically; import org.jclouds.deltacloud.domain.TransitionOnAction; +import org.jclouds.deltacloud.domain.Instance.Action; +import org.jclouds.deltacloud.domain.Instance.State; import org.jclouds.http.functions.ParseSax; import org.jclouds.logging.Logger; import org.jclouds.util.SaxUtils; diff --git a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/DeltacloudAsyncClientTest.java b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/DeltacloudAsyncClientTest.java index d8f0e1899b..cc0463dd8e 100644 --- a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/DeltacloudAsyncClientTest.java +++ b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/DeltacloudAsyncClientTest.java @@ -41,7 +41,6 @@ import org.jclouds.deltacloud.xml.InstancesHandler; import org.jclouds.deltacloud.xml.RealmHandler; import org.jclouds.deltacloud.xml.RealmsHandler; import org.jclouds.http.HttpRequest; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.filters.BasicAuthentication; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ReleasePayloadAndReturn; @@ -298,8 +297,7 @@ public class DeltacloudAsyncClientTest extends BaseAsyncClientTest createApiMetadata() { + protected ApiMetadata createApiMetadata() { return new DeltacloudApiMetadata(); } } diff --git a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/ReadOnlyDeltacloudClientLiveTest.java b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/ReadOnlyDeltacloudClientLiveTest.java index 3aefc77489..c63cbd8b47 100644 --- a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/ReadOnlyDeltacloudClientLiveTest.java +++ b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/ReadOnlyDeltacloudClientLiveTest.java @@ -25,15 +25,14 @@ import static org.testng.Assert.assertTrue; import java.util.Set; import java.util.concurrent.TimeUnit; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.deltacloud.domain.DeltacloudCollection; import org.jclouds.deltacloud.domain.HardwareProfile; import org.jclouds.deltacloud.domain.Image; import org.jclouds.deltacloud.domain.Instance; -import org.jclouds.deltacloud.domain.Instance.State; import org.jclouds.deltacloud.domain.Realm; import org.jclouds.deltacloud.domain.Transition; +import org.jclouds.deltacloud.domain.Instance.State; import org.jclouds.deltacloud.predicates.InstanceFinished; import org.jclouds.deltacloud.predicates.InstanceRunning; import org.jclouds.net.IPSocket; @@ -57,9 +56,7 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "ReadOnlyDeltacloudClientLiveTest") -public class ReadOnlyDeltacloudClientLiveTest - extends - BaseComputeServiceContextLiveTest> { +public class ReadOnlyDeltacloudClientLiveTest extends BaseComputeServiceContextLiveTest { public ReadOnlyDeltacloudClientLiveTest() { provider = "deltacloud"; @@ -74,7 +71,7 @@ public class ReadOnlyDeltacloudClientLiveTest @BeforeClass(groups = { "integration", "live" }) public void setupContext() { super.setupContext(); - client = context.getProviderSpecificContext().getApi(); + client = context.unwrap(DeltacloudApiMetadata.CONTEXT_TOKEN).getApi(); socketTester = new RetryablePredicate(new InetSocketAddressConnect(), 180, 1, TimeUnit.SECONDS); stateChanges = ImmutableMap.> of(// Instance.State.RUNNING, new RetryablePredicate(new InstanceRunning(client), 600, 1, diff --git a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/compute/DeltacloudComputeServiceLiveTest.java b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/compute/DeltacloudComputeServiceLiveTest.java index 7fc4ca3ff2..55ce6df8ac 100644 --- a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/compute/DeltacloudComputeServiceLiveTest.java +++ b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/compute/DeltacloudComputeServiceLiveTest.java @@ -22,13 +22,9 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.internal.BaseComputeServiceLiveTest; -import org.jclouds.deltacloud.DeltacloudAsyncClient; -import org.jclouds.deltacloud.DeltacloudClient; import org.jclouds.domain.LocationScope; -import org.jclouds.rest.RestContext; import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.Test; @@ -41,9 +37,7 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", enabled = true, singleThreaded = true, testName = "DeltacloudComputeServiceLiveTest") -public class DeltacloudComputeServiceLiveTest - extends - BaseComputeServiceLiveTest> { +public class DeltacloudComputeServiceLiveTest extends BaseComputeServiceLiveTest { public DeltacloudComputeServiceLiveTest() { provider = "deltacloud"; @@ -61,11 +55,6 @@ public class DeltacloudComputeServiceLiveTest "node userMetadata did not match %s %s", userMetadata, node); } - public void testAssignability() throws Exception { - @SuppressWarnings("unused") - RestContext tmContext = context.getProviderSpecificContext(); - } - @Override protected void checkNodes(Iterable nodes, String group, String task) throws IOException { super.checkNodes(nodes, group, task); diff --git a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/compute/DeltacloudTemplateBuilderLiveTest.java b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/compute/DeltacloudTemplateBuilderLiveTest.java index b1aaea7f7c..4af99e42f0 100644 --- a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/compute/DeltacloudTemplateBuilderLiveTest.java +++ b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/compute/DeltacloudTemplateBuilderLiveTest.java @@ -23,13 +23,10 @@ import static org.testng.Assert.assertEquals; import java.util.Set; -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.compute.internal.BaseTemplateBuilderLiveTest; -import org.jclouds.deltacloud.DeltacloudAsyncClient; -import org.jclouds.deltacloud.DeltacloudClient; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -41,9 +38,7 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live") -public class DeltacloudTemplateBuilderLiveTest - extends - BaseTemplateBuilderLiveTest> { +public class DeltacloudTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { public DeltacloudTemplateBuilderLiveTest() { provider = "deltacloud"; diff --git a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/handlers/DeltacloudRedirectionRetryHandlerTest.java b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/handlers/DeltacloudRedirectionRetryHandlerTest.java index 1403fdf20e..ae78bdc42a 100644 --- a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/handlers/DeltacloudRedirectionRetryHandlerTest.java +++ b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/handlers/DeltacloudRedirectionRetryHandlerTest.java @@ -25,7 +25,7 @@ import static org.easymock.EasyMock.verify; import java.net.URI; -import org.jclouds.compute.ComputeServiceContextBuilder; +import org.jclouds.ContextBuilder; import org.jclouds.http.HttpCommand; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; @@ -40,7 +40,7 @@ import com.google.inject.Injector; */ @Test(groups = "unit") public class DeltacloudRedirectionRetryHandlerTest { - Injector injector = ComputeServiceContextBuilder.forTests().buildInjector(); + Injector injector = ContextBuilder.newBuilder("stub").buildInjector(); @Test public void test302DoesNotRetryOnDelete() { diff --git a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/xml/InstanceHandlerTest.java b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/xml/InstanceHandlerTest.java index 3c335e0b9c..e50213ab28 100644 --- a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/xml/InstanceHandlerTest.java +++ b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/xml/InstanceHandlerTest.java @@ -24,9 +24,9 @@ import java.io.InputStream; import java.net.URI; import org.jclouds.deltacloud.domain.Instance; -import org.jclouds.deltacloud.domain.Instance.Authentication; import org.jclouds.deltacloud.domain.KeyAuthentication; import org.jclouds.deltacloud.domain.PasswordAuthentication; +import org.jclouds.deltacloud.domain.Instance.Authentication; import org.jclouds.domain.LoginCredentials; import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; diff --git a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/xml/InstanceStatesHandlerTest.java b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/xml/InstanceStatesHandlerTest.java index 95daf73045..3c818153ce 100644 --- a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/xml/InstanceStatesHandlerTest.java +++ b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/xml/InstanceStatesHandlerTest.java @@ -22,11 +22,11 @@ import static org.testng.Assert.assertEquals; import java.io.InputStream; -import org.jclouds.deltacloud.domain.Instance.Action; -import org.jclouds.deltacloud.domain.Instance.State; import org.jclouds.deltacloud.domain.Transition; import org.jclouds.deltacloud.domain.TransitionAutomatically; import org.jclouds.deltacloud.domain.TransitionOnAction; +import org.jclouds.deltacloud.domain.Instance.Action; +import org.jclouds.deltacloud.domain.Instance.State; import org.jclouds.http.functions.BaseHandlerTest; import org.testng.annotations.Test; diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/EC2ApiMetadata.java b/apis/ec2/src/main/java/org/jclouds/ec2/EC2ApiMetadata.java index 80c26fc456..b15f95636d 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/EC2ApiMetadata.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/EC2ApiMetadata.java @@ -29,11 +29,16 @@ import java.net.URI; import java.util.Properties; import org.jclouds.apis.ApiMetadata; -import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; import org.jclouds.ec2.compute.EC2ComputeServiceContext; +import org.jclouds.ec2.compute.config.EC2ComputeServiceContextModule; +import org.jclouds.ec2.compute.config.EC2ResolveImagesModule; +import org.jclouds.ec2.config.EC2RestClientModule; +import org.jclouds.rest.RestContext; +import org.jclouds.rest.internal.BaseRestApiMetadata; -import com.google.common.reflect.TypeParameter; +import com.google.common.collect.ImmutableSet; import com.google.common.reflect.TypeToken; +import com.google.inject.Module; /** * Implementation of {@link ApiMetadata} for Amazon's EC2 api. @@ -52,26 +57,30 @@ import com.google.common.reflect.TypeToken; * * @author Adrian Cole */ -public class EC2ApiMetadata, M extends EC2ApiMetadata> - extends BaseComputeServiceApiMetadata { +public class EC2ApiMetadata extends BaseRestApiMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 4424763314988423886L; + + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; - @SuppressWarnings({ "unchecked", "rawtypes" }) @Override - public Builder toBuilder() { - return (Builder) new Builder(getApi(), getAsyncApi()).fromApiMetadata(this); + public Builder toBuilder() { + return (Builder) new Builder(getApi(), getAsyncApi()).fromApiMetadata(this); } - @SuppressWarnings({ "unchecked", "rawtypes" }) public EC2ApiMetadata() { this(new Builder(EC2Client.class, EC2AsyncClient.class)); } - protected EC2ApiMetadata(Builder builder) { + protected EC2ApiMetadata(Builder builder) { super(builder); } - protected static Properties defaultProperties() { - Properties properties = BaseComputeServiceApiMetadata.Builder.defaultProperties(); + public static Properties defaultProperties() { + Properties properties = BaseRestApiMetadata.defaultProperties(); properties.setProperty(PROPERTY_AUTH_TAG, "AWS"); properties.setProperty(PROPERTY_HEADER_TAG, "amz"); properties.setProperty(PROPERTY_EC2_AMI_OWNERS, "*"); @@ -81,10 +90,11 @@ public class EC2ApiMetadata, M extends EC2ApiMetadata> - extends BaseComputeServiceApiMetadata.Builder { + public static class Builder + extends BaseRestApiMetadata.Builder { - protected Builder(Class syncClient, Class asyncClient) { + protected Builder(Class syncClient, Class asyncClient) { + super(syncClient, asyncClient); id("ec2") .name("Amazon Elastic Compute Cloud (EC2) API") .identityName("Access Key ID") @@ -93,32 +103,17 @@ public class EC2ApiMetadata>(getClass()) { - private static final long serialVersionUID = 1L; - }); + .wrapper(EC2ComputeServiceContext.class) + .defaultModules(ImmutableSet.>of(EC2RestClientModule.class, EC2ResolveImagesModule.class, EC2ComputeServiceContextModule.class)); } - - /** - * {@inheritDoc} - */ + @Override - @SuppressWarnings("rawtypes") - protected TypeToken contextToken(TypeToken clientToken, TypeToken asyncClientToken) { - return new TypeToken>() { - private static final long serialVersionUID = 1L; - }.where(new TypeParameter() { - }, clientToken).where(new TypeParameter() { - }, asyncClientToken); + public ApiMetadata build() { + return new EC2ApiMetadata(this); } - @SuppressWarnings({ "rawtypes", "unchecked" }) + @Override - public M build() { - return (M) new EC2ApiMetadata(this); - } - - @Override - public Builder fromApiMetadata(M in) { + public Builder fromApiMetadata(ApiMetadata in) { super.fromApiMetadata(in); return this; } diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/EC2ContextBuilder.java b/apis/ec2/src/main/java/org/jclouds/ec2/EC2ContextBuilder.java deleted file mode 100644 index 4836d97f87..0000000000 --- a/apis/ec2/src/main/java/org/jclouds/ec2/EC2ContextBuilder.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * 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.ec2; - -import java.util.List; - -import org.jclouds.compute.ComputeServiceContextBuilder; -import org.jclouds.ec2.compute.EC2ComputeServiceContext; -import org.jclouds.ec2.compute.config.EC2ComputeServiceContextModule; -import org.jclouds.ec2.compute.config.EC2ResolveImagesModule; -import org.jclouds.ec2.config.EC2RestClientModule; -import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; -import org.jclouds.logging.jdk.config.JDKLoggingModule; -import org.jclouds.providers.ProviderMetadata; - -import com.google.inject.Injector; -import com.google.inject.Module; - -/** - * Creates {@link EC2ComputeServiceContext} or {@link Injector} instances based - * on the most commonly requested arguments. - *

- * Note that Threadsafe objects will be bound as singletons to the Injector or - * Context provided. - *

- *

- * If no Modules are specified, the default - * {@link JDKLoggingModule logging} and - * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be - * installed. - * - * @author Adrian Cole - * @see EC2ComputeServiceContext - */ -public class EC2ContextBuilder, M extends EC2ApiMetadata> - extends ComputeServiceContextBuilder { - - public EC2ContextBuilder(ProviderMetadata providerMetadata) { - super(providerMetadata); - } - - public EC2ContextBuilder(M apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new EC2ComputeServiceContextModule()); - } - - @Override - protected void addClientModule(List modules) { - modules.add(new EC2RestClientModule(apiMetadata.getApi(), apiMetadata.getAsyncApi(), - EC2RestClientModule.DELEGATE_MAP)); - } - - @Override - protected void addImageResolutionModule() { - modules.add(new EC2ResolveImagesModule()); - } -} diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/EC2ComputeService.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/EC2ComputeService.java index be5f90d46f..3ea04e1638 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/EC2ComputeService.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/EC2ComputeService.java @@ -87,7 +87,7 @@ public class EC2ComputeService extends BaseComputeService { private final LoadingCache securityGroupMap; @Inject - protected EC2ComputeService(@SuppressWarnings("rawtypes") ComputeServiceContext context, Map credentialStore, + protected EC2ComputeService(ComputeServiceContext context, Map credentialStore, @Memoized Supplier> images, @Memoized Supplier> sizes, @Memoized Supplier> locations, ListNodesStrategy listNodesStrategy, GetNodeMetadataStrategy getNodeMetadataStrategy, CreateNodesInGroupThenAddToSet runNodesAndAddToSetStrategy, diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/EC2ComputeServiceContext.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/EC2ComputeServiceContext.java index 255d4dd868..606c8b7ceb 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/EC2ComputeServiceContext.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/EC2ComputeServiceContext.java @@ -19,8 +19,6 @@ package org.jclouds.ec2.compute; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.ec2.EC2AsyncClient; -import org.jclouds.ec2.EC2Client; import org.jclouds.ec2.compute.internal.EC2ComputeServiceContextImpl; import com.google.inject.ImplementedBy; @@ -29,7 +27,7 @@ import com.google.inject.ImplementedBy; * @author Adrian Cole */ @ImplementedBy(EC2ComputeServiceContextImpl.class) -public interface EC2ComputeServiceContext extends ComputeServiceContext { +public interface EC2ComputeServiceContext extends ComputeServiceContext { @Override EC2ComputeService getComputeService(); diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/config/EC2ComputeServiceDependenciesModule.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/config/EC2ComputeServiceDependenciesModule.java index 9055515736..f82fa97ec4 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/config/EC2ComputeServiceDependenciesModule.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/config/EC2ComputeServiceDependenciesModule.java @@ -29,16 +29,12 @@ import javax.inject.Named; import javax.inject.Singleton; import org.jclouds.compute.ComputeService; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.domain.TemplateBuilder; -import org.jclouds.compute.internal.ComputeServiceContextImpl; import org.jclouds.compute.options.TemplateOptions; import org.jclouds.domain.Credentials; -import org.jclouds.ec2.EC2AsyncClient; -import org.jclouds.ec2.EC2Client; import org.jclouds.ec2.compute.EC2ComputeService; import org.jclouds.ec2.compute.domain.RegionAndName; import org.jclouds.ec2.compute.functions.AddElasticIpsToNodemetadata; @@ -70,7 +66,6 @@ import com.google.common.collect.Maps; import com.google.inject.AbstractModule; import com.google.inject.Injector; import com.google.inject.Provides; -import com.google.inject.Scopes; import com.google.inject.TypeLiteral; import com.google.inject.name.Names; @@ -93,7 +88,6 @@ public class EC2ComputeServiceDependenciesModule extends AbstractModule { return instanceToNodeState; } - @SuppressWarnings("rawtypes") @Override protected void configure() { bind(TemplateBuilder.class).to(EC2TemplateBuilderImpl.class); @@ -109,9 +103,6 @@ public class EC2ComputeServiceDependenciesModule extends AbstractModule { }).annotatedWith(Names.named("SECURITY")).to(CreateSecurityGroupIfNeeded.class); bind(new TypeLiteral>() { }).annotatedWith(Names.named("ELASTICIP")).to(LoadPublicIpForInstanceOrNull.class); - bind(new TypeLiteral() { - }).to(new TypeLiteral>() { - }).in(Scopes.SINGLETON); bind(WindowsLoginCredentialsFromEncryptedData.class); } diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/internal/EC2ComputeServiceContextImpl.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/internal/EC2ComputeServiceContextImpl.java index 1d55021e64..b63728b8b1 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/internal/EC2ComputeServiceContextImpl.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/internal/EC2ComputeServiceContextImpl.java @@ -18,6 +18,7 @@ */ package org.jclouds.ec2.compute.internal; +import java.io.Closeable; import java.util.Map; import javax.inject.Inject; @@ -26,22 +27,21 @@ import javax.inject.Singleton; import org.jclouds.compute.Utils; import org.jclouds.compute.internal.ComputeServiceContextImpl; import org.jclouds.domain.Credentials; -import org.jclouds.ec2.EC2AsyncClient; -import org.jclouds.ec2.EC2Client; import org.jclouds.ec2.compute.EC2ComputeService; import org.jclouds.ec2.compute.EC2ComputeServiceContext; -import org.jclouds.rest.RestContext; +import org.jclouds.location.Provider; + +import com.google.common.reflect.TypeToken; /** * @author Adrian Cole */ @Singleton -public class EC2ComputeServiceContextImpl extends - ComputeServiceContextImpl implements EC2ComputeServiceContext { +public class EC2ComputeServiceContextImpl extends ComputeServiceContextImpl implements EC2ComputeServiceContext { @Inject - public EC2ComputeServiceContextImpl(EC2ComputeService computeService, Map credentialStore, - Utils utils, @SuppressWarnings("rawtypes") RestContext providerSpecificContext) { - super(computeService, credentialStore, utils, providerSpecificContext); + public EC2ComputeServiceContextImpl(@Provider Closeable wrapped, @Provider TypeToken wrappedType, + EC2ComputeService computeService, Map credentialStore, Utils utils){ + super(wrapped, wrappedType, computeService, credentialStore, utils); } @Override diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/config/EC2RestClientModule.java b/apis/ec2/src/main/java/org/jclouds/ec2/config/EC2RestClientModule.java index e9d1862270..aad33fa08f 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/config/EC2RestClientModule.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/config/EC2RestClientModule.java @@ -41,7 +41,6 @@ import org.jclouds.ec2.services.WindowsAsyncClient; import org.jclouds.ec2.services.WindowsClient; import org.jclouds.ec2.suppliers.DescribeAvailabilityZonesInRegion; import org.jclouds.ec2.suppliers.DescribeRegionsForConfiguredRegions; -import org.jclouds.http.RequiresHttp; import org.jclouds.location.config.LocationModule; import org.jclouds.location.suppliers.RegionIdToURISupplier; import org.jclouds.location.suppliers.RegionIdToZoneIdsSupplier; @@ -57,7 +56,6 @@ import com.google.inject.Scopes; * * @author Adrian Cole (EDIT: Nick Terry nterry@familysearch.org) */ -@RequiresHttp @ConfiguresRestClient public class EC2RestClientModule extends WithZonesFormSigningRestClientModule { @@ -73,6 +71,11 @@ public class EC2RestClientModule .put(ElasticBlockStoreClient.class, ElasticBlockStoreAsyncClient.class)// .build(); + @SuppressWarnings("unchecked") + public EC2RestClientModule() { + this((Class) EC2Client.class, (Class) EC2AsyncClient.class, DELEGATE_MAP); + } + public EC2RestClientModule(Class sync, Class async, Map, Class> delegateMap) { super(sync, async, delegateMap); } diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/CloudApplicationArchitecturesEC2ClientLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/CloudApplicationArchitecturesEC2ClientLiveTest.java index 8efc145d76..1993e42c3a 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/CloudApplicationArchitecturesEC2ClientLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/CloudApplicationArchitecturesEC2ClientLiveTest.java @@ -36,9 +36,7 @@ import org.jclouds.aws.AWSResponseException; import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.domain.LoginCredentials; -import org.jclouds.ec2.compute.EC2ComputeServiceContext; import org.jclouds.ec2.domain.BlockDevice; -import org.jclouds.ec2.domain.Image.EbsBlockDevice; import org.jclouds.ec2.domain.InstanceState; import org.jclouds.ec2.domain.InstanceType; import org.jclouds.ec2.domain.IpProtocol; @@ -46,6 +44,7 @@ import org.jclouds.ec2.domain.KeyPair; import org.jclouds.ec2.domain.PublicIpInstanceIdPair; import org.jclouds.ec2.domain.Reservation; import org.jclouds.ec2.domain.RunningInstance; +import org.jclouds.ec2.domain.Image.EbsBlockDevice; import org.jclouds.ec2.domain.Volume.InstanceInitiatedShutdownBehavior; import org.jclouds.ec2.predicates.InstanceHasIpAddress; import org.jclouds.ec2.predicates.InstanceStateRunning; @@ -76,7 +75,7 @@ import com.google.inject.Injector; * @author Adrian Cole */ @Test(groups = "live", enabled = false, singleThreaded = true, testName = "CloudApplicationArchitecturesEC2ClientLiveTest") -public class CloudApplicationArchitecturesEC2ClientLiveTest> extends BaseComputeServiceContextLiveTest { +public class CloudApplicationArchitecturesEC2ClientLiveTest extends BaseComputeServiceContextLiveTest { public CloudApplicationArchitecturesEC2ClientLiveTest() { provider = "ec2"; } diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/EBSBootEC2ClientLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/EBSBootEC2ClientLiveTest.java index c51173f3d0..87c75162a6 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/EBSBootEC2ClientLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/EBSBootEC2ClientLiveTest.java @@ -36,12 +36,9 @@ import org.jclouds.aws.AWSResponseException; import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.domain.LoginCredentials; -import org.jclouds.ec2.compute.EC2ComputeServiceContext; import org.jclouds.ec2.domain.Attachment; import org.jclouds.ec2.domain.BlockDevice; import org.jclouds.ec2.domain.Image; -import org.jclouds.ec2.domain.Image.Architecture; -import org.jclouds.ec2.domain.Image.ImageType; import org.jclouds.ec2.domain.InstanceState; import org.jclouds.ec2.domain.InstanceType; import org.jclouds.ec2.domain.IpProtocol; @@ -51,6 +48,8 @@ import org.jclouds.ec2.domain.RootDeviceType; import org.jclouds.ec2.domain.RunningInstance; import org.jclouds.ec2.domain.Snapshot; import org.jclouds.ec2.domain.Volume; +import org.jclouds.ec2.domain.Image.Architecture; +import org.jclouds.ec2.domain.Image.ImageType; import org.jclouds.ec2.domain.Volume.InstanceInitiatedShutdownBehavior; import org.jclouds.ec2.predicates.InstanceStateRunning; import org.jclouds.ec2.predicates.InstanceStateStopped; @@ -89,7 +88,7 @@ import com.google.inject.Injector; * @author Adrian Cole */ @Test(groups = "live", enabled = false, singleThreaded = true, testName = "EBSBootEC2ClientLiveTest") -public class EBSBootEC2ClientLiveTest> extends BaseComputeServiceContextLiveTest { +public class EBSBootEC2ClientLiveTest extends BaseComputeServiceContextLiveTest { public EBSBootEC2ClientLiveTest() { provider = "ec2"; } diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/EC2ApiMetadataTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/EC2ApiMetadataTest.java index 74478bf7b0..35f5e82578 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/EC2ApiMetadataTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/EC2ApiMetadataTest.java @@ -25,7 +25,6 @@ import org.testng.annotations.Test; * * @author Adrian Cole */ -@SuppressWarnings("rawtypes") @Test(groups = "unit", testName = "EC2ApiMetadataTest") public class EC2ApiMetadataTest extends BaseComputeServiceApiMetadataTest { diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceLiveTest.java index 41d53a20fd..500a0b0786 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceLiveTest.java @@ -37,7 +37,7 @@ import org.jclouds.compute.predicates.NodePredicates; import org.jclouds.domain.Location; import org.jclouds.domain.LocationScope; import org.jclouds.domain.LoginCredentials; -import org.jclouds.ec2.EC2AsyncClient; +import org.jclouds.ec2.EC2ApiMetadata; import org.jclouds.ec2.EC2Client; import org.jclouds.ec2.compute.options.EC2TemplateOptions; import org.jclouds.ec2.domain.BlockDevice; @@ -72,7 +72,7 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true) -public class EC2ComputeServiceLiveTest> extends BaseComputeServiceLiveTest { +public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest { public EC2ComputeServiceLiveTest() { provider = "ec2"; @@ -102,13 +102,13 @@ public class EC2ComputeServiceLiveTest context = null; + ComputeServiceContext context = null; String group = this.group + "aip"; try { Properties overrides = setupProperties(); @@ -202,7 +202,7 @@ public class EC2ComputeServiceLiveTest ipidpairs = ec2.getElasticIPAddressServices().describeAddressesInRegion(region, publicIps.toArray(new String[0])); assertEquals(ipidpairs.size(), 1, String.format("there should only be one address pair (%s)", @@ -233,10 +233,10 @@ public class EC2ComputeServiceLiveTest> extends BaseTemplateBuilderLiveTest { +public abstract class EC2TemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { @Test public void testTemplateBuilderCanUseImageIdWithoutFetchingAllImages() throws Exception { @@ -56,7 +54,7 @@ public abstract class EC2TemplateBuilderLiveTest context = null; + ComputeServiceContext context = null; try { // Track http commands final List commandsInvoked = Lists.newArrayList(); diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/compute/TestCanRecreateGroupLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/compute/TestCanRecreateGroupLiveTest.java index c0dbdb145f..fc7ca34a97 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/compute/TestCanRecreateGroupLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/compute/TestCanRecreateGroupLiveTest.java @@ -22,8 +22,6 @@ import org.jclouds.compute.RunNodesException; import org.jclouds.compute.domain.Template; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.compute.predicates.NodePredicates; -import org.jclouds.ec2.EC2AsyncClient; -import org.jclouds.ec2.EC2Client; import org.testng.annotations.Test; import com.google.common.base.Throwables; @@ -33,7 +31,7 @@ import com.google.common.base.Throwables; * @author Adrian Cole */ @Test(groups = "live", testName="TestCanRecreateGroupLiveTest") -public class TestCanRecreateGroupLiveTest> extends BaseComputeServiceContextLiveTest { +public class TestCanRecreateGroupLiveTest extends BaseComputeServiceContextLiveTest { public TestCanRecreateGroupLiveTest() { provider = "ec2"; } diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/AvailabilityZoneAndRegionClientLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/services/AvailabilityZoneAndRegionClientLiveTest.java index dff51b3b23..80dbaf4d1c 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/AvailabilityZoneAndRegionClientLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/services/AvailabilityZoneAndRegionClientLiveTest.java @@ -25,15 +25,13 @@ import static org.testng.Assert.assertNotNull; import java.net.URI; import java.util.Iterator; -import java.util.Map.Entry; import java.util.Set; import java.util.SortedMap; +import java.util.Map.Entry; import org.jclouds.aws.domain.Region; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; -import org.jclouds.ec2.EC2AsyncClient; -import org.jclouds.ec2.EC2Client; -import org.jclouds.ec2.compute.EC2ComputeServiceContext; +import org.jclouds.ec2.EC2ApiMetadata; import org.jclouds.ec2.domain.AvailabilityZoneInfo; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -47,7 +45,7 @@ import com.google.common.collect.Maps; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "AvailabilityZoneAndRegionClientLiveTest") -public class AvailabilityZoneAndRegionClientLiveTest> extends BaseComputeServiceContextLiveTest { +public class AvailabilityZoneAndRegionClientLiveTest extends BaseComputeServiceContextLiveTest { public AvailabilityZoneAndRegionClientLiveTest() { provider = "ec2"; } @@ -58,7 +56,7 @@ public class AvailabilityZoneAndRegionClientLiveTest extends BaseAsyncClientTest { - @RequiresHttp - @ConfiguresRestClient + @ConfiguresRestClient protected static class StubEC2RestClientModule extends EC2RestClientModule { public StubEC2RestClientModule() { @@ -143,9 +141,8 @@ public abstract class BaseEC2AsyncClientTest extends BaseAsyncClientTest { return new StubEC2RestClientModule(); } - @SuppressWarnings("rawtypes") @Override - protected ApiMetadata createApiMetadata() { + protected ApiMetadata createApiMetadata() { return new EC2ApiMetadata(); } } diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticBlockStoreClientLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticBlockStoreClientLiveTest.java index 6871c9cc7c..4fd9676cec 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticBlockStoreClientLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticBlockStoreClientLiveTest.java @@ -28,9 +28,7 @@ import java.util.concurrent.TimeUnit; import org.jclouds.aws.domain.Region; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; -import org.jclouds.ec2.EC2AsyncClient; -import org.jclouds.ec2.EC2Client; -import org.jclouds.ec2.compute.EC2ComputeServiceContext; +import org.jclouds.ec2.EC2ApiMetadata; import org.jclouds.ec2.domain.Snapshot; import org.jclouds.ec2.domain.Volume; import org.jclouds.ec2.predicates.SnapshotCompleted; @@ -50,7 +48,7 @@ import com.google.common.collect.Sets; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "ElasticBlockStoreClientLiveTest") -public class ElasticBlockStoreClientLiveTest> extends BaseComputeServiceContextLiveTest { +public class ElasticBlockStoreClientLiveTest extends BaseComputeServiceContextLiveTest { public ElasticBlockStoreClientLiveTest() { provider = "ec2"; } @@ -63,12 +61,12 @@ public class ElasticBlockStoreClientLiveTest allResults = Sets.newTreeSet(client.describeVolumesInRegion(region)); assertNotNull(allResults); if (allResults.size() >= 1) { diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticIPAddressClientLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticIPAddressClientLiveTest.java index a1de5fc423..83bb5c4503 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticIPAddressClientLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticIPAddressClientLiveTest.java @@ -25,9 +25,7 @@ import java.util.SortedSet; import org.jclouds.aws.domain.Region; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; -import org.jclouds.ec2.EC2AsyncClient; -import org.jclouds.ec2.EC2Client; -import org.jclouds.ec2.compute.EC2ComputeServiceContext; +import org.jclouds.ec2.EC2ApiMetadata; import org.jclouds.ec2.domain.PublicIpInstanceIdPair; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -41,7 +39,7 @@ import com.google.common.collect.Sets; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "ElasticIPAddressClientLiveTest") -public class ElasticIPAddressClientLiveTest> extends BaseComputeServiceContextLiveTest { +public class ElasticIPAddressClientLiveTest extends BaseComputeServiceContextLiveTest { public ElasticIPAddressClientLiveTest() { provider = "ec2"; } @@ -52,7 +50,7 @@ public class ElasticIPAddressClientLiveTest> extends BaseComputeServiceContextLiveTest { +public class InstanceClientLiveTest extends BaseComputeServiceContextLiveTest { public InstanceClientLiveTest() { provider = "ec2"; } @@ -51,7 +49,7 @@ public class InstanceClientLiveTest> extends BaseComputeServiceContextLiveTest { +public class KeyPairClientLiveTest extends BaseComputeServiceContextLiveTest { public KeyPairClientLiveTest() { provider = "ec2"; } @@ -53,7 +51,7 @@ public class KeyPairClientLiveTest> extends BaseComputeServiceContextLiveTest { +public class SecurityGroupClientLiveTest extends BaseComputeServiceContextLiveTest { public SecurityGroupClientLiveTest() { provider = "ec2"; } @@ -62,7 +60,7 @@ public class SecurityGroupClientLiveTest> extends BaseComputeServiceContextLiveTest { +public class WindowsClientLiveTest extends BaseComputeServiceContextLiveTest { public WindowsClientLiveTest() { provider = "ec2"; } @@ -78,7 +76,7 @@ public class WindowsClientLiveTest, ElasticStackApiMetadata> { +public class ElasticStackApiMetadata extends BaseRestApiMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 6725672099385580694L; + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; + @Override public Builder toBuilder() { return new Builder().fromApiMetadata(this); @@ -51,8 +61,8 @@ public class ElasticStackApiMetadata super(builder); } - protected static Properties defaultProperties() { - Properties properties = BaseComputeServiceApiMetadata.Builder.defaultProperties(); + public static Properties defaultProperties() { + Properties properties = BaseRestApiMetadata.defaultProperties(); properties.setProperty(PROPERTY_VNC_PASSWORD, "IL9vs34d"); // passwords are set post-boot, so auth failures are possible // from a race condition applying the password set script @@ -63,9 +73,10 @@ public class ElasticStackApiMetadata public static class Builder extends - BaseComputeServiceApiMetadata.Builder, ElasticStackApiMetadata> { + BaseRestApiMetadata.Builder { protected Builder() { + super(ElasticStackClient.class, ElasticStackAsyncClient.class); id("elasticstack") .name("ElasticStack API") .identityName("UUID") @@ -74,8 +85,8 @@ public class ElasticStackApiMetadata .version("1.0") .defaultEndpoint("https://api.lon-p.elastichosts.com") .defaultProperties(ElasticStackApiMetadata.defaultProperties()) - .javaApi(ElasticStackClient.class, ElasticStackAsyncClient.class) - .contextBuilder(TypeToken.of(ElasticStackContextBuilder.class)); + .wrapper(TypeToken.of(ComputeServiceContext.class)) + .defaultModules(ImmutableSet.>of(ElasticStackRestClientModule.class, ElasticStackComputeServiceContextModule.class)); } @Override @@ -84,7 +95,7 @@ public class ElasticStackApiMetadata } @Override - public Builder fromApiMetadata(ElasticStackApiMetadata in) { + public Builder fromApiMetadata(ApiMetadata in) { super.fromApiMetadata(in); return this; } diff --git a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/ElasticStackContextBuilder.java b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/ElasticStackContextBuilder.java deleted file mode 100644 index 63b5f65cb5..0000000000 --- a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/ElasticStackContextBuilder.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * 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.elasticstack; - -import java.util.List; - -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextBuilder; -import org.jclouds.elasticstack.compute.config.ElasticStackComputeServiceContextModule; -import org.jclouds.elasticstack.config.ElasticStackRestClientModule; -import org.jclouds.providers.ProviderMetadata; - -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class ElasticStackContextBuilder - extends - ComputeServiceContextBuilder, ElasticStackApiMetadata> { - - public ElasticStackContextBuilder( - ProviderMetadata, ElasticStackApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public ElasticStackContextBuilder(ElasticStackApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new ElasticStackComputeServiceContextModule()); - } - - protected void addClientModule(List modules) { - modules.add(new ElasticStackRestClientModule()); - } - -} diff --git a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/config/ElasticStackComputeServiceContextModule.java b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/config/ElasticStackComputeServiceContextModule.java index d98a4c388c..e38b10138b 100644 --- a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/config/ElasticStackComputeServiceContextModule.java +++ b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/config/ElasticStackComputeServiceContextModule.java @@ -34,14 +34,13 @@ import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.Volume; import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.domain.Location; -import org.jclouds.elasticstack.ElasticStackAsyncClient; import org.jclouds.elasticstack.ElasticStackClient; import org.jclouds.elasticstack.compute.ElasticStackComputeServiceAdapter; import org.jclouds.elasticstack.compute.functions.ServerInfoToNodeMetadata; +import org.jclouds.elasticstack.compute.functions.WellKnownImageToImage; import org.jclouds.elasticstack.compute.functions.ServerInfoToNodeMetadata.DeviceToVolume; import org.jclouds.elasticstack.compute.functions.ServerInfoToNodeMetadata.FindImageForId; import org.jclouds.elasticstack.compute.functions.ServerInfoToNodeMetadata.GetImageIdFromServer; -import org.jclouds.elasticstack.compute.functions.WellKnownImageToImage; import org.jclouds.elasticstack.domain.Device; import org.jclouds.elasticstack.domain.DriveInfo; import org.jclouds.elasticstack.domain.Server; @@ -68,13 +67,8 @@ import com.google.inject.TypeLiteral; * * @author Adrian Cole */ -public class ElasticStackComputeServiceContextModule - extends - ComputeServiceAdapterContextModule { - - public ElasticStackComputeServiceContextModule() { - super(ElasticStackClient.class, ElasticStackAsyncClient.class); - } +public class ElasticStackComputeServiceContextModule extends + ComputeServiceAdapterContextModule { @SuppressWarnings( { "unchecked", "rawtypes" }) @Override diff --git a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/config/ElasticStackRestClientModule.java b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/config/ElasticStackRestClientModule.java index c0c0cc2b42..93781f3be8 100644 --- a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/config/ElasticStackRestClientModule.java +++ b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/config/ElasticStackRestClientModule.java @@ -33,14 +33,13 @@ import org.jclouds.elasticstack.domain.ServerMetrics; import org.jclouds.elasticstack.functions.CreateDriveRequestToMap; import org.jclouds.elasticstack.functions.DriveDataToMap; import org.jclouds.elasticstack.functions.MapToDevices; -import org.jclouds.elasticstack.functions.MapToDevices.DeviceToId; import org.jclouds.elasticstack.functions.MapToDriveMetrics; import org.jclouds.elasticstack.functions.MapToNICs; import org.jclouds.elasticstack.functions.MapToServerMetrics; import org.jclouds.elasticstack.functions.ServerToMap; +import org.jclouds.elasticstack.functions.MapToDevices.DeviceToId; import org.jclouds.elasticstack.handlers.ElasticStackErrorHandler; import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.ServerError; @@ -55,7 +54,6 @@ import com.google.inject.TypeLiteral; * * @author Adrian Cole */ -@RequiresHttp @ConfiguresRestClient public class ElasticStackRestClientModule extends RestClientModule { diff --git a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/functions/MapToDevices.java b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/functions/MapToDevices.java index 9df5195ae8..6d0a5875ea 100644 --- a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/functions/MapToDevices.java +++ b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/functions/MapToDevices.java @@ -31,8 +31,8 @@ import org.jclouds.elasticstack.domain.SCSIDevice; import com.google.common.base.Function; import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSet.Builder; import com.google.common.collect.Maps; +import com.google.common.collect.ImmutableSet.Builder; /** * diff --git a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackAsyncClientTest.java b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackAsyncClientTest.java index 37dccdfe18..37d82bae9f 100644 --- a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackAsyncClientTest.java +++ b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackAsyncClientTest.java @@ -453,7 +453,7 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest createApiMetadata() { + protected ApiMetadata createApiMetadata() { return new ElasticStackApiMetadata(); } diff --git a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackClientLiveTest.java b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackClientLiveTest.java index 3a199e02b5..0eb8854bf1 100644 --- a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackClientLiveTest.java +++ b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackClientLiveTest.java @@ -26,7 +26,6 @@ import java.util.Set; import java.util.concurrent.TimeUnit; import java.util.logging.Logger; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.domain.LoginCredentials; @@ -71,7 +70,7 @@ import com.google.inject.Guice; @Test(groups = "live", singleThreaded = true, testName = "ElasticStackClientLiveTest") public class ElasticStackClientLiveTest extends - BaseComputeServiceContextLiveTest> { + BaseComputeServiceContextLiveTest { public ElasticStackClientLiveTest() { provider = "elasticstack"; @@ -89,7 +88,7 @@ public class ElasticStackClientLiveTest @Override public void setupContext() { super.setupContext(); - cloudStackContext = context.getProviderSpecificContext(); + cloudStackContext = context.unwrap(); client = cloudStackContext.getApi(); driveNotClaimed = new RetryablePredicate(Predicates.not(new DriveClaimed(client)), maxDriveImageTime, diff --git a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/compute/ElasticStackComputeServiceLiveTest.java b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/compute/ElasticStackComputeServiceLiveTest.java index 6f4e93ebae..98af64bd1c 100644 --- a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/compute/ElasticStackComputeServiceLiveTest.java +++ b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/compute/ElasticStackComputeServiceLiveTest.java @@ -18,12 +18,9 @@ */ package org.jclouds.elasticstack.compute; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.internal.BaseComputeServiceLiveTest; -import org.jclouds.elasticstack.ElasticStackAsyncClient; -import org.jclouds.elasticstack.ElasticStackClient; import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.Test; @@ -34,9 +31,7 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live") -public class ElasticStackComputeServiceLiveTest - extends - BaseComputeServiceLiveTest> { +public class ElasticStackComputeServiceLiveTest extends BaseComputeServiceLiveTest { public ElasticStackComputeServiceLiveTest() { provider = "elasticstack"; diff --git a/apis/eucalyptus/src/main/java/org/jclouds/eucalyptus/EucalyptusApiMetadata.java b/apis/eucalyptus/src/main/java/org/jclouds/eucalyptus/EucalyptusApiMetadata.java index 0297ea0b50..80855d365b 100644 --- a/apis/eucalyptus/src/main/java/org/jclouds/eucalyptus/EucalyptusApiMetadata.java +++ b/apis/eucalyptus/src/main/java/org/jclouds/eucalyptus/EucalyptusApiMetadata.java @@ -28,14 +28,16 @@ import org.jclouds.apis.ApiMetadata; import org.jclouds.ec2.EC2ApiMetadata; import org.jclouds.ec2.EC2AsyncClient; import org.jclouds.ec2.EC2Client; -import org.jclouds.ec2.compute.EC2ComputeServiceContext; /** * Implementation of {@link ApiMetadata} for the Eucalyptus (EC2 clone) api. * * @author Adrian Cole */ -public class EucalyptusApiMetadata extends EC2ApiMetadata, EucalyptusApiMetadata> { +public class EucalyptusApiMetadata extends EC2ApiMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = 3060225665040763827L; + private static Builder builder() { return new Builder(); } @@ -53,7 +55,7 @@ public class EucalyptusApiMetadata extends EC2ApiMetadata, EucalyptusApiMetadata> { + public static class Builder extends EC2ApiMetadata.Builder { protected Builder(){ super(EC2Client.class, EC2AsyncClient.class); id("eucalyptus") @@ -76,7 +78,7 @@ public class EucalyptusApiMetadata extends EC2ApiMetadata> { +public class EucalyptusComputeServiceLiveTest extends EC2ComputeServiceLiveTest { public EucalyptusComputeServiceLiveTest() { provider = "eucalyptus"; diff --git a/apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemApiMetadata.java b/apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemApiMetadata.java index 91595c3389..3ea463e4f9 100644 --- a/apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemApiMetadata.java +++ b/apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemApiMetadata.java @@ -18,27 +18,22 @@ */ package org.jclouds.filesystem; -import static org.jclouds.Constants.PROPERTY_IO_WORKER_THREADS; -import static org.jclouds.Constants.PROPERTY_USER_THREADS; - import java.net.URI; import org.jclouds.apis.ApiMetadata; -import org.jclouds.blobstore.BlobStore; +import org.jclouds.apis.internal.BaseApiMetadata; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.internal.BaseBlobStoreApiMetadata; - -import com.google.common.collect.ImmutableMap; -import com.google.common.reflect.TypeToken; +import org.jclouds.filesystem.config.FilesystemBlobStoreContextModule; /** * Implementation of {@link ApiMetadata} for jclouds Filesystem-based BlobStore * * @author Adrian Cole */ -public class FilesystemApiMetadata - extends - BaseBlobStoreApiMetadata, FilesystemApiMetadata> { +public class FilesystemApiMetadata extends BaseApiMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = -2625620001657309404L; public static Builder builder() { return new Builder(); @@ -57,24 +52,19 @@ public class FilesystemApiMetadata super(builder); } -public static class Builder extends - BaseBlobStoreApiMetadata.Builder, FilesystemApiMetadata> { + public static class Builder extends BaseApiMetadata.Builder { protected Builder() { id("filesystem") .name("Filesystem-based BlobStore") .identityName("Unused") - .contextBuilder(TypeToken.of(FilesystemBlobStoreContextBuilder.class)) - .javaApi(BlobStore.class, FilesystemAsyncBlobStore.class) - .identityName("Unused") .defaultEndpoint("http://localhost/transient") .defaultIdentity(System.getProperty("user.name")) .defaultCredential("bar") .version("1") - .defaultProperties( - BaseBlobStoreApiMetadata.Builder.defaultPropertiesAnd(ImmutableMap.of(PROPERTY_USER_THREADS, "0", - PROPERTY_IO_WORKER_THREADS, "0"))) - .documentation(URI.create("http://www.jclouds.org/documentation/userguide/blobstore-guide")); + .documentation(URI.create("http://www.jclouds.org/documentation/userguide/blobstore-guide")) + .wrapper(BlobStoreContext.class) + .defaultModule(FilesystemBlobStoreContextModule.class); } @Override diff --git a/apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemAsyncBlobStore.java b/apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemAsyncBlobStore.java index 6b9013fb76..7c828ec7ff 100644 --- a/apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemAsyncBlobStore.java +++ b/apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemAsyncBlobStore.java @@ -48,10 +48,10 @@ import java.util.Collection; import java.util.Date; import java.util.List; import java.util.Map; -import java.util.Map.Entry; import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; +import java.util.Map.Entry; import java.util.concurrent.ExecutorService; import javax.annotation.Resource; @@ -126,7 +126,7 @@ public class FilesystemAsyncBlobStore extends BaseAsyncBlobStore { protected final FilesystemStorageStrategy storageStrategy; @Inject - protected FilesystemAsyncBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, DateService dateService, Crypto crypto, + protected FilesystemAsyncBlobStore(BlobStoreContext context, DateService dateService, Crypto crypto, HttpGetOptionsListToGetOptions httpGetOptionsConverter, IfDirectoryReturnNameStrategy ifDirectoryReturnName, BlobUtils blobUtils, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService service, Supplier defaultLocation, @Memoized Supplier> locations, diff --git a/apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemBlobStoreContextBuilder.java b/apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemBlobStoreContextBuilder.java deleted file mode 100644 index eb5cd39033..0000000000 --- a/apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemBlobStoreContextBuilder.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * 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.filesystem; - -import java.util.List; - -import org.jclouds.blobstore.BlobStore; -import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextBuilder; -import org.jclouds.filesystem.config.FilesystemBlobStoreContextModule; -import org.jclouds.filesystem.config.FilesystemBlobStoreModule; -import org.jclouds.providers.ProviderMetadata; - -import com.google.inject.Module; - -/** - * - * @author Alfredo "Rainbowbreeze" Morresi - */ -public class FilesystemBlobStoreContextBuilder - extends - BlobStoreContextBuilder, FilesystemApiMetadata> { - - public FilesystemBlobStoreContextBuilder( - ProviderMetadata, FilesystemApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public FilesystemBlobStoreContextBuilder(FilesystemApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - public void addContextModule(List modules) { - modules.add(new FilesystemBlobStoreContextModule()); - } - - @Override - protected void addClientModule(List modules) { - modules.add(new FilesystemBlobStoreModule()); - } - -} diff --git a/apis/filesystem/src/main/java/org/jclouds/filesystem/config/FilesystemBlobStoreContextModule.java b/apis/filesystem/src/main/java/org/jclouds/filesystem/config/FilesystemBlobStoreContextModule.java index 8223e1280b..4560bd5156 100644 --- a/apis/filesystem/src/main/java/org/jclouds/filesystem/config/FilesystemBlobStoreContextModule.java +++ b/apis/filesystem/src/main/java/org/jclouds/filesystem/config/FilesystemBlobStoreContextModule.java @@ -21,13 +21,12 @@ package org.jclouds.filesystem.config; import org.jclouds.blobstore.AsyncBlobStore; import org.jclouds.blobstore.BlobRequestSigner; import org.jclouds.blobstore.BlobStore; -import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.blobstore.TransientBlobRequestSigner; import org.jclouds.blobstore.attr.ConsistencyModel; import org.jclouds.blobstore.config.BlobStoreMapModule; import org.jclouds.blobstore.config.BlobStoreObjectModule; -import org.jclouds.blobstore.internal.BlobStoreContextImpl; import org.jclouds.blobstore.util.BlobUtils; +import org.jclouds.filesystem.FilesystemAsyncBlobStore; import org.jclouds.filesystem.FilesystemBlobStore; import org.jclouds.filesystem.predicates.validators.FilesystemBlobKeyValidator; import org.jclouds.filesystem.predicates.validators.FilesystemContainerNameValidator; @@ -36,12 +35,10 @@ import org.jclouds.filesystem.predicates.validators.internal.FilesystemContainer import org.jclouds.filesystem.strategy.FilesystemStorageStrategy; import org.jclouds.filesystem.strategy.internal.FilesystemStorageStrategyImpl; import org.jclouds.filesystem.util.internal.FileSystemBlobUtilsImpl; +import org.jclouds.rest.config.BinderUtils; +import com.google.common.collect.ImmutableMap; import com.google.inject.AbstractModule; -import com.google.inject.Provides; -import com.google.inject.Scopes; -import com.google.inject.Singleton; -import com.google.inject.TypeLiteral; /** * @@ -49,12 +46,13 @@ import com.google.inject.TypeLiteral; */ public class FilesystemBlobStoreContextModule extends AbstractModule { - @SuppressWarnings("rawtypes") @Override protected void configure() { - bind(new TypeLiteral() { - }).to(new TypeLiteral>() { - }).in(Scopes.SINGLETON); + bind(AsyncBlobStore.class).to(FilesystemAsyncBlobStore.class).asEagerSingleton(); + // forward all requests from TransientBlobStore to TransientAsyncBlobStore. needs above binding as cannot proxy a class + BinderUtils.bindClient(binder(), FilesystemBlobStore.class, AsyncBlobStore.class, ImmutableMap., Class>of()); + bind(BlobStore.class).to(FilesystemBlobStore.class); + install(new BlobStoreObjectModule()); install(new BlobStoreMapModule()); bind(ConsistencyModel.class).toInstance(ConsistencyModel.STRICT); @@ -65,10 +63,4 @@ public class FilesystemBlobStoreContextModule extends AbstractModule { bind(BlobRequestSigner.class).to(TransientBlobRequestSigner.class); } - @Provides - @Singleton - BlobStore provide(FilesystemBlobStore in) { - return in; - } - } diff --git a/apis/filesystem/src/main/java/org/jclouds/filesystem/config/FilesystemBlobStoreModule.java b/apis/filesystem/src/main/java/org/jclouds/filesystem/config/FilesystemBlobStoreModule.java deleted file mode 100644 index f836d82ab0..0000000000 --- a/apis/filesystem/src/main/java/org/jclouds/filesystem/config/FilesystemBlobStoreModule.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * 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.filesystem.config; - -import org.jclouds.blobstore.AsyncBlobStore; -import org.jclouds.filesystem.FilesystemAsyncBlobStore; -import org.jclouds.filesystem.FilesystemBlobStore; -import org.jclouds.rest.config.RestClientModule; - -/** - * - * @author Alfredo "Rainbowbreeze" Morresi - */ -public class FilesystemBlobStoreModule extends RestClientModule { - - public FilesystemBlobStoreModule() { - super(FilesystemBlobStore.class, AsyncBlobStore.class); - } - - @Override - protected void configure() { - super.configure(); - } - - @Override - protected void bindAsyncClient() { - bind(AsyncBlobStore.class).to(FilesystemAsyncBlobStore.class).asEagerSingleton(); - } -} diff --git a/apis/filesystem/src/test/java/org/jclouds/filesystem/FilesystemAsyncBlobStoreTest.java b/apis/filesystem/src/test/java/org/jclouds/filesystem/FilesystemAsyncBlobStoreTest.java index 37907664e7..e9f6b3cbb5 100644 --- a/apis/filesystem/src/test/java/org/jclouds/filesystem/FilesystemAsyncBlobStoreTest.java +++ b/apis/filesystem/src/test/java/org/jclouds/filesystem/FilesystemAsyncBlobStoreTest.java @@ -40,10 +40,10 @@ import junit.framework.Assert; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; +import org.jclouds.ContextBuilder; import org.jclouds.blobstore.BlobRequestSigner; import org.jclouds.blobstore.BlobStore; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextBuilder; import org.jclouds.blobstore.ContainerNotFoundException; import org.jclouds.blobstore.domain.Blob; import org.jclouds.blobstore.domain.BlobMetadata; @@ -85,7 +85,7 @@ public class FilesystemAsyncBlobStoreTest { System.setProperty(LOGGING_CONFIG_KEY, LOGGING_CONFIG_VALUE); } - private BlobStoreContext context = null; + private BlobStoreContext context = null; private BlobStore blobStore = null; private Set resourcesToBeDeleted = new HashSet(); @@ -94,7 +94,7 @@ public class FilesystemAsyncBlobStoreTest { // create context for filesystem container Properties prop = new Properties(); prop.setProperty(FilesystemConstants.PROPERTY_BASEDIR, TestUtils.TARGET_BASE_DIR); - context = BlobStoreContextBuilder.newBuilder(PROVIDER).overrides(prop).build(); + context = ContextBuilder.newBuilder(PROVIDER).overrides(prop).build(BlobStoreContext.class); // create a container in the default location blobStore = context.getBlobStore(); @@ -131,7 +131,7 @@ public class FilesystemAsyncBlobStoreTest { // no base directory declared in properties try { Properties props = new Properties(); - context = BlobStoreContextBuilder.newBuilder(PROVIDER).overrides(props).build(); + context = ContextBuilder.newBuilder(PROVIDER).overrides(props).build(); fail("No error if base directory is not specified"); } catch (CreationException e) { } @@ -140,7 +140,7 @@ public class FilesystemAsyncBlobStoreTest { try { Properties props = new Properties(); props.setProperty(FilesystemConstants.PROPERTY_BASEDIR, null); - context = BlobStoreContextBuilder.newBuilder(PROVIDER).overrides(props).build(); + context = ContextBuilder.newBuilder(PROVIDER).overrides(props).build(); fail("No error if base directory is null in the option"); } catch (NullPointerException e) { } diff --git a/apis/nova/src/main/java/org/jclouds/openstack/nova/NovaApiMetadata.java b/apis/nova/src/main/java/org/jclouds/openstack/nova/NovaApiMetadata.java index 80a98df306..60540982d9 100644 --- a/apis/nova/src/main/java/org/jclouds/openstack/nova/NovaApiMetadata.java +++ b/apis/nova/src/main/java/org/jclouds/openstack/nova/NovaApiMetadata.java @@ -23,18 +23,28 @@ import java.util.Properties; import org.jclouds.apis.ApiMetadata; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; +import org.jclouds.openstack.nova.compute.config.NovaComputeServiceContextModule; +import org.jclouds.openstack.nova.config.NovaRestClientModule; +import org.jclouds.rest.RestContext; +import org.jclouds.rest.internal.BaseRestApiMetadata; +import com.google.common.collect.ImmutableSet; import com.google.common.reflect.TypeToken; +import com.google.inject.Module; /** * Implementation of {@link ApiMetadata} for Nova 1.0 API * * @author Adrian Cole */ -public class NovaApiMetadata - extends - BaseComputeServiceApiMetadata, NovaApiMetadata> { +public class NovaApiMetadata extends BaseRestApiMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 6725672099385580694L; + + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; @Override public Builder toBuilder() { @@ -49,26 +59,25 @@ public class NovaApiMetadata super(builder); } - protected static Properties defaultProperties() { - Properties properties = BaseComputeServiceApiMetadata.Builder.defaultProperties(); + public static Properties defaultProperties() { + Properties properties = BaseRestApiMetadata.defaultProperties(); return properties; } - public static class Builder - extends - BaseComputeServiceApiMetadata.Builder, NovaApiMetadata> { + public static class Builder extends BaseRestApiMetadata.Builder { protected Builder() { - id("nova") + super(NovaClient.class, NovaAsyncClient.class); + id("nova") .name("OpenStack Nova Pre-Diablo API") .identityName("accessKey") .credentialName("secretKey") .documentation(URI.create("http://api.openstack.org/")) .version("1.1") .defaultEndpoint("http://localhost:5000") - .javaApi(NovaClient.class, NovaAsyncClient.class) .defaultProperties(NovaApiMetadata.defaultProperties()) - .contextBuilder(TypeToken.of(NovaContextBuilder.class)); + .wrapper(TypeToken.of(ComputeServiceContext.class)) + .defaultModules(ImmutableSet.>of(NovaRestClientModule.class, NovaComputeServiceContextModule.class)); } @Override @@ -77,7 +86,7 @@ public class NovaApiMetadata } @Override - public Builder fromApiMetadata(NovaApiMetadata in) { + public Builder fromApiMetadata(ApiMetadata in) { super.fromApiMetadata(in); return this; } diff --git a/apis/nova/src/main/java/org/jclouds/openstack/nova/NovaContextBuilder.java b/apis/nova/src/main/java/org/jclouds/openstack/nova/NovaContextBuilder.java deleted file mode 100644 index 6a147dbfe6..0000000000 --- a/apis/nova/src/main/java/org/jclouds/openstack/nova/NovaContextBuilder.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * 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.openstack.nova; - -import java.util.List; - -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextBuilder; -import org.jclouds.openstack.nova.compute.config.NovaComputeServiceContextModule; -import org.jclouds.openstack.nova.config.NovaRestClientModule; -import org.jclouds.providers.ProviderMetadata; - -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class NovaContextBuilder - extends - ComputeServiceContextBuilder, NovaApiMetadata> { - - public NovaContextBuilder( - ProviderMetadata, NovaApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public NovaContextBuilder(NovaApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new NovaComputeServiceContextModule()); - } - - protected void addClientModule(List modules) { - modules.add(new NovaRestClientModule()); - } - -} \ No newline at end of file diff --git a/apis/nova/src/main/java/org/jclouds/openstack/nova/compute/config/NovaComputeServiceContextModule.java b/apis/nova/src/main/java/org/jclouds/openstack/nova/compute/config/NovaComputeServiceContextModule.java index b027028613..6ac995e84e 100644 --- a/apis/nova/src/main/java/org/jclouds/openstack/nova/compute/config/NovaComputeServiceContextModule.java +++ b/apis/nova/src/main/java/org/jclouds/openstack/nova/compute/config/NovaComputeServiceContextModule.java @@ -32,8 +32,6 @@ import org.jclouds.compute.domain.OperatingSystem; import org.jclouds.compute.internal.BaseComputeService; import org.jclouds.domain.Location; import org.jclouds.functions.IdentityFunction; -import org.jclouds.openstack.nova.NovaAsyncClient; -import org.jclouds.openstack.nova.NovaClient; import org.jclouds.openstack.nova.compute.functions.FlavorToHardware; import org.jclouds.openstack.nova.compute.functions.NovaImageToImage; import org.jclouds.openstack.nova.compute.functions.NovaImageToOperatingSystem; @@ -54,12 +52,8 @@ import com.google.inject.TypeLiteral; * * @author Adrian Cole */ -public class NovaComputeServiceContextModule - extends - ComputeServiceAdapterContextModule { - public NovaComputeServiceContextModule() { - super(NovaClient.class, NovaAsyncClient.class); - } +public class NovaComputeServiceContextModule extends + ComputeServiceAdapterContextModule { @SuppressWarnings("unchecked") @Override diff --git a/apis/nova/src/main/java/org/jclouds/openstack/nova/config/NovaRestClientModule.java b/apis/nova/src/main/java/org/jclouds/openstack/nova/config/NovaRestClientModule.java index e5cf6aac85..e1c3186b98 100644 --- a/apis/nova/src/main/java/org/jclouds/openstack/nova/config/NovaRestClientModule.java +++ b/apis/nova/src/main/java/org/jclouds/openstack/nova/config/NovaRestClientModule.java @@ -23,7 +23,6 @@ import java.net.URI; import javax.inject.Singleton; import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.ServerError; @@ -47,7 +46,6 @@ import com.google.inject.Provides; * @author Adrian Cole */ @ConfiguresRestClient -@RequiresHttp public class NovaRestClientModule extends RestClientModule { private final OpenStackAuthenticationModule module; diff --git a/apis/nova/src/main/java/org/jclouds/openstack/nova/options/CreateServerOptions.java b/apis/nova/src/main/java/org/jclouds/openstack/nova/options/CreateServerOptions.java index 03f5e5cedf..902d074d0a 100644 --- a/apis/nova/src/main/java/org/jclouds/openstack/nova/options/CreateServerOptions.java +++ b/apis/nova/src/main/java/org/jclouds/openstack/nova/options/CreateServerOptions.java @@ -24,8 +24,8 @@ import static com.google.common.base.Preconditions.checkState; import java.util.List; import java.util.Map; -import java.util.Map.Entry; import java.util.Set; +import java.util.Map.Entry; import javax.inject.Inject; diff --git a/apis/nova/src/test/java/org/jclouds/openstack/nova/NovaAsyncClientTest.java b/apis/nova/src/test/java/org/jclouds/openstack/nova/NovaAsyncClientTest.java index c9d67a097a..792101bb3c 100644 --- a/apis/nova/src/test/java/org/jclouds/openstack/nova/NovaAsyncClientTest.java +++ b/apis/nova/src/test/java/org/jclouds/openstack/nova/NovaAsyncClientTest.java @@ -32,7 +32,6 @@ import java.util.Date; import javax.ws.rs.core.MediaType; import org.jclouds.http.HttpRequest; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.functions.ReleasePayloadAndReturn; import org.jclouds.http.functions.ReturnTrueIf2xx; import org.jclouds.http.functions.UnwrapOnlyJsonValue; @@ -44,7 +43,7 @@ import org.jclouds.openstack.nova.domain.RebootType; import org.jclouds.openstack.nova.options.CreateServerOptions; import org.jclouds.openstack.nova.options.ListOptions; import org.jclouds.openstack.nova.options.RebuildServerOptions; -import org.jclouds.providers.AnonymousProviderMetadata; +import org.jclouds.providers.AnonymousProviderMetadata; import org.jclouds.providers.ProviderMetadata; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; @@ -767,8 +766,7 @@ public class NovaAsyncClientTest extends BaseAsyncClientTest { } @ConfiguresRestClient - @RequiresHttp - protected static class TestNovaRestClientModule extends NovaRestClientModule { + protected static class TestNovaRestClientModule extends NovaRestClientModule { private TestNovaRestClientModule() { super(new TestOpenStackAuthenticationModule()); } @@ -778,7 +776,7 @@ public class NovaAsyncClientTest extends BaseAsyncClientTest { protected String provider = "nova"; @Override - protected ProviderMetadata createProviderMetadata() { + protected ProviderMetadata createProviderMetadata() { return AnonymousProviderMetadata.forApiWithEndpoint(new NovaApiMetadata(), "http://endpoint"); } } diff --git a/apis/nova/src/test/java/org/jclouds/openstack/nova/NovaClientLiveTest.java b/apis/nova/src/test/java/org/jclouds/openstack/nova/NovaClientLiveTest.java index d93ec24277..117e97c726 100644 --- a/apis/nova/src/test/java/org/jclouds/openstack/nova/NovaClientLiveTest.java +++ b/apis/nova/src/test/java/org/jclouds/openstack/nova/NovaClientLiveTest.java @@ -32,7 +32,6 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.TimeUnit; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.domain.LoginCredentials; import org.jclouds.http.HttpResponseException; @@ -65,9 +64,7 @@ import com.google.inject.Injector; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "NovaClientLiveTest") -public class NovaClientLiveTest - extends - BaseComputeServiceContextLiveTest> { +public class NovaClientLiveTest extends BaseComputeServiceContextLiveTest { public NovaClientLiveTest() { provider = "nova"; diff --git a/apis/nova/src/test/java/org/jclouds/openstack/nova/compute/NovaComputeServiceLiveTest.java b/apis/nova/src/test/java/org/jclouds/openstack/nova/compute/NovaComputeServiceLiveTest.java index eb0dc9eea2..11fa629666 100644 --- a/apis/nova/src/test/java/org/jclouds/openstack/nova/compute/NovaComputeServiceLiveTest.java +++ b/apis/nova/src/test/java/org/jclouds/openstack/nova/compute/NovaComputeServiceLiveTest.java @@ -22,12 +22,9 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.internal.BaseComputeServiceLiveTest; import org.jclouds.domain.LocationScope; -import org.jclouds.openstack.nova.NovaAsyncClient; -import org.jclouds.openstack.nova.NovaClient; import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.Test; @@ -39,8 +36,7 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", enabled = true, singleThreaded = true, testName = "NovaComputeServiceLiveTest") -public class NovaComputeServiceLiveTest extends - BaseComputeServiceLiveTest> { +public class NovaComputeServiceLiveTest extends BaseComputeServiceLiveTest { public NovaComputeServiceLiveTest() { provider = "nova"; diff --git a/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/NovaEC2ApiMetadata.java b/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/NovaEC2ApiMetadata.java index 240b37c49f..e0c53d8051 100644 --- a/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/NovaEC2ApiMetadata.java +++ b/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/NovaEC2ApiMetadata.java @@ -31,16 +31,29 @@ import org.jclouds.apis.ApiMetadata; import org.jclouds.ec2.EC2ApiMetadata; import org.jclouds.ec2.EC2AsyncClient; import org.jclouds.ec2.EC2Client; -import org.jclouds.ec2.compute.EC2ComputeServiceContext; +import org.jclouds.ec2.compute.config.EC2ResolveImagesModule; +import org.jclouds.openstack.nova.ec2.config.NovaEC2ComputeServiceContextModule; +import org.jclouds.openstack.nova.ec2.config.NovaEC2RestClientModule; +import org.jclouds.rest.RestContext; +import com.google.common.collect.ImmutableSet; import com.google.common.reflect.TypeToken; +import com.google.inject.Module; /** * Implementation of {@link ApiMetadata} for the OpenStack Nova's EC2-clone API * * @author Adrian Cole */ -public class NovaEC2ApiMetadata extends EC2ApiMetadata, NovaEC2ApiMetadata> { +public class NovaEC2ApiMetadata extends EC2ApiMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = -1492951757032303845L; + + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; + private static Builder builder() { return new Builder(); } @@ -58,7 +71,7 @@ public class NovaEC2ApiMetadata extends EC2ApiMetadata, NovaEC2ApiMetadata> { + public static class Builder extends EC2ApiMetadata.Builder { protected Builder(){ super(EC2Client.class, EC2AsyncClient.class); id("openstack-nova-ec2") @@ -83,7 +96,7 @@ public class NovaEC2ApiMetadata extends EC2ApiMetadata>of(NovaEC2RestClientModule.class, EC2ResolveImagesModule.class, NovaEC2ComputeServiceContextModule.class)); } @Override @@ -92,7 +105,7 @@ public class NovaEC2ApiMetadata extends EC2ApiMetadata, NovaEC2ApiMetadata> { - - public NovaEC2ContextBuilder( - ProviderMetadata, NovaEC2ApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public NovaEC2ContextBuilder(NovaEC2ApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addClientModule(List modules) { - modules.add(new NovaEC2RestClientModule()); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new NovaEC2ComputeServiceContextModule()); - } - -} diff --git a/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/config/NovaEC2RestClientModule.java b/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/config/NovaEC2RestClientModule.java index 0ac573ff26..f2ff664f35 100644 --- a/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/config/NovaEC2RestClientModule.java +++ b/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/config/NovaEC2RestClientModule.java @@ -22,7 +22,6 @@ import org.jclouds.ec2.EC2AsyncClient; import org.jclouds.ec2.EC2Client; import org.jclouds.ec2.config.EC2RestClientModule; import org.jclouds.ec2.suppliers.DescribeAvailabilityZonesInRegion; -import org.jclouds.http.RequiresHttp; import org.jclouds.location.config.LocationModule; import org.jclouds.location.suppliers.RegionIdToZoneIdsSupplier; import org.jclouds.location.suppliers.ZoneIdsSupplier; @@ -35,7 +34,6 @@ import com.google.inject.Scopes; * * @author Adrian Cole */ -@RequiresHttp @ConfiguresRestClient public class NovaEC2RestClientModule extends EC2RestClientModule { diff --git a/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/compute/NovaEC2ComputeServiceLiveTest.java b/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/compute/NovaEC2ComputeServiceLiveTest.java index 253a799832..14d614e7b6 100644 --- a/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/compute/NovaEC2ComputeServiceLiveTest.java +++ b/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/compute/NovaEC2ComputeServiceLiveTest.java @@ -20,9 +20,6 @@ package org.jclouds.openstack.nova.ec2.compute; import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.ec2.EC2AsyncClient; -import org.jclouds.ec2.EC2Client; -import org.jclouds.ec2.compute.EC2ComputeServiceContext; import org.jclouds.ec2.compute.EC2ComputeServiceLiveTest; import org.testng.annotations.Test; @@ -31,7 +28,7 @@ import org.testng.annotations.Test; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "NovaEC2ComputeServiceLiveTest") -public class NovaEC2ComputeServiceLiveTest extends EC2ComputeServiceLiveTest> { +public class NovaEC2ComputeServiceLiveTest extends EC2ComputeServiceLiveTest { public NovaEC2ComputeServiceLiveTest() { provider = "openstack-nova-ec2"; diff --git a/apis/openstack-nova/pom.xml b/apis/openstack-nova/pom.xml index fa2663a3c3..8e144f766b 100644 --- a/apis/openstack-nova/pom.xml +++ b/apis/openstack-nova/pom.xml @@ -45,6 +45,7 @@ false + passwordCredentials @@ -125,6 +126,7 @@ ${test.openstack-nova.image.login-user} ${test.openstack-nova.image.authenticate-sudo} ${test.jclouds.openstack-nova.auto-allocate-floating-ips} + ${test.jclouds.keystone.credential-type} diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaApiMetadata.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaApiMetadata.java index 578d6b929d..de321c2366 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaApiMetadata.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaApiMetadata.java @@ -28,20 +28,30 @@ import java.util.Properties; import org.jclouds.apis.ApiMetadata; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties; +import org.jclouds.openstack.nova.v1_1.compute.config.NovaComputeServiceContextModule; +import org.jclouds.openstack.nova.v1_1.config.NovaRestClientModule; import org.jclouds.openstack.services.ServiceType; +import org.jclouds.rest.RestContext; +import org.jclouds.rest.internal.BaseRestApiMetadata; +import com.google.common.collect.ImmutableSet; import com.google.common.reflect.TypeToken; +import com.google.inject.Module; /** * Implementation of {@link ApiMetadata} for Nova 1.0 API * * @author Adrian Cole */ -public class NovaApiMetadata - extends - BaseComputeServiceApiMetadata, NovaApiMetadata> { +public class NovaApiMetadata extends BaseRestApiMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 6725672099385580694L; + + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; @Override public Builder toBuilder() { @@ -56,8 +66,8 @@ public class NovaApiMetadata super(builder); } - protected static Properties defaultProperties() { - Properties properties = BaseComputeServiceApiMetadata.Builder.defaultProperties(); + public static Properties defaultProperties() { + Properties properties = BaseRestApiMetadata.defaultProperties(); // auth fail can happen while cloud-init applies keypair updates properties.setProperty("jclouds.ssh.max-retries", "7"); properties.setProperty("jclouds.ssh.retry-auth", "true"); @@ -72,11 +82,10 @@ public class NovaApiMetadata return properties; } - public static class Builder - extends - BaseComputeServiceApiMetadata.Builder, NovaApiMetadata> { + public static class Builder extends BaseRestApiMetadata.Builder { protected Builder() { + super(NovaClient.class, NovaAsyncClient.class); id("openstack-nova") .name("OpenStack Nova Diablo+ API") .identityName("tenantId:user") @@ -84,18 +93,18 @@ public class NovaApiMetadata .documentation(URI.create("http://api.openstack.org/")) .version("1.1") .defaultEndpoint("http://localhost:5000") - .javaApi(NovaClient.class, NovaAsyncClient.class) .defaultProperties(NovaApiMetadata.defaultProperties()) - .contextBuilder(TypeToken.of(NovaContextBuilder.class)); + .wrapper(TypeToken.of(ComputeServiceContext.class)) + .defaultModules(ImmutableSet.>of(NovaRestClientModule.class, NovaComputeServiceContextModule.class)); } - + @Override public NovaApiMetadata build() { return new NovaApiMetadata(this); } @Override - public Builder fromApiMetadata(NovaApiMetadata in) { + public Builder fromApiMetadata(ApiMetadata in) { super.fromApiMetadata(in); return this; } diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaContextBuilder.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaContextBuilder.java deleted file mode 100644 index 06be070cb8..0000000000 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaContextBuilder.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * 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.openstack.nova.v1_1; - -import java.util.List; - -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextBuilder; -import org.jclouds.openstack.nova.v1_1.compute.config.NovaComputeServiceContextModule; -import org.jclouds.openstack.nova.v1_1.config.NovaRestClientModule; -import org.jclouds.providers.ProviderMetadata; - -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class NovaContextBuilder - extends - ComputeServiceContextBuilder, NovaApiMetadata> { - - public NovaContextBuilder( - ProviderMetadata, NovaApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public NovaContextBuilder(NovaApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new NovaComputeServiceContextModule()); - } - - protected void addClientModule(List modules) { - modules.add(new NovaRestClientModule()); - } - -} \ No newline at end of file diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/binders/BindSecurityGroupRuleToJsonPayload.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/binders/BindSecurityGroupRuleToJsonPayload.java index 90e229479a..ee9fec20ec 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/binders/BindSecurityGroupRuleToJsonPayload.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/binders/BindSecurityGroupRuleToJsonPayload.java @@ -35,8 +35,8 @@ import org.jclouds.rest.internal.GeneratedHttpRequest; import com.google.common.base.Predicates; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMap.Builder; import com.google.common.collect.Iterables; +import com.google.common.collect.ImmutableMap.Builder; /** * diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeService.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeService.java index d3f56d941c..bd799523ce 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeService.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeService.java @@ -86,7 +86,7 @@ public class NovaComputeService extends BaseComputeService { protected final GroupNamingConvention.Factory namingConvention; @Inject - protected NovaComputeService(@SuppressWarnings("rawtypes") ComputeServiceContext context, Map credentialStore, + protected NovaComputeService(ComputeServiceContext context, Map credentialStore, @Memoized Supplier> images, @Memoized Supplier> sizes, @Memoized Supplier> locations, ListNodesStrategy listNodesStrategy, GetNodeMetadataStrategy getNodeMetadataStrategy, CreateNodesInGroupThenAddToSet runNodesAndAddToSetStrategy, diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/compute/config/NovaComputeServiceContextModule.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/compute/config/NovaComputeServiceContextModule.java index 37e169c240..2351ac7164 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/compute/config/NovaComputeServiceContextModule.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/compute/config/NovaComputeServiceContextModule.java @@ -44,8 +44,6 @@ import org.jclouds.compute.strategy.impl.CreateNodesWithGroupEncodedIntoNameThen import org.jclouds.domain.Location; import org.jclouds.domain.LoginCredentials; import org.jclouds.functions.IdentityFunction; -import org.jclouds.openstack.nova.v1_1.NovaAsyncClient; -import org.jclouds.openstack.nova.v1_1.NovaClient; import org.jclouds.openstack.nova.v1_1.compute.NovaComputeService; import org.jclouds.openstack.nova.v1_1.compute.NovaComputeServiceAdapter; import org.jclouds.openstack.nova.v1_1.compute.functions.CreateSecurityGroupIfNeeded; @@ -91,12 +89,8 @@ import com.google.inject.name.Names; * * @author Matt Stephenson */ -public class NovaComputeServiceContextModule - extends - ComputeServiceAdapterContextModule { - public NovaComputeServiceContextModule() { - super(NovaClient.class, NovaAsyncClient.class); - } +public class NovaComputeServiceContextModule extends + ComputeServiceAdapterContextModule { @SuppressWarnings("unchecked") @Override diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/compute/options/NovaTemplateOptions.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/compute/options/NovaTemplateOptions.java index cfa96773a8..bc0d9e43b4 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/compute/options/NovaTemplateOptions.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/compute/options/NovaTemplateOptions.java @@ -31,8 +31,8 @@ import org.jclouds.scriptbuilder.domain.Statement; import org.jclouds.util.Preconditions2; import com.google.common.base.Objects; -import com.google.common.base.Objects.ToStringHelper; import com.google.common.base.Optional; +import com.google.common.base.Objects.ToStringHelper; import com.google.common.collect.ImmutableSet; /** diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/config/NovaRestClientModule.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/config/NovaRestClientModule.java index 0b4fdc5602..32c8513874 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/config/NovaRestClientModule.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/config/NovaRestClientModule.java @@ -26,7 +26,6 @@ import javax.inject.Provider; import javax.inject.Singleton; import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.ServerError; @@ -68,7 +67,6 @@ import com.google.inject.Scopes; * * @author Adrian Cole */ -@RequiresHttp @ConfiguresRestClient public class NovaRestClientModule extends RestClientModule { diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/Server.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/Server.java index e8bee1ae3c..985066392c 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/Server.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/Server.java @@ -34,10 +34,10 @@ import org.jclouds.openstack.nova.v1_1.extensions.KeyPairClient; import org.jclouds.util.InetAddresses2; import org.jclouds.util.Multimaps2; -import com.google.common.base.Objects.ToStringHelper; import com.google.common.base.Predicate; import com.google.common.base.Predicates; import com.google.common.base.Strings; +import com.google.common.base.Objects.ToStringHelper; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.ImmutableSet; diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/zonescoped/ZoneAndName.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/zonescoped/ZoneAndName.java index c09b0ccb01..1bc8b5a631 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/zonescoped/ZoneAndName.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/zonescoped/ZoneAndName.java @@ -24,8 +24,8 @@ import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.base.Function; import com.google.common.base.Objects; -import com.google.common.base.Objects.ToStringHelper; import com.google.common.base.Splitter; +import com.google.common.base.Objects.ToStringHelper; import com.google.common.collect.Iterables; /** diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/functions/ParseImageIdFromLocationHeader.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/functions/ParseImageIdFromLocationHeader.java index 1bdeb2c8f0..0b4873b3a2 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/functions/ParseImageIdFromLocationHeader.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/functions/ParseImageIdFromLocationHeader.java @@ -20,11 +20,10 @@ package org.jclouds.openstack.nova.v1_1.functions; import javax.inject.Singleton; - import javax.ws.rs.core.HttpHeaders; -import org.jclouds.openstack.nova.v1_1.domain.Image; import org.jclouds.http.HttpResponse; +import org.jclouds.openstack.nova.v1_1.domain.Image; import com.google.common.base.Function; diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/options/CreateServerOptions.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/options/CreateServerOptions.java index ff9bb7269a..3bd7fad2b3 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/options/CreateServerOptions.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/options/CreateServerOptions.java @@ -26,8 +26,8 @@ import static com.google.common.base.Preconditions.checkState; import java.util.List; import java.util.Map; -import java.util.Map.Entry; import java.util.Set; +import java.util.Map.Entry; import javax.inject.Inject; @@ -40,8 +40,8 @@ import org.jclouds.rest.binders.BindToJsonPayload; import org.jclouds.util.Preconditions2; import com.google.common.base.Objects; -import com.google.common.base.Objects.ToStringHelper; import com.google.common.base.Optional; +import com.google.common.base.Objects.ToStringHelper; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeServiceAdapterExpectTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeServiceAdapterExpectTest.java index e2072a77b3..b2df3a5eee 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeServiceAdapterExpectTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeServiceAdapterExpectTest.java @@ -24,8 +24,8 @@ import static org.testng.Assert.assertNotNull; import java.net.URI; import java.util.Map; -import org.jclouds.compute.ComputeServiceAdapter.NodeAndInitialCredentials; import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.compute.ComputeServiceAdapter.NodeAndInitialCredentials; import org.jclouds.compute.domain.Template; import org.jclouds.compute.domain.TemplateBuilder; import org.jclouds.domain.LoginCredentials; diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeServiceExpectTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeServiceExpectTest.java index 23e4de0e8b..ac69ac22b6 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeServiceExpectTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeServiceExpectTest.java @@ -41,9 +41,9 @@ import org.testng.annotations.Test; import com.google.common.base.Supplier; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMap.Builder; import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.Iterables; +import com.google.common.collect.ImmutableMap.Builder; import com.google.inject.AbstractModule; import com.google.inject.TypeLiteral; diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeServiceLiveTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeServiceLiveTest.java index 683fb6b301..df697bc88a 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeServiceLiveTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/compute/NovaComputeServiceLiveTest.java @@ -1,9 +1,10 @@ package org.jclouds.openstack.nova.v1_1.compute; -import org.jclouds.compute.ComputeServiceContext; +import java.util.Properties; + import org.jclouds.compute.internal.BaseComputeServiceLiveTest; -import org.jclouds.openstack.nova.v1_1.NovaAsyncClient; -import org.jclouds.openstack.nova.v1_1.NovaClient; +import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties; +import org.jclouds.openstack.nova.v1_1.config.NovaProperties; import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.Test; @@ -14,8 +15,7 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "NovaComputeServiceLiveTest") -public class NovaComputeServiceLiveTest extends - BaseComputeServiceLiveTest> { +public class NovaComputeServiceLiveTest extends BaseComputeServiceLiveTest { public NovaComputeServiceLiveTest() { provider = "openstack-nova"; @@ -53,4 +53,12 @@ public class NovaComputeServiceLiveTest extends public void testDestroyNodes() { super.testDestroyNodes(); } + + @Override + protected Properties setupProperties() { + Properties props = super.setupProperties(); + setIfTestSystemPropertyPresent(props, KeystoneProperties.CREDENTIAL_TYPE); + setIfTestSystemPropertyPresent(props, NovaProperties.AUTO_ALLOCATE_FLOATING_IPS); + return props; + } } diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/compute/loaders/CreateUniqueKeyPairTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/compute/loaders/CreateUniqueKeyPairTest.java index 8c62b08550..8f99d867c0 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/compute/loaders/CreateUniqueKeyPairTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/compute/loaders/CreateUniqueKeyPairTest.java @@ -27,7 +27,6 @@ import static org.testng.Assert.assertEquals; import java.net.UnknownHostException; import org.jclouds.openstack.nova.v1_1.NovaClient; -import org.jclouds.openstack.nova.v1_1.compute.loaders.CreateUniqueKeyPair; import org.jclouds.openstack.nova.v1_1.domain.KeyPair; import org.jclouds.openstack.nova.v1_1.domain.zonescoped.ZoneAndName; import org.jclouds.openstack.nova.v1_1.extensions.KeyPairClient; diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/functions/CreateSecurityGroupIfNeededTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/functions/CreateSecurityGroupIfNeededTest.java index fcdd6cfd3c..3b15224a9d 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/functions/CreateSecurityGroupIfNeededTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/functions/CreateSecurityGroupIfNeededTest.java @@ -34,9 +34,9 @@ import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMap.Builder; import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableMap.Builder; /** * diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaClientLiveTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaClientLiveTest.java index 3e6679ed37..f4cc9157e4 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaClientLiveTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaClientLiveTest.java @@ -18,10 +18,13 @@ */ package org.jclouds.openstack.nova.v1_1.internal; -import org.jclouds.compute.ComputeServiceContext; +import java.util.Properties; + import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; +import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties; import org.jclouds.openstack.nova.v1_1.NovaAsyncClient; import org.jclouds.openstack.nova.v1_1.NovaClient; +import org.jclouds.openstack.nova.v1_1.config.NovaProperties; import org.jclouds.rest.RestContext; import org.testng.annotations.AfterGroups; import org.testng.annotations.BeforeGroups; @@ -33,9 +36,7 @@ import org.testng.annotations.Test; * @author Adrian Cole */ @Test(groups = "live") -public class BaseNovaClientLiveTest - extends - BaseComputeServiceContextLiveTest> { +public class BaseNovaClientLiveTest extends BaseComputeServiceContextLiveTest { public BaseNovaClientLiveTest() { provider = "openstack-nova"; @@ -47,9 +48,17 @@ public class BaseNovaClientLiveTest @Override public void setupContext() { super.setupContext(); - novaContext = context.getProviderSpecificContext(); + novaContext = context.unwrap(); } + @Override + protected Properties setupProperties() { + Properties props = super.setupProperties(); + setIfTestSystemPropertyPresent(props, KeystoneProperties.CREDENTIAL_TYPE); + setIfTestSystemPropertyPresent(props, NovaProperties.AUTO_ALLOCATE_FLOATING_IPS); + return props; + } + @AfterGroups(groups = "live") protected void tearDown() { if (novaContext != null) diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaComputeServiceContextExpectTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaComputeServiceContextExpectTest.java index 59f81af989..f7e3681aad 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaComputeServiceContextExpectTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaComputeServiceContextExpectTest.java @@ -33,7 +33,6 @@ import org.jclouds.rest.config.CredentialStoreModule; import com.google.common.base.Function; import com.google.common.collect.ImmutableMultimap; -import com.google.common.collect.ImmutableSet; import com.google.common.io.InputSupplier; import com.google.inject.Module; @@ -88,7 +87,7 @@ public abstract class BaseNovaComputeServiceContextExpectTest extends BaseNov } @Override - protected ApiMetadata createApiMetadata() { + protected ApiMetadata createApiMetadata() { return new NovaApiMetadata(); } diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaComputeServiceExpectTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaComputeServiceExpectTest.java index d79e19dc45..15f68e6afa 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaComputeServiceExpectTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaComputeServiceExpectTest.java @@ -30,7 +30,7 @@ import org.jclouds.compute.ComputeServiceContext; public class BaseNovaComputeServiceExpectTest extends BaseNovaComputeServiceContextExpectTest { @Override - public ComputeService apply(@SuppressWarnings("rawtypes") ComputeServiceContext input) { + public ComputeService apply(ComputeServiceContext input) { return input.getComputeService(); } diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseCreatedServerTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseCreatedServerTest.java index 66110be35c..b322aad8e5 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseCreatedServerTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseCreatedServerTest.java @@ -27,8 +27,8 @@ import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.json.BaseItemParserTest; import org.jclouds.json.config.GsonModule; import org.jclouds.openstack.domain.Link; -import org.jclouds.openstack.domain.Link.Relation; import org.jclouds.openstack.domain.Resource; +import org.jclouds.openstack.domain.Link.Relation; import org.jclouds.openstack.nova.v1_1.config.NovaParserModule; import org.jclouds.openstack.nova.v1_1.domain.Server; import org.jclouds.openstack.nova.v1_1.domain.Server.Status; diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseFlavorListTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseFlavorListTest.java index 0f92a1c75f..eb78746d73 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseFlavorListTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseFlavorListTest.java @@ -27,8 +27,8 @@ import javax.ws.rs.core.MediaType; import org.jclouds.json.BaseSetParserTest; import org.jclouds.json.config.GsonModule; import org.jclouds.openstack.domain.Link; -import org.jclouds.openstack.domain.Link.Relation; import org.jclouds.openstack.domain.Resource; +import org.jclouds.openstack.domain.Link.Relation; import org.jclouds.openstack.nova.v1_1.config.NovaParserModule; import org.jclouds.rest.annotations.SelectJson; import org.testng.annotations.Test; diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseImageListTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseImageListTest.java index 45d20150ea..da4a4c63bd 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseImageListTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseImageListTest.java @@ -27,8 +27,8 @@ import javax.ws.rs.core.MediaType; import org.jclouds.json.BaseSetParserTest; import org.jclouds.json.config.GsonModule; import org.jclouds.openstack.domain.Link; -import org.jclouds.openstack.domain.Link.Relation; import org.jclouds.openstack.domain.Resource; +import org.jclouds.openstack.domain.Link.Relation; import org.jclouds.openstack.nova.v1_1.config.NovaParserModule; import org.jclouds.rest.annotations.SelectJson; import org.testng.annotations.Test; diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseImageTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseImageTest.java index 33efaacb56..c7579ee71d 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseImageTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseImageTest.java @@ -27,8 +27,8 @@ import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.json.BaseItemParserTest; import org.jclouds.json.config.GsonModule; import org.jclouds.openstack.domain.Link; -import org.jclouds.openstack.domain.Link.Relation; import org.jclouds.openstack.domain.Resource; +import org.jclouds.openstack.domain.Link.Relation; import org.jclouds.openstack.nova.v1_1.config.NovaParserModule; import org.jclouds.openstack.nova.v1_1.domain.Image; import org.jclouds.openstack.nova.v1_1.domain.Image.Status; diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerListTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerListTest.java index dc911c2515..7ad940b6a9 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerListTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerListTest.java @@ -27,8 +27,8 @@ import javax.ws.rs.core.MediaType; import org.jclouds.json.BaseSetParserTest; import org.jclouds.json.config.GsonModule; import org.jclouds.openstack.domain.Link; -import org.jclouds.openstack.domain.Link.Relation; import org.jclouds.openstack.domain.Resource; +import org.jclouds.openstack.domain.Link.Relation; import org.jclouds.openstack.nova.v1_1.config.NovaParserModule; import org.jclouds.rest.annotations.SelectJson; import org.testng.annotations.Test; diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerTest.java index cf7d2760bc..f249f3bdb1 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerTest.java @@ -27,8 +27,8 @@ import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.json.BaseItemParserTest; import org.jclouds.json.config.GsonModule; import org.jclouds.openstack.domain.Link; -import org.jclouds.openstack.domain.Link.Relation; import org.jclouds.openstack.domain.Resource; +import org.jclouds.openstack.domain.Link.Relation; import org.jclouds.openstack.nova.v1_1.config.NovaParserModule; import org.jclouds.openstack.nova.v1_1.domain.Address; import org.jclouds.openstack.nova.v1_1.domain.Server; diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerWithInternetAddressesTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerWithInternetAddressesTest.java index a7703ea142..b5272f2cbc 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerWithInternetAddressesTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerWithInternetAddressesTest.java @@ -27,8 +27,8 @@ import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.json.BaseItemParserTest; import org.jclouds.json.config.GsonModule; import org.jclouds.openstack.domain.Link; -import org.jclouds.openstack.domain.Link.Relation; import org.jclouds.openstack.domain.Resource; +import org.jclouds.openstack.domain.Link.Relation; import org.jclouds.openstack.nova.v1_1.config.NovaParserModule; import org.jclouds.openstack.nova.v1_1.domain.Address; import org.jclouds.openstack.nova.v1_1.domain.Server; diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/PublicIpsInPrivateAddressBlockShouldRerouteToPublicBlockExpectTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/PublicIpsInPrivateAddressBlockShouldRerouteToPublicBlockExpectTest.java index 789234c3fd..7df750e8c3 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/PublicIpsInPrivateAddressBlockShouldRerouteToPublicBlockExpectTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/PublicIpsInPrivateAddressBlockShouldRerouteToPublicBlockExpectTest.java @@ -27,8 +27,8 @@ import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.json.BaseItemParserTest; import org.jclouds.json.config.GsonModule; import org.jclouds.openstack.domain.Link; -import org.jclouds.openstack.domain.Link.Relation; import org.jclouds.openstack.domain.Resource; +import org.jclouds.openstack.domain.Link.Relation; import org.jclouds.openstack.nova.v1_1.config.NovaParserModule; import org.jclouds.openstack.nova.v1_1.domain.Address; import org.jclouds.openstack.nova.v1_1.domain.Server; diff --git a/apis/s3/src/main/java/org/jclouds/s3/S3ApiMetadata.java b/apis/s3/src/main/java/org/jclouds/s3/S3ApiMetadata.java index 45b84df2e6..10f0ce4ee6 100644 --- a/apis/s3/src/main/java/org/jclouds/s3/S3ApiMetadata.java +++ b/apis/s3/src/main/java/org/jclouds/s3/S3ApiMetadata.java @@ -32,12 +32,16 @@ import java.net.URI; import java.util.Properties; import org.jclouds.apis.ApiMetadata; -import org.jclouds.blobstore.internal.BaseBlobStoreApiMetadata; +import org.jclouds.rest.RestContext; +import org.jclouds.rest.internal.BaseRestApiMetadata; import org.jclouds.s3.blobstore.S3BlobStoreContext; +import org.jclouds.s3.blobstore.config.S3BlobStoreContextModule; +import org.jclouds.s3.config.S3RestClientModule; import org.jclouds.s3.reference.S3Headers; -import com.google.common.reflect.TypeParameter; +import com.google.common.collect.ImmutableSet; import com.google.common.reflect.TypeToken; +import com.google.inject.Module; /** * Implementation of {@link ApiMetadata} for Amazon's S3 api. @@ -56,26 +60,30 @@ import com.google.common.reflect.TypeToken; * * @author Adrian Cole */ -public class S3ApiMetadata, M extends S3ApiMetadata> - extends BaseBlobStoreApiMetadata { +public class S3ApiMetadata extends BaseRestApiMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 820062881469203616L; + + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; - @SuppressWarnings({ "unchecked", "rawtypes" }) @Override - public Builder toBuilder() { - return (Builder) new Builder(getApi(), getAsyncApi()).fromApiMetadata(this); + public Builder toBuilder() { + return (Builder) new Builder(getApi(), getAsyncApi()).fromApiMetadata(this); } - @SuppressWarnings({ "unchecked", "rawtypes" }) public S3ApiMetadata() { this(new Builder(S3Client.class, S3AsyncClient.class)); } - protected S3ApiMetadata(Builder builder) { + protected S3ApiMetadata(Builder builder) { super(builder); } - protected static Properties defaultProperties() { - Properties properties = BaseBlobStoreApiMetadata.Builder.defaultProperties(); + public static Properties defaultProperties() { + Properties properties = BaseRestApiMetadata.defaultProperties(); properties.setProperty(PROPERTY_API_VERSION, S3AsyncClient.VERSION); properties.setProperty(PROPERTY_AUTH_TAG, "AWS"); properties.setProperty(PROPERTY_HEADER_TAG, S3Headers.DEFAULT_AMAZON_HEADERTAG); @@ -87,9 +95,10 @@ public class S3ApiMetadata, M extends S3ApiMetadata> extends BaseBlobStoreApiMetadata.Builder { + public static class Builder extends BaseRestApiMetadata.Builder { - protected Builder(Class syncClient, Class asyncClient){ + protected Builder(Class syncClient, Class asyncClient){ + super(syncClient, asyncClient); id("s3") .name("Amazon Simple Storage Service (S3) API") .identityName("Access Key ID") @@ -98,32 +107,17 @@ public class S3ApiMetadata>(getClass()){ - private static final long serialVersionUID = 1L; - }); + .wrapper(TypeToken.of(S3BlobStoreContext.class)) + .defaultModules(ImmutableSet.>of(S3RestClientModule.class, S3BlobStoreContextModule.class)); } - - /** - * {@inheritDoc} - */ + @Override - @SuppressWarnings("rawtypes") - protected TypeToken contextToken(TypeToken clientToken, TypeToken asyncClientToken) { - return new TypeToken>() { - private static final long serialVersionUID = 1L; - }.where(new TypeParameter() { - }, clientToken).where(new TypeParameter() { - }, asyncClientToken); + public ApiMetadata build() { + return new S3ApiMetadata(this); } - @SuppressWarnings({ "rawtypes", "unchecked" }) + @Override - public M build() { - return (M) new S3ApiMetadata(this); - } - - @Override - public Builder fromApiMetadata(M in) { + public Builder fromApiMetadata(ApiMetadata in) { super.fromApiMetadata(in); return this; } diff --git a/apis/s3/src/main/java/org/jclouds/s3/S3ContextBuilder.java b/apis/s3/src/main/java/org/jclouds/s3/S3ContextBuilder.java deleted file mode 100644 index 8c011628d1..0000000000 --- a/apis/s3/src/main/java/org/jclouds/s3/S3ContextBuilder.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * 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.s3; - -import java.util.List; - -import org.jclouds.blobstore.BlobStoreContextBuilder; -import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; -import org.jclouds.logging.jdk.config.JDKLoggingModule; -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.s3.blobstore.S3BlobStoreContext; -import org.jclouds.s3.blobstore.config.S3BlobStoreContextModule; -import org.jclouds.s3.config.S3RestClientModule; - -import com.google.inject.Injector; -import com.google.inject.Module; - -/** - * Creates {@link S3Context} or {@link Injector} instances based on the most commonly requested - * arguments. - *

- * Note that Threadsafe objects will be bound as singletons to the Injector or Context provided. - *

- *

- * If no Modules are specified, the default {@link JDKLoggingModule logging} and - * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be installed. - * - * @author Adrian Cole, Andrew Newdigate - * @see S3Context - */ -public class S3ContextBuilder, M extends S3ApiMetadata> - extends BlobStoreContextBuilder { - - public S3ContextBuilder(ProviderMetadata providerMetadata) { - super(providerMetadata); - } - - public S3ContextBuilder(M apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new S3BlobStoreContextModule()); - } - - @Override - protected void addClientModule(List modules) { - modules.add(S3RestClientModule.create()); - } -} diff --git a/apis/s3/src/main/java/org/jclouds/s3/blobstore/S3AsyncBlobStore.java b/apis/s3/src/main/java/org/jclouds/s3/blobstore/S3AsyncBlobStore.java index 0bd44b881c..3bded56016 100644 --- a/apis/s3/src/main/java/org/jclouds/s3/blobstore/S3AsyncBlobStore.java +++ b/apis/s3/src/main/java/org/jclouds/s3/blobstore/S3AsyncBlobStore.java @@ -93,7 +93,7 @@ public class S3AsyncBlobStore extends BaseAsyncBlobStore { private final LoadingCache bucketAcls; @Inject - protected S3AsyncBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, + protected S3AsyncBlobStore(BlobStoreContext context, BlobUtils blobUtils, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService service, Supplier defaultLocation, @Memoized Supplier> locations, S3AsyncClient async, S3Client sync, BucketToResourceMetadata bucket2ResourceMd, ContainerToBucketListOptions container2BucketListOptions, diff --git a/apis/s3/src/main/java/org/jclouds/s3/blobstore/S3BlobStore.java b/apis/s3/src/main/java/org/jclouds/s3/blobstore/S3BlobStore.java index 2e2104879b..3c75d3d3c2 100644 --- a/apis/s3/src/main/java/org/jclouds/s3/blobstore/S3BlobStore.java +++ b/apis/s3/src/main/java/org/jclouds/s3/blobstore/S3BlobStore.java @@ -84,7 +84,7 @@ public class S3BlobStore extends BaseBlobStore { private final LoadingCache bucketAcls; @Inject - protected S3BlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, Supplier defaultLocation, + protected S3BlobStore(BlobStoreContext context, BlobUtils blobUtils, Supplier defaultLocation, @Memoized Supplier> locations, S3Client sync, BucketToResourceMetadata bucket2ResourceMd, ContainerToBucketListOptions container2BucketListOptions, BucketToResourceList bucket2ResourceList, ObjectToBlob object2Blob, diff --git a/apis/s3/src/main/java/org/jclouds/s3/blobstore/S3BlobStoreContext.java b/apis/s3/src/main/java/org/jclouds/s3/blobstore/S3BlobStoreContext.java index 58e8b1fec6..f60926047d 100644 --- a/apis/s3/src/main/java/org/jclouds/s3/blobstore/S3BlobStoreContext.java +++ b/apis/s3/src/main/java/org/jclouds/s3/blobstore/S3BlobStoreContext.java @@ -19,8 +19,6 @@ package org.jclouds.s3.blobstore; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.s3.S3AsyncClient; -import org.jclouds.s3.S3Client; import org.jclouds.s3.blobstore.internal.S3BlobStoreContextImpl; import com.google.inject.ImplementedBy; @@ -29,7 +27,7 @@ import com.google.inject.ImplementedBy; * @author Adrian Cole */ @ImplementedBy(S3BlobStoreContextImpl.class) -public interface S3BlobStoreContext extends BlobStoreContext { +public interface S3BlobStoreContext extends BlobStoreContext { @Override S3BlobStore getBlobStore(); diff --git a/apis/s3/src/main/java/org/jclouds/s3/blobstore/config/S3BlobStoreContextModule.java b/apis/s3/src/main/java/org/jclouds/s3/blobstore/config/S3BlobStoreContextModule.java index 709333e7df..165257678e 100644 --- a/apis/s3/src/main/java/org/jclouds/s3/blobstore/config/S3BlobStoreContextModule.java +++ b/apis/s3/src/main/java/org/jclouds/s3/blobstore/config/S3BlobStoreContextModule.java @@ -25,16 +25,14 @@ import javax.inject.Singleton; import org.jclouds.blobstore.AsyncBlobStore; import org.jclouds.blobstore.BlobRequestSigner; import org.jclouds.blobstore.BlobStore; -import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.blobstore.attr.ConsistencyModel; import org.jclouds.blobstore.config.BlobStoreMapModule; -import org.jclouds.blobstore.internal.BlobStoreContextImpl; import org.jclouds.domain.Location; -import org.jclouds.s3.S3AsyncClient; import org.jclouds.s3.S3Client; import org.jclouds.s3.blobstore.S3AsyncBlobStore; import org.jclouds.s3.blobstore.S3BlobRequestSigner; import org.jclouds.s3.blobstore.S3BlobStore; +import org.jclouds.s3.blobstore.S3BlobStoreContext; import org.jclouds.s3.blobstore.functions.LocationFromBucketLocation; import org.jclouds.s3.domain.AccessControlList; import org.jclouds.s3.domain.BucketMetadata; @@ -61,16 +59,10 @@ public class S3BlobStoreContextModule extends AbstractModule { bind(ConsistencyModel.class).toInstance(ConsistencyModel.EVENTUAL); bind(AsyncBlobStore.class).to(S3AsyncBlobStore.class).in(Scopes.SINGLETON); bind(BlobStore.class).to(S3BlobStore.class).in(Scopes.SINGLETON); - bindContext(); bind(BlobRequestSigner.class).to(S3BlobRequestSigner.class); bindBucketLocationStrategy(); } - protected void bindContext() { - bind(BlobStoreContext.class).to(new TypeLiteral>() { - }).in(Scopes.SINGLETON); - } - protected void bindBucketLocationStrategy() { bind(new TypeLiteral>() { }).to(LocationFromBucketLocation.class); diff --git a/apis/s3/src/main/java/org/jclouds/s3/blobstore/internal/S3BlobStoreContextImpl.java b/apis/s3/src/main/java/org/jclouds/s3/blobstore/internal/S3BlobStoreContextImpl.java index 92f9066a67..16146c35c8 100644 --- a/apis/s3/src/main/java/org/jclouds/s3/blobstore/internal/S3BlobStoreContextImpl.java +++ b/apis/s3/src/main/java/org/jclouds/s3/blobstore/internal/S3BlobStoreContextImpl.java @@ -18,34 +18,39 @@ */ package org.jclouds.s3.blobstore.internal; +import java.io.Closeable; + import javax.inject.Inject; import javax.inject.Singleton; +import org.jclouds.blobstore.AsyncBlobStore; import org.jclouds.blobstore.BlobMap; import org.jclouds.blobstore.BlobRequestSigner; +import org.jclouds.blobstore.BlobStore; import org.jclouds.blobstore.InputStreamMap; import org.jclouds.blobstore.attr.ConsistencyModel; import org.jclouds.blobstore.internal.BlobStoreContextImpl; -import org.jclouds.rest.RestContext; +import org.jclouds.location.Provider; import org.jclouds.rest.Utils; -import org.jclouds.s3.S3AsyncClient; -import org.jclouds.s3.S3Client; import org.jclouds.s3.blobstore.S3AsyncBlobStore; import org.jclouds.s3.blobstore.S3BlobStore; import org.jclouds.s3.blobstore.S3BlobStoreContext; +import com.google.common.reflect.TypeToken; + /** * @author Adrian Cole */ @Singleton -public class S3BlobStoreContextImpl extends - BlobStoreContextImpl implements S3BlobStoreContext { - +public class S3BlobStoreContextImpl extends BlobStoreContextImpl implements S3BlobStoreContext { + @Inject - public S3BlobStoreContextImpl(BlobMap.Factory blobMapFactory, Utils utils, ConsistencyModel consistencyModel, - InputStreamMap.Factory inputStreamMapFactory, S3AsyncBlobStore ablobStore, S3BlobStore blobStore, - @SuppressWarnings("rawtypes") RestContext providerSpecificContext, BlobRequestSigner blobRequestSigner) { - super(blobMapFactory, utils, consistencyModel, inputStreamMapFactory, ablobStore, blobStore, providerSpecificContext, blobRequestSigner); + public S3BlobStoreContextImpl(@Provider Closeable wrapped, @Provider TypeToken wrappedType, + BlobMap.Factory blobMapFactory, Utils utils, ConsistencyModel consistencyModel, + InputStreamMap.Factory inputStreamMapFactory, AsyncBlobStore ablobStore, BlobStore blobStore, + BlobRequestSigner blobRequestSigner) { + super(wrapped, wrappedType, blobMapFactory, utils, consistencyModel, inputStreamMapFactory, ablobStore, + blobStore, blobRequestSigner); } @Override diff --git a/apis/s3/src/main/java/org/jclouds/s3/config/S3RestClientModule.java b/apis/s3/src/main/java/org/jclouds/s3/config/S3RestClientModule.java index 9fcfb355df..a1c4450ebb 100644 --- a/apis/s3/src/main/java/org/jclouds/s3/config/S3RestClientModule.java +++ b/apis/s3/src/main/java/org/jclouds/s3/config/S3RestClientModule.java @@ -30,7 +30,6 @@ 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; @@ -56,10 +55,11 @@ import com.google.inject.Scopes; * @author Adrian Cole */ @ConfiguresRestClient -@RequiresHttp public class S3RestClientModule extends AWSRestClientModule { - public static S3RestClientModule create() { - return new S3RestClientModule(S3Client.class, S3AsyncClient.class); + + @SuppressWarnings("unchecked") + public S3RestClientModule() { + this((Class) S3Client.class, (Class) S3AsyncClient.class); } public S3RestClientModule(Class sync, Class async) { @@ -100,7 +100,7 @@ public class S3RestClientModule ext protected RequestSigner provideRequestSigner(RequestAuthorizeSignature in) { return in; } - + @Override protected void bindRetryHandlers() { bind(HttpRetryHandler.class).annotatedWith(Redirection.class).to(S3RedirectionRetryHandler.class); @@ -119,7 +119,7 @@ public class S3RestClientModule ext @TimeStamp @Singleton protected Supplier provideTimeStampCache(@Named(Constants.PROPERTY_SESSION_INTERVAL) long seconds, - final DateService dateService) { + final DateService dateService) { return Suppliers.memoizeWithExpiration(new Supplier() { public String get() { return dateService.rfc822DateFormat(); diff --git a/apis/s3/src/test/java/org/jclouds/s3/S3ApiMetadataTest.java b/apis/s3/src/test/java/org/jclouds/s3/S3ApiMetadataTest.java index 8445d01a19..dc4a6838ed 100644 --- a/apis/s3/src/test/java/org/jclouds/s3/S3ApiMetadataTest.java +++ b/apis/s3/src/test/java/org/jclouds/s3/S3ApiMetadataTest.java @@ -25,7 +25,6 @@ import org.testng.annotations.Test; * * @author Adrian Cole */ -@SuppressWarnings("rawtypes") @Test(groups = "unit", testName = "S3ApiMetadataTest") public class S3ApiMetadataTest extends BaseBlobStoreApiMetadataTest { diff --git a/apis/s3/src/test/java/org/jclouds/s3/S3AsyncClientTest.java b/apis/s3/src/test/java/org/jclouds/s3/S3AsyncClientTest.java index 94b088cee4..5e54b10483 100644 --- a/apis/s3/src/test/java/org/jclouds/s3/S3AsyncClientTest.java +++ b/apis/s3/src/test/java/org/jclouds/s3/S3AsyncClientTest.java @@ -33,7 +33,6 @@ import org.jclouds.blobstore.functions.ThrowContainerNotFoundOn404; import org.jclouds.blobstore.functions.ThrowKeyNotFoundOn404; import org.jclouds.date.TimeStamp; import org.jclouds.http.HttpRequest; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.functions.ParseETagHeader; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ReleasePayloadAndReturn; @@ -43,13 +42,13 @@ import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; import org.jclouds.s3.config.S3RestClientModule; import org.jclouds.s3.domain.AccessControlList; -import org.jclouds.s3.domain.AccessControlList.EmailAddressGrantee; -import org.jclouds.s3.domain.AccessControlList.Grant; -import org.jclouds.s3.domain.AccessControlList.Permission; import org.jclouds.s3.domain.BucketLogging; import org.jclouds.s3.domain.CannedAccessPolicy; import org.jclouds.s3.domain.Payer; import org.jclouds.s3.domain.S3Object; +import org.jclouds.s3.domain.AccessControlList.EmailAddressGrantee; +import org.jclouds.s3.domain.AccessControlList.Grant; +import org.jclouds.s3.domain.AccessControlList.Permission; import org.jclouds.s3.functions.ParseObjectFromHeadersAndHttpContent; import org.jclouds.s3.functions.ParseObjectMetadataFromHeaders; import org.jclouds.s3.functions.ReturnFalseIfBucketAlreadyOwnedByYouOrIllegalState; @@ -479,8 +478,7 @@ public abstract class S3AsyncClientTest extends BaseS3A checkFilters(request); } - @RequiresHttp - @ConfiguresRestClient + @ConfiguresRestClient private static final class TestS3RestClientModule extends S3RestClientModule { public TestS3RestClientModule() { diff --git a/apis/s3/src/test/java/org/jclouds/s3/S3ClientLiveTest.java b/apis/s3/src/test/java/org/jclouds/s3/S3ClientLiveTest.java index c5ee33c702..74c0b0989a 100644 --- a/apis/s3/src/test/java/org/jclouds/s3/S3ClientLiveTest.java +++ b/apis/s3/src/test/java/org/jclouds/s3/S3ClientLiveTest.java @@ -32,6 +32,7 @@ import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertTrue; import java.io.IOException; +import java.net.URI; import java.net.URL; import java.util.Date; import java.util.Map; @@ -41,13 +42,13 @@ import java.util.concurrent.TimeoutException; import org.jclouds.blobstore.integration.internal.BaseBlobStoreIntegrationTest; import org.jclouds.http.HttpResponseException; import org.jclouds.s3.domain.AccessControlList; +import org.jclouds.s3.domain.CannedAccessPolicy; +import org.jclouds.s3.domain.ObjectMetadata; +import org.jclouds.s3.domain.S3Object; import org.jclouds.s3.domain.AccessControlList.CanonicalUserGrantee; import org.jclouds.s3.domain.AccessControlList.EmailAddressGrantee; import org.jclouds.s3.domain.AccessControlList.GroupGranteeURI; import org.jclouds.s3.domain.AccessControlList.Permission; -import org.jclouds.s3.domain.CannedAccessPolicy; -import org.jclouds.s3.domain.ObjectMetadata; -import org.jclouds.s3.domain.S3Object; import org.jclouds.s3.options.PutObjectOptions; import org.jclouds.util.Strings2; import org.testng.annotations.Test; @@ -67,7 +68,7 @@ public class S3ClientLiveTest extends BaseBlobStoreIntegrationTest { } public S3Client getApi() { - return (S3Client) context.getProviderSpecificContext().getApi(); + return context.unwrap(S3ApiMetadata.CONTEXT_TOKEN).getApi(); } /** @@ -90,8 +91,7 @@ public class S3ClientLiveTest extends BaseBlobStoreIntegrationTest { } protected URL getObjectURL(String containerName, String key) throws Exception { - URL url = new URL(String.format("http://%s.%s/%s", containerName, context.getProviderSpecificContext() - .getEndpoint().getHost(), key)); + URL url = new URL(String.format("http://%s.%s/%s", containerName, URI.create(endpoint).getHost(), key)); return url; } diff --git a/apis/s3/src/test/java/org/jclouds/s3/blobstore/S3BlobRequestSignerTest.java b/apis/s3/src/test/java/org/jclouds/s3/blobstore/S3BlobRequestSignerTest.java index c88a77899e..edc9b03ad1 100644 --- a/apis/s3/src/test/java/org/jclouds/s3/blobstore/S3BlobRequestSignerTest.java +++ b/apis/s3/src/test/java/org/jclouds/s3/blobstore/S3BlobRequestSignerTest.java @@ -29,7 +29,6 @@ import org.jclouds.blobstore.domain.Blob; import org.jclouds.blobstore.domain.BlobBuilder; import org.jclouds.date.TimeStamp; import org.jclouds.http.HttpRequest; -import org.jclouds.http.RequiresHttp; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.s3.S3AsyncClient; @@ -116,7 +115,6 @@ public class S3BlobRequestSignerTest extends BaseS3AsyncClientTest { diff --git a/apis/s3/src/test/java/org/jclouds/s3/internal/BaseS3AsyncClientTest.java b/apis/s3/src/test/java/org/jclouds/s3/internal/BaseS3AsyncClientTest.java index 2fbccb556c..de840e6b59 100644 --- a/apis/s3/src/test/java/org/jclouds/s3/internal/BaseS3AsyncClientTest.java +++ b/apis/s3/src/test/java/org/jclouds/s3/internal/BaseS3AsyncClientTest.java @@ -60,7 +60,6 @@ public abstract class BaseS3AsyncClientTest extends Bas super(); } - @SuppressWarnings({ "rawtypes", "unchecked" }) @Override public S3ApiMetadata createApiMetadata() { return new S3ApiMetadata(); diff --git a/apis/s3/src/test/java/org/jclouds/s3/internal/BaseS3ClientExpectTest.java b/apis/s3/src/test/java/org/jclouds/s3/internal/BaseS3ClientExpectTest.java index c759c546ff..f38e1e4659 100644 --- a/apis/s3/src/test/java/org/jclouds/s3/internal/BaseS3ClientExpectTest.java +++ b/apis/s3/src/test/java/org/jclouds/s3/internal/BaseS3ClientExpectTest.java @@ -19,7 +19,6 @@ package org.jclouds.s3.internal; import org.jclouds.date.TimeStamp; -import org.jclouds.http.RequiresHttp; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.internal.BaseRestClientExpectTest; import org.jclouds.s3.S3ApiMetadata; @@ -38,8 +37,7 @@ public abstract class BaseS3ClientExpectTest extends BaseRestClientExpectTest { public TestS3RestClientModule() { @@ -57,7 +55,6 @@ public abstract class BaseS3ClientExpectTest extends BaseRestClientExpectTest, SwiftApiMetadata> { +public class SwiftApiMetadata extends BaseRestApiMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = 6725672099385580694L; + + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; + private static Builder builder() { return new Builder(); } @@ -57,27 +66,25 @@ public class SwiftApiMetadata super(builder); } - protected static Properties defaultProperties() { - Properties properties = BaseBlobStoreApiMetadata.Builder.defaultProperties(); + public static Properties defaultProperties() { + Properties properties = BaseRestApiMetadata.defaultProperties(); properties.setProperty(PROPERTY_REGIONS, "DEFAULT"); properties.setProperty(PROPERTY_USER_METADATA_PREFIX, "X-Object-Meta-"); return properties; } - public static class Builder - extends - BaseBlobStoreApiMetadata.Builder, SwiftApiMetadata> { + public static class Builder extends BaseRestApiMetadata.Builder { protected Builder() { + super(SwiftClient.class, SwiftAsyncClient.class); id("swift") - .type(ApiType.BLOBSTORE) .name("OpenStack Swift Pre-Diablo API") .identityName("tenantId:user") .credentialName("password") .documentation(URI.create("http://api.openstack.org/")) .version(OpenStackAuthAsyncClient.VERSION) - .contextBuilder(TypeToken.of(SwiftContextBuilder.class)) .defaultProperties(SwiftApiMetadata.defaultProperties()) - .javaApi(SwiftClient.class, SwiftAsyncClient.class); + .wrapper(TypeToken.of(BlobStoreContext.class)) + .defaultModules(ImmutableSet.>of(SwiftRestClientModule.class, SwiftBlobStoreContextModule.class)); } @Override @@ -86,7 +93,7 @@ public class SwiftApiMetadata } @Override - public Builder fromApiMetadata(SwiftApiMetadata in) { + public Builder fromApiMetadata(ApiMetadata in) { super.fromApiMetadata(in); return this; } diff --git a/apis/swift/src/main/java/org/jclouds/openstack/swift/SwiftContextBuilder.java b/apis/swift/src/main/java/org/jclouds/openstack/swift/SwiftContextBuilder.java deleted file mode 100644 index a64a01c24a..0000000000 --- a/apis/swift/src/main/java/org/jclouds/openstack/swift/SwiftContextBuilder.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * 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.openstack.swift; - -import java.util.List; - -import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextBuilder; -import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; -import org.jclouds.logging.jdk.config.JDKLoggingModule; -import org.jclouds.openstack.swift.blobstore.config.SwiftBlobStoreContextModule; -import org.jclouds.openstack.swift.config.SwiftRestClientModule; -import org.jclouds.providers.ProviderMetadata; - -import com.google.inject.Injector; -import com.google.inject.Module; - -/** - * Creates {@link SwiftStoreContext} or {@link Injector} instances based on - * the most commonly requested arguments. - *

- * Note that Threadsafe objects will be bound as singletons to the Injector or - * Context provided. - *

- *

- * If no Modules are specified, the default - * {@link JDKLoggingModule logging} and - * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be - * installed. - * - * @author Adrian Cole, Andrew Newdigate - * @see SwiftStoreContext - */ -public class SwiftContextBuilder - extends - BlobStoreContextBuilder, SwiftApiMetadata> { - - public SwiftContextBuilder( - ProviderMetadata, SwiftApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public SwiftContextBuilder(SwiftApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new SwiftBlobStoreContextModule()); - } - - @Override - protected void addClientModule(List modules) { - modules.add(new SwiftRestClientModule()); - } -} \ No newline at end of file diff --git a/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/SwiftAsyncBlobStore.java b/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/SwiftAsyncBlobStore.java index ec12eec9ec..b0873c9af6 100644 --- a/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/SwiftAsyncBlobStore.java +++ b/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/SwiftAsyncBlobStore.java @@ -83,7 +83,7 @@ public class SwiftAsyncBlobStore extends BaseAsyncBlobStore { private final Provider fetchBlobMetadataProvider; @Inject - protected SwiftAsyncBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, + protected SwiftAsyncBlobStore(BlobStoreContext context, BlobUtils blobUtils, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService service, Supplier defaultLocation, @Memoized Supplier> locations, CommonSwiftClient sync, CommonSwiftAsyncClient async, ContainerToResourceMetadata container2ResourceMd, diff --git a/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/SwiftBlobStore.java b/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/SwiftBlobStore.java index 9d2fab5638..e96909ba18 100644 --- a/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/SwiftBlobStore.java +++ b/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/SwiftBlobStore.java @@ -73,7 +73,7 @@ public class SwiftBlobStore extends BaseBlobStore { private final Provider fetchBlobMetadataProvider; @Inject - protected SwiftBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, Supplier defaultLocation, + protected SwiftBlobStore(BlobStoreContext context, BlobUtils blobUtils, Supplier defaultLocation, @Memoized Supplier> locations, CommonSwiftClient sync, ContainerToResourceMetadata container2ResourceMd, BlobStoreListContainerOptionsToListContainerOptions container2ContainerListOptions, diff --git a/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/config/SwiftBlobStoreContextModule.java b/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/config/SwiftBlobStoreContextModule.java index ff440f8b59..01d39c7d2d 100644 --- a/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/config/SwiftBlobStoreContextModule.java +++ b/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/config/SwiftBlobStoreContextModule.java @@ -21,19 +21,14 @@ package org.jclouds.openstack.swift.blobstore.config; import org.jclouds.blobstore.AsyncBlobStore; import org.jclouds.blobstore.BlobRequestSigner; import org.jclouds.blobstore.BlobStore; -import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.blobstore.attr.ConsistencyModel; import org.jclouds.blobstore.config.BlobStoreMapModule; -import org.jclouds.blobstore.internal.BlobStoreContextImpl; -import org.jclouds.openstack.swift.CommonSwiftAsyncClient; -import org.jclouds.openstack.swift.CommonSwiftClient; import org.jclouds.openstack.swift.blobstore.SwiftAsyncBlobStore; import org.jclouds.openstack.swift.blobstore.SwiftBlobRequestSigner; import org.jclouds.openstack.swift.blobstore.SwiftBlobStore; import com.google.inject.AbstractModule; import com.google.inject.Scopes; -import com.google.inject.TypeLiteral; /** * Configures the {@link CloudFilesBlobStoreContext}; requires {@link SwiftAsyncBlobStore} @@ -49,8 +44,6 @@ public class SwiftBlobStoreContextModule extends AbstractModule { bind(ConsistencyModel.class).toInstance(ConsistencyModel.STRICT); bind(AsyncBlobStore.class).to(SwiftAsyncBlobStore.class).in(Scopes.SINGLETON); bind(BlobStore.class).to(SwiftBlobStore.class).in(Scopes.SINGLETON); - bind(BlobStoreContext.class).to(new TypeLiteral>() { - }).in(Scopes.SINGLETON); bind(BlobRequestSigner.class).to(SwiftBlobRequestSigner.class); } diff --git a/apis/swift/src/main/java/org/jclouds/openstack/swift/config/BaseSwiftRestClientModule.java b/apis/swift/src/main/java/org/jclouds/openstack/swift/config/BaseSwiftRestClientModule.java index d750b7a325..4dd913724a 100644 --- a/apis/swift/src/main/java/org/jclouds/openstack/swift/config/BaseSwiftRestClientModule.java +++ b/apis/swift/src/main/java/org/jclouds/openstack/swift/config/BaseSwiftRestClientModule.java @@ -23,7 +23,6 @@ import java.net.URI; import javax.inject.Singleton; import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.ServerError; @@ -47,7 +46,6 @@ import com.google.inject.Provides; * @author Adrian Cole */ @ConfiguresRestClient -@RequiresHttp public class BaseSwiftRestClientModule extends RestClientModule { private final OpenStackAuthenticationModule module; diff --git a/apis/swift/src/main/java/org/jclouds/openstack/swift/config/SwiftRestClientModule.java b/apis/swift/src/main/java/org/jclouds/openstack/swift/config/SwiftRestClientModule.java index 9186c7e38c..a647924ca4 100644 --- a/apis/swift/src/main/java/org/jclouds/openstack/swift/config/SwiftRestClientModule.java +++ b/apis/swift/src/main/java/org/jclouds/openstack/swift/config/SwiftRestClientModule.java @@ -20,7 +20,6 @@ package org.jclouds.openstack.swift.config; import javax.inject.Singleton; -import org.jclouds.http.RequiresHttp; import org.jclouds.openstack.swift.CommonSwiftAsyncClient; import org.jclouds.openstack.swift.CommonSwiftClient; import org.jclouds.openstack.swift.SwiftAsyncClient; @@ -34,7 +33,6 @@ import com.google.inject.Provides; * @author Adrian Cole */ @ConfiguresRestClient -@RequiresHttp public class SwiftRestClientModule extends BaseSwiftRestClientModule { public SwiftRestClientModule() { diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/CommonSwiftClientTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/CommonSwiftClientTest.java index 4906ebd24e..ced9b5fab5 100644 --- a/apis/swift/src/test/java/org/jclouds/openstack/swift/CommonSwiftClientTest.java +++ b/apis/swift/src/test/java/org/jclouds/openstack/swift/CommonSwiftClientTest.java @@ -24,16 +24,20 @@ import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; import java.util.Properties; +import javax.inject.Singleton; + import org.jclouds.apis.ApiMetadata; import org.jclouds.http.HttpRequest; -import org.jclouds.http.RequiresHttp; import org.jclouds.openstack.TestOpenStackAuthenticationModule; import org.jclouds.openstack.swift.config.BaseSwiftRestClientModule; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.internal.BaseAsyncClientTest; +import org.jclouds.rest.internal.RestAnnotationProcessor; import org.testng.annotations.Test; import com.google.inject.Module; +import com.google.inject.Provides; +import com.google.inject.TypeLiteral; /** * Tests behavior of {@code BindSwiftObjectMetadataToRequest} @@ -42,8 +46,14 @@ import com.google.inject.Module; */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "SwiftClientTest") -public abstract class CommonSwiftClientTest extends BaseAsyncClientTest { - +public abstract class CommonSwiftClientTest extends BaseAsyncClientTest { + + @Override + protected TypeLiteral> createTypeLiteral() { + return new TypeLiteral>() { + }; + } + @Override protected void checkFilters(HttpRequest request) { } @@ -54,17 +64,27 @@ public abstract class CommonSwiftClientTest ex } @ConfiguresRestClient - @RequiresHttp protected static class TestSwiftRestClientModule extends - BaseSwiftRestClientModule { + BaseSwiftRestClientModule { private TestSwiftRestClientModule() { - super(new TestOpenStackAuthenticationModule(), CommonSwiftClient.class, CommonSwiftAsyncClient.class); + super(new TestOpenStackAuthenticationModule(), SwiftClient.class, SwiftAsyncClient.class); + } + @Provides + @Singleton + CommonSwiftClient provideCommonSwiftClient(SwiftClient in) { + return in; + } + + @Provides + @Singleton + CommonSwiftAsyncClient provideCommonSwiftClient(SwiftAsyncClient in) { + return in; } } protected String provider = "swift"; - protected ApiMetadata createApiMetadata() { + protected ApiMetadata createApiMetadata() { return new SwiftApiMetadata(); } diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/SwiftApiMetadataTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/SwiftApiMetadataTest.java index f9cd2b4882..383d5cd173 100644 --- a/apis/swift/src/test/java/org/jclouds/openstack/swift/SwiftApiMetadataTest.java +++ b/apis/swift/src/test/java/org/jclouds/openstack/swift/SwiftApiMetadataTest.java @@ -1,3 +1,21 @@ +/** + * 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.openstack.swift; import org.jclouds.blobstore.internal.BaseBlobStoreApiMetadataTest; diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/SwiftClientLiveTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/SwiftClientLiveTest.java index 8cc7bd1e1a..06a26a5ca3 100644 --- a/apis/swift/src/test/java/org/jclouds/openstack/swift/SwiftClientLiveTest.java +++ b/apis/swift/src/test/java/org/jclouds/openstack/swift/SwiftClientLiveTest.java @@ -33,7 +33,7 @@ public class SwiftClientLiveTest extends CommonSwiftClientLiveTest @Override public SwiftClient getApi() { - return (SwiftClient) context.getProviderSpecificContext().getApi(); + return context.unwrap(SwiftApiMetadata.CONTEXT_TOKEN).getApi(); } } diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/binders/BindSwiftObjectMetadataToRequestTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/binders/BindSwiftObjectMetadataToRequestTest.java index d2b5ddb5f9..7cd857c41b 100644 --- a/apis/swift/src/test/java/org/jclouds/openstack/swift/binders/BindSwiftObjectMetadataToRequestTest.java +++ b/apis/swift/src/test/java/org/jclouds/openstack/swift/binders/BindSwiftObjectMetadataToRequestTest.java @@ -28,15 +28,12 @@ import javax.ws.rs.HttpMethod; import org.jclouds.http.HttpRequest; import org.jclouds.io.Payload; import org.jclouds.io.Payloads; -import org.jclouds.openstack.swift.CommonSwiftAsyncClient; import org.jclouds.openstack.swift.CommonSwiftClientTest; import org.jclouds.openstack.swift.domain.SwiftObject; -import org.jclouds.rest.internal.RestAnnotationProcessor; import org.testng.annotations.Test; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMultimap; -import com.google.inject.TypeLiteral; /** * Tests behavior of {@code BindSwiftObjectMetadataToRequest} @@ -45,12 +42,7 @@ import com.google.inject.TypeLiteral; */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "BindSwiftObjectMetadataToRequestTest") -public class BindSwiftObjectMetadataToRequestTest extends CommonSwiftClientTest { - @Override - protected TypeLiteral> createTypeLiteral() { - return new TypeLiteral>() { - }; - } +public class BindSwiftObjectMetadataToRequestTest extends CommonSwiftClientTest { @Test public void testPassWithMinimumDetailsAndPayload5GB() { diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/SwiftBlobRequestSignerTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/SwiftBlobRequestSignerTest.java index bdfe049363..127d4d1945 100644 --- a/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/SwiftBlobRequestSignerTest.java +++ b/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/SwiftBlobRequestSignerTest.java @@ -26,14 +26,10 @@ import org.jclouds.blobstore.BlobRequestSigner; import org.jclouds.blobstore.domain.Blob; import org.jclouds.blobstore.domain.Blob.Factory; import org.jclouds.http.HttpRequest; -import org.jclouds.openstack.swift.CommonSwiftAsyncClient; import org.jclouds.openstack.swift.CommonSwiftClientTest; -import org.jclouds.rest.internal.RestAnnotationProcessor; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import com.google.inject.TypeLiteral; - /** * Tests behavior of {@code CommonSwiftBlobRequestSigner} * @@ -41,12 +37,7 @@ import com.google.inject.TypeLiteral; */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "SwiftBlobRequestSignerTest") -public class SwiftBlobRequestSignerTest extends CommonSwiftClientTest { - @Override - protected TypeLiteral> createTypeLiteral() { - return new TypeLiteral>() { - }; - } +public class SwiftBlobRequestSignerTest extends CommonSwiftClientTest { private BlobRequestSigner signer; private Factory blobFactory; diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudApiMetadata.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudApiMetadata.java index 9238fca5ea..eeb118be97 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudApiMetadata.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudApiMetadata.java @@ -30,20 +30,30 @@ import java.util.Properties; import org.jclouds.apis.ApiMetadata; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; +import org.jclouds.rest.RestContext; +import org.jclouds.rest.internal.BaseRestApiMetadata; +import org.jclouds.vcloud.compute.config.VCloudComputeServiceContextModule; +import org.jclouds.vcloud.config.VCloudRestClientModule; import org.jclouds.vcloud.domain.network.FenceMode; +import com.google.common.collect.ImmutableSet; import com.google.common.reflect.TypeToken; +import com.google.inject.Module; /** * Implementation of {@link ApiMetadata} for VCloud 1.0 API * * @author Adrian Cole */ -public class VCloudApiMetadata - extends - BaseComputeServiceApiMetadata, VCloudApiMetadata> { +public class VCloudApiMetadata extends BaseRestApiMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 6725672099385580694L; + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; + @Override public Builder toBuilder() { return new Builder().fromApiMetadata(this); @@ -57,8 +67,8 @@ public class VCloudApiMetadata super(builder); } - protected static Properties defaultProperties() { - Properties properties = BaseComputeServiceApiMetadata.Builder.defaultProperties(); + public static Properties defaultProperties() { + Properties properties = BaseRestApiMetadata.defaultProperties(); properties.setProperty(PROPERTY_VCLOUD_VERSION_SCHEMA, "1"); properties.setProperty(PROPERTY_VCLOUD_XML_NAMESPACE, String.format("http://www.vmware.com/vcloud/v${%s}", PROPERTY_VCLOUD_VERSION_SCHEMA)); @@ -75,20 +85,19 @@ public class VCloudApiMetadata return properties; } - public static class Builder - extends - BaseComputeServiceApiMetadata.Builder, VCloudApiMetadata> { + public static class Builder extends BaseRestApiMetadata.Builder { protected Builder() { + super(VCloudClient.class, VCloudAsyncClient.class); id("vcloud") .name("VCloud 1.0 API") .identityName("User at Organization (user@org)") .credentialName("Password") .documentation(URI.create("http://www.vmware.com/support/pubs/vcd_pubs.html")) .version("1.0") - .javaApi(VCloudClient.class, VCloudAsyncClient.class) .defaultProperties(VCloudApiMetadata.defaultProperties()) - .contextBuilder(TypeToken.of(VCloudContextBuilder.class)); + .wrapper(TypeToken.of(ComputeServiceContext.class)) + .defaultModules(ImmutableSet.>of(VCloudRestClientModule.class, VCloudComputeServiceContextModule.class)); } @Override @@ -97,7 +106,7 @@ public class VCloudApiMetadata } @Override - public Builder fromApiMetadata(VCloudApiMetadata in) { + public Builder fromApiMetadata(ApiMetadata in) { super.fromApiMetadata(in); return this; } diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudContextBuilder.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudContextBuilder.java deleted file mode 100644 index a69b0105c2..0000000000 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudContextBuilder.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * 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.vcloud; - -import java.util.List; - -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextBuilder; -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.vcloud.compute.config.VCloudComputeServiceContextModule; -import org.jclouds.vcloud.config.VCloudRestClientModule; - -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class VCloudContextBuilder - extends - ComputeServiceContextBuilder, VCloudApiMetadata> { - - public VCloudContextBuilder( - ProviderMetadata, VCloudApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public VCloudContextBuilder(VCloudApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new VCloudComputeServiceContextModule()); - } - - protected void addClientModule(List modules) { - modules.add(new VCloudRestClientModule()); - } - -} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceContextModule.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceContextModule.java index 7dd57118dc..bc29a2fe87 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceContextModule.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceContextModule.java @@ -23,8 +23,6 @@ import static org.jclouds.compute.domain.OsFamily.UBUNTU; import org.jclouds.compute.config.ComputeServiceAdapterContextModule; import org.jclouds.compute.domain.TemplateBuilder; import org.jclouds.domain.Location; -import org.jclouds.vcloud.VCloudAsyncClient; -import org.jclouds.vcloud.VCloudClient; import org.jclouds.vcloud.domain.VApp; import org.jclouds.vcloud.domain.VAppTemplate; @@ -36,12 +34,8 @@ import com.google.inject.Injector; * * @author Adrian Cole */ -public class VCloudComputeServiceContextModule - extends - ComputeServiceAdapterContextModule { - public VCloudComputeServiceContextModule() { - super(VCloudClient.class, VCloudAsyncClient.class); - } +public class VCloudComputeServiceContextModule extends + ComputeServiceAdapterContextModule { @Override protected void configure() { diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/config/VCloudRestClientModule.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/config/VCloudRestClientModule.java index 910e5d37d9..486df9b030 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/config/VCloudRestClientModule.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/config/VCloudRestClientModule.java @@ -47,7 +47,6 @@ import javax.inject.Singleton; import org.jclouds.cim.xml.ResourceAllocationSettingDataHandler; import org.jclouds.domain.Location; import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.ServerError; @@ -129,7 +128,6 @@ import com.google.inject.TypeLiteral; * * @author Adrian Cole */ -@RequiresHttp @ConfiguresRestClient public class VCloudRestClientModule extends RestClientModule { diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudApiMetadataTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudApiMetadataTest.java index 9bb06859b2..6751518b91 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudApiMetadataTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudApiMetadataTest.java @@ -18,8 +18,7 @@ */ package org.jclouds.vcloud; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.internal.BaseApiMetadataTest; +import org.jclouds.compute.internal.BaseComputeServiceApiMetadataTest; import org.testng.annotations.Test; /** @@ -27,9 +26,9 @@ import org.testng.annotations.Test; * @author Adrian Cole */ @Test(groups = "unit", testName = "VCloudApiMetadataTest") -public class VCloudApiMetadataTest extends BaseApiMetadataTest { +public class VCloudApiMetadataTest extends BaseComputeServiceApiMetadataTest { public VCloudApiMetadataTest() { - super(new VCloudApiMetadata(), ApiType.COMPUTE); + super(new VCloudApiMetadata()); } } diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudSessionRefreshLiveTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudSessionRefreshLiveTest.java index cf802d6715..bcbaa94231 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudSessionRefreshLiveTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudSessionRefreshLiveTest.java @@ -33,7 +33,8 @@ public class VCloudSessionRefreshLiveTest extends BaseVCloudClientLiveTest { @Test public void testSessionRefresh() throws Exception { - VCloudClient connection = VCloudClient.class.cast(client.getContext().getProviderSpecificContext().getApi()); + VCloudClient connection = VCloudClient.class.cast(client.getContext().unwrap(VCloudApiMetadata.CONTEXT_TOKEN) + .getApi()); connection.getOrgClient().findOrgNamed(null); Thread.sleep(timeOut * 1000); diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudVersionsAsyncClientTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudVersionsAsyncClientTest.java index 0afb3ade55..5f98738c1b 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudVersionsAsyncClientTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudVersionsAsyncClientTest.java @@ -70,7 +70,7 @@ public class VCloudVersionsAsyncClientTest extends BaseAsyncClientTest createProviderMetadata() { + protected ProviderMetadata createProviderMetadata() { return AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint(VCloudVersionsClient.class, VCloudVersionsAsyncClient.class, "http://localhost:8080"); } diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayloadTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayloadTest.java index fb2c2c2483..a2aac9fe2a 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayloadTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayloadTest.java @@ -27,9 +27,9 @@ import java.io.IOException; import java.net.URI; import java.util.Properties; -import org.jclouds.PropertiesBuilder; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.util.Strings2; +import org.jclouds.vcloud.VCloudApiMetadata; import org.jclouds.vcloud.options.CloneVAppOptions; import org.testng.annotations.Test; @@ -52,10 +52,10 @@ public class BindCloneVAppParamsToXmlPayloadTest { @Override protected void configure() { - Properties props = new Properties(); + Properties props = new VCloudApiMetadata().getDefaultProperties(); props.setProperty("jclouds.vcloud.xml.ns", "http://www.vmware.com/vcloud/v1"); props.setProperty("jclouds.vcloud.xml.schema", "http://vcloud.safesecureweb.com/ns/vcloud.xsd"); - Names.bindProperties(binder(), new PropertiesBuilder(props).build()); + Names.bindProperties(binder(), props); } }); diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppTemplateParamsToXmlPayloadTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppTemplateParamsToXmlPayloadTest.java index e0caf5fbdc..8212c52f23 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppTemplateParamsToXmlPayloadTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppTemplateParamsToXmlPayloadTest.java @@ -27,9 +27,9 @@ import java.io.IOException; import java.net.URI; import java.util.Properties; -import org.jclouds.PropertiesBuilder; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.util.Strings2; +import org.jclouds.vcloud.VCloudApiMetadata; import org.jclouds.vcloud.options.CloneVAppTemplateOptions; import org.testng.annotations.Test; @@ -55,7 +55,7 @@ public class BindCloneVAppTemplateParamsToXmlPayloadTest { Properties props = new Properties(); props.setProperty("jclouds.vcloud.xml.ns", "http://www.vmware.com/vcloud/v1"); props.setProperty("jclouds.vcloud.xml.schema", "http://vcloud.safesecureweb.com/ns/vcloud.xsd"); - Names.bindProperties(binder(), new PropertiesBuilder(props).build()); + Names.bindProperties(binder(), new VCloudApiMetadata().getDefaultProperties()); } }); diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/BaseVCloudComputeServiceExpectTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/BaseVCloudComputeServiceExpectTest.java index 59b371f4e3..3dca2658d4 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/BaseVCloudComputeServiceExpectTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/BaseVCloudComputeServiceExpectTest.java @@ -151,7 +151,7 @@ public abstract class BaseVCloudComputeServiceExpectTest extends BaseRestClientE } @Override - protected ApiMetadata createApiMetadata() { + protected ApiMetadata createApiMetadata() { return new VCloudApiMetadata(); } diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/VCloudComputeServiceLiveTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/VCloudComputeServiceLiveTest.java index e10e9dc449..b2b266c854 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/VCloudComputeServiceLiveTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/VCloudComputeServiceLiveTest.java @@ -18,12 +18,9 @@ */ package org.jclouds.vcloud.compute; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.internal.BaseComputeServiceLiveTest; import org.jclouds.sshj.config.SshjSshClientModule; -import org.jclouds.vcloud.VCloudAsyncClient; -import org.jclouds.vcloud.VCloudClient; import org.testng.annotations.Test; import com.google.common.collect.ImmutableMap; @@ -35,9 +32,7 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", enabled = true, singleThreaded = true) -public class VCloudComputeServiceLiveTest - extends - BaseComputeServiceLiveTest> { +public class VCloudComputeServiceLiveTest extends BaseComputeServiceLiveTest { public VCloudComputeServiceLiveTest() { provider = "vcloud"; diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/CatalogClientLiveTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/CatalogClientLiveTest.java index 28e1aeed00..36ee0a4b00 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/CatalogClientLiveTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/CatalogClientLiveTest.java @@ -22,12 +22,15 @@ import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; +import org.jclouds.rest.annotations.ApiVersion; import org.jclouds.vcloud.VCloudMediaType; import org.jclouds.vcloud.domain.Org; import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.internal.BaseVCloudClientLiveTest; import org.testng.annotations.Test; +import com.google.inject.Key; + /** * @author Adrian Cole */ @@ -46,7 +49,7 @@ public class CatalogClientLiveTest extends BaseVCloudClientLiveTest { public void testFindCatalogIsWriteableIfNotVersion1_5() throws Exception { // when we are in vCloud 1.0.0 public catalogs don't work, so our default // catalog is private - if (!context.getProviderSpecificContext().getApiVersion().startsWith("1.5")) + if (!context.utils().injector().getInstance(Key.get(String.class, ApiVersion.class)).startsWith("1.5")) assertTrue(getVCloudApi().getCatalogClient().findCatalogInOrgNamed(null, null).isReadOnly()); } } \ No newline at end of file diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VmClientLiveTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VmClientLiveTest.java index eee3b7ecb8..2fd7661601 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VmClientLiveTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VmClientLiveTest.java @@ -29,7 +29,7 @@ import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.options.TemplateOptions; import org.jclouds.net.IPSocket; -import org.jclouds.vcloud.VCloudClient; +import org.jclouds.vcloud.VCloudApiMetadata; import org.jclouds.vcloud.VCloudMediaType; import org.jclouds.vcloud.compute.options.VCloudTemplateOptions; import org.jclouds.vcloud.domain.Org; @@ -109,8 +109,8 @@ public class VmClientLiveTest extends BaseVCloudClientLiveTest { options.as(VCloudTemplateOptions.class).description(group); node = getOnlyElement(client.createNodesInGroup(group, 1, options)); - VApp vapp = ((VCloudClient) client.getContext().getProviderSpecificContext().getApi()).getVAppClient() - .getVApp(node.getUri()); + VApp vapp = client.getContext().unwrap(VCloudApiMetadata.CONTEXT_TOKEN).getApi().getVAppClient().getVApp( + node.getUri()); assertEquals(vapp.getDescription(), group); Vm vm = Iterables.get(vapp.getChildren(), 0); diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BaseVCloudAsyncClientTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BaseVCloudAsyncClientTest.java index a954d20ab7..93edd14153 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BaseVCloudAsyncClientTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BaseVCloudAsyncClientTest.java @@ -30,7 +30,6 @@ import javax.inject.Named; import javax.inject.Singleton; import org.jclouds.http.HttpRequest; -import org.jclouds.http.RequiresHttp; import org.jclouds.ovf.Envelope; import org.jclouds.ovf.xml.EnvelopeHandlerTest; import org.jclouds.providers.AnonymousProviderMetadata; @@ -91,7 +90,7 @@ public abstract class BaseVCloudAsyncClientTest extends BaseAsyncClientTest createProviderMetadata() { + protected ProviderMetadata createProviderMetadata() { return AnonymousProviderMetadata.forApiWithEndpoint(new VCloudApiMetadata(), "https://vcenterprise.bluelock.com/api/v1.0"); } @@ -126,8 +125,7 @@ public abstract class BaseVCloudAsyncClientTest extends BaseAsyncClientTest of(NETWORK_REF.getName(), NETWORK_REF), 0, 0, 0, false); - @RequiresHttp - @ConfiguresRestClient + @ConfiguresRestClient public static class VCloudRestClientModuleExtension extends VCloudRestClientModule { @Override diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BaseVCloudClientLiveTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BaseVCloudClientLiveTest.java index 07edbf1379..e806763fe3 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BaseVCloudClientLiveTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BaseVCloudClientLiveTest.java @@ -19,10 +19,9 @@ package org.jclouds.vcloud.internal; import org.jclouds.compute.ComputeService; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.sshj.config.SshjSshClientModule; -import org.jclouds.vcloud.VCloudAsyncClient; +import org.jclouds.vcloud.VCloudApiMetadata; import org.jclouds.vcloud.VCloudClient; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -34,9 +33,7 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", enabled = true, singleThreaded = true) -public abstract class BaseVCloudClientLiveTest - extends - BaseComputeServiceContextLiveTest> { +public abstract class BaseVCloudClientLiveTest extends BaseComputeServiceContextLiveTest { // username is too long for name constraints protected String prefix = "vcd"; @@ -48,7 +45,7 @@ public abstract class BaseVCloudClientLiveTest } protected VCloudClient getVCloudApi() { - return VCloudClient.class.cast(context.getProviderSpecificContext().getApi()); + return VCloudClient.class.cast(context.unwrap(VCloudApiMetadata.CONTEXT_TOKEN).getApi()); } @Override diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/VCloudLoginAsyncClientTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/VCloudLoginAsyncClientTest.java index 9bc2626430..b9f72de188 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/VCloudLoginAsyncClientTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/VCloudLoginAsyncClientTest.java @@ -98,7 +98,7 @@ public class VCloudLoginAsyncClientTest extends BaseAsyncClientTest createProviderMetadata() { + protected ProviderMetadata createProviderMetadata() { return AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint(VCloudLoginClient.class, VCloudLoginAsyncClient.class, "http://localhost:8080/login"); } diff --git a/apis/walrus/src/main/java/org/jclouds/walrus/WalrusApiMetadata.java b/apis/walrus/src/main/java/org/jclouds/walrus/WalrusApiMetadata.java index d69db928ac..c2d4364949 100644 --- a/apis/walrus/src/main/java/org/jclouds/walrus/WalrusApiMetadata.java +++ b/apis/walrus/src/main/java/org/jclouds/walrus/WalrusApiMetadata.java @@ -27,16 +27,21 @@ import org.jclouds.apis.ApiMetadata; import org.jclouds.s3.S3ApiMetadata; import org.jclouds.s3.S3AsyncClient; import org.jclouds.s3.S3Client; -import org.jclouds.s3.blobstore.S3BlobStoreContext; +import org.jclouds.s3.blobstore.config.S3BlobStoreContextModule; +import org.jclouds.walrus.config.WalrusRestClientModule; -import com.google.common.reflect.TypeToken; +import com.google.common.collect.ImmutableSet; +import com.google.inject.Module; /** * Implementation of {@link ApiMetadata} for the Walrus S3 API * * @author Adrian Cole */ -public class WalrusApiMetadata extends S3ApiMetadata, WalrusApiMetadata> { +public class WalrusApiMetadata extends S3ApiMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = 820062881469203616L; + private static Builder builder() { return new Builder(); } @@ -54,21 +59,21 @@ public class WalrusApiMetadata extends S3ApiMetadata, WalrusApiMetadata> { + public static class Builder extends S3ApiMetadata.Builder { protected Builder(){ super(S3Client.class, S3AsyncClient.class); id("walrus") .name("Walrus (S3 clone) API") .version("Walrus-1.6") .defaultProperties(WalrusApiMetadata.defaultProperties()) - .contextBuilder(TypeToken.of(WalrusContextBuilder.class)); + .defaultModules(ImmutableSet.>of(WalrusRestClientModule.class, S3BlobStoreContextModule.class)); } @Override @@ -77,7 +82,7 @@ public class WalrusApiMetadata extends S3ApiMetadata, WalrusApiMetadata> { - public WalrusContextBuilder() { - this(new WalrusApiMetadata()); - } - - public WalrusContextBuilder( - ProviderMetadata, WalrusApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public WalrusContextBuilder(WalrusApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addClientModule(List modules) { - modules.add(new WalrusRestClientModule()); - } -} diff --git a/apis/walrus/src/main/java/org/jclouds/walrus/config/WalrusRestClientModule.java b/apis/walrus/src/main/java/org/jclouds/walrus/config/WalrusRestClientModule.java index 3f1fc1784d..9cf9b5560a 100644 --- a/apis/walrus/src/main/java/org/jclouds/walrus/config/WalrusRestClientModule.java +++ b/apis/walrus/src/main/java/org/jclouds/walrus/config/WalrusRestClientModule.java @@ -20,7 +20,6 @@ package org.jclouds.walrus.config; import javax.inject.Singleton; -import org.jclouds.http.RequiresHttp; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.s3.S3AsyncClient; import org.jclouds.s3.S3Client; @@ -34,7 +33,6 @@ import com.google.inject.Provides; * @author Adrian Cole */ @ConfiguresRestClient -@RequiresHttp public class WalrusRestClientModule extends S3RestClientModule { public WalrusRestClientModule() { diff --git a/apis/walrus/src/test/java/org/jclouds/walrus/WalrusClientLiveTest.java b/apis/walrus/src/test/java/org/jclouds/walrus/WalrusClientLiveTest.java index 57a35d2fb9..f939eeca1f 100644 --- a/apis/walrus/src/test/java/org/jclouds/walrus/WalrusClientLiveTest.java +++ b/apis/walrus/src/test/java/org/jclouds/walrus/WalrusClientLiveTest.java @@ -36,8 +36,7 @@ public class WalrusClientLiveTest extends S3ClientLiveTest { // path based, not virtual host @Override protected URL getObjectURL(String containerName, String key) throws Exception { - URL url = new URL(String.format(context.getProviderSpecificContext().getEndpoint().toASCIIString() - + "/services/Walrus/%s/%s", containerName, key)); + URL url = new URL(String.format(endpoint + "/services/Walrus/%s/%s", containerName, key)); return url; } diff --git a/blobstore/src/main/clojure/org/jclouds/blobstore2.clj b/blobstore/src/main/clojure/org/jclouds/blobstore2.clj index 5e85f0ab2f..1bb2a87abb 100644 --- a/blobstore/src/main/clojure/org/jclouds/blobstore2.clj +++ b/blobstore/src/main/clojure/org/jclouds/blobstore2.clj @@ -44,9 +44,10 @@ See http://code.google.com/p/jclouds for details." (:use [org.jclouds.core]) (:import [java.io File FileOutputStream OutputStream] java.util.Properties + [org.jclouds ContextBuilder] [org.jclouds.blobstore AsyncBlobStore domain.BlobBuilder BlobStore BlobStoreContext - BlobStoreContextBuilder domain.BlobMetadata domain.StorageMetadata + domain.BlobMetadata domain.StorageMetadata domain.Blob domain.internal.BlobBuilderImpl options.PutOptions options.PutOptions$Builder options.CreateContainerOptions options.ListContainerOptions] @@ -112,12 +113,12 @@ Options can also be specified for extension modules (let [module-keys (set (keys module-lookup)) ext-modules (filter #(module-keys %) options) opts (apply hash-map (filter #(not (module-keys %)) options))] - (let [context (.. (BlobStoreContextBuilder/newBuilder provider) + (let [context (.. (ContextBuilder/newBuilder provider) (credentials provider-identity provider-credential) (modules (apply modules (concat ext-modules (opts :extensions)))) (overrides (reduce #(do (.put %1 (name (first %2)) (second %2)) %1) (Properties.) (dissoc opts :extensions))) - (build))] + (build BlobStoreContext))] (if (some #(= :async %) options) (.getAsyncBlobStore context) (.getBlobStore context))))) diff --git a/blobstore/src/main/java/org/jclouds/blobstore/AsyncBlobStore.java b/blobstore/src/main/java/org/jclouds/blobstore/AsyncBlobStore.java index 1a7427e43d..cf2897988b 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/AsyncBlobStore.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/AsyncBlobStore.java @@ -43,7 +43,7 @@ public interface AsyncBlobStore { /** * @see BlobStore#getContext */ - BlobStoreContext getContext(); + BlobStoreContext getContext(); /** * @see BlobStore#blobBuilder diff --git a/blobstore/src/main/java/org/jclouds/blobstore/BlobStore.java b/blobstore/src/main/java/org/jclouds/blobstore/BlobStore.java index 89a9b4359a..b9fa416c25 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/BlobStore.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/BlobStore.java @@ -44,7 +44,7 @@ public interface BlobStore { /** * @return a reference to the context that created this BlobStore. */ - BlobStoreContext getContext(); + BlobStoreContext getContext(); /** * diff --git a/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreApiMetadata.java b/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreApiMetadata.java deleted file mode 100644 index 77d55ce334..0000000000 --- a/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreApiMetadata.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.jclouds.blobstore; - -import org.jclouds.apis.ApiMetadata; - -import com.google.common.annotations.Beta; - -/** - * - * @author Adrian Cole - * @since 1.5 - */ -@Beta -public interface BlobStoreApiMetadata, M extends BlobStoreApiMetadata> - extends ApiMetadata { - - public static interface Builder, M extends BlobStoreApiMetadata> - extends ApiMetadata.Builder { - } - -} \ No newline at end of file diff --git a/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreContext.java b/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreContext.java index 81f42afbe1..c30a7adb7d 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreContext.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreContext.java @@ -20,10 +20,11 @@ package org.jclouds.blobstore; import java.io.Closeable; +import org.jclouds.Wrapper; import org.jclouds.blobstore.attr.ConsistencyModel; import org.jclouds.blobstore.internal.BlobStoreContextImpl; import org.jclouds.blobstore.options.ListContainerOptions; -import org.jclouds.rest.BackedByRestContext; +import org.jclouds.rest.RestContext; import org.jclouds.rest.Utils; import com.google.inject.ImplementedBy; @@ -36,7 +37,7 @@ import com.google.inject.ImplementedBy; * */ @ImplementedBy(BlobStoreContextImpl.class) -public interface BlobStoreContext extends Closeable, BackedByRestContext { +public interface BlobStoreContext extends Closeable, Wrapper { /** * * Generates signed requests for blobs. useful in other tools such as backup utilities. @@ -115,6 +116,15 @@ public interface BlobStoreContext extends Closeable, BackedByRestContext RestContext getProviderSpecificContext(); + /** * closes threads and resources related to this connection. * diff --git a/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreContextBuilder.java b/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreContextBuilder.java deleted file mode 100644 index e38fad5fa1..0000000000 --- a/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreContextBuilder.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * 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.blobstore; -import static com.google.common.base.Preconditions.checkArgument; - -import java.util.NoSuchElementException; - -import org.jclouds.blobstore.config.TransientBlobStore; -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.rest.internal.ContextBuilder; - -/** - * @author Adrian Cole - */ -public abstract class BlobStoreContextBuilder, M extends BlobStoreApiMetadata> - extends ContextBuilder { - - /** - * looks up a provider or api with the given id - * - * @param providerOrApi - * id of the provider or api - * @return means to build a context to that provider - * @throws NoSuchElementException - * if the id was not configured. - * @throws IllegalArgumentException - * if the api or provider isn't assignable from BlobStoreContext - */ - public static BlobStoreContextBuilder newBuilder(String providerOrApi) throws NoSuchElementException { - ContextBuilder builder = ContextBuilder.newBuilder(providerOrApi); - checkArgument(builder instanceof BlobStoreContextBuilder, - "type of providerOrApi[%s] is not BlobStoreContextBuilder: %s", providerOrApi, builder); - return BlobStoreContextBuilder.class.cast(builder); - } - - public static ContextBuilder, TransientApiMetadata> forTests() { - return ContextBuilder.newBuilder(new TransientApiMetadata()); - } - - public BlobStoreContextBuilder(ProviderMetadata providerMetadata) { - super(providerMetadata); - } - - public BlobStoreContextBuilder(M apiMetadata) { - super(apiMetadata); - } -} \ No newline at end of file diff --git a/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreContextFactory.java b/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreContextFactory.java index 9c32b49d99..f663d220bf 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreContextFactory.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/BlobStoreContextFactory.java @@ -21,11 +21,11 @@ package org.jclouds.blobstore; import java.util.NoSuchElementException; import java.util.Properties; +import org.jclouds.ContextBuilder; import org.jclouds.apis.Apis; import org.jclouds.javax.annotation.Nullable; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.Providers; -import org.jclouds.rest.internal.ContextBuilder; import com.google.common.collect.ImmutableSet; import com.google.inject.Module; @@ -54,21 +54,21 @@ public class BlobStoreContextFactory { /** * @see #createContext(String, String,String, Iterable, Properties) */ - public BlobStoreContext createContext(String providerOrApi, String identity, String credential) { + public BlobStoreContext createContext(String providerOrApi, String identity, String credential) { return createContext(providerOrApi, identity, credential, ImmutableSet. of(), new Properties()); } /** * @see #createContext(String, String, String, Iterable, Properties) */ - public BlobStoreContext createContext(String providerOrApi, Properties overrides) { + public BlobStoreContext createContext(String providerOrApi, Properties overrides) { return createContext(providerOrApi, null, null, ImmutableSet. of(), overrides); } /** * @see #createContext(String, String,String, Iterable, Properties) */ - public BlobStoreContext createContext(String providerOrApi, Iterable wiring, + public BlobStoreContext createContext(String providerOrApi, Iterable wiring, Properties overrides) { return createContext(providerOrApi, null, null, wiring, overrides); } @@ -76,7 +76,7 @@ public class BlobStoreContextFactory { /** * @see #createContext(String, String,String, Iterable, Properties) */ - public BlobStoreContext createContext(String providerOrApi, @Nullable String identity, + public BlobStoreContext createContext(String providerOrApi, @Nullable String identity, @Nullable String credential, Properties overrides) { return createContext(providerOrApi, identity, credential, ImmutableSet. of(), overrides); } @@ -84,7 +84,7 @@ public class BlobStoreContextFactory { /** * @see createContext(String, String,String, Iterable, Properties) */ - public BlobStoreContext createContext(String providerOrApi, @Nullable String identity, + public BlobStoreContext createContext(String providerOrApi, @Nullable String identity, @Nullable String credential, Iterable wiring) { return createContext(providerOrApi, identity, credential, wiring, new Properties()); } @@ -104,28 +104,20 @@ public class BlobStoreContextFactory { * properties to override defaults with. * @return initialized context ready for use */ - @SuppressWarnings("unchecked") - public BlobStoreContext createContext(String providerOrApi, @Nullable String identity, + public BlobStoreContext createContext(String providerOrApi, @Nullable String identity, @Nullable String credential, Iterable wiring, Properties overrides) { - ContextBuilder builder = null; + ContextBuilder builder = null; try { - ProviderMetadata pm = Providers.withId(providerOrApi); - builder = BlobStoreContextBuilder.newBuilder(pm); + ProviderMetadata pm = Providers.withId(providerOrApi); + builder = ContextBuilder.newBuilder(pm); } catch (NoSuchElementException e) { builder = ContextBuilder.newBuilder(Apis.withId(providerOrApi)); } - builder.modules(Iterable.class.cast(wiring)); + builder.modules(wiring); builder.overrides(overrides); if (identity != null) builder.credentials(identity, credential); - Object context = builder.build(); - if (context instanceof BlobStoreContext) { - return BlobStoreContext.class.cast(context); - } else { - throw new IllegalArgumentException("provider " + providerOrApi + " contains an unknown context type: " - + context.getClass().getSimpleName()); - } - + return builder.build(BlobStoreContext.class); } } diff --git a/blobstore/src/main/java/org/jclouds/blobstore/TransientApiMetadata.java b/blobstore/src/main/java/org/jclouds/blobstore/TransientApiMetadata.java index fbd1465eb7..88f9fc1d07 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/TransientApiMetadata.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/TransientApiMetadata.java @@ -18,26 +18,21 @@ */ package org.jclouds.blobstore; -import static org.jclouds.Constants.PROPERTY_IO_WORKER_THREADS; -import static org.jclouds.Constants.PROPERTY_USER_THREADS; - import java.net.URI; import org.jclouds.apis.ApiMetadata; import org.jclouds.apis.internal.BaseApiMetadata; -import org.jclouds.blobstore.config.TransientBlobStore; -import org.jclouds.blobstore.internal.BaseBlobStoreApiMetadata; - -import com.google.common.collect.ImmutableMap; -import com.google.common.reflect.TypeToken; +import org.jclouds.blobstore.config.TransientBlobStoreContextModule; /** * Implementation of {@link ApiMetadata} for jclouds in-memory (Transient) API * * @author Adrian Cole */ -public class TransientApiMetadata extends - BaseBlobStoreApiMetadata, TransientApiMetadata> { +public class TransientApiMetadata extends BaseApiMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = -6541485071006878726L; public static Builder builder() { return new Builder(); @@ -56,23 +51,19 @@ public class TransientApiMetadata extends super(builder); } - public static class Builder extends - BaseBlobStoreApiMetadata.Builder, TransientApiMetadata> { + public static class Builder extends BaseApiMetadata.Builder { protected Builder() { id("transient") - .name("in-memory (Transient) API") - .javaApi(TransientBlobStore.class, AsyncBlobStore.class) - .contextBuilder(TypeToken.of(TransientBlobStoreContextBuilder.class)) - .identityName("Unused") - .defaultEndpoint("http://localhost") - .defaultIdentity(System.getProperty("user.name")) - .defaultCredential("bar") - .version("1") - .defaultProperties( - BaseBlobStoreApiMetadata.Builder.defaultPropertiesAnd(ImmutableMap.of(PROPERTY_USER_THREADS, "0", - PROPERTY_IO_WORKER_THREADS, "0"))) - .documentation(URI.create("http://www.jclouds.org/documentation/userguide/blobstore-guide")); + .name("in-memory (Transient) API") + .identityName("Unused") + .defaultEndpoint("http://localhost") + .defaultIdentity(System.getProperty("user.name")) + .defaultCredential("bar") + .version("1") + .wrapper(BlobStoreContext.class) + .defaultModule(TransientBlobStoreContextModule.class) + .documentation(URI.create("http://www.jclouds.org/documentation/userguide/blobstore-guide")); } @Override diff --git a/blobstore/src/main/java/org/jclouds/blobstore/TransientAsyncBlobStore.java b/blobstore/src/main/java/org/jclouds/blobstore/TransientAsyncBlobStore.java index 44fdce6afa..81ef2f5dfd 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/TransientAsyncBlobStore.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/TransientAsyncBlobStore.java @@ -128,7 +128,7 @@ public class TransientAsyncBlobStore extends BaseAsyncBlobStore { protected final Factory blobFactory; @Inject - protected TransientAsyncBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, DateService dateService, Crypto crypto, + protected TransientAsyncBlobStore(BlobStoreContext context, DateService dateService, Crypto crypto, ConcurrentMap> containerToBlobs, Provider uriBuilders, ConcurrentMap containerToLocation, HttpGetOptionsListToGetOptions httpGetOptionsConverter, diff --git a/blobstore/src/main/java/org/jclouds/blobstore/TransientBlobStoreContextBuilder.java b/blobstore/src/main/java/org/jclouds/blobstore/TransientBlobStoreContextBuilder.java deleted file mode 100644 index e85910ecad..0000000000 --- a/blobstore/src/main/java/org/jclouds/blobstore/TransientBlobStoreContextBuilder.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * 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.blobstore; - -import java.util.List; - -import org.jclouds.blobstore.config.TransientBlobStore; -import org.jclouds.blobstore.config.TransientBlobStoreContextModule; -import org.jclouds.blobstore.config.TransientBlobStoreModule; -import org.jclouds.providers.ProviderMetadata; - -import com.google.inject.Module; - -/** - * @author Adrian Cole - */ -public class TransientBlobStoreContextBuilder extends - BlobStoreContextBuilder, TransientApiMetadata> { - - public TransientBlobStoreContextBuilder( - ProviderMetadata, TransientApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public TransientBlobStoreContextBuilder(TransientApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - public void addContextModule(List modules) { - modules.add(new TransientBlobStoreContextModule()); - } - - @Override - protected void addClientModule(List modules) { - modules.add(new TransientBlobStoreModule()); - } - -} \ No newline at end of file diff --git a/blobstore/src/main/java/org/jclouds/blobstore/config/TransientBlobStoreContextModule.java b/blobstore/src/main/java/org/jclouds/blobstore/config/TransientBlobStoreContextModule.java index 2381329687..32dcfca029 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/config/TransientBlobStoreContextModule.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/config/TransientBlobStoreContextModule.java @@ -24,16 +24,15 @@ import java.util.concurrent.ConcurrentMap; import org.jclouds.blobstore.AsyncBlobStore; import org.jclouds.blobstore.BlobRequestSigner; import org.jclouds.blobstore.BlobStore; -import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.blobstore.TransientAsyncBlobStore; import org.jclouds.blobstore.TransientBlobRequestSigner; import org.jclouds.blobstore.attr.ConsistencyModel; import org.jclouds.blobstore.domain.Blob; -import org.jclouds.blobstore.internal.BlobStoreContextImpl; import org.jclouds.domain.Location; +import org.jclouds.rest.config.BinderUtils; +import com.google.common.collect.ImmutableMap; import com.google.inject.AbstractModule; -import com.google.inject.Scopes; import com.google.inject.TypeLiteral; /** @@ -47,12 +46,11 @@ public class TransientBlobStoreContextModule extends AbstractModule { static final ConcurrentHashMap> map = new ConcurrentHashMap>(); static final ConcurrentHashMap containerToLocation = new ConcurrentHashMap(); - @SuppressWarnings("rawtypes") @Override protected void configure() { - bind(new TypeLiteral() { - }).to(new TypeLiteral>() { - }).in(Scopes.SINGLETON); + bind(AsyncBlobStore.class).to(TransientAsyncBlobStore.class).asEagerSingleton(); + // forward all requests from TransientBlobStore to TransientAsyncBlobStore. needs above binding as cannot proxy a class + BinderUtils.bindClient(binder(), TransientBlobStore.class, AsyncBlobStore.class, ImmutableMap., Class>of()); bind(new TypeLiteral>>() { }).toInstance(map); bind(new TypeLiteral>() { diff --git a/blobstore/src/main/java/org/jclouds/blobstore/config/TransientBlobStoreModule.java b/blobstore/src/main/java/org/jclouds/blobstore/config/TransientBlobStoreModule.java deleted file mode 100644 index e9db97e6c4..0000000000 --- a/blobstore/src/main/java/org/jclouds/blobstore/config/TransientBlobStoreModule.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * 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.blobstore.config; - -import org.jclouds.blobstore.AsyncBlobStore; -import org.jclouds.blobstore.TransientAsyncBlobStore; -import org.jclouds.rest.config.RestClientModule; - -/** - * - * @author Adrian Cole - */ -public class TransientBlobStoreModule extends RestClientModule { - - public TransientBlobStoreModule() { - super(TransientBlobStore.class, AsyncBlobStore.class); - } - - @Override - protected void bindAsyncClient() { - bind(AsyncBlobStore.class).to(TransientAsyncBlobStore.class).asEagerSingleton(); - } - -} \ No newline at end of file diff --git a/blobstore/src/main/java/org/jclouds/blobstore/internal/BaseAsyncBlobStore.java b/blobstore/src/main/java/org/jclouds/blobstore/internal/BaseAsyncBlobStore.java index f698a7b6ca..ef1b3f455b 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/internal/BaseAsyncBlobStore.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/internal/BaseAsyncBlobStore.java @@ -53,14 +53,14 @@ import com.google.common.util.concurrent.ListenableFuture; */ public abstract class BaseAsyncBlobStore implements AsyncBlobStore { - protected final BlobStoreContext context; + protected final BlobStoreContext context; protected final BlobUtils blobUtils; protected final ExecutorService service; protected final Supplier defaultLocation; protected final Supplier> locations; @Inject - protected BaseAsyncBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, + protected BaseAsyncBlobStore(BlobStoreContext context, BlobUtils blobUtils, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService service, Supplier defaultLocation, @Memoized Supplier> locations) { this.context = checkNotNull(context, "context"); @@ -71,7 +71,7 @@ public abstract class BaseAsyncBlobStore implements AsyncBlobStore { } @Override - public BlobStoreContext getContext() { + public BlobStoreContext getContext() { return context; } diff --git a/blobstore/src/main/java/org/jclouds/blobstore/internal/BaseBlobStore.java b/blobstore/src/main/java/org/jclouds/blobstore/internal/BaseBlobStore.java index 8b2d980452..dc344cf454 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/internal/BaseBlobStore.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/internal/BaseBlobStore.java @@ -47,13 +47,13 @@ import com.google.common.base.Supplier; */ public abstract class BaseBlobStore implements BlobStore { - protected final BlobStoreContext context; + protected final BlobStoreContext context; protected final BlobUtils blobUtils; protected final Supplier defaultLocation; protected final Supplier> locations; @Inject - protected BaseBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, Supplier defaultLocation, + protected BaseBlobStore(BlobStoreContext context, BlobUtils blobUtils, Supplier defaultLocation, @Memoized Supplier> locations) { this.context = checkNotNull(context, "context"); this.blobUtils = checkNotNull(blobUtils, "blobUtils"); @@ -62,7 +62,7 @@ public abstract class BaseBlobStore implements BlobStore { } @Override - public BlobStoreContext getContext() { + public BlobStoreContext getContext() { return context; } diff --git a/blobstore/src/main/java/org/jclouds/blobstore/internal/BaseBlobStoreApiMetadata.java b/blobstore/src/main/java/org/jclouds/blobstore/internal/BaseBlobStoreApiMetadata.java deleted file mode 100644 index d89c1f0d8e..0000000000 --- a/blobstore/src/main/java/org/jclouds/blobstore/internal/BaseBlobStoreApiMetadata.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * 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.blobstore.internal; - -import org.jclouds.apis.ApiType; -import org.jclouds.apis.internal.BaseApiMetadata; -import org.jclouds.blobstore.BlobStoreApiMetadata; -import org.jclouds.blobstore.BlobStoreContext; - -import com.google.common.annotations.Beta; -import com.google.common.reflect.TypeParameter; -import com.google.common.reflect.TypeToken; - -/** - * - * @author Adrian Cole - * @since 1.5 - */ -@Beta -public abstract class BaseBlobStoreApiMetadata, M extends BlobStoreApiMetadata> - extends BaseApiMetadata implements BlobStoreApiMetadata { - - public static class Builder, M extends BlobStoreApiMetadata> - extends BaseApiMetadata.Builder implements BlobStoreApiMetadata.Builder { - public Builder() { - type(ApiType.BLOBSTORE); - } - - /** - * {@inheritDoc} - */ - @Override - @SuppressWarnings("rawtypes") - protected TypeToken contextToken(TypeToken clientToken, TypeToken asyncClientToken) { - return new TypeToken>() { - private static final long serialVersionUID = 1L; - }.where(new TypeParameter() { - }, clientToken).where(new TypeParameter() { - }, asyncClientToken); - } - - } - - - protected BaseBlobStoreApiMetadata(BaseBlobStoreApiMetadata.Builder builder) { - super(builder); - } - -} \ No newline at end of file diff --git a/blobstore/src/main/java/org/jclouds/blobstore/internal/BlobStoreContextImpl.java b/blobstore/src/main/java/org/jclouds/blobstore/internal/BlobStoreContextImpl.java index 6c8abad039..3a08168b26 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/internal/BlobStoreContextImpl.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/internal/BlobStoreContextImpl.java @@ -20,6 +20,8 @@ package org.jclouds.blobstore.internal; import static com.google.common.base.Preconditions.checkNotNull; +import java.io.Closeable; + import javax.inject.Inject; import javax.inject.Singleton; @@ -31,31 +33,33 @@ import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.blobstore.InputStreamMap; import org.jclouds.blobstore.attr.ConsistencyModel; import org.jclouds.blobstore.options.ListContainerOptions; +import org.jclouds.internal.BaseWrapper; +import org.jclouds.location.Provider; import org.jclouds.rest.RestContext; import org.jclouds.rest.Utils; +import com.google.common.io.Closeables; +import com.google.common.reflect.TypeToken; + /** * @author Adrian Cole */ @Singleton -public class BlobStoreContextImpl implements BlobStoreContext { +public class BlobStoreContextImpl extends BaseWrapper implements BlobStoreContext { private final BlobMap.Factory blobMapFactory; private final InputStreamMap.Factory inputStreamMapFactory; private final AsyncBlobStore ablobStore; private final BlobStore blobStore; - private final RestContext providerSpecificContext; private final ConsistencyModel consistencyModel; private final Utils utils; private final BlobRequestSigner blobRequestSigner; - @SuppressWarnings("unchecked") @Inject - public BlobStoreContextImpl(BlobMap.Factory blobMapFactory, Utils utils, ConsistencyModel consistencyModel, + public BlobStoreContextImpl(@Provider Closeable wrapped, @Provider TypeToken wrappedType, + BlobMap.Factory blobMapFactory, Utils utils, ConsistencyModel consistencyModel, InputStreamMap.Factory inputStreamMapFactory, AsyncBlobStore ablobStore, BlobStore blobStore, - @SuppressWarnings("rawtypes") RestContext providerSpecificContext, BlobRequestSigner blobRequestSigner) { - // unravel guice and avoid passing in a million type args by not injecting generic types for - // rest context - this.providerSpecificContext = checkNotNull(providerSpecificContext, "providerSpecificContext"); + BlobRequestSigner blobRequestSigner) { + super(wrapped, wrappedType); this.consistencyModel = checkNotNull(consistencyModel, "consistencyModel"); this.blobMapFactory = checkNotNull(blobMapFactory, "blobMapFactory"); this.inputStreamMapFactory = checkNotNull(inputStreamMapFactory, "inputStreamMapFactory"); @@ -100,16 +104,6 @@ public class BlobStoreContextImpl implements BlobStoreContext { return ablobStore; } - @Override - public RestContext getProviderSpecificContext() { - return providerSpecificContext; - } - - @Override - public void close() { - providerSpecificContext.close(); - } - @Override public Utils getUtils() { return utils(); @@ -121,22 +115,33 @@ public class BlobStoreContextImpl implements BlobStoreContext { } @Override + public BlobRequestSigner getSigner() { + return blobRequestSigner; + } + + @SuppressWarnings("unchecked") + @Override + public RestContext getProviderSpecificContext() { + return (RestContext) getWrapped(); + } + + @Override + public void close() { + Closeables.closeQuietly(getWrapped()); + } + public int hashCode() { - return providerSpecificContext.hashCode(); + return getWrapped().hashCode(); } @Override public String toString() { - return providerSpecificContext.toString(); + return getWrapped().toString(); } @Override public boolean equals(Object obj) { - return providerSpecificContext.equals(obj); + return getWrapped().equals(obj); } - @Override - public BlobRequestSigner getSigner() { - return blobRequestSigner; - } } diff --git a/blobstore/src/test/java/org/jclouds/blobstore/BlobStoresTest.java b/blobstore/src/test/java/org/jclouds/blobstore/BlobStoresTest.java index 3422312966..41cf4c711d 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/BlobStoresTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/BlobStoresTest.java @@ -26,6 +26,7 @@ import java.util.HashSet; import java.util.Set; import org.easymock.EasyMock; +import org.jclouds.ContextBuilder; import org.jclouds.blobstore.domain.PageSet; import org.jclouds.blobstore.domain.StorageMetadata; import org.jclouds.blobstore.domain.internal.PageSetImpl; @@ -47,7 +48,7 @@ public class BlobStoresTest { public void testListAllForUnknownContainerFromTransientBlobStoreEagerly() throws Exception { ListContainerOptions containerOptions = ListContainerOptions.NONE; ListAllOptions listAllOptions = ListAllOptions.Builder.eager(true); - BlobStoreContext context = blobStoreContext(); + BlobStoreContext context = blobStoreContext(); try { BlobStore blobStore = context.getBlobStore(); BlobStores.listAll(blobStore, "wrongcontainer", containerOptions, listAllOptions); @@ -62,7 +63,7 @@ public class BlobStoresTest { @Test(expectedExceptions = { ContainerNotFoundException.class }) public void testListAllForUnknownContainerFromTransientBlobStore() throws Exception { ListContainerOptions options = ListContainerOptions.NONE; - BlobStoreContext context = blobStoreContext(); + BlobStoreContext context = blobStoreContext(); try { BlobStore blobStore = context.getBlobStore(); Iterable iterable = BlobStores.listAll(blobStore, "wrongcontainer", options); @@ -72,8 +73,8 @@ public class BlobStoresTest { } } - protected BlobStoreContext blobStoreContext() { - return BlobStoreContextBuilder.forTests().build(); + protected BlobStoreContext blobStoreContext() { + return ContextBuilder.newBuilder("transient").build(BlobStoreContext.class); } @Test @@ -90,7 +91,7 @@ public class BlobStoresTest { final int numTimesToIterate = 2; final int NUM_BLOBS = 31; ListContainerOptions containerOptions = ListContainerOptions.Builder.maxResults(10); - BlobStoreContext context = blobStoreContext(); + BlobStoreContext context = blobStoreContext(); BlobStore blobStore = null; try { blobStore = context.getBlobStore(); diff --git a/blobstore/src/test/java/org/jclouds/blobstore/TransientBlobRequestSignerTest.java b/blobstore/src/test/java/org/jclouds/blobstore/TransientBlobRequestSignerTest.java index f3edf1a509..a1bb3f59c9 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/TransientBlobRequestSignerTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/TransientBlobRequestSignerTest.java @@ -128,7 +128,7 @@ public class TransientBlobRequestSignerTest extends BaseAsyncClientTest createApiMetadata() { + public ApiMetadata createApiMetadata() { return new TransientApiMetadata(); } diff --git a/blobstore/src/test/java/org/jclouds/blobstore/binders/BindBlobToMultipartFormTest.java b/blobstore/src/test/java/org/jclouds/blobstore/binders/BindBlobToMultipartFormTest.java index 4b0be65a8d..65a2f9c78e 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/binders/BindBlobToMultipartFormTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/binders/BindBlobToMultipartFormTest.java @@ -28,7 +28,7 @@ import java.net.URI; import javax.ws.rs.HttpMethod; import javax.ws.rs.core.MediaType; -import org.jclouds.blobstore.BlobStoreContextBuilder; +import org.jclouds.ContextBuilder; import org.jclouds.blobstore.domain.Blob; import org.jclouds.blobstore.domain.Blob.Factory; import org.jclouds.http.HttpRequest; @@ -47,7 +47,7 @@ public class BindBlobToMultipartFormTest { public static final Blob TEST_BLOB; static { - blobProvider = BlobStoreContextBuilder.forTests().buildInjector().getInstance(Blob.Factory.class); + blobProvider = ContextBuilder.newBuilder("transient").buildInjector().getInstance(Blob.Factory.class); StringBuilder builder = new StringBuilder("--"); addData(BOUNDARY, "hello", builder); builder.append("--").append(BOUNDARY).append("--").append("\r\n"); diff --git a/blobstore/src/test/java/org/jclouds/blobstore/binders/BindUserMetadataToHeadersWithPrefixTest.java b/blobstore/src/test/java/org/jclouds/blobstore/binders/BindUserMetadataToHeadersWithPrefixTest.java index 5f5e4c798c..d01894630b 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/binders/BindUserMetadataToHeadersWithPrefixTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/binders/BindUserMetadataToHeadersWithPrefixTest.java @@ -25,7 +25,7 @@ import java.net.URI; import javax.ws.rs.HttpMethod; -import org.jclouds.blobstore.BlobStoreContextBuilder; +import org.jclouds.ContextBuilder; import org.jclouds.blobstore.domain.Blob; import org.jclouds.http.HttpRequest; import org.testng.annotations.Test; @@ -47,7 +47,7 @@ public class BindUserMetadataToHeadersWithPrefixTest { BindUserMetadataToHeadersWithPrefix binder = new BindUserMetadataToHeadersWithPrefix( new BindMapToHeadersWithPrefix("prefix:")); - Blob blob = BlobStoreContextBuilder.forTests().buildInjector().getInstance(Blob.Factory.class).create(null); + Blob blob = ContextBuilder.newBuilder("transient").buildInjector().getInstance(Blob.Factory.class).create(null); blob.getMetadata().setUserMetadata(ImmutableMap.of("imageName", "foo", "serverId", "2")); diff --git a/blobstore/src/test/java/org/jclouds/blobstore/functions/BlobNameTest.java b/blobstore/src/test/java/org/jclouds/blobstore/functions/BlobNameTest.java index 551ff1147d..dece50daa0 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/functions/BlobNameTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/functions/BlobNameTest.java @@ -1,5 +1,5 @@ /** - * Licensed to jclouds, Inc. (jclouds) under one or more +s * 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 @@ -22,7 +22,7 @@ import static org.testng.Assert.assertEquals; import java.io.File; -import org.jclouds.blobstore.BlobStoreContextBuilder; +import org.jclouds.ContextBuilder; import org.jclouds.blobstore.domain.Blob; import org.jclouds.blobstore.domain.Blob.Factory; import org.testng.annotations.Test; @@ -35,7 +35,7 @@ import org.testng.annotations.Test; public class BlobNameTest { BlobName fn = new BlobName(); - private static final Factory BLOB_FACTORY = BlobStoreContextBuilder.forTests().buildInjector().getInstance(Blob.Factory.class); + private static final Factory BLOB_FACTORY = ContextBuilder.newBuilder("transient").buildInjector().getInstance(Blob.Factory.class); @Test public void testCorrect() throws SecurityException, NoSuchMethodException { diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobMapIntegrationTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobMapIntegrationTest.java index e5667e2325..384c9121f5 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobMapIntegrationTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobMapIntegrationTest.java @@ -266,12 +266,12 @@ public abstract class BaseBlobMapIntegrationTest extends BaseMapIntegrationTest< } @Override - protected BlobMap createMap(BlobStoreContext context, String bucket) { + protected BlobMap createMap(BlobStoreContext context, String bucket) { return createMap(context, bucket, maxResults(maxResultsForTestListings())); } @Override - protected BlobMap createMap(BlobStoreContext context, String bucket, ListContainerOptions options) { + protected BlobMap createMap(BlobStoreContext context, String bucket, ListContainerOptions options) { return context.createBlobMap(bucket, options); } diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobStoreIntegrationTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobStoreIntegrationTest.java index c57d41ed55..2872c1db01 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobStoreIntegrationTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobStoreIntegrationTest.java @@ -24,8 +24,8 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.util.Map; -import java.util.Map.Entry; import java.util.Set; +import java.util.Map.Entry; import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.BlockingQueue; import java.util.concurrent.CancellationException; @@ -36,6 +36,7 @@ import java.util.concurrent.atomic.AtomicInteger; import javax.ws.rs.core.MediaType; +import org.jclouds.apis.BaseContextLiveTest; import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.blobstore.attr.ConsistencyModel; import org.jclouds.blobstore.domain.Blob; @@ -43,7 +44,6 @@ import org.jclouds.blobstore.domain.BlobMetadata; import org.jclouds.blobstore.domain.StorageMetadata; import org.jclouds.blobstore.domain.StorageType; import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; -import org.jclouds.rest.internal.BaseContextLiveTest; import org.testng.ITestContext; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; @@ -56,9 +56,10 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.common.collect.Sets; +import com.google.common.reflect.TypeToken; import com.google.inject.Module; -public class BaseBlobStoreIntegrationTest extends BaseContextLiveTest>{ +public class BaseBlobStoreIntegrationTest extends BaseContextLiveTest { protected static final String LOCAL_ENCODING = System.getProperty("file.encoding"); protected static final String XML_STRING_FORMAT = " "; protected static final String TEST_STRING = String.format(XML_STRING_FORMAT, "apple"); @@ -123,7 +124,7 @@ public class BaseBlobStoreIntegrationTest extends BaseContextLiveTest context, ITestContext testContext) + protected void createContainersSharedByAllThreads(BlobStoreContext context, ITestContext testContext) throws Exception { while (!initialized) { synchronized (BaseBlobStoreIntegrationTest.class) { @@ -156,7 +157,7 @@ public class BaseBlobStoreIntegrationTest extends BaseContextLiveTest context, String containerName) { + private static void deleteContainerOrWarnIfUnable(BlobStoreContext context, String containerName) { try { context.getBlobStore().deleteContainer(containerName); } catch (Throwable ex) { @@ -171,7 +172,7 @@ public class BaseBlobStoreIntegrationTest extends BaseContextLiveTest context) throws Exception { + protected static void deleteEverything(final BlobStoreContext context) throws Exception { try { for (int i = 0; i < 2; i++) { Iterable testContainers = Iterables.filter(context.getBlobStore().list(), @@ -200,7 +201,7 @@ public class BaseBlobStoreIntegrationTest extends BaseContextLiveTest context, Runnable assertion) + protected static void assertConsistencyAware(BlobStoreContext context, Runnable assertion) throws InterruptedException { if (context.getConsistencyModel() == ConsistencyModel.STRICT) { assertion.run(); @@ -226,7 +227,7 @@ public class BaseBlobStoreIntegrationTest extends BaseContextLiveTest context, final String containerName) + protected static void createContainerAndEnsureEmpty(BlobStoreContext context, final String containerName) throws InterruptedException { context.getBlobStore().createContainerInLocation(null, containerName); if (context.getConsistencyModel() == ConsistencyModel.EVENTUAL) @@ -427,4 +428,9 @@ public class BaseBlobStoreIntegrationTest extends BaseContextLiveTest contextType() { + return TypeToken.of(BlobStoreContext.class); + } + } \ No newline at end of file diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseInputStreamMapIntegrationTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseInputStreamMapIntegrationTest.java index a92952c6e0..085b0d7fc9 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseInputStreamMapIntegrationTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseInputStreamMapIntegrationTest.java @@ -330,11 +330,11 @@ public abstract class BaseInputStreamMapIntegrationTest extends BaseMapIntegrati return 100; } - protected InputStreamMap createMap(BlobStoreContext context, String bucket) { + protected InputStreamMap createMap(BlobStoreContext context, String bucket) { return createMap(context, bucket, maxResults(maxResultsForTestListings())); } - protected InputStreamMap createMap(BlobStoreContext context, String bucket, ListContainerOptions options) { + protected InputStreamMap createMap(BlobStoreContext context, String bucket, ListContainerOptions options) { return context.createInputStreamMap(bucket, options); } } diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseMapIntegrationTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseMapIntegrationTest.java index 5d0e089ab1..6e59bd2a58 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseMapIntegrationTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseMapIntegrationTest.java @@ -97,9 +97,9 @@ public abstract class BaseMapIntegrationTest extends BaseBlobStoreIntegration } } - protected abstract Map createMap(BlobStoreContext context, String containerName); + protected abstract Map createMap(BlobStoreContext context, String containerName); - protected abstract Map createMap(BlobStoreContext context, String containerName, + protected abstract Map createMap(BlobStoreContext context, String containerName, ListContainerOptions options); @Test(groups = { "integration", "live" }) diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseServiceIntegrationTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseServiceIntegrationTest.java index 12816e33d1..43a5abb102 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseServiceIntegrationTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseServiceIntegrationTest.java @@ -79,7 +79,8 @@ public class BaseServiceIntegrationTest extends BaseBlobStoreIntegrationTest { @Test(groups = { "integration", "live" }) public void testGetAssignableLocations() throws Exception { - assertProvider(context.getProviderSpecificContext()); + if (context.unwrap() instanceof Location) + assertProvider(Location.class.cast(context.unwrap())); for (Location location : context.getBlobStore().listAssignableLocations()) { System.err.printf("location %s%n", location); assert location.getId() != null : location; diff --git a/blobstore/src/test/java/org/jclouds/blobstore/internal/BaseBlobMapTest.java b/blobstore/src/test/java/org/jclouds/blobstore/internal/BaseBlobMapTest.java index a109ea9317..baa5e6309c 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/internal/BaseBlobMapTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/internal/BaseBlobMapTest.java @@ -22,8 +22,8 @@ import static org.testng.Assert.assertEquals; import java.util.Map; +import org.jclouds.ContextBuilder; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextBuilder; import org.jclouds.blobstore.domain.Blob; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -40,13 +40,13 @@ import com.google.inject.util.Types; @Test(groups = { "unit" }) public class BaseBlobMapTest { - BlobStoreContext context; + BlobStoreContext context; InputStreamMapImpl map; @BeforeClass void addDefaultObjectsSoThatTestsWillPass() { - context = BlobStoreContextBuilder.forTests().build(); + context = ContextBuilder.newBuilder("transient").build(BlobStoreContext.class); map = (InputStreamMapImpl) context.createInputStreamMap("test"); } diff --git a/blobstore/src/test/java/org/jclouds/blobstore/internal/BaseBlobStoreApiMetadataTest.java b/blobstore/src/test/java/org/jclouds/blobstore/internal/BaseBlobStoreApiMetadataTest.java index 32a2303059..fcb31cdbe3 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/internal/BaseBlobStoreApiMetadataTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/internal/BaseBlobStoreApiMetadataTest.java @@ -1,12 +1,26 @@ +/** + * 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.blobstore.internal; -import java.util.Set; - +import org.jclouds.Wrapper; import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.Apis; import org.jclouds.apis.internal.BaseApiMetadataTest; -import org.jclouds.blobstore.BlobStoreApiMetadata; import org.jclouds.blobstore.BlobStoreContext; import org.testng.annotations.Test; @@ -20,15 +34,8 @@ import com.google.common.reflect.TypeToken; @Test(groups = "unit") public abstract class BaseBlobStoreApiMetadataTest extends BaseApiMetadataTest { - @SuppressWarnings("rawtypes") - public BaseBlobStoreApiMetadataTest(BlobStoreApiMetadata toTest) { - super(toTest, ApiType.BLOBSTORE); - } - - @Test - public void testContextAssignableFromBlobStoreContext() { - Set> all = ImmutableSet.copyOf(Apis.contextAssignableFrom(TypeToken.of(BlobStoreContext.class))); - assert all.contains(toTest) : String.format("%s not found in %s", toTest, all); - } + public BaseBlobStoreApiMetadataTest(ApiMetadata toTest) { + super(toTest, ImmutableSet.>of(TypeToken.of(BlobStoreContext.class))); + } } \ No newline at end of file diff --git a/blobstore/src/test/java/org/jclouds/blobstore/strategy/internal/BiggerThanPageSizeTest.java b/blobstore/src/test/java/org/jclouds/blobstore/strategy/internal/BiggerThanPageSizeTest.java index a95f01ca9c..32aa5fe42d 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/strategy/internal/BiggerThanPageSizeTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/strategy/internal/BiggerThanPageSizeTest.java @@ -22,8 +22,9 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; +import org.jclouds.ContextBuilder; import org.jclouds.blobstore.BlobStore; -import org.jclouds.blobstore.BlobStoreContextBuilder; +import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.blobstore.options.ListContainerOptions; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; @@ -38,7 +39,7 @@ public class BiggerThanPageSizeTest { @BeforeTest void setupBlobStore() { - blobstore = BlobStoreContextBuilder.forTests().build().getBlobStore(); + blobstore = ContextBuilder.newBuilder("transient").build(BlobStoreContext.class).getBlobStore(); } public void test() throws IOException { diff --git a/common/aws/src/main/java/org/jclouds/aws/config/AWSRestClientModule.java b/common/aws/src/main/java/org/jclouds/aws/config/AWSRestClientModule.java index 42f5929b52..62772ab3d1 100644 --- a/common/aws/src/main/java/org/jclouds/aws/config/AWSRestClientModule.java +++ b/common/aws/src/main/java/org/jclouds/aws/config/AWSRestClientModule.java @@ -25,7 +25,6 @@ import org.jclouds.aws.handlers.AWSClientErrorRetryHandler; import org.jclouds.aws.handlers.ParseAWSErrorFromXmlContent; 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; @@ -38,7 +37,6 @@ import org.jclouds.rest.config.RestClientModule; * @author Adrian Cole */ @ConfiguresRestClient -@RequiresHttp public class AWSRestClientModule extends RestClientModule { public AWSRestClientModule(Class syncClientType, Class asyncClientType, Map, Class> delegates) { diff --git a/common/aws/src/main/java/org/jclouds/aws/config/FormSigningRestClientModule.java b/common/aws/src/main/java/org/jclouds/aws/config/FormSigningRestClientModule.java index 42c7d0bfe7..cda15e2d13 100644 --- a/common/aws/src/main/java/org/jclouds/aws/config/FormSigningRestClientModule.java +++ b/common/aws/src/main/java/org/jclouds/aws/config/FormSigningRestClientModule.java @@ -28,7 +28,6 @@ import org.jclouds.Constants; import org.jclouds.aws.filters.FormSigner; import org.jclouds.date.DateService; import org.jclouds.date.TimeStamp; -import org.jclouds.http.RequiresHttp; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.RequestSigner; @@ -39,7 +38,6 @@ import com.google.inject.Provides; * @author Adrian Cole */ @ConfiguresRestClient -@RequiresHttp public class FormSigningRestClientModule extends AWSRestClientModule { public FormSigningRestClientModule(Class syncClientType, Class asyncClientType, diff --git a/common/aws/src/main/java/org/jclouds/aws/config/WithZonesFormSigningRestClientModule.java b/common/aws/src/main/java/org/jclouds/aws/config/WithZonesFormSigningRestClientModule.java index 0d2d8f21ad..de773344e6 100644 --- a/common/aws/src/main/java/org/jclouds/aws/config/WithZonesFormSigningRestClientModule.java +++ b/common/aws/src/main/java/org/jclouds/aws/config/WithZonesFormSigningRestClientModule.java @@ -21,7 +21,6 @@ package org.jclouds.aws.config; import java.util.Map; -import org.jclouds.http.RequiresHttp; import org.jclouds.rest.ConfiguresRestClient; @@ -30,7 +29,6 @@ import org.jclouds.rest.ConfiguresRestClient; * @author Adrian Cole */ @ConfiguresRestClient -@RequiresHttp public class WithZonesFormSigningRestClientModule extends FormSigningRestClientModule { public WithZonesFormSigningRestClientModule(Class syncClientType, Class asyncClientType, diff --git a/common/aws/src/main/java/org/jclouds/aws/util/AWSUtils.java b/common/aws/src/main/java/org/jclouds/aws/util/AWSUtils.java index 7e25dfc498..9863c38399 100644 --- a/common/aws/src/main/java/org/jclouds/aws/util/AWSUtils.java +++ b/common/aws/src/main/java/org/jclouds/aws/util/AWSUtils.java @@ -46,9 +46,9 @@ import org.jclouds.rest.internal.GeneratedHttpRequest; import com.google.common.base.Function; import com.google.common.collect.ImmutableMultimap; -import com.google.common.collect.ImmutableMultimap.Builder; import com.google.common.collect.Iterables; import com.google.common.collect.Multimap; +import com.google.common.collect.ImmutableMultimap.Builder; /** * Needed to sign and verify requests and responses. diff --git a/common/aws/src/test/java/org/jclouds/aws/filters/FormSignerTest.java b/common/aws/src/test/java/org/jclouds/aws/filters/FormSignerTest.java index 06ddfdebfd..76d3f8375a 100644 --- a/common/aws/src/test/java/org/jclouds/aws/filters/FormSignerTest.java +++ b/common/aws/src/test/java/org/jclouds/aws/filters/FormSignerTest.java @@ -24,6 +24,7 @@ import java.net.URI; import javax.ws.rs.core.HttpHeaders; +import org.jclouds.ContextBuilder; import org.jclouds.date.TimeStamp; import org.jclouds.http.HttpRequest; import org.jclouds.http.IntegrationTestAsyncClient; @@ -33,7 +34,6 @@ import org.jclouds.logging.config.NullLoggingModule; import org.jclouds.providers.AnonymousProviderMetadata; import org.jclouds.rest.RequestSigner; import org.jclouds.rest.internal.BaseRestClientTest.MockModule; -import org.jclouds.rest.internal.ContextBuilder; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; diff --git a/common/azure/src/main/java/org/jclouds/azure/storage/AzureStorageContextBuilder.java b/common/azure/src/main/java/org/jclouds/azure/storage/AzureStorageContextBuilder.java deleted file mode 100644 index ef23a9a7d8..0000000000 --- a/common/azure/src/main/java/org/jclouds/azure/storage/AzureStorageContextBuilder.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * 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.azure.storage; - -import java.io.Closeable; -import java.util.List; - -import org.jclouds.apis.ApiMetadata; -import org.jclouds.azure.storage.config.AzureStorageRestClientModule; -import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; -import org.jclouds.logging.jdk.config.JDKLoggingModule; -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.rest.internal.ContextBuilder; - -import com.google.inject.Injector; -import com.google.inject.Module; - -/** - * Creates {@link AzureStorageStoreContext} or {@link Injector} instances based - * on the most commonly requested arguments. - *

- * Note that Threadsafe objects will be bound as singletons to the Injector or - * Context provided. - *

- *

- * If no Modules are specified, the default - * {@link JDKLoggingModule logging} and - * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be - * installed. - * - * @author Adrian Cole, Andrew Newdigate - * @see AzureStorageStoreContext - */ -public class AzureStorageContextBuilder> extends - ContextBuilder { - public AzureStorageContextBuilder(ProviderMetadata providerMetadata) { - super(providerMetadata); - } - - public AzureStorageContextBuilder(M apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addClientModule(List modules) { - modules.add(new AzureStorageRestClientModule(apiMetadata.getApi(), apiMetadata.getAsyncApi())); - } -} diff --git a/common/azure/src/main/java/org/jclouds/azure/storage/config/AzureStorageRestClientModule.java b/common/azure/src/main/java/org/jclouds/azure/storage/config/AzureStorageRestClientModule.java index 1420f4c075..2a8ed8caf2 100644 --- a/common/azure/src/main/java/org/jclouds/azure/storage/config/AzureStorageRestClientModule.java +++ b/common/azure/src/main/java/org/jclouds/azure/storage/config/AzureStorageRestClientModule.java @@ -30,7 +30,6 @@ 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; @@ -47,7 +46,6 @@ import com.google.inject.Provides; * @author Adrian Cole */ @ConfiguresRestClient -@RequiresHttp public class AzureStorageRestClientModule extends RestClientModule { public AzureStorageRestClientModule(Class syncClientType, Class asyncClientType) { diff --git a/common/azure/src/main/java/org/jclouds/azure/storage/filters/SharedKeyLiteAuthentication.java b/common/azure/src/main/java/org/jclouds/azure/storage/filters/SharedKeyLiteAuthentication.java index 9bdb901e71..a6c38634f9 100644 --- a/common/azure/src/main/java/org/jclouds/azure/storage/filters/SharedKeyLiteAuthentication.java +++ b/common/azure/src/main/java/org/jclouds/azure/storage/filters/SharedKeyLiteAuthentication.java @@ -49,8 +49,8 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Strings; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMap.Builder; import com.google.common.collect.Multimaps; +import com.google.common.collect.ImmutableMap.Builder; /** * Signs the Azure Storage request. diff --git a/common/azure/src/test/java/org/jclouds/azure/storage/filters/SharedKeyLiteAuthenticationTest.java b/common/azure/src/test/java/org/jclouds/azure/storage/filters/SharedKeyLiteAuthenticationTest.java index 5e3b0e16c6..4f9c8b6d27 100644 --- a/common/azure/src/test/java/org/jclouds/azure/storage/filters/SharedKeyLiteAuthenticationTest.java +++ b/common/azure/src/test/java/org/jclouds/azure/storage/filters/SharedKeyLiteAuthenticationTest.java @@ -26,6 +26,7 @@ import java.net.URI; import javax.ws.rs.HttpMethod; import javax.ws.rs.core.HttpHeaders; +import org.jclouds.ContextBuilder; import org.jclouds.azure.storage.config.AzureStorageRestClientModule; import org.jclouds.http.HttpRequest; import org.jclouds.http.IntegrationTestAsyncClient; @@ -33,7 +34,6 @@ import org.jclouds.http.IntegrationTestClient; import org.jclouds.logging.config.NullLoggingModule; import org.jclouds.rest.AnonymousRestApiMetadata; import org.jclouds.rest.internal.BaseRestClientTest.MockModule; -import org.jclouds.rest.internal.ContextBuilder; import org.testng.annotations.BeforeClass; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; diff --git a/common/openstack/src/main/java/org/jclouds/openstack/config/OpenStackAuthenticationModule.java b/common/openstack/src/main/java/org/jclouds/openstack/config/OpenStackAuthenticationModule.java index f9f2ccb760..eca6fe8678 100644 --- a/common/openstack/src/main/java/org/jclouds/openstack/config/OpenStackAuthenticationModule.java +++ b/common/openstack/src/main/java/org/jclouds/openstack/config/OpenStackAuthenticationModule.java @@ -33,7 +33,6 @@ import org.jclouds.concurrent.RetryOnTimeOutExceptionFunction; import org.jclouds.date.TimeStamp; import org.jclouds.domain.Credentials; import org.jclouds.http.HttpRetryHandler; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.annotation.ClientError; import org.jclouds.location.Provider; import org.jclouds.openstack.Authentication; @@ -58,7 +57,6 @@ import com.google.inject.assistedinject.FactoryModuleBuilder; * * @author Adrian Cole */ -@RequiresHttp public class OpenStackAuthenticationModule extends AbstractModule { @Override diff --git a/common/openstack/src/main/java/org/jclouds/openstack/keystone/v1_1/config/AuthenticationServiceModule.java b/common/openstack/src/main/java/org/jclouds/openstack/keystone/v1_1/config/AuthenticationServiceModule.java index 26545f9c30..ba16265d27 100644 --- a/common/openstack/src/main/java/org/jclouds/openstack/keystone/v1_1/config/AuthenticationServiceModule.java +++ b/common/openstack/src/main/java/org/jclouds/openstack/keystone/v1_1/config/AuthenticationServiceModule.java @@ -31,7 +31,6 @@ import javax.inject.Singleton; import org.jclouds.concurrent.RetryOnTimeOutExceptionFunction; import org.jclouds.domain.Credentials; import org.jclouds.http.HttpRetryHandler; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.annotation.ClientError; import org.jclouds.location.Provider; import org.jclouds.location.suppliers.RegionIdToURISupplier; @@ -56,7 +55,6 @@ import com.google.inject.assistedinject.FactoryModuleBuilder; * * @author Adrian Cole */ -@RequiresHttp public class AuthenticationServiceModule extends AbstractModule { @Override diff --git a/common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneAuthenticationModule.java b/common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneAuthenticationModule.java index 24eef509e6..4730cf4efd 100644 --- a/common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneAuthenticationModule.java +++ b/common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneAuthenticationModule.java @@ -31,7 +31,6 @@ import javax.inject.Singleton; import org.jclouds.concurrent.RetryOnTimeOutExceptionFunction; import org.jclouds.domain.Credentials; import org.jclouds.http.HttpRetryHandler; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.annotation.ClientError; import org.jclouds.location.Provider; import org.jclouds.location.suppliers.RegionIdToURISupplier; @@ -66,7 +65,6 @@ import com.google.inject.assistedinject.FactoryModuleBuilder; * * @author Adrian Cole */ -@RequiresHttp public class KeystoneAuthenticationModule extends AbstractModule { private final Module locationModule; diff --git a/common/openstack/src/test/java/org/jclouds/openstack/OpenStackAuthAsyncClientTest.java b/common/openstack/src/test/java/org/jclouds/openstack/OpenStackAuthAsyncClientTest.java index bcfcc5017f..7acee18f31 100644 --- a/common/openstack/src/test/java/org/jclouds/openstack/OpenStackAuthAsyncClientTest.java +++ b/common/openstack/src/test/java/org/jclouds/openstack/OpenStackAuthAsyncClientTest.java @@ -72,7 +72,7 @@ public class OpenStackAuthAsyncClientTest extends BaseAsyncClientTest createApiMetadata() { + public ApiMetadata createApiMetadata() { return AnonymousRestApiMetadata.forClientMappedToAsyncClient(IntegrationTestClient.class, IntegrationTestAsyncClient.class).toBuilder().defaultEndpoint( "http://localhost:8080").version("1.0").build(); } diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/TerremarkVCloudContextBuilder.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/TerremarkVCloudContextBuilder.java deleted file mode 100644 index 2876428613..0000000000 --- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/TerremarkVCloudContextBuilder.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * 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.trmk.vcloud_0_8; - -import java.util.List; - -import org.jclouds.compute.ComputeServiceApiMetadata; -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextBuilder; -import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; -import org.jclouds.logging.jdk.config.JDKLoggingModule; -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.trmk.vcloud_0_8.compute.config.TerremarkVCloudComputeServiceContextModule; -import org.jclouds.trmk.vcloud_0_8.config.TerremarkVCloudRestClientModule; - -import com.google.inject.Injector; -import com.google.inject.Module; - -/** - * Creates {@link VCloudComputeServiceContext} or {@link Injector} instances - * based on the most commonly requested arguments. - *

- * Note that Threadsafe objects will be bound as singletons to the Injector or - * Context provided. - *

- *

- * If no Modules are specified, the default - * {@link JDKLoggingModule logging} and - * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be - * installed. - * - * @author Adrian Cole - * @see VCloudComputeServiceContext - */ -public class TerremarkVCloudContextBuilder, M extends ComputeServiceApiMetadata> - extends ComputeServiceContextBuilder { - - public TerremarkVCloudContextBuilder(ProviderMetadata providerMetadata) { - super(providerMetadata); - } - - public TerremarkVCloudContextBuilder(M apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new TerremarkVCloudComputeServiceContextModule()); - } - - @Override - protected void addClientModule(List modules) { - modules.add(new TerremarkVCloudRestClientModule(apiMetadata.getApi(), apiMetadata.getAsyncApi())); - } -} diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/TerremarkVCloudPropertiesBuilder.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/TerremarkVCloudPropertiesBuilder.java deleted file mode 100644 index c294ec643b..0000000000 --- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/TerremarkVCloudPropertiesBuilder.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * 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.trmk.vcloud_0_8; - -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; -import static org.jclouds.trmk.vcloud_0_8.reference.TerremarkConstants.PROPERTY_TERREMARK_EXTENSION_NAME; -import static org.jclouds.trmk.vcloud_0_8.reference.TerremarkConstants.PROPERTY_TERREMARK_EXTENSION_NS; -import static org.jclouds.trmk.vcloud_0_8.reference.TerremarkConstants.PROPERTY_TERREMARK_EXTENSION_VERSION; -import static org.jclouds.trmk.vcloud_0_8.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_FENCEMODE; -import static org.jclouds.trmk.vcloud_0_8.reference.VCloudConstants.PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED; -import static org.jclouds.trmk.vcloud_0_8.reference.VCloudConstants.PROPERTY_VCLOUD_VERSION_SCHEMA; -import static org.jclouds.trmk.vcloud_0_8.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE; -import static org.jclouds.trmk.vcloud_0_8.reference.VCloudConstants.PROPERTY_VCLOUD_XML_SCHEMA; - -import java.util.Properties; -import java.util.concurrent.TimeUnit; - -import org.jclouds.PropertiesBuilder; - -/** - * Builds properties used in Terremark VCloud Clients - * - * @author Adrian Cole - */ -public class TerremarkVCloudPropertiesBuilder extends PropertiesBuilder { - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_API_VERSION, "0.8"); - properties.setProperty(PROPERTY_VCLOUD_VERSION_SCHEMA, "0.8"); - properties.setProperty(PROPERTY_SESSION_INTERVAL, 8 * 60 + ""); - properties.setProperty(PROPERTY_VCLOUD_XML_SCHEMA, "http://vcloud.safesecureweb.com/ns/vcloud.xsd"); - properties.setProperty(PROPERTY_VCLOUD_DEFAULT_FENCEMODE, "allowInOut"); - properties.setProperty(PROPERTY_TERREMARK_EXTENSION_NS, String.format("urn:tmrk:${%s}-${%s}", - PROPERTY_TERREMARK_EXTENSION_NAME, PROPERTY_TERREMARK_EXTENSION_VERSION)); - properties.setProperty(PROPERTY_VCLOUD_XML_NAMESPACE, - String.format("http://www.vmware.com/vcloud/v${%s}", PROPERTY_VCLOUD_VERSION_SCHEMA)); - properties.setProperty("jclouds.dns_name_length_min", "1"); - properties.setProperty("jclouds.dns_name_length_max", "15"); - // terremark can sometimes block extremely long times - properties.setProperty(PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED, TimeUnit.MINUTES.toMillis(20) + ""); - - return properties; - } - - public TerremarkVCloudPropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/binders/BindVAppConfigurationToXmlPayload.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/binders/BindVAppConfigurationToXmlPayload.java index 8c26cf4888..5d7de94ad2 100644 --- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/binders/BindVAppConfigurationToXmlPayload.java +++ b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/binders/BindVAppConfigurationToXmlPayload.java @@ -23,7 +23,6 @@ import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; import static com.google.common.collect.Iterables.filter; import static com.google.common.collect.Iterables.find; -import static org.jclouds.Constants.PROPERTY_API_VERSION; import static org.jclouds.trmk.vcloud_0_8.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE; import static org.jclouds.trmk.vcloud_0_8.reference.VCloudConstants.PROPERTY_VCLOUD_XML_SCHEMA; @@ -42,6 +41,7 @@ import org.jclouds.cim.ResourceAllocationSettingData; import org.jclouds.cim.ResourceAllocationSettingData.ResourceType; import org.jclouds.http.HttpRequest; import org.jclouds.rest.MapBinder; +import org.jclouds.rest.annotations.ApiVersion; import org.jclouds.rest.binders.BindToStringPayload; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.trmk.vcloud_0_8.domain.Status; @@ -68,7 +68,7 @@ public class BindVAppConfigurationToXmlPayload implements MapBinder, Function credentialStore, @Memoized Supplier> images, @Memoized Supplier> sizes, diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/compute/config/TerremarkVCloudComputeServiceContextModule.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/compute/config/TerremarkVCloudComputeServiceContextModule.java index 5d13535e30..4788da82b6 100644 --- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/compute/config/TerremarkVCloudComputeServiceContextModule.java +++ b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/compute/config/TerremarkVCloudComputeServiceContextModule.java @@ -25,17 +25,13 @@ import javax.inject.Named; import javax.inject.Singleton; import org.jclouds.compute.ComputeService; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.config.BaseComputeServiceContextModule; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeState; 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.trmk.vcloud_0_8.TerremarkVCloudAsyncClient; -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.domain.OrgAndName; import org.jclouds.trmk.vcloud_0_8.compute.functions.ImagesInVCloudExpressOrg; @@ -53,7 +49,6 @@ import com.google.common.base.Function; import com.google.common.base.Supplier; import com.google.common.collect.ImmutableMap; import com.google.inject.Provides; -import com.google.inject.Scopes; import com.google.inject.TypeLiteral; /** @@ -77,7 +72,6 @@ public class TerremarkVCloudComputeServiceContextModule extends BaseComputeServi return VAPPSTATUS_TO_NODESTATE; } - @SuppressWarnings("rawtypes") @Override protected void configure() { super.configure(); @@ -92,9 +86,6 @@ public class TerremarkVCloudComputeServiceContextModule extends BaseComputeServi install(new TerremarkBindComputeStrategiesByClass()); install(new TerremarkBindComputeSuppliersByClass()); bindVAppConverter(); - bind(new TypeLiteral() { - }).to(new TypeLiteral>() { - }).in(Scopes.SINGLETON); bind(new TypeLiteral>>() { }).to(new TypeLiteral() { }); diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/config/TerremarkVCloudRestClientModule.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/config/TerremarkVCloudRestClientModule.java index 0d48d18910..393690996f 100644 --- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/config/TerremarkVCloudRestClientModule.java +++ b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/config/TerremarkVCloudRestClientModule.java @@ -33,8 +33,8 @@ import static org.jclouds.trmk.vcloud_0_8.reference.VCloudConstants.PROPERTY_VCL import java.io.IOException; import java.net.URI; import java.util.Map; -import java.util.Map.Entry; import java.util.SortedMap; +import java.util.Map.Entry; import java.util.concurrent.atomic.AtomicReference; import javax.inject.Inject; @@ -52,7 +52,6 @@ import org.jclouds.predicates.RetryablePredicate; import org.jclouds.rest.AuthorizationException; import org.jclouds.rest.config.RestClientModule; import org.jclouds.rest.suppliers.MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier; -import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudAsyncClient; import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudClient; import org.jclouds.trmk.vcloud_0_8.VCloudToken; import org.jclouds.trmk.vcloud_0_8.compute.functions.FindLocationForResource; @@ -88,15 +87,14 @@ import com.google.common.base.Predicate; import com.google.common.base.Supplier; import com.google.common.base.Suppliers; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMap.Builder; import com.google.common.collect.Maps; +import com.google.common.collect.ImmutableMap.Builder; import com.google.inject.Injector; import com.google.inject.Provides; import com.google.inject.Scopes; import com.google.inject.TypeLiteral; -public class TerremarkVCloudRestClientModule - extends RestClientModule { +public class TerremarkVCloudRestClientModule extends RestClientModule { public TerremarkVCloudRestClientModule(Class syncClientType, Class asyncClientType) { super(syncClientType, asyncClientType); diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudApiMetadata.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudApiMetadata.java index 713450b93e..cf132779ed 100644 --- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudApiMetadata.java +++ b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudApiMetadata.java @@ -15,36 +15,24 @@ import java.util.concurrent.TimeUnit; import org.jclouds.apis.ApiMetadata; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; -import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudAsyncClient; -import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudClient; +import org.jclouds.rest.internal.BaseRestApiMetadata; /** - * Implementation of {@link ApiMetadata} for Amazon's TerremarkVCloud api. - * - *

note

- *

- * This class allows overriding of types {@code S}(client) and {@code A} - * (asyncClient), so that children can add additional methods not declared here, - * such as new features from AWS. - *

- * - * As this is a popular api, we also allow overrides for type {@code C} - * (context). This allows subtypes to add in new feature groups or extensions, - * not present in the base api. For example, you could make a subtype for - * context, that exposes admin operations. - * + * Implementation of {@link ApiMetadata} for Terremark's VCloud api. + * @author Adrian Cole */ -public abstract class TerremarkVCloudApiMetadata> - extends BaseComputeServiceApiMetadata, M> { +public abstract class TerremarkVCloudApiMetadata extends BaseRestApiMetadata { - protected TerremarkVCloudApiMetadata(Builder builder) { + /** The serialVersionUID */ + private static final long serialVersionUID = 866164758867358381L; + + protected TerremarkVCloudApiMetadata(Builder builder) { super(builder); } - protected static Properties defaultProperties() { - Properties properties = BaseComputeServiceApiMetadata.Builder.defaultProperties(); + public static Properties defaultProperties() { + Properties properties = BaseRestApiMetadata.defaultProperties(); properties.setProperty(PROPERTY_VCLOUD_VERSION_SCHEMA, "0.8"); properties.setProperty(PROPERTY_SESSION_INTERVAL, 8 * 60 + ""); properties.setProperty(PROPERTY_VCLOUD_XML_SCHEMA, "http://vcloud.safesecureweb.com/ns/vcloud.xsd"); @@ -60,20 +48,19 @@ public abstract class TerremarkVCloudApiMetadata> - extends BaseComputeServiceApiMetadata.Builder, M> { + public static abstract class Builder extends BaseRestApiMetadata.Builder { - protected Builder(Class syncClient, Class asyncClient) { - id("vcloud-common") - .identityName("Email") + protected Builder(Class syncClient, Class asyncClient) { + super(syncClient, asyncClient); + identityName("Email") .credentialName("Password") .version("0.8") .defaultProperties(TerremarkVCloudApiMetadata.defaultProperties()) - .javaApi(syncClient, asyncClient); + .wrapper(ComputeServiceContext.class); } @Override - public Builder fromApiMetadata(M in) { + public Builder fromApiMetadata(ApiMetadata in) { super.fromApiMetadata(in); return this; } diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/TerremarkClientLiveTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/TerremarkClientLiveTest.java index b25256d6f3..c193253b2b 100644 --- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/TerremarkClientLiveTest.java +++ b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/TerremarkClientLiveTest.java @@ -32,9 +32,9 @@ import java.io.IOException; import java.net.URI; import java.util.List; import java.util.Map; -import java.util.Map.Entry; import java.util.Properties; import java.util.Set; +import java.util.Map.Entry; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; @@ -42,7 +42,6 @@ import java.util.concurrent.TimeoutException; import org.jclouds.cim.CIMPredicates; import org.jclouds.cim.ResourceAllocationSettingData; import org.jclouds.cim.ResourceAllocationSettingData.ResourceType; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.net.IPSocket; import org.jclouds.predicates.RetryablePredicate; @@ -50,8 +49,8 @@ import org.jclouds.predicates.SocketOpen; import org.jclouds.rest.AuthorizationException; import org.jclouds.rest.RestContext; import org.jclouds.ssh.SshClient; -import org.jclouds.ssh.SshClient.Factory; import org.jclouds.ssh.SshException; +import org.jclouds.ssh.SshClient.Factory; import org.jclouds.trmk.vcloud_0_8.domain.Catalog; import org.jclouds.trmk.vcloud_0_8.domain.CatalogItem; import org.jclouds.trmk.vcloud_0_8.domain.CustomizationParameters; @@ -84,8 +83,7 @@ import com.google.common.collect.Lists; import com.google.inject.Injector; @Test(groups = "live", singleThreaded = true) -public abstract class TerremarkClientLiveTest - extends BaseComputeServiceContextLiveTest> { +public abstract class TerremarkClientLiveTest extends BaseComputeServiceContextLiveTest { protected String expectedOs = "Ubuntu Linux (64-bit)"; protected String itemName = "Ubuntu JeOS 9.10 (64-bit)"; @@ -103,6 +101,7 @@ public abstract class TerremarkClientLiveTest(injector.getInstance(TaskSuccess.class), 650, 10, TimeUnit.SECONDS); - connection = context.getProviderSpecificContext().getApi(); + connection = (S) RestContext.class.cast(context.unwrap()).getApi(); orgs = listOrgs(); } - protected S connection; @Test public void testOrg() throws Exception { @@ -517,7 +516,7 @@ public abstract class TerremarkClientLiveTest -extends BaseComputeServiceContextLiveTest> { +public class VAppTemplatesInOrgsLiveTest +extends BaseComputeServiceContextLiveTest { public VAppTemplatesInOrgsLiveTest() { provider = "trmk-vcloudexpress"; diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/BaseTerremarkClientLiveTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/BaseTerremarkClientLiveTest.java index f8e90f1d2c..453b394d0e 100644 --- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/BaseTerremarkClientLiveTest.java +++ b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/BaseTerremarkClientLiveTest.java @@ -21,11 +21,11 @@ package org.jclouds.trmk.vcloud_0_8.internal; import java.util.concurrent.TimeUnit; import org.jclouds.compute.ComputeService; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.net.IPSocket; import org.jclouds.predicates.InetSocketAddressConnect; import org.jclouds.predicates.RetryablePredicate; +import org.jclouds.rest.RestContext; import org.jclouds.ssh.SshClient.Factory; import org.jclouds.sshj.config.SshjSshClientModule; import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudAsyncClient; @@ -41,9 +41,8 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", enabled = true, singleThreaded = true) -public abstract class BaseTerremarkClientLiveTest - extends BaseComputeServiceContextLiveTest> { - +public abstract class BaseTerremarkClientLiveTest extends BaseComputeServiceContextLiveTest { + protected String prefix = System.getProperty("user.name"); protected ComputeService client; @@ -54,11 +53,9 @@ public abstract class BaseTerremarkClientLiveTest socketTester; protected Factory sshFactory; + protected S connection; - protected S getApi() { - return context.getProviderSpecificContext().getApi(); - } - + @SuppressWarnings("unchecked") @Override @BeforeClass(groups = { "integration", "live" }) public void setupContext() { @@ -66,6 +63,7 @@ public abstract class BaseTerremarkClientLiveTest(new InetSocketAddressConnect(), 300, 1, TimeUnit.SECONDS); sshFactory = injector.getInstance(Factory.class); + connection = (S) RestContext.class.cast(context.unwrap()).getApi(); } protected Module getSshModule() { diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudLoginAsyncClientTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudLoginAsyncClientTest.java index f63b0a87e1..0f05666743 100644 --- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudLoginAsyncClientTest.java +++ b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudLoginAsyncClientTest.java @@ -99,7 +99,7 @@ public class TerremarkVCloudLoginAsyncClientTest extends BaseAsyncClientTest createProviderMetadata() { + protected ProviderMetadata createProviderMetadata() { return AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint(TerremarkVCloudLoginClient.class, TerremarkVCloudLoginAsyncClient.class, "http://localhost:8080/login"); } diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudVersionsAsyncClientTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudVersionsAsyncClientTest.java index a1ef333f32..7830e6cee1 100644 --- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudVersionsAsyncClientTest.java +++ b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/TerremarkVCloudVersionsAsyncClientTest.java @@ -70,7 +70,7 @@ public class TerremarkVCloudVersionsAsyncClientTest extends BaseAsyncClientTest< } @Override - protected ProviderMetadata createProviderMetadata() { + protected ProviderMetadata createProviderMetadata() { return AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint(TerremarkVCloudVersionsClient.class, TerremarkVCloudVersionsAsyncClient.class, "http://localhost:8080"); } diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/xml/CatalogItemHandlerTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/xml/CatalogItemHandlerTest.java index 1a4e1631ee..7fb74cf3be 100644 --- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/xml/CatalogItemHandlerTest.java +++ b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/xml/CatalogItemHandlerTest.java @@ -18,20 +18,18 @@ */ package org.jclouds.trmk.vcloud_0_8.xml; -import static com.google.common.base.Preconditions.checkNotNull; import static org.testng.Assert.assertEquals; import java.io.InputStream; import java.net.URI; -import java.util.Properties; import org.jclouds.http.functions.BaseHandlerTest; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.config.SaxParserModule; -import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudPropertiesBuilder; import org.jclouds.trmk.vcloud_0_8.domain.CatalogItem; import org.jclouds.trmk.vcloud_0_8.domain.internal.CatalogItemImpl; import org.jclouds.trmk.vcloud_0_8.domain.internal.ReferenceTypeImpl; +import org.jclouds.trmk.vcloud_0_8.internal.TerremarkVCloudApiMetadata; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; @@ -55,9 +53,7 @@ public class CatalogItemHandlerTest extends BaseHandlerTest { @Override public void configure() { super.configure(); - Properties props = new Properties(); - Names.bindProperties(binder(), - checkNotNull(new TerremarkVCloudPropertiesBuilder(props).build(), "properties")); + Names.bindProperties(binder(), TerremarkVCloudApiMetadata.defaultProperties()); } }); factory = injector.getInstance(ParseSax.Factory.class); diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/xml/OrgHandlerTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/xml/OrgHandlerTest.java index 58f95b8772..29a9b4779c 100644 --- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/xml/OrgHandlerTest.java +++ b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/xml/OrgHandlerTest.java @@ -18,22 +18,20 @@ */ package org.jclouds.trmk.vcloud_0_8.xml; -import static com.google.common.base.Preconditions.checkNotNull; import static org.jclouds.trmk.vcloud_0_8.TerremarkVCloudMediaType.CATALOG_XML; import static org.jclouds.trmk.vcloud_0_8.TerremarkVCloudMediaType.TASKSLIST_XML; import static org.testng.Assert.assertEquals; import java.io.InputStream; import java.net.URI; -import java.util.Properties; import org.jclouds.http.functions.BaseHandlerTest; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.config.SaxParserModule; import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudMediaType; -import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudPropertiesBuilder; import org.jclouds.trmk.vcloud_0_8.domain.Org; import org.jclouds.trmk.vcloud_0_8.domain.internal.ReferenceTypeImpl; +import org.jclouds.trmk.vcloud_0_8.internal.TerremarkVCloudApiMetadata; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; @@ -56,9 +54,7 @@ public class OrgHandlerTest extends BaseHandlerTest { @Override public void configure() { super.configure(); - Properties props = new Properties(); - Names.bindProperties(binder(), checkNotNull(new TerremarkVCloudPropertiesBuilder(props).build(), - "properties")); + Names.bindProperties(binder(), TerremarkVCloudApiMetadata.defaultProperties()); } }); factory = injector.getInstance(ParseSax.Factory.class); diff --git a/compute/src/main/clojure/org/jclouds/compute2.clj b/compute/src/main/clojure/org/jclouds/compute2.clj index a54023c97a..35169afb6a 100644 --- a/compute/src/main/clojure/org/jclouds/compute2.clj +++ b/compute/src/main/clojure/org/jclouds/compute2.clj @@ -64,9 +64,10 @@ Here's an example of creating and running a small linux node in the group webser (org.jclouds predicate) [clojure.core.incubator :only (-?>)]) (:import java.io.File java.util.Properties + [org.jclouds ContextBuilder] [org.jclouds.domain Location] [org.jclouds.compute - ComputeService ComputeServiceContext ComputeServiceContextBuilder] + ComputeService ComputeServiceContext] [org.jclouds.compute.domain Template TemplateBuilder ComputeMetadata NodeMetadata Hardware OsFamily Image] @@ -84,12 +85,12 @@ Here's an example of creating and running a small linux node in the group webser (let [module-keys (set (keys module-lookup)) ext-modules (filter #(module-keys %) options) opts (apply hash-map (filter #(not (module-keys %)) options))] - (.. (ComputeServiceContextBuilder/newBuilder provider) + (.. (ContextBuilder/newBuilder provider) (credentials provider-identity provider-credential) (modules (apply modules (concat ext-modules (opts :extensions)))) (overrides (reduce #(do (.put %1 (name (first %2)) (second %2)) %1) (Properties.) (dissoc opts :extensions))) - (build) + (build ComputeServiceContext) (getComputeService)))) ([#^ComputeServiceContext compute-context] (.getComputeService compute-context))) diff --git a/compute/src/main/java/org/jclouds/compute/ComputeService.java b/compute/src/main/java/org/jclouds/compute/ComputeService.java index 1fd310b619..701f8f3102 100644 --- a/compute/src/main/java/org/jclouds/compute/ComputeService.java +++ b/compute/src/main/java/org/jclouds/compute/ComputeService.java @@ -54,7 +54,7 @@ public interface ComputeService { /** * @return a reference to the context that created this ComputeService. */ - ComputeServiceContext getContext(); + ComputeServiceContext getContext(); /** * Makes a new template builder for this service diff --git a/compute/src/main/java/org/jclouds/compute/ComputeServiceApiMetadata.java b/compute/src/main/java/org/jclouds/compute/ComputeServiceApiMetadata.java deleted file mode 100644 index f3927be7f6..0000000000 --- a/compute/src/main/java/org/jclouds/compute/ComputeServiceApiMetadata.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * 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.compute; - -import org.jclouds.apis.ApiMetadata; - -import com.google.common.annotations.Beta; - -/** - * - * @author Adrian Cole - * @since 1.5 - */ -@Beta -public interface ComputeServiceApiMetadata, M extends ComputeServiceApiMetadata> - extends ApiMetadata { - - public static interface Builder, M extends ComputeServiceApiMetadata> - extends ApiMetadata.Builder { - } - -} \ No newline at end of file diff --git a/compute/src/main/java/org/jclouds/compute/ComputeServiceContext.java b/compute/src/main/java/org/jclouds/compute/ComputeServiceContext.java index e89f428708..1d0b93fd5e 100644 --- a/compute/src/main/java/org/jclouds/compute/ComputeServiceContext.java +++ b/compute/src/main/java/org/jclouds/compute/ComputeServiceContext.java @@ -21,9 +21,10 @@ package org.jclouds.compute; import java.io.Closeable; import java.util.Map; +import org.jclouds.Wrapper; import org.jclouds.compute.internal.ComputeServiceContextImpl; import org.jclouds.domain.Credentials; -import org.jclouds.rest.BackedByRestContext; +import org.jclouds.rest.RestContext; import com.google.common.annotations.Beta; import com.google.inject.ImplementedBy; @@ -36,7 +37,7 @@ import com.google.inject.ImplementedBy; * */ @ImplementedBy(ComputeServiceContextImpl.class) -public interface ComputeServiceContext extends Closeable, BackedByRestContext { +public interface ComputeServiceContext extends Closeable, Wrapper { ComputeService getComputeService(); @@ -71,6 +72,15 @@ public interface ComputeServiceContext extends Closeable, BackedByRestCont * @see #getUtils */ Utils utils(); + + /** + * will be removed in jclouds 1.6 + * + * @see Wrapper#getInputType + * @see Wrapper#unwrap + */ + @Deprecated + RestContext getProviderSpecificContext(); @Override void close(); diff --git a/compute/src/main/java/org/jclouds/compute/ComputeServiceContextBuilder.java b/compute/src/main/java/org/jclouds/compute/ComputeServiceContextBuilder.java deleted file mode 100644 index 5a1c302eac..0000000000 --- a/compute/src/main/java/org/jclouds/compute/ComputeServiceContextBuilder.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * 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.compute; - -import static com.google.common.base.Preconditions.checkArgument; - -import java.util.NoSuchElementException; -import java.util.concurrent.ConcurrentMap; - -import org.jclouds.compute.config.ResolvesImages; -import org.jclouds.compute.stub.StubApiMetadata; -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.rest.internal.ContextBuilder; - -import com.google.common.base.Predicate; -import com.google.common.collect.Iterables; -import com.google.inject.Injector; -import com.google.inject.Module; - -/** - * @author Adrian Cole - */ -public abstract class ComputeServiceContextBuilder, M extends ComputeServiceApiMetadata> extends - ContextBuilder { - - /** - * looks up a provider or api with the given id - * - * @param providerOrApi - * id of the provider or api - * @return means to build a context to that provider - * @throws NoSuchElementException - * if the id was not configured. - * @throws IllegalArgumentException - * if the api or provider isn't assignable from ComputeServiceContext - */ - public static ComputeServiceContextBuilder newBuilder(String providerOrApi) throws NoSuchElementException { - ContextBuilder builder = ContextBuilder.newBuilder(providerOrApi); - checkArgument(builder instanceof ComputeServiceContextBuilder, - "type of providerOrApi[%s] is not ComputeServiceContextBuilder: %s", providerOrApi, builder); - return ComputeServiceContextBuilder.class.cast(builder); - } - - @SuppressWarnings("rawtypes") - public static ContextBuilder, StubApiMetadata> forTests() { - return ContextBuilder.newBuilder(new StubApiMetadata()); - } - - public ComputeServiceContextBuilder(ProviderMetadata providerMetadata) { - super(providerMetadata); - } - - public ComputeServiceContextBuilder(M apiMetadata) { - super(apiMetadata); - } - - protected void addImageResolutionModule() { - // do nothing; - // this is to be overridden when needed - } - - @Override - public Injector buildInjector() { - addImageResolutionModuleIfNotPresent(); - return super.buildInjector(); - } - - protected void addImageResolutionModuleIfNotPresent() { - if (!Iterables.any(modules, new Predicate() { - public boolean apply(Module input) { - return input.getClass().isAnnotationPresent(ResolvesImages.class); - } - - })) { - addImageResolutionModule(); - } - } - -} \ No newline at end of file diff --git a/compute/src/main/java/org/jclouds/compute/ComputeServiceContextFactory.java b/compute/src/main/java/org/jclouds/compute/ComputeServiceContextFactory.java index 0aaa4f3b06..30b697a25d 100644 --- a/compute/src/main/java/org/jclouds/compute/ComputeServiceContextFactory.java +++ b/compute/src/main/java/org/jclouds/compute/ComputeServiceContextFactory.java @@ -21,11 +21,11 @@ package org.jclouds.compute; import java.util.NoSuchElementException; import java.util.Properties; +import org.jclouds.ContextBuilder; import org.jclouds.apis.Apis; import org.jclouds.javax.annotation.Nullable; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.Providers; -import org.jclouds.rest.internal.ContextBuilder; import com.google.common.collect.ImmutableSet; import com.google.inject.Module; @@ -54,21 +54,21 @@ public class ComputeServiceContextFactory { /** * @see #createContext(String, String,String, Iterable, Properties) */ - public ComputeServiceContext createContext(String providerOrApi, String identity, String credential) { + public ComputeServiceContext createContext(String providerOrApi, String identity, String credential) { return createContext(providerOrApi, identity, credential, ImmutableSet. of(), new Properties()); } /** * @see #createContext(String, String, String, Iterable, Properties) */ - public ComputeServiceContext createContext(String providerOrApi, Properties overrides) { + public ComputeServiceContext createContext(String providerOrApi, Properties overrides) { return createContext(providerOrApi, null, null, ImmutableSet. of(), overrides); } /** * @see #createContext(String, String,String, Iterable, Properties) */ - public ComputeServiceContext createContext(String providerOrApi, Iterable wiring, + public ComputeServiceContext createContext(String providerOrApi, Iterable wiring, Properties overrides) { return createContext(providerOrApi, null, null, wiring, overrides); } @@ -76,7 +76,7 @@ public class ComputeServiceContextFactory { /** * @see #createContext(String, String,String, Iterable, Properties) */ - public ComputeServiceContext createContext(String providerOrApi, @Nullable String identity, + public ComputeServiceContext createContext(String providerOrApi, @Nullable String identity, @Nullable String credential, Properties overrides) { return createContext(providerOrApi, identity, credential, ImmutableSet. of(), overrides); } @@ -84,7 +84,7 @@ public class ComputeServiceContextFactory { /** * @see createContext(String, String,String, Iterable, Properties) */ - public ComputeServiceContext createContext(String providerOrApi, @Nullable String identity, + public ComputeServiceContext createContext(String providerOrApi, @Nullable String identity, @Nullable String credential, Iterable wiring) { return createContext(providerOrApi, identity, credential, wiring, new Properties()); } @@ -104,28 +104,20 @@ public class ComputeServiceContextFactory { * properties to override defaults with. * @return initialized context ready for use */ - @SuppressWarnings("unchecked") - public ComputeServiceContext createContext(String providerOrApi, @Nullable String identity, + public ComputeServiceContext createContext(String providerOrApi, @Nullable String identity, @Nullable String credential, Iterable wiring, Properties overrides) { - ContextBuilder builder = null; + ContextBuilder builder = null; try { - ProviderMetadata pm = Providers.withId(providerOrApi); - builder = ComputeServiceContextBuilder.newBuilder(pm); + ProviderMetadata pm = Providers.withId(providerOrApi); + builder = ContextBuilder.newBuilder(pm); } catch (NoSuchElementException e) { builder = ContextBuilder.newBuilder(Apis.withId(providerOrApi)); } - builder.modules(Iterable.class.cast(wiring)); + builder.modules(wiring); builder.overrides(overrides); if (identity != null) builder.credentials(identity, credential); - Object context = builder.build(); - if (context instanceof ComputeServiceContext) { - return ComputeServiceContext.class.cast(context); - } else { - throw new IllegalArgumentException("provider " + providerOrApi + " contains an unknown context type: " - + context.getClass().getSimpleName()); - } - + return builder.build(ComputeServiceContext.class); } } diff --git a/compute/src/main/java/org/jclouds/compute/RunScriptData.java b/compute/src/main/java/org/jclouds/compute/RunScriptData.java index c678d6b851..c2ecdedfc1 100644 --- a/compute/src/main/java/org/jclouds/compute/RunScriptData.java +++ b/compute/src/main/java/org/jclouds/compute/RunScriptData.java @@ -36,8 +36,8 @@ import org.jclouds.scriptbuilder.statements.login.AdminAccess; import com.google.common.base.Splitter; import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableList.Builder; import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableList.Builder; /** * diff --git a/compute/src/main/java/org/jclouds/compute/StandaloneComputeServiceContextBuilder.java b/compute/src/main/java/org/jclouds/compute/StandaloneComputeServiceContextBuilder.java deleted file mode 100644 index 218c2d876b..0000000000 --- a/compute/src/main/java/org/jclouds/compute/StandaloneComputeServiceContextBuilder.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * 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.compute; - -import java.util.List; - -import org.jclouds.compute.ComputeServiceApiMetadata; -import org.jclouds.compute.config.StandaloneComputeServiceClientModule; -import org.jclouds.providers.ProviderMetadata; - -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class StandaloneComputeServiceContextBuilder, M extends ComputeServiceApiMetadata> - extends ComputeServiceContextBuilder { - - public StandaloneComputeServiceContextBuilder(ProviderMetadata providerMetadata) { - super(providerMetadata); - } - - public StandaloneComputeServiceContextBuilder(M apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addClientModule(List modules) { - modules.add(new StandaloneComputeServiceClientModule(providerMetadata.getApiMetadata() - .getApi())); - } - -} \ No newline at end of file diff --git a/compute/src/main/java/org/jclouds/compute/config/ComputeServiceAdapterContextModule.java b/compute/src/main/java/org/jclouds/compute/config/ComputeServiceAdapterContextModule.java index f478be5af8..212ab43b6f 100644 --- a/compute/src/main/java/org/jclouds/compute/config/ComputeServiceAdapterContextModule.java +++ b/compute/src/main/java/org/jclouds/compute/config/ComputeServiceAdapterContextModule.java @@ -22,7 +22,6 @@ import static com.google.common.base.Functions.compose; import static com.google.common.base.Predicates.notNull; import static com.google.common.collect.Iterables.filter; import static com.google.common.collect.Iterables.transform; -import static com.google.inject.util.Types.newParameterizedType; import java.util.Set; @@ -31,11 +30,9 @@ import javax.inject.Singleton; import org.jclouds.collect.TransformingSetSupplier; import org.jclouds.compute.ComputeServiceAdapter; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.Hardware; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.ImageBuilder; -import org.jclouds.compute.internal.ComputeServiceContextImpl; import org.jclouds.compute.strategy.CreateNodeWithGroupEncodedIntoName; import org.jclouds.compute.strategy.DestroyNodeStrategy; import org.jclouds.compute.strategy.GetNodeMetadataStrategy; @@ -54,33 +51,13 @@ import com.google.common.base.Supplier; import com.google.common.collect.ImmutableSet; import com.google.inject.AbstractModule; import com.google.inject.Provides; -import com.google.inject.Scopes; -import com.google.inject.TypeLiteral; /** * * @author Adrian Cole */ -public class ComputeServiceAdapterContextModule extends BaseComputeServiceContextModule { +public class ComputeServiceAdapterContextModule extends BaseComputeServiceContextModule { - private Class asyncClientType; - private Class syncClientType; - - public ComputeServiceAdapterContextModule(Class syncClientType, Class asyncClientType) { - this.syncClientType = syncClientType; - this.asyncClientType = asyncClientType; - } - - @SuppressWarnings( { "unchecked", "rawtypes" }) - @Override - protected void configure() { - super.configure(); - bind(new TypeLiteral() { - }).to( - (TypeLiteral) TypeLiteral.get(newParameterizedType(ComputeServiceContextImpl.class, syncClientType, - asyncClientType))).in(Scopes.SINGLETON); - } - /** * install this, if you want to use your computeservice adapter to handle locations. Note that if * you do this, you'll want to instantiate a subclass to prevent type erasure. diff --git a/compute/src/main/java/org/jclouds/compute/config/ComputeServiceTimeoutsModule.java b/compute/src/main/java/org/jclouds/compute/config/ComputeServiceTimeoutsModule.java index aa49e72ea9..311a651175 100644 --- a/compute/src/main/java/org/jclouds/compute/config/ComputeServiceTimeoutsModule.java +++ b/compute/src/main/java/org/jclouds/compute/config/ComputeServiceTimeoutsModule.java @@ -29,8 +29,8 @@ import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.predicates.AtomicNodeRunning; import org.jclouds.compute.predicates.AtomicNodeSuspended; import org.jclouds.compute.predicates.ScriptStatusReturnsZero; -import org.jclouds.compute.predicates.ScriptStatusReturnsZero.CommandUsingClient; import org.jclouds.compute.predicates.TrueIfNullOrTerminatedRefreshAndDoubleCheckOnFalse; +import org.jclouds.compute.predicates.ScriptStatusReturnsZero.CommandUsingClient; import org.jclouds.compute.reference.ComputeServiceConstants.Timeouts; import org.jclouds.predicates.RetryablePredicate; diff --git a/compute/src/main/java/org/jclouds/compute/config/JCloudsNativeComputeServiceAdapterContextModule.java b/compute/src/main/java/org/jclouds/compute/config/JCloudsNativeComputeServiceAdapterContextModule.java index fce4c42be7..1dd4c5937d 100644 --- a/compute/src/main/java/org/jclouds/compute/config/JCloudsNativeComputeServiceAdapterContextModule.java +++ b/compute/src/main/java/org/jclouds/compute/config/JCloudsNativeComputeServiceAdapterContextModule.java @@ -33,13 +33,12 @@ import com.google.inject.TypeLiteral; * * @author Adrian Cole */ -public class JCloudsNativeComputeServiceAdapterContextModule extends - ComputeServiceAdapterContextModule { +public class JCloudsNativeComputeServiceAdapterContextModule extends + ComputeServiceAdapterContextModule { protected final Class> adapter; - public JCloudsNativeComputeServiceAdapterContextModule(Class syncClientType, Class asyncClientType, - Class> adapter) { - super(syncClientType, asyncClientType); + public JCloudsNativeComputeServiceAdapterContextModule( + Class> adapter) { this.adapter = adapter; } diff --git a/compute/src/main/java/org/jclouds/compute/config/StandaloneComputeServiceClientModule.java b/compute/src/main/java/org/jclouds/compute/config/StandaloneComputeServiceClientModule.java deleted file mode 100644 index bcc424b1da..0000000000 --- a/compute/src/main/java/org/jclouds/compute/config/StandaloneComputeServiceClientModule.java +++ /dev/null @@ -1,41 +0,0 @@ -/** - * 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.compute.config; - -import org.jclouds.http.RequiresHttp; -import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.rest.config.RestClientModule; - -@ConfiguresRestClient -@RequiresHttp -public class StandaloneComputeServiceClientModule extends RestClientModule { - - public StandaloneComputeServiceClientModule(Class clazz) { - super(clazz, clazz); - } - - @Override - protected void bindAsyncClient() { - } - - @Override - protected void bindClient() { - - } -} \ No newline at end of file diff --git a/compute/src/main/java/org/jclouds/compute/internal/BaseComputeService.java b/compute/src/main/java/org/jclouds/compute/internal/BaseComputeService.java index 72fd556769..bd4496b219 100644 --- a/compute/src/main/java/org/jclouds/compute/internal/BaseComputeService.java +++ b/compute/src/main/java/org/jclouds/compute/internal/BaseComputeService.java @@ -110,7 +110,7 @@ public class BaseComputeService implements ComputeService { @Named(ComputeServiceConstants.COMPUTE_LOGGER) protected Logger logger = Logger.NULL; - protected final ComputeServiceContext context; + protected final ComputeServiceContext context; protected final Map credentialStore; private final Supplier> images; @@ -136,7 +136,7 @@ public class BaseComputeService implements ComputeService { private final ExecutorService executor; @Inject - protected BaseComputeService(@SuppressWarnings("rawtypes") ComputeServiceContext context, Map credentialStore, + protected BaseComputeService(ComputeServiceContext context, Map credentialStore, @Memoized Supplier> images, @Memoized Supplier> hardwareProfiles, @Memoized Supplier> locations, ListNodesStrategy listNodesStrategy, GetNodeMetadataStrategy getNodeMetadataStrategy, CreateNodesInGroupThenAddToSet runNodesAndAddToSetStrategy, @@ -178,7 +178,7 @@ public class BaseComputeService implements ComputeService { * {@inheritDoc} */ @Override - public ComputeServiceContext getContext() { + public ComputeServiceContext getContext() { return context; } diff --git a/compute/src/main/java/org/jclouds/compute/internal/BaseComputeServiceApiMetadata.java b/compute/src/main/java/org/jclouds/compute/internal/BaseComputeServiceApiMetadata.java deleted file mode 100644 index c5d828eac0..0000000000 --- a/compute/src/main/java/org/jclouds/compute/internal/BaseComputeServiceApiMetadata.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * 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.compute.internal; - -import org.jclouds.apis.ApiType; -import org.jclouds.apis.internal.BaseApiMetadata; -import org.jclouds.compute.ComputeServiceApiMetadata; -import org.jclouds.compute.ComputeServiceContext; - -import com.google.common.annotations.Beta; -import com.google.common.reflect.TypeParameter; -import com.google.common.reflect.TypeToken; - -/** - * - * @author Adrian Cole - * @since 1.5 - */ -@Beta -public abstract class BaseComputeServiceApiMetadata, M extends ComputeServiceApiMetadata> - extends BaseApiMetadata implements ComputeServiceApiMetadata { - - public static class Builder, M extends ComputeServiceApiMetadata> - extends BaseApiMetadata.Builder implements ComputeServiceApiMetadata.Builder { - public Builder() { - type(ApiType.COMPUTE); - } - - /** - * {@inheritDoc} - */ - @Override - @SuppressWarnings("rawtypes") - protected TypeToken contextToken(TypeToken clientToken, TypeToken asyncClientToken) { - return new TypeToken>() { - private static final long serialVersionUID = 1L; - }.where(new TypeParameter() { - }, clientToken).where(new TypeParameter() { - }, asyncClientToken); - } - } - - protected BaseComputeServiceApiMetadata(BaseComputeServiceApiMetadata.Builder builder) { - super(builder); - } - -} \ No newline at end of file diff --git a/compute/src/main/java/org/jclouds/compute/internal/ComputeServiceContextImpl.java b/compute/src/main/java/org/jclouds/compute/internal/ComputeServiceContextImpl.java index b880525b78..dfcfdfdb8f 100644 --- a/compute/src/main/java/org/jclouds/compute/internal/ComputeServiceContextImpl.java +++ b/compute/src/main/java/org/jclouds/compute/internal/ComputeServiceContextImpl.java @@ -20,6 +20,7 @@ package org.jclouds.compute.internal; import static com.google.common.base.Preconditions.checkNotNull; +import java.io.Closeable; import java.util.Map; import javax.inject.Inject; @@ -29,25 +30,28 @@ import org.jclouds.compute.ComputeService; import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.Utils; import org.jclouds.domain.Credentials; +import org.jclouds.internal.BaseWrapper; +import org.jclouds.location.Provider; import org.jclouds.rest.RestContext; +import com.google.common.io.Closeables; +import com.google.common.reflect.TypeToken; + /** * @author Adrian Cole */ @Singleton -public class ComputeServiceContextImpl implements ComputeServiceContext { +public class ComputeServiceContextImpl extends BaseWrapper implements ComputeServiceContext { private final ComputeService computeService; - private final RestContext providerSpecificContext; private final Utils utils; private final Map credentialStore; - @SuppressWarnings( { "unchecked" }) @Inject - public ComputeServiceContextImpl(ComputeService computeService, Map credentialStore, - Utils utils, @SuppressWarnings("rawtypes") RestContext providerSpecificContext) { + public ComputeServiceContextImpl(@Provider Closeable wrapped, @Provider TypeToken wrappedType, + ComputeService computeService, Map credentialStore, Utils utils) { + super(wrapped, wrappedType); this.credentialStore = credentialStore; this.utils = utils; - this.providerSpecificContext = providerSpecificContext; this.computeService = checkNotNull(computeService, "computeService"); } @@ -55,16 +59,6 @@ public class ComputeServiceContextImpl implements ComputeServiceContext getProviderSpecificContext() { - return (RestContext) providerSpecificContext; - } - - @Override - public void close() { - providerSpecificContext.close(); - } - @Override public Utils getUtils() { return utils(); @@ -75,20 +69,6 @@ public class ComputeServiceContextImpl implements ComputeServiceContext getCredentialStore() { return credentialStore; @@ -98,4 +78,30 @@ public class ComputeServiceContextImpl implements ComputeServiceContext credentialStore() { return credentialStore; } + + @SuppressWarnings("unchecked") + @Override + public RestContext getProviderSpecificContext() { + return (RestContext) getWrapped(); + } + + @Override + public void close() { + Closeables.closeQuietly(getWrapped()); + } + + public int hashCode() { + return getWrapped().hashCode(); + } + + @Override + public String toString() { + return getWrapped().toString(); + } + + @Override + public boolean equals(Object obj) { + return getWrapped().equals(obj); + } + } diff --git a/compute/src/main/java/org/jclouds/compute/options/RunScriptOptions.java b/compute/src/main/java/org/jclouds/compute/options/RunScriptOptions.java index 4057142a93..534b8b7c4f 100644 --- a/compute/src/main/java/org/jclouds/compute/options/RunScriptOptions.java +++ b/compute/src/main/java/org/jclouds/compute/options/RunScriptOptions.java @@ -26,8 +26,8 @@ import org.jclouds.domain.LoginCredentials; import org.jclouds.javax.annotation.Nullable; import com.google.common.base.Objects; -import com.google.common.base.Objects.ToStringHelper; import com.google.common.base.Optional; +import com.google.common.base.Objects.ToStringHelper; /** * Enables additional options for running a script. diff --git a/compute/src/main/java/org/jclouds/compute/stub/StubApiMetadata.java b/compute/src/main/java/org/jclouds/compute/stub/StubApiMetadata.java index c8c299c620..c08c89ab6f 100644 --- a/compute/src/main/java/org/jclouds/compute/stub/StubApiMetadata.java +++ b/compute/src/main/java/org/jclouds/compute/stub/StubApiMetadata.java @@ -19,22 +19,22 @@ package org.jclouds.compute.stub; import java.net.URI; -import java.util.concurrent.ConcurrentMap; import org.jclouds.apis.ApiMetadata; +import org.jclouds.apis.internal.BaseApiMetadata; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; -import org.jclouds.compute.stub.internal.StubComputeServiceContextBuilder; - -import com.google.common.reflect.TypeToken; +import org.jclouds.compute.stub.config.StubComputeServiceContextModule; /** * Implementation of {@link ApiMetadata} for jclouds in-memory (Stub) API * * @author Adrian Cole */ -@SuppressWarnings("rawtypes") -public class StubApiMetadata extends BaseComputeServiceApiMetadata, StubApiMetadata> { +public class StubApiMetadata extends BaseApiMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = -4880642520937391337L; + public static Builder builder() { return new Builder(); } @@ -52,7 +52,7 @@ public class StubApiMetadata extends BaseComputeServiceApiMetadata, StubApiMetadata> { + public static class Builder extends BaseApiMetadata.Builder { protected Builder(){ id("stub") @@ -61,12 +61,9 @@ public class StubApiMetadata extends BaseComputeServiceApiMetadata>(getClass()){ - private static final long serialVersionUID = 1L; - }) - .javaApi(ConcurrentMap.class, ConcurrentMap.class) .documentation(URI.create("http://www.jclouds.org/documentation/userguide/compute")) - .contextBuilder(TypeToken.of(StubComputeServiceContextBuilder.class)); + .wrapper(ComputeServiceContext.class) + .defaultModule(StubComputeServiceContextModule.class); } @Override diff --git a/compute/src/main/java/org/jclouds/compute/stub/config/StubComputeServiceAdapter.java b/compute/src/main/java/org/jclouds/compute/stub/config/StubComputeServiceAdapter.java index 0bb2a81782..0200b4474e 100644 --- a/compute/src/main/java/org/jclouds/compute/stub/config/StubComputeServiceAdapter.java +++ b/compute/src/main/java/org/jclouds/compute/stub/config/StubComputeServiceAdapter.java @@ -19,8 +19,8 @@ package org.jclouds.compute.stub.config; import java.util.Map; -import java.util.Map.Entry; import java.util.Set; +import java.util.Map.Entry; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ExecutorService; @@ -48,8 +48,8 @@ import org.jclouds.rest.ResourceNotFoundException; import com.google.common.base.Supplier; import com.google.common.base.Throwables; import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableList.Builder; import com.google.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableList.Builder; /** * diff --git a/compute/src/main/java/org/jclouds/compute/stub/config/StubComputeServiceContextModule.java b/compute/src/main/java/org/jclouds/compute/stub/config/StubComputeServiceContextModule.java index 50e80faefc..dec1c7f0ad 100644 --- a/compute/src/main/java/org/jclouds/compute/stub/config/StubComputeServiceContextModule.java +++ b/compute/src/main/java/org/jclouds/compute/stub/config/StubComputeServiceContextModule.java @@ -18,33 +18,18 @@ */ package org.jclouds.compute.stub.config; -import java.util.concurrent.ConcurrentMap; - -import javax.inject.Singleton; - import org.jclouds.compute.config.JCloudsNativeComputeServiceAdapterContextModule; -import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.concurrent.SingleThreaded; -import com.google.inject.Provides; - /** * * @author Adrian Cole */ -@SuppressWarnings("rawtypes") @SingleThreaded -public class StubComputeServiceContextModule extends - JCloudsNativeComputeServiceAdapterContextModule { +public class StubComputeServiceContextModule extends JCloudsNativeComputeServiceAdapterContextModule { public StubComputeServiceContextModule() { - super(ConcurrentMap.class, ConcurrentMap.class, StubComputeServiceAdapter.class); - } - - @Provides - @Singleton - ConcurrentMap provideApi(ConcurrentMap in) { - return in; + super(StubComputeServiceAdapter.class); } @Override diff --git a/compute/src/main/java/org/jclouds/compute/stub/internal/StubComputeServiceContextBuilder.java b/compute/src/main/java/org/jclouds/compute/stub/internal/StubComputeServiceContextBuilder.java deleted file mode 100644 index 843939dcb8..0000000000 --- a/compute/src/main/java/org/jclouds/compute/stub/internal/StubComputeServiceContextBuilder.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * 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.compute.stub.internal; - -import java.util.List; -import java.util.concurrent.ConcurrentMap; - -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.StandaloneComputeServiceContextBuilder; -import org.jclouds.compute.stub.StubApiMetadata; -import org.jclouds.compute.stub.config.StubComputeServiceContextModule; -import org.jclouds.providers.ProviderMetadata; - -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -@SuppressWarnings("rawtypes") -public class StubComputeServiceContextBuilder extends - StandaloneComputeServiceContextBuilder, StubApiMetadata> { - - public StubComputeServiceContextBuilder( - ProviderMetadata, StubApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public StubComputeServiceContextBuilder(StubApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new StubComputeServiceContextModule()); - } - -} diff --git a/compute/src/main/java/org/jclouds/compute/util/ComputeServiceUtils.java b/compute/src/main/java/org/jclouds/compute/util/ComputeServiceUtils.java index a5f0ab0035..34e73036a0 100644 --- a/compute/src/main/java/org/jclouds/compute/util/ComputeServiceUtils.java +++ b/compute/src/main/java/org/jclouds/compute/util/ComputeServiceUtils.java @@ -30,8 +30,8 @@ import static org.jclouds.scriptbuilder.domain.Statements.pipeHttpResponseToBash import java.net.URI; import java.util.Formatter; import java.util.Map; -import java.util.Map.Entry; import java.util.NoSuchElementException; +import java.util.Map.Entry; import java.util.regex.Pattern; import org.jclouds.compute.ComputeServiceContext; diff --git a/compute/src/main/java/org/jclouds/ovf/xml/EnvelopeHandler.java b/compute/src/main/java/org/jclouds/ovf/xml/EnvelopeHandler.java index 5a05f4bc30..b415224d16 100644 --- a/compute/src/main/java/org/jclouds/ovf/xml/EnvelopeHandler.java +++ b/compute/src/main/java/org/jclouds/ovf/xml/EnvelopeHandler.java @@ -22,8 +22,8 @@ import javax.inject.Inject; import javax.inject.Provider; import org.jclouds.ovf.Envelope; -import org.jclouds.ovf.Envelope.Builder; import org.jclouds.ovf.VirtualSystem; +import org.jclouds.ovf.Envelope.Builder; import org.jclouds.ovf.xml.internal.BaseEnvelopeHandler; /** diff --git a/compute/src/test/java/org/jclouds/cim/xml/VirtualSystemSettingDataHandlerTest.java b/compute/src/test/java/org/jclouds/cim/xml/VirtualSystemSettingDataHandlerTest.java index 5417fab19e..d693593ee9 100644 --- a/compute/src/test/java/org/jclouds/cim/xml/VirtualSystemSettingDataHandlerTest.java +++ b/compute/src/test/java/org/jclouds/cim/xml/VirtualSystemSettingDataHandlerTest.java @@ -23,8 +23,8 @@ import static org.testng.Assert.assertEquals; import java.io.InputStream; import org.jclouds.cim.ResourceAllocationSettingData; -import org.jclouds.cim.ResourceAllocationSettingData.ResourceType; import org.jclouds.cim.VirtualSystemSettingData; +import org.jclouds.cim.ResourceAllocationSettingData.ResourceType; import org.jclouds.http.functions.BaseHandlerTest; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ParseSax.Factory; diff --git a/compute/src/test/java/org/jclouds/compute/StubComputeServiceIntegrationTest.java b/compute/src/test/java/org/jclouds/compute/StubComputeServiceIntegrationTest.java index 340817a75f..de65693865 100644 --- a/compute/src/test/java/org/jclouds/compute/StubComputeServiceIntegrationTest.java +++ b/compute/src/test/java/org/jclouds/compute/StubComputeServiceIntegrationTest.java @@ -29,7 +29,6 @@ import java.io.IOException; import java.io.Serializable; import java.util.Map; import java.util.Set; -import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; @@ -63,10 +62,8 @@ import com.google.inject.Module; * * @author Adrian Cole */ -@SuppressWarnings("rawtypes") @Test(groups = "live", testName="StubComputeServiceIntegrationTest") -public class StubComputeServiceIntegrationTest extends - BaseComputeServiceLiveTest> { +public class StubComputeServiceIntegrationTest extends BaseComputeServiceLiveTest { private static final ExecResponse EXEC_GOOD = new ExecResponse("", "", 0); private static final ExecResponse EXEC_BAD = new ExecResponse("", "", 1); diff --git a/compute/src/test/java/org/jclouds/compute/StubTemplateBuilderIntegrationTest.java b/compute/src/test/java/org/jclouds/compute/StubTemplateBuilderIntegrationTest.java index 50955a05cf..8ffffecf35 100644 --- a/compute/src/test/java/org/jclouds/compute/StubTemplateBuilderIntegrationTest.java +++ b/compute/src/test/java/org/jclouds/compute/StubTemplateBuilderIntegrationTest.java @@ -19,7 +19,6 @@ package org.jclouds.compute; import java.util.Set; -import java.util.concurrent.ConcurrentMap; import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; import org.testng.annotations.Test; @@ -31,10 +30,8 @@ import com.google.common.collect.ImmutableSet; * * @author Adrian Cole */ -@SuppressWarnings("rawtypes") @Test(groups = { "integration", "live" }) -public class StubTemplateBuilderIntegrationTest extends - BaseTemplateBuilderLiveTest> { +public class StubTemplateBuilderIntegrationTest extends BaseTemplateBuilderLiveTest { public StubTemplateBuilderIntegrationTest() { provider = "stub"; @@ -44,5 +41,5 @@ public class StubTemplateBuilderIntegrationTest extends protected Set getIso3166Codes() { return ImmutableSet. of(); } - + } \ No newline at end of file diff --git a/compute/src/test/java/org/jclouds/compute/config/ComputeServicePropertiesTest.java b/compute/src/test/java/org/jclouds/compute/config/ComputeServicePropertiesTest.java index 206d6d574c..573d333351 100644 --- a/compute/src/test/java/org/jclouds/compute/config/ComputeServicePropertiesTest.java +++ b/compute/src/test/java/org/jclouds/compute/config/ComputeServicePropertiesTest.java @@ -22,7 +22,7 @@ import static org.testng.Assert.assertEquals; import java.util.Properties; -import org.jclouds.compute.ComputeServiceContextBuilder; +import org.jclouds.ContextBuilder; import org.jclouds.compute.reference.ComputeServiceConstants.InitStatusProperties; import org.testng.annotations.Test; @@ -33,7 +33,7 @@ import org.testng.annotations.Test; @Test(groups = "unit", testName = "ComputeServicePropertiesTest") public class ComputeServicePropertiesTest { public void testDefaultInitStatusProperties() { - InitStatusProperties props = ComputeServiceContextBuilder.forTests().buildInjector() + InitStatusProperties props = ContextBuilder.newBuilder("stub").buildInjector() .getInstance(InitStatusProperties.class); assertEquals(props.initStatusInitialPeriod, 500); assertEquals(props.initStatusMaxPeriod, 5000); @@ -44,7 +44,7 @@ public class ComputeServicePropertiesTest { overrides.setProperty(ComputeServiceProperties.INIT_STATUS_INITIAL_PERIOD, "501"); overrides.setProperty(ComputeServiceProperties.INIT_STATUS_MAX_PERIOD, "5001"); - InitStatusProperties props = ComputeServiceContextBuilder.forTests().overrides(overrides).buildInjector() + InitStatusProperties props = ContextBuilder.newBuilder("stub").overrides(overrides).buildInjector() .getInstance(InitStatusProperties.class); assertEquals(props.initStatusInitialPeriod, 501); diff --git a/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceApiMetadataTest.java b/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceApiMetadataTest.java index acbe40a87f..2079f0ef67 100644 --- a/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceApiMetadataTest.java +++ b/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceApiMetadataTest.java @@ -1,12 +1,8 @@ package org.jclouds.compute.internal; -import java.util.Set; - +import org.jclouds.Wrapper; import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.Apis; import org.jclouds.apis.internal.BaseApiMetadataTest; -import org.jclouds.compute.ComputeServiceApiMetadata; import org.jclouds.compute.ComputeServiceContext; import org.testng.annotations.Test; @@ -20,15 +16,8 @@ import com.google.common.reflect.TypeToken; @Test(groups = "unit") public abstract class BaseComputeServiceApiMetadataTest extends BaseApiMetadataTest { - @SuppressWarnings("rawtypes") - public BaseComputeServiceApiMetadataTest(ComputeServiceApiMetadata toTest) { - super(toTest, ApiType.COMPUTE); - } - - @Test - public void testContextAssignableFromComputeServiceContext() { - Set> all = ImmutableSet.copyOf(Apis.contextAssignableFrom(TypeToken.of(ComputeServiceContext.class))); - assert all.contains(toTest) : String.format("%s not found in %s", toTest, all); + public BaseComputeServiceApiMetadataTest(ApiMetadata toTest) { + super(toTest, ImmutableSet.>of(TypeToken.of(ComputeServiceContext.class))); } } \ No newline at end of file diff --git a/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceContextLiveTest.java b/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceContextLiveTest.java index a9f8eb3b3d..c1c4f90d21 100644 --- a/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceContextLiveTest.java +++ b/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceContextLiveTest.java @@ -22,24 +22,25 @@ import java.io.InputStream; import java.util.Properties; import java.util.concurrent.ConcurrentHashMap; +import org.jclouds.apis.BaseContextLiveTest; import org.jclouds.compute.ComputeServiceContext; import org.jclouds.domain.LoginCredentials; import org.jclouds.domain.LoginCredentials.Builder; import org.jclouds.io.CopyInputStreamInputSupplierMap; import org.jclouds.rest.config.CredentialStoreModule; -import org.jclouds.rest.internal.BaseContextLiveTest; import com.google.common.base.Splitter; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.common.io.InputSupplier; +import com.google.common.reflect.TypeToken; import com.google.inject.Module; import com.google.inject.util.Modules; /** * @author Jason King, Adrian Cole */ -public abstract class BaseComputeServiceContextLiveTest> extends BaseContextLiveTest { +public abstract class BaseComputeServiceContextLiveTest extends BaseContextLiveTest { protected String imageId; protected String loginUser; @@ -49,7 +50,12 @@ public abstract class BaseComputeServiceContextLiveTest>())); - + + @Override + protected TypeToken contextType() { + return TypeToken.of(ComputeServiceContext.class); + } + @Override protected Properties setupProperties() { Properties overrides = super.setupProperties(); diff --git a/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceLiveTest.java b/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceLiveTest.java index 78d3d65f08..eff4c31be0 100644 --- a/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceLiveTest.java +++ b/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceLiveTest.java @@ -53,10 +53,10 @@ import java.io.InputStream; import java.net.URI; import java.util.Collection; import java.util.Map; -import java.util.Map.Entry; import java.util.NoSuchElementException; import java.util.Set; import java.util.SortedSet; +import java.util.Map.Entry; import java.util.concurrent.Callable; import java.util.concurrent.CancellationException; import java.util.concurrent.ExecutionException; @@ -119,7 +119,7 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = { "integration", "live" }, singleThreaded = true) -public abstract class BaseComputeServiceLiveTest> extends BaseComputeServiceContextLiveTest { +public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceContextLiveTest { protected String group; @@ -174,12 +174,12 @@ public abstract class BaseComputeServiceLiveTest context = null; + ComputeServiceContext context = null; try { context = newBuilder() .credentials("MOMMA", "MIA") .modules(ImmutableSet.of(getLoggingModule(), credentialStoreModule)) - .overrides(setupProperties()).build(); + .overrides(setupProperties()).build(ComputeServiceContext.class); context.getComputeService().listNodes(); } catch (AuthorizationException e) { throw e; diff --git a/compute/src/test/java/org/jclouds/compute/internal/BaseTemplateBuilderLiveTest.java b/compute/src/test/java/org/jclouds/compute/internal/BaseTemplateBuilderLiveTest.java index 7dc9760c6c..51fe154b80 100644 --- a/compute/src/test/java/org/jclouds/compute/internal/BaseTemplateBuilderLiveTest.java +++ b/compute/src/test/java/org/jclouds/compute/internal/BaseTemplateBuilderLiveTest.java @@ -24,10 +24,10 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.io.InputStream; import java.util.Map; -import java.util.Map.Entry; import java.util.NoSuchElementException; import java.util.Properties; import java.util.Set; +import java.util.Map.Entry; import java.util.concurrent.ConcurrentHashMap; import org.jclouds.compute.ComputeServiceContext; @@ -63,8 +63,8 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "integration,live") -public abstract class BaseTemplateBuilderLiveTest> extends - BaseComputeServiceContextLiveTest { +public abstract class BaseTemplateBuilderLiveTest extends + BaseComputeServiceContextLiveTest { public void testCompareSizes() throws Exception { Hardware defaultSize = context.getComputeService().templateBuilder().build().getHardware(); @@ -180,7 +180,8 @@ public abstract class BaseTemplateBuilderLiveTest context = null; + ComputeServiceContext context = null; try { Properties overrides = setupProperties(); overrides.setProperty("jclouds.image-id", defaultTemplate.getImage().getId()); @@ -259,7 +260,7 @@ public abstract class BaseTemplateBuilderLiveTest>())); - ComputeServiceContext context = null; + ComputeServiceContext context = null; try { Properties overrides = setupProperties(); String login = loginUser != null ? loginUser : "foo:bar"; diff --git a/compute/src/test/java/org/jclouds/compute/predicates/ImagePredicatesTest.java b/compute/src/test/java/org/jclouds/compute/predicates/ImagePredicatesTest.java index 23ccd6f0af..4987dbc940 100644 --- a/compute/src/test/java/org/jclouds/compute/predicates/ImagePredicatesTest.java +++ b/compute/src/test/java/org/jclouds/compute/predicates/ImagePredicatesTest.java @@ -18,8 +18,9 @@ */ package org.jclouds.compute.predicates; +import org.jclouds.ContextBuilder; import org.jclouds.compute.ComputeService; -import org.jclouds.compute.ComputeServiceContextBuilder; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.ImageBuilder; import org.testng.annotations.Test; @@ -34,7 +35,7 @@ import com.google.common.collect.Iterables; */ @Test public class ImagePredicatesTest { - ComputeService computeService = ComputeServiceContextBuilder.forTests().build().getComputeService(); + ComputeService computeService = ContextBuilder.newBuilder("stub").build(ComputeServiceContext.class).getComputeService(); public void testImageId() { Image first = Iterables.get(computeService.listImages(), 0); diff --git a/core/src/main/java/org/jclouds/rest/internal/ContextBuilder.java b/core/src/main/java/org/jclouds/ContextBuilder.java similarity index 62% rename from core/src/main/java/org/jclouds/rest/internal/ContextBuilder.java rename to core/src/main/java/org/jclouds/ContextBuilder.java index 2a96fd74f7..b3ed279960 100644 --- a/core/src/main/java/org/jclouds/rest/internal/ContextBuilder.java +++ b/core/src/main/java/org/jclouds/ContextBuilder.java @@ -16,14 +16,12 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.rest.internal; +package org.jclouds; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Predicates.instanceOf; import static com.google.common.collect.Iterables.addAll; import static com.google.common.collect.Iterables.any; -import static com.google.inject.Scopes.SINGLETON; -import static com.google.inject.util.Types.newParameterizedType; import static org.jclouds.Constants.PROPERTY_API; import static org.jclouds.Constants.PROPERTY_API_VERSION; import static org.jclouds.Constants.PROPERTY_BUILD_VERSION; @@ -35,13 +33,14 @@ import static org.jclouds.Constants.PROPERTY_PROVIDER; import static org.jclouds.util.Throwables2.propagateAuthorizationOrOriginalException; import java.io.Closeable; -import java.lang.reflect.Constructor; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.NoSuchElementException; import java.util.Properties; +import javax.inject.Singleton; + import org.jclouds.apis.ApiMetadata; import org.jclouds.apis.Apis; import org.jclouds.concurrent.MoreExecutors; @@ -50,11 +49,12 @@ import org.jclouds.concurrent.config.ConfiguresExecutorService; import org.jclouds.concurrent.config.ExecutorServiceModule; import org.jclouds.events.config.ConfiguresEventBus; import org.jclouds.events.config.EventBusModule; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.config.ConfiguresHttpCommandExecutorService; import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; import org.jclouds.javax.annotation.Nullable; +import org.jclouds.lifecycle.Closer; import org.jclouds.lifecycle.config.LifeCycleModule; +import org.jclouds.location.Provider; import org.jclouds.logging.config.LoggingModule; import org.jclouds.logging.jdk.config.JDKLoggingModule; import org.jclouds.providers.AnonymousProviderMetadata; @@ -62,7 +62,7 @@ import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.Providers; import org.jclouds.rest.ConfiguresCredentialStore; import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.rest.ConfiguresRestContext; +import org.jclouds.rest.RestApiMetadata; import org.jclouds.rest.RestContext; import org.jclouds.rest.config.BindPropertiesToAnnotations; import org.jclouds.rest.config.CredentialStoreModule; @@ -72,41 +72,58 @@ import org.nnsoft.guice.rocoto.Rocoto; import org.nnsoft.guice.rocoto.configuration.ConfigurationModule; import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Function; import com.google.common.base.Joiner; import com.google.common.base.Objects; import com.google.common.base.Predicate; import com.google.common.base.Predicates; +import com.google.common.base.Throwables; import com.google.common.collect.ImmutableMultimap; -import com.google.common.collect.ImmutableMultimap.Builder; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Maps; +import com.google.common.collect.ImmutableMultimap.Builder; +import com.google.common.reflect.TypeToken; import com.google.common.util.concurrent.ExecutionList; import com.google.inject.AbstractModule; import com.google.inject.Guice; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.Module; +import com.google.inject.Provides; import com.google.inject.Stage; import com.google.inject.TypeLiteral; /** - * Creates {@link RestContext} or {@link Injector} instances based on the most - * commonly requested arguments. + * Creates {@link RestContext} or {@link Injector} instances based on the most commonly requested + * arguments. *

- * Note that Threadsafe objects will be bound as singletons to the Injector or - * Context provided. + * Note that Threadsafe objects will be bound as singletons to the Injector or Context provided. *

*

- * If no Modules are specified, the default - * {@link JDKLoggingModule logging} and - * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be - * installed. + * If no Modules are specified, the default {@link JDKLoggingModule logging} and + * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be installed. * * @author Adrian Cole, Andrew Newdigate * @see RestContext */ -public class ContextBuilder> { +public final class ContextBuilder { + + private final class BindDefaultContextQualifiedToProvider extends AbstractModule { + @Override + protected void configure() { + bind(new TypeLiteral>() { + }).annotatedWith(Provider.class).toInstance(apiMetadata.getContext()); + } + + @SuppressWarnings("unused") + @Provides + @Provider + @Singleton + protected Closeable wrapped(Injector i, @Provider TypeToken wrappedType) { + return (Closeable) i.getInstance(Key.get(TypeLiteral.get(wrappedType.getType()))); + } + } /** * looks up a provider or api with the given id @@ -117,7 +134,7 @@ public class ContextBuilder newBuilder(String providerOrApi) throws NoSuchElementException { + public static ContextBuilder newBuilder(String providerOrApi) throws NoSuchElementException { try { try { return ContextBuilder.newBuilder(Providers.withId(providerOrApi)); @@ -129,41 +146,31 @@ public class ContextBuilder> ContextBuilder newBuilder( - ApiMetadata apiMetadata) { + public static ContextBuilder newBuilder(ApiMetadata apiMetadata) { try { - for (Constructor ctor : apiMetadata.getContextBuilder().getRawType().getConstructors()) { - if (ctor.getParameterTypes().length == 1 - && ctor.getParameterTypes()[0].isAssignableFrom(apiMetadata.getClass())) - return (ContextBuilder) ctor.newInstance(apiMetadata); - } - throw new IllegalArgumentException(String.format("class %s has no constructor that accepts %s", apiMetadata - .getContextBuilder().getRawType().getSimpleName(), apiMetadata.getClass().getSimpleName())); + return new ContextBuilder(apiMetadata); } catch (Exception e) { return propagateAuthorizationOrOriginalException(e); } } - public static > ContextBuilder newBuilder( - ProviderMetadata providerMetadata) { + public static ContextBuilder newBuilder(ProviderMetadata providerMetadata) { try { - Class contextBuilderClass = providerMetadata.getApiMetadata().getContextBuilder().getRawType(); - return (ContextBuilder) contextBuilderClass.getConstructor(ProviderMetadata.class).newInstance( - providerMetadata); + return new ContextBuilder(providerMetadata); } catch (Exception e) { return propagateAuthorizationOrOriginalException(e); } } - protected ProviderMetadata providerMetadata; + protected ProviderMetadata providerMetadata; protected String endpoint; protected String identity; protected String credential; - protected M apiMetadata; + protected ApiMetadata apiMetadata; protected String apiVersion; protected String buildVersion; protected Properties overrides = new Properties();; @@ -172,14 +179,14 @@ public class ContextBuilder providerMetadata) { + + protected ContextBuilder(ProviderMetadata providerMetadata) { this(providerMetadata, providerMetadata.getApiMetadata()); } - protected ContextBuilder(@Nullable ProviderMetadata providerMetadata, M apiMetadata) { + protected ContextBuilder(@Nullable ProviderMetadata providerMetadata, ApiMetadata apiMetadata) { this.apiMetadata = checkNotNull(apiMetadata, "apiMetadata"); this.providerMetadata = providerMetadata; if (providerMetadata != null) @@ -194,37 +201,37 @@ public class ContextBuilder credentials(String identity, String credential) { + public ContextBuilder credentials(String identity, String credential) { this.identity = identity; this.credential = credential; return this; } - public ContextBuilder endpoint(String endpoint) { + public ContextBuilder endpoint(String endpoint) { this.endpoint = endpoint; return this; } - public ContextBuilder apiVersion(String apiVersion) { + public ContextBuilder apiVersion(String apiVersion) { this.apiVersion = checkNotNull(apiVersion, "apiVersion"); return this; } - public ContextBuilder buildVersion(String buildVersion) { + public ContextBuilder buildVersion(String buildVersion) { this.buildVersion = checkNotNull(buildVersion, "buildVersion"); return this; } - public ContextBuilder modules(Iterable modules) { + public ContextBuilder modules(Iterable modules) { addAll(this.modules, modules); return this; } - public ContextBuilder overrides(Properties overrides) { + public ContextBuilder overrides(Properties overrides) { this.overrides.putAll(overrides); return this; } @@ -233,10 +240,10 @@ public class ContextBuilder defaultModules = ifSpecifiedByUserDontIncludeDefaultRestModule(restModuleSpecifiedByUser); + Iterables.addAll(modules, defaultModules); addClientModuleIfNotPresent(modules); addLoggingModuleIfNotPresent(modules); addHttpModuleIfNeededAndNotPresent(modules); - ifHttpConfigureRestOtherwiseGuiceClientFactory(modules); addExecutorServiceIfNotPresent(modules); addEventBusIfNotPresent(modules); addCredentialStoreIfNotPresent(modules); modules.add(new LifeCycleModule()); modules.add(new BindPropertiesToAnnotations()); + modules.add(new BindDefaultContextQualifiedToProvider()); Injector returnVal = Guice.createInjector(Stage.PRODUCTION, modules); returnVal.getInstance(ExecutionList.class).execute(); return returnVal; } - @SuppressWarnings({ "unchecked", "rawtypes" }) + private Iterable ifSpecifiedByUserDontIncludeDefaultRestModule(boolean restModuleSpecifiedByUser) { + Iterable defaultModules = Iterables.transform(apiMetadata.getDefaultModules(), + new Function, Module>() { + + @Override + public Module apply(Class arg0) { + try { + return arg0.newInstance(); + } catch (InstantiationException e) { + throw Throwables.propagate(e); + } catch (IllegalAccessException e) { + throw Throwables.propagate(e); + } + } + + }); + if (restModuleSpecifiedByUser) + defaultModules = Iterables.filter(defaultModules, Predicates.not(configuresRest)); + return defaultModules; + } + + @SuppressWarnings( { "unchecked" }) Map propertiesPrefixedWithJcloudsApiOrProviderId(Properties properties, String providerId) { - return Maps.filterKeys((Map) System.getProperties(), - Predicates.containsPattern("^(jclouds|" + providerId + "|" + apiMetadata.getId() + ").*")); + return Maps.filterKeys((Map) System.getProperties(), Predicates.containsPattern("^(jclouds|" + providerId + "|" + + apiMetadata.getId() + ").*")); } @VisibleForTesting @@ -317,7 +349,7 @@ public class ContextBuilder modules) { - if (defaultOrAtLeastOneModuleRequiresHttp(modules) && nothingConfiguresAnHttpService(modules)) + if (nothingConfiguresAnHttpService(modules)) modules.add(new JavaUrlHttpCommandExecutorServiceModule()); } @@ -330,59 +362,6 @@ public class ContextBuilder modules) { - if (!any(modules, new Predicate() { - public boolean apply(Module input) { - return input.getClass().isAnnotationPresent(ConfiguresRestContext.class); - } - - })) { - addContextModule(modules); - } - } - - @VisibleForTesting - protected void addContextModule(List modules) { - modules.add(new AbstractModule() { - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - protected void configure() { - bind( - (TypeLiteral) TypeLiteral.get(newParameterizedType(RestContext.class, providerMetadata - .getApiMetadata().getApi(), apiMetadata.getAsyncApi()))).to( - TypeLiteral.get(newParameterizedType(RestContextImpl.class, apiMetadata.getApi(), - apiMetadata.getAsyncApi()))).in(SINGLETON); - } - - public String toString() { - return String.format("configure rest context %s->%s", apiMetadata.getApi().getSimpleName(), apiMetadata - .getAsyncApi().getSimpleName()); - } - - }); - } - - @VisibleForTesting - protected void ifHttpConfigureRestOtherwiseGuiceClientFactory(List modules) { - if (defaultOrAtLeastOneModuleRequiresHttp(modules)) { - modules.add(new RestModule()); - } - } - - private boolean defaultOrAtLeastOneModuleRequiresHttp(List modules) { - return atLeastOneModuleRequiresHttp(modules) || !restClientModulePresent(modules); - } - - private boolean atLeastOneModuleRequiresHttp(List modules) { - return any(modules, new Predicate() { - public boolean apply(Module input) { - return input.getClass().isAnnotationPresent(RequiresHttp.class); - } - }); - } - @VisibleForTesting protected void addClientModuleIfNotPresent(List modules) { if (!restClientModulePresent(modules)) { @@ -390,32 +369,41 @@ public class ContextBuilder configuresRest = new Predicate() { + public boolean apply(Module input) { + return input.getClass().isAnnotationPresent(ConfiguresRestClient.class); + } + + }; + private boolean restClientModulePresent(List modules) { - return any(modules, new Predicate() { - public boolean apply(Module input) { - return input.getClass().isAnnotationPresent(ConfiguresRestClient.class); - } - - }); + return any(modules, configuresRest); } + @SuppressWarnings("unchecked") protected void addClientModule(List modules) { - modules.add(new RestClientModule(apiMetadata.getApi(), providerMetadata.getApiMetadata().getAsyncApi())); + // TODO: move this up + if (apiMetadata instanceof RestApiMetadata) { + final RestApiMetadata rest = RestApiMetadata.class.cast(apiMetadata); + modules.add(new RestClientModule(rest.getApi(), rest.getAsyncApi())); + } else { + modules.add(new RestModule()); + } } - + @VisibleForTesting protected void addEventBusIfNotPresent(List modules) { - if (!any(modules, new Predicate() { - public boolean apply(Module input) { - return input.getClass().isAnnotationPresent(ConfiguresEventBus.class); - } - } - - )) { - modules.add(new EventBusModule()); - } + if (!any(modules, new Predicate() { + public boolean apply(Module input) { + return input.getClass().isAnnotationPresent(ConfiguresEventBus.class); + } + } + + )) { + modules.add(new EventBusModule()); + } } - + @VisibleForTesting protected void addExecutorServiceIfNotPresent(List modules) { if (!any(modules, new Predicate() { @@ -431,7 +419,7 @@ public class ContextBuilder C build() { + return (C) build(apiMetadata.getContext()); } - - public M getApiMetadata() { + + /** + * @see #build(TypeToken) + */ + public C build(Class contextType) { + return build(TypeToken.of(checkNotNull(contextType, "contextType"))); + } + + /** + * this will build any context supported by the ApiMetadata. This includes the base + * {@link ApiMetadata#getContext() context}, or any {@link ApiMetadata#getWrappers() wrapper} it + * supports. + * + * ex. {@code builder.build(BlobStoreContext.class) } will work, if {@code TypeToken} + * is a configured {@link ApiMetadata#getWrappers() wrapper} of this api. + * + * + */ + @SuppressWarnings("unchecked") + public C build(final TypeToken contextType) { + TypeToken returnType = null; + if (contextType.isAssignableFrom(apiMetadata.getContext())) + returnType = (TypeToken) apiMetadata.getContext(); + else + try { + returnType = (TypeToken) Apis.findWrapper(apiMetadata, contextType); + } catch (NoSuchElementException e) { + throw new IllegalArgumentException(String.format( + "api %s not assignable from or transformable to %s; context: %s, wrappers: %s", apiMetadata, + contextType, apiMetadata.getContext(), apiMetadata.getWrappers())); + } + return (C) buildInjector().getInstance(Key.get(TypeLiteral.get(returnType.getType()))); + } + + public ApiMetadata getApiMetadata() { return apiMetadata; } } diff --git a/core/src/main/java/org/jclouds/PropertiesBuilder.java b/core/src/main/java/org/jclouds/PropertiesBuilder.java deleted file mode 100644 index ceaba15898..0000000000 --- a/core/src/main/java/org/jclouds/PropertiesBuilder.java +++ /dev/null @@ -1,288 +0,0 @@ -/** - * 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; - -import static org.jclouds.Constants.PROPERTY_API; -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_BUILD_VERSION; -import static org.jclouds.Constants.PROPERTY_CONNECTION_TIMEOUT; -import static org.jclouds.Constants.PROPERTY_CREDENTIAL; -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.Constants.PROPERTY_IDENTITY; -import static org.jclouds.Constants.PROPERTY_IO_WORKER_THREADS; -import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; -import static org.jclouds.Constants.PROPERTY_MAX_CONNECTIONS_PER_CONTEXT; -import static org.jclouds.Constants.PROPERTY_MAX_CONNECTIONS_PER_HOST; -import static org.jclouds.Constants.PROPERTY_MAX_CONNECTION_REUSE; -import static org.jclouds.Constants.PROPERTY_MAX_REDIRECTS; -import static org.jclouds.Constants.PROPERTY_MAX_RETRIES; -import static org.jclouds.Constants.PROPERTY_MAX_SESSION_FAILURES; -import static org.jclouds.Constants.PROPERTY_PROVIDER; -import static org.jclouds.Constants.PROPERTY_PROXY_HOST; -import static org.jclouds.Constants.PROPERTY_PROXY_PASSWORD; -import static org.jclouds.Constants.PROPERTY_PROXY_PORT; -import static org.jclouds.Constants.PROPERTY_PROXY_SYSTEM; -import static org.jclouds.Constants.PROPERTY_PROXY_USER; -import static org.jclouds.Constants.PROPERTY_RELAX_HOSTNAME; -import static org.jclouds.Constants.PROPERTY_RETRY_DELAY_START; -import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; -import static org.jclouds.Constants.PROPERTY_SO_TIMEOUT; -import static org.jclouds.Constants.PROPERTY_TRUST_ALL_CERTS; -import static org.jclouds.Constants.PROPERTY_USER_THREADS; -import static org.jclouds.Constants.PROPERTY_PRETTY_PRINT_PAYLOADS; - -import java.util.Properties; - -import org.jclouds.javax.annotation.Nullable; - -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Joiner; - -/** - * Builds properties used in Http engines - * - * @author Adrian Cole, Andrew Newdigate - */ -public class PropertiesBuilder { - - /** - * @see org.jclouds.Constants.PROPERTY_RELAX_HOSTNAME - */ - public PropertiesBuilder relaxSSLHostname(boolean relax) { - properties.setProperty(PROPERTY_RELAX_HOSTNAME, relax + ""); - return this; - } - - /** - * @see org.jclouds.Constants.PROPERTY_TRUST_ALL_CERTS - */ - public PropertiesBuilder trustAllCerts(boolean trust) { - properties.setProperty(PROPERTY_TRUST_ALL_CERTS, trust + ""); - return this; - } - - /** - * @see org.jclouds.Constants.PROPERTY_PROXY_SYSTEM - */ - public PropertiesBuilder useSystemProxies(boolean useSystemProxies) { - properties.setProperty(PROPERTY_PROXY_SYSTEM, useSystemProxies + ""); - return this; - } - - /** - * @see org.jclouds.Constants.PROPERTY_PROXY_HOST - */ - public PropertiesBuilder withProxyHost(String proxyHost) { - properties.setProperty(PROPERTY_PROXY_HOST, proxyHost); - return this; - } - - /** - * @see org.jclouds.Constants.PROPERTY_PROXY_PORT - */ - public PropertiesBuilder withProxyPort(int proxyPort) { - properties.setProperty(PROPERTY_PROXY_PORT, Integer.toString(proxyPort)); - return this; - } - - /** - * @see org.jclouds.Constants.PROPERTY_PROXY_USER - */ - public PropertiesBuilder withProxyUser(String proxyUser) { - properties.setProperty(PROPERTY_PROXY_USER, proxyUser); - return this; - } - - /** - * @see org.jclouds.Constants.PROPERTY_PROXY_PASSWORD - */ - public PropertiesBuilder withProxyPassword(String proxyPassword) { - properties.setProperty(PROPERTY_PROXY_PASSWORD, proxyPassword); - return this; - } - - /** - * @see org.jclouds.Constants.PROPERTY_SO_TIMEOUT - */ - public PropertiesBuilder withSOTimeout(long soTimeout) { - properties.setProperty(PROPERTY_SO_TIMEOUT, Long.toString(soTimeout)); - return this; - } - - /** - * @see org.jclouds.Constants.PROPERTY_CONNECTION_TIMEOUT - */ - public PropertiesBuilder withConnectionTimeout(long connectionTimeout) { - properties.setProperty(PROPERTY_CONNECTION_TIMEOUT, Long.toString(connectionTimeout)); - return this; - } - - /** - * @see org.jclouds.Constants.PROPERTY_MAX_RETRIES - */ - public PropertiesBuilder withMaxRetries(int httpMaxRetries) { - properties.setProperty(PROPERTY_MAX_RETRIES, Integer.toString(httpMaxRetries)); - return this; - } - - /** - * @see org.jclouds.Constants.PROPERTY_RETRY_DELAY_START - */ - public PropertiesBuilder withRetriesDelayStart(long delayStart) { - properties.setProperty(PROPERTY_RETRY_DELAY_START, Long.toString(delayStart)); - return this; - } - - /** - * @see org.jclouds.Constants.PROPERTY_MAX_REDIRECTS - */ - public PropertiesBuilder withMaxRedirects(int httpMaxRedirects) { - properties.setProperty(PROPERTY_MAX_REDIRECTS, Integer.toString(httpMaxRedirects)); - return this; - } - - /** - * @see org.jclouds.Constants.PROPERTY_MAX_CONNECTION_REUSE - */ - public PropertiesBuilder withMaxClientReuse(int poolMaxClientReuse) { - properties.setProperty(PROPERTY_MAX_CONNECTION_REUSE, Integer.toString(poolMaxClientReuse)); - return this; - } - - /** - * @see org.jclouds.Constants.PROPERTY_MAX_SESSION_FAILURES - */ - public PropertiesBuilder withMaxSessionFailures(int poolMaxSessionFailures) { - properties.setProperty(PROPERTY_MAX_SESSION_FAILURES, Integer.toString(poolMaxSessionFailures)); - return this; - - } - - /** - * @see org.jclouds.Constants.PROPERTY_IO_WORKER_THREADS - */ - public PropertiesBuilder limitIoWorkerThreadsTo(int poolIoWorkerThreads) { - properties.setProperty(PROPERTY_IO_WORKER_THREADS, Integer.toString(poolIoWorkerThreads)); - return this; - } - - /** - * @see org.jclouds.Constants.PROPERTY_USER_THREADS - */ - public PropertiesBuilder limitUserThreadsTo(int poolUserThreads) { - properties.setProperty(PROPERTY_USER_THREADS, Integer.toString(poolUserThreads)); - return this; - } - - /** - * @see org.jclouds.Constants.PROPERTY_MAX_CONNECTIONS_PER_CONTEXT - */ - public PropertiesBuilder limitConnectionsTo(int connectionLimit) { - properties.setProperty(PROPERTY_MAX_CONNECTIONS_PER_CONTEXT, Integer.toString(connectionLimit)); - return this; - } - - /** - * @see org.jclouds.Constants.PROPERTY_MAX_CONNECTIONS_PER_HOST - */ - public PropertiesBuilder limitConnectionsPerHostTo(int connectionLimit) { - properties.setProperty(PROPERTY_MAX_CONNECTIONS_PER_HOST, Integer.toString(connectionLimit)); - return this; - } - - /** - * @see org.jclouds.Constants.PROPERTY_PRETTY_PRINT_PAYLOADS - */ - public PropertiesBuilder prettyPrintPayloads(boolean prettyPrintPayloads) { - properties.setProperty(PROPERTY_PRETTY_PRINT_PAYLOADS, Boolean.toString(prettyPrintPayloads)); - return this; - } - - protected final Properties properties; - - public PropertiesBuilder() { - this.properties = defaultProperties(); - } - - protected Properties defaultProperties() { - Properties props = new Properties(); - props.setProperty(PROPERTY_ISO3166_CODES, ""); - props.setProperty(PROPERTY_MAX_CONNECTIONS_PER_CONTEXT, 20 + ""); - props.setProperty(PROPERTY_MAX_CONNECTIONS_PER_HOST, 0 + ""); - props.setProperty(PROPERTY_SO_TIMEOUT, 60000 + ""); - props.setProperty(PROPERTY_CONNECTION_TIMEOUT, 60000 + ""); - props.setProperty(PROPERTY_IO_WORKER_THREADS, 20 + ""); - props.setProperty(PROPERTY_USER_THREADS, 0 + ""); - props.setProperty(PROPERTY_API, ""); - props.setProperty(PROPERTY_API_VERSION, ""); - props.setProperty(PROPERTY_BUILD_VERSION, ""); - props.setProperty(PROPERTY_MAX_CONNECTION_REUSE, 75 + ""); - props.setProperty(PROPERTY_MAX_SESSION_FAILURES, 2 + ""); - props.setProperty(PROPERTY_SESSION_INTERVAL, 60 + ""); - props.setProperty(PROPERTY_PRETTY_PRINT_PAYLOADS, "true"); - return props; - } - - public PropertiesBuilder(Properties properties) { - this(); - this.properties.putAll(properties); - } - - public PropertiesBuilder provider(String providerName) { - properties.setProperty(PROPERTY_PROVIDER, providerName); - return this; - } - - public PropertiesBuilder endpoint(String endpoint) { - properties.setProperty(PROPERTY_ENDPOINT, endpoint); - return this; - } - - public PropertiesBuilder iso3166Codes(Iterable codes) { - properties.setProperty(PROPERTY_ISO3166_CODES, Joiner.on(',').join(codes)); - return this; - } - - public PropertiesBuilder apiVersion(String apiVersion) { - properties.setProperty(PROPERTY_API_VERSION, apiVersion); - return this; - } - - public PropertiesBuilder buildVersion(String buildVersion) { - properties.setProperty(PROPERTY_BUILD_VERSION, buildVersion); - return this; - } - - public PropertiesBuilder credentials(String identity, @Nullable String credential) { - properties.setProperty(PROPERTY_IDENTITY, identity); - if (credential != null) - properties.setProperty(PROPERTY_CREDENTIAL, credential); - return this; - } - - public PropertiesBuilder sessionInterval(long seconds) { - properties.setProperty(PROPERTY_SESSION_INTERVAL, seconds + ""); - return this; - } - - @VisibleForTesting - public Properties build() { - return properties; - } -} diff --git a/core/src/main/java/org/jclouds/Wrapper.java b/core/src/main/java/org/jclouds/Wrapper.java new file mode 100644 index 0000000000..e5a740a46c --- /dev/null +++ b/core/src/main/java/org/jclouds/Wrapper.java @@ -0,0 +1,65 @@ +/** + * 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; + +import java.io.Closeable; + +import com.google.common.annotations.Beta; +import com.google.common.reflect.TypeToken; + +/** + * + * + * @author Adrian Cole + * + */ +@Beta +public interface Wrapper { + + /** + * + * @return type of the context powering the current one. + */ + TypeToken getWrappedType(); + + /** + * Return an object of the specified type to allow access to the wrapped context. If the wrapped + * context is not assignable from the supplied type, an {@link IllegalArgumentException} is + * thrown. + * + * @param type + * the type of the context to be returned. The wrapped context must be assignable from + * this type. + * @return an instance of the specified type + * @throws IllegalArgumentException + * if the wrapped context is not assignable from the specified class. + * @see #getWrappedType() + */ + C unwrap(TypeToken type); + + /** + * shortcut for {@code unwrap(getWrappedType())} + * + * @throws ClassCastException + * if the user supplied {@code C} param is not assignableFrom + * {@link #getWrappedType()} + */ + C unwrap() throws ClassCastException; + +} \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/apis/ApiMetadata.java b/core/src/main/java/org/jclouds/apis/ApiMetadata.java index f81e3040a5..736a0fcdfc 100644 --- a/core/src/main/java/org/jclouds/apis/ApiMetadata.java +++ b/core/src/main/java/org/jclouds/apis/ApiMetadata.java @@ -19,16 +19,18 @@ package org.jclouds.apis; import java.io.Closeable; +import java.io.Serializable; import java.net.URI; import java.util.Properties; +import java.util.Set; +import org.jclouds.Wrapper; import org.jclouds.javax.annotation.Nullable; -import org.jclouds.rest.internal.ContextBuilder; import com.google.common.annotations.Beta; import com.google.common.base.Optional; import com.google.common.reflect.TypeToken; -import com.google.common.util.concurrent.ListenableFuture; +import com.google.inject.Module; /** * The ApiMetadata interface allows jclouds to provide a plugin framework for @@ -38,94 +40,109 @@ import com.google.common.util.concurrent.ListenableFuture; * @since 1.5 */ @Beta -public interface ApiMetadata> { +public interface ApiMetadata extends Serializable { - public static interface Builder> { + public static interface Builder { /** * @see ApiMetadata#getId() */ - Builder id(String id); + Builder id(String id); /** * @see ApiMetadata#getName() */ - Builder name(String name); + Builder name(String name); /** - * @see ApiMetadata#getType() + * @see ApiMetadata#getContext() */ - Builder type(ApiType type); + Builder context(TypeToken context); + + /** + * @see ApiMetadata#getWrappers() + */ + Builder wrapper(Class wrapper); + /** + * @see ApiMetadata#getWrappers() + */ + Builder wrapper(TypeToken wrapper); + + /** + * @see ApiMetadata#getWrappers() + */ + Builder wrappers(Set> wrappers); + /** * @see ApiMetadata#getEndpointName() */ - Builder endpointName(String endpointName); + Builder endpointName(String endpointName); /** * @see ApiMetadata#getIdentityName() */ - Builder identityName(String identityName); + Builder identityName(String identityName); /** * @see ApiMetadata#getCredentialName() */ - Builder credentialName(@Nullable String credentialName); + Builder credentialName(@Nullable String credentialName); /** * @see ApiMetadata#getVersion() */ - Builder version(String version); + Builder version(String version); /** * @see ApiMetadata#getBuildVersion() */ - Builder buildVersion(@Nullable String buildVersion); + Builder buildVersion(@Nullable String buildVersion); /** * @see ApiMetadata#getDefaultEndpoint() */ - Builder defaultEndpoint(@Nullable String defaultEndpoint); + Builder defaultEndpoint(@Nullable String defaultEndpoint); /** * @see ApiMetadata#getDefaultIdentity() */ - Builder defaultIdentity(@Nullable String defaultIdentity); + Builder defaultIdentity(@Nullable String defaultIdentity); /** * @see ApiMetadata#getDefaultCredential() */ - Builder defaultCredential(@Nullable String defaultCredential); + Builder defaultCredential(@Nullable String defaultCredential); /** * @see ApiMetadata#getDefaultProperties() */ - Builder defaultProperties(Properties defaultProperties); + Builder defaultProperties(Properties defaultProperties); + + /** + * @see ApiMetadata#getDefaultModules() + */ + Builder defaultModule(Class defaultModule); /** - * @see ApiMetadata#getApi() - * @see ApiMetadata#getAsyncApi() + * @see ApiMetadata#getDefaultModules() */ - Builder javaApi(Class api, Class asyncApi); - + Builder defaultModules(Set> defaultModules); + /** * @see ApiMetadata#getDocumentation() */ - Builder documentation(URI documentation); + Builder documentation(URI documentation); - M build(); + ApiMetadata build(); - Builder fromApiMetadata(M from); - - Builder context(TypeToken context); - - Builder contextBuilder(TypeToken> contextBuilder); + Builder fromApiMetadata(ApiMetadata from); } /** * @see Builder */ - Builder> toBuilder(); + Builder toBuilder(); /** * @@ -139,12 +156,6 @@ public interface ApiMetadata> getDefaultModules(); + /** * * @return the url for the API documentation related to this service @@ -242,21 +260,13 @@ public interface ApiMetadata} */ - Class getApi(); - + TypeToken getContext(); + /** - * - * @return the type of the api, which is the same as {@link #getApi}, except - * all methods return {@link ListenableFuture} + * @return types of contexts this can be transformed into, for example {@code BlobStoreContext} */ - Class getAsyncApi(); - - TypeToken getContext(); - - // internal use - TypeToken> getContextBuilder(); + Set> getWrappers(); } \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/apis/ApiPredicates.java b/core/src/main/java/org/jclouds/apis/ApiPredicates.java index 45b8e5e770..2e9327ec5f 100644 --- a/core/src/main/java/org/jclouds/apis/ApiPredicates.java +++ b/core/src/main/java/org/jclouds/apis/ApiPredicates.java @@ -20,6 +20,8 @@ package org.jclouds.apis; import static com.google.common.base.Preconditions.checkNotNull; +import org.jclouds.Wrapper; +import org.jclouds.rest.RestApiMetadata; import org.jclouds.util.Preconditions2; import com.google.common.base.Predicate; @@ -28,36 +30,36 @@ import com.google.common.reflect.TypeToken; /** * Container for api filters (predicates). - * + * * @author Jeremy Whitlock */ public class ApiPredicates { /** * Returns all apis available to jclouds regardless of type. - * + * * @return all available apis */ - public static Predicate> all() { - return Predicates.> alwaysTrue(); + public static Predicate all() { + return Predicates. alwaysTrue(); } /** * Returns all apis with the given id. - * + * * @param id * the id of the api to return - * + * * @return the apis with the given id */ - public static Predicate> id(final String id) { + public static Predicate id(final String id) { Preconditions2.checkNotEmpty(id, "id must be defined"); - return new Predicate>() { + return new Predicate() { /** * {@inheritDoc} */ @Override - public boolean apply(ApiMetadata apiMetadata) { + public boolean apply(ApiMetadata apiMetadata) { return apiMetadata.getId().equals(id); } @@ -73,49 +75,20 @@ public class ApiPredicates { /** * Returns all apis with the given type. - * + * * @param type * the type of the api to return - * + * * @return the apis with the given type */ - public static Predicate> type(final ApiType type) { + public static Predicate apiAssignableFrom(final TypeToken type) { checkNotNull(type, "type must be defined"); - return new Predicate>() { + return new Predicate() { /** * {@inheritDoc} */ @Override - public boolean apply(ApiMetadata apiMetadata) { - return apiMetadata.getType().equals(type); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return "type(" + type + ")"; - } - }; - } - - /** - * Returns all apis with the given type. - * - * @param type - * the type of the api to return - * - * @return the apis with the given type - */ - public static Predicate> apiAssignableFrom(final TypeToken type) { - checkNotNull(type, "type must be defined"); - return new Predicate>() { - /** - * {@inheritDoc} - */ - @Override - public boolean apply(ApiMetadata apiMetadata) { + public boolean apply(RestApiMetadata apiMetadata) { return type.isAssignableFrom(apiMetadata.getApi()); } @@ -131,21 +104,21 @@ public class ApiPredicates { /** * Returns all apis who's contexts are assignable from the parameter - * + * * @param type * the type of the context to search for - * + * * @return the apis with contexts assignable from given type */ - public static Predicate> contextAssignableFrom(final TypeToken contextType) { - checkNotNull(contextType, "context must be defined"); - return new Predicate>() { + public static Predicate contextAssignableFrom(final TypeToken type) { + checkNotNull(type, "context must be defined"); + return new Predicate() { /** * {@inheritDoc} */ @Override - public boolean apply(ApiMetadata apiMetadata) { - return contextType.isAssignableFrom(apiMetadata.getContext().getRawType()); + public boolean apply(ApiMetadata apiMetadata) { + return type.isAssignableFrom(apiMetadata.getContext()); } /** @@ -153,7 +126,39 @@ public class ApiPredicates { */ @Override public String toString() { - return "contextAssignableFrom(" + contextType + ")"; + return "contextAssignableFrom(" + type + ")"; + } + }; + } + + /** + * Returns all apis who's contexts are transformable to the parameter + * + * @param type + * the type of the context to search for + * + * @return the apis with contexts transformable to the given type + */ + public static Predicate contextWrappableAs(final TypeToken type) { + checkNotNull(type, "context must be defined"); + return new Predicate() { + /** + * {@inheritDoc} + */ + @Override + public boolean apply(ApiMetadata apiMetadata) { + for (TypeToken to : apiMetadata.getWrappers()) + if (type.isAssignableFrom(to)) + return true; + return false; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return "contextWrappableAs(" + type + ")"; } }; } diff --git a/core/src/main/java/org/jclouds/apis/ApiType.java b/core/src/main/java/org/jclouds/apis/ApiType.java deleted file mode 100644 index f923d4bec1..0000000000 --- a/core/src/main/java/org/jclouds/apis/ApiType.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * 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.apis; - -import static org.jclouds.util.Preconditions2.checkNotEmpty; - -import com.google.common.base.CaseFormat; - -/** - * - * @author Adrian Cole - */ -public enum ApiType { - - BLOBSTORE, COMPUTE, LOADBALANCER, TABLE, QUEUE, MONITOR, UNRECOGNIZED; - - @Override - public String toString() { - return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name()); - } - - public static ApiType fromValue(String type) { - checkNotEmpty(type, "type must be defined"); - try { - return valueOf(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, type)); - } catch (IllegalArgumentException e) { - return UNRECOGNIZED; - } - } -} \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/apis/Apis.java b/core/src/main/java/org/jclouds/apis/Apis.java index 2629f1edc8..35e36af2d9 100644 --- a/core/src/main/java/org/jclouds/apis/Apis.java +++ b/core/src/main/java/org/jclouds/apis/Apis.java @@ -18,13 +18,18 @@ */ package org.jclouds.apis; +import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.collect.Iterables.filter; import static com.google.common.collect.Iterables.find; import java.util.NoSuchElementException; import java.util.ServiceLoader; +import org.jclouds.Wrapper; + import com.google.common.base.Function; +import com.google.common.base.Predicate; +import com.google.common.collect.Iterables; import com.google.common.reflect.TypeToken; /** @@ -34,28 +39,27 @@ import com.google.common.reflect.TypeToken; */ public class Apis { - public static enum IdFunction implements Function, String> { + public static enum IdFunction implements Function { INSTANCE; @Override - public String apply(ApiMetadata input) { + public String apply(ApiMetadata input) { return input.getId(); } } - public static Function, String> idFunction() { + public static Function idFunction() { return IdFunction.INSTANCE; } - + /** - * Returns the apis located on the classpath via - * {@link java.util.ServiceLoader}. + * Returns the apis located on the classpath via {@link java.util.ServiceLoader}. * * @return all available apis loaded from classpath via ServiceLoader */ @SuppressWarnings("unchecked") - private static Iterable> fromServiceLoader() { + private static Iterable fromServiceLoader() { return Iterable.class.cast(ServiceLoader.load(ApiMetadata.class)); } @@ -64,7 +68,7 @@ public class Apis { * * @return all available apis */ - public static Iterable> all() { + public static Iterable all() { return fromServiceLoader(); } @@ -79,92 +83,57 @@ public class Apis { * @throws NoSuchElementException * whenever there are no apis with the provided id */ - public static ApiMetadata withId(String id) throws NoSuchElementException { + public static ApiMetadata withId(String id) throws NoSuchElementException { return find(all(), ApiPredicates.id(id)); } - - /** - * Returns the apis that are of type - * {@link org.jclouds.apis.ApiMetadata#BLOBSTORE}. - * - * @return the blobstore apis - */ - public static Iterable> allBlobStore() { - return filter(all(), ApiPredicates.type(ApiType.BLOBSTORE)); - } - - /** - * Returns the apis that are of type - * {@link org.jclouds.apis.ApiMetadata#COMPUTE}. - * - * @return the compute service apis - */ - public static Iterable> allCompute() { - return filter(all(), ApiPredicates.type(ApiType.COMPUTE)); - } - - /** - * Returns the apis that are of type - * {@link org.jclouds.apis.ApiMetadata#QUEUE}. - * - * @return the queue service apis - */ - public static Iterable> allQueue() { - return filter(all(), ApiPredicates.type(ApiType.QUEUE)); - } - - /** - * Returns the apis that are of type - * {@link org.jclouds.apis.ApiMetadata#TABLE}. - * - * @return the table service apis - */ - public static Iterable> allTable() { - return filter(all(), ApiPredicates.type(ApiType.TABLE)); - } - - /** - * Returns the apis that are of type - * {@link org.jclouds.apis.ApiMetadata#LOADBALANCER}. - * - * @return the load balancer service apis - */ - public static Iterable> allLoadBalancer() { - return filter(all(), ApiPredicates.type(ApiType.LOADBALANCER)); - } - - /** - * Returns the apis that are of type - * {@link org.jclouds.apis.ApiMetadata#MONITOR}. - * - * @return the load balancer service apis - */ - public static Iterable> allMonitor() { - return filter(all(), ApiPredicates.type(ApiType.MONITOR)); - } - - /** - * Returns the apis that are of the provided type. - * - * @param type - * the type to apis to return - * - * @return the apis of the provided type - */ - public static Iterable> ofType(ApiType type) { - return filter(all(), ApiPredicates.type(type)); - } /** * Returns all apis who's contexts are assignable from the parameter - * + * * @param type * the type of the context to search for - * + * * @return the apis with contexts assignable from given type */ - public static Iterable> contextAssignableFrom(TypeToken type) { + public static Iterable contextAssignableFrom(TypeToken type) { return filter(all(), ApiPredicates.contextAssignableFrom(type)); } + /** + * Returns all apis who's contexts are assignable from the parameter + * + * @param type + * the type of the context to search for + * + * @return the apis with contexts assignable from given type + */ + public static Iterable contextWrappableAs(TypeToken type) { + return filter(all(), ApiPredicates.contextWrappableAs(type)); + } + + public static Iterable contextWrappableAs(Class type) { + return filter(all(), ApiPredicates.contextWrappableAs(TypeToken.of(type))); + } + + /** + * Returns the type of context + * + * @param type + * the type of the context to search for + * + * @return the apis with contexts transformable to the given type + */ + public static TypeToken findWrapper(final ApiMetadata apiMetadata, final TypeToken wrapper) + throws NoSuchElementException { + checkNotNull(apiMetadata, "apiMetadata must be defined"); + checkNotNull(wrapper, "context must be defined"); + return Iterables.find(apiMetadata.getWrappers(), new Predicate>() { + + @Override + public boolean apply(TypeToken input) { + return wrapper.isAssignableFrom(input); + } + + }); + } } \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/apis/internal/BaseApiMetadata.java b/core/src/main/java/org/jclouds/apis/internal/BaseApiMetadata.java index 8496c32620..ac87f3641b 100644 --- a/core/src/main/java/org/jclouds/apis/internal/BaseApiMetadata.java +++ b/core/src/main/java/org/jclouds/apis/internal/BaseApiMetadata.java @@ -34,37 +34,54 @@ import static org.jclouds.Constants.PROPERTY_USER_THREADS; import java.io.Closeable; import java.net.URI; -import java.util.Map; import java.util.Properties; +import java.util.Set; +import org.jclouds.Wrapper; import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.ApiType; -import org.jclouds.rest.RestContext; -import org.jclouds.rest.internal.ContextBuilder; +import org.jclouds.lifecycle.Closer; import com.google.common.base.Objects; -import com.google.common.base.Objects.ToStringHelper; import com.google.common.base.Optional; -import com.google.common.reflect.TypeParameter; +import com.google.common.base.Objects.ToStringHelper; +import com.google.common.collect.ImmutableSet; import com.google.common.reflect.TypeToken; +import com.google.inject.Module; /** - * The BaseApiMetadata class is an abstraction of {@link ApiMetadata} to be - * extended by those implementing ApiMetadata. + * The BaseApiMetadata class is an abstraction of {@link ApiMetadata} to be extended by those + * implementing ApiMetadata. * - * (Note: This class must be abstract to allow {@link java.util.ServiceLoader} - * to work properly. + * (Note: This class must be abstract to allow {@link java.util.ServiceLoader} to work properly. * * @author Jeremy Whitlock , Adrian Cole */ -public abstract class BaseApiMetadata> implements - ApiMetadata { +public abstract class BaseApiMetadata implements ApiMetadata { - public static class Builder> implements - ApiMetadata.Builder { + /** The serialVersionUID */ + private static final long serialVersionUID = -8080028444066498110L; + + public static Properties defaultProperties() { + Properties props = new Properties(); + // TODO: move this to ApiMetadata + props.setProperty(PROPERTY_ISO3166_CODES, ""); + props.setProperty(PROPERTY_MAX_CONNECTIONS_PER_CONTEXT, 20 + ""); + props.setProperty(PROPERTY_MAX_CONNECTIONS_PER_HOST, 0 + ""); + props.setProperty(PROPERTY_SO_TIMEOUT, 60000 + ""); + props.setProperty(PROPERTY_CONNECTION_TIMEOUT, 60000 + ""); + props.setProperty(PROPERTY_IO_WORKER_THREADS, 20 + ""); + props.setProperty(PROPERTY_USER_THREADS, 0 + ""); + props.setProperty(PROPERTY_MAX_CONNECTION_REUSE, 75 + ""); + props.setProperty(PROPERTY_MAX_SESSION_FAILURES, 2 + ""); + props.setProperty(PROPERTY_SESSION_INTERVAL, 60 + ""); + props.setProperty(PROPERTY_PRETTY_PRINT_PAYLOADS, "true"); + return props; + } + + public static class Builder implements ApiMetadata.Builder { protected String id; protected String name; - protected ApiType type; + protected Set> wrappers = ImmutableSet.of(); protected String endpointName = "https endpoint"; protected String identityName; protected Optional credentialName = Optional.absent(); @@ -73,44 +90,17 @@ public abstract class BaseApiMetadata defaultEndpoint = Optional.absent(); protected Optional defaultIdentity = Optional.absent(); protected Optional defaultCredential = Optional.absent(); - protected Properties defaultProperties = defaultProperties(); + protected Properties defaultProperties = BaseApiMetadata.defaultProperties(); protected URI documentation; // - protected Class api; - protected Class asyncApi; - protected TypeToken context; - protected TypeToken> contextBuilder = new TypeToken>(getClass()) { - private static final long serialVersionUID = 1L; - }; - - public static Properties defaultProperties() { - Properties props = new Properties(); - // TODO: move this to ApiMetadata - props.setProperty(PROPERTY_ISO3166_CODES, ""); - props.setProperty(PROPERTY_MAX_CONNECTIONS_PER_CONTEXT, 20 + ""); - props.setProperty(PROPERTY_MAX_CONNECTIONS_PER_HOST, 0 + ""); - props.setProperty(PROPERTY_SO_TIMEOUT, 60000 + ""); - props.setProperty(PROPERTY_CONNECTION_TIMEOUT, 60000 + ""); - props.setProperty(PROPERTY_IO_WORKER_THREADS, 20 + ""); - props.setProperty(PROPERTY_USER_THREADS, 0 + ""); - props.setProperty(PROPERTY_MAX_CONNECTION_REUSE, 75 + ""); - props.setProperty(PROPERTY_MAX_SESSION_FAILURES, 2 + ""); - props.setProperty(PROPERTY_SESSION_INTERVAL, 60 + ""); - props.setProperty(PROPERTY_PRETTY_PRINT_PAYLOADS, "true"); - return props; - } - - public static Properties defaultPropertiesAnd(Map overrides) { - Properties props = defaultProperties(); - props.putAll(overrides); - return props; - } + protected TypeToken context = TypeToken.of(Closer.class); + protected Set> defaultModules = ImmutableSet.of(); /** * {@inheritDoc} */ @Override - public Builder id(String id) { + public Builder id(String id) { this.id = checkNotNull(id, "id"); return this; } @@ -119,17 +109,33 @@ public abstract class BaseApiMetadata name(String name) { + public Builder name(String name) { this.name = checkNotNull(name, "name"); return this; } - + /** * {@inheritDoc} */ @Override - public Builder type(ApiType type) { - this.type = checkNotNull(type, "type"); + public Builder wrapper(Class wrapper) { + return wrapper(TypeToken.of(checkNotNull(wrapper, "wrapper"))); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder wrapper(TypeToken wrapper) { + return wrappers(ImmutableSet.>of(checkNotNull(wrapper, "wrapper"))); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder wrappers(Set> wrappers) { + this.wrappers = ImmutableSet.copyOf(checkNotNull(wrappers, "wrappers")); return this; } @@ -137,7 +143,7 @@ public abstract class BaseApiMetadata endpointName(String endpointName) { + public Builder endpointName(String endpointName) { this.endpointName = checkNotNull(endpointName, "endpointName"); return this; } @@ -146,7 +152,7 @@ public abstract class BaseApiMetadata identityName(String identityName) { + public Builder identityName(String identityName) { this.identityName = checkNotNull(identityName, "identityName"); return this; } @@ -155,7 +161,7 @@ public abstract class BaseApiMetadata credentialName(String credentialName) { + public Builder credentialName(String credentialName) { this.credentialName = Optional.fromNullable(credentialName); return this; } @@ -164,7 +170,7 @@ public abstract class BaseApiMetadata version(String version) { + public Builder version(String version) { this.version = checkNotNull(version, "version"); return this; } @@ -173,7 +179,7 @@ public abstract class BaseApiMetadata buildVersion(String buildVersion) { + public Builder buildVersion(String buildVersion) { this.buildVersion = Optional.fromNullable(buildVersion); return this; } @@ -182,7 +188,7 @@ public abstract class BaseApiMetadata defaultEndpoint(String defaultEndpoint) { + public Builder defaultEndpoint(String defaultEndpoint) { this.defaultEndpoint = Optional.fromNullable(defaultEndpoint); return this; } @@ -191,7 +197,7 @@ public abstract class BaseApiMetadata defaultIdentity(String defaultIdentity) { + public Builder defaultIdentity(String defaultIdentity) { this.defaultIdentity = Optional.fromNullable(defaultIdentity); return this; } @@ -200,7 +206,7 @@ public abstract class BaseApiMetadata defaultCredential(String defaultCredential) { + public Builder defaultCredential(String defaultCredential) { this.defaultCredential = Optional.fromNullable(defaultCredential); return this; } @@ -209,7 +215,7 @@ public abstract class BaseApiMetadata defaultProperties(Properties defaultProperties) { + public Builder defaultProperties(Properties defaultProperties) { this.defaultProperties = checkNotNull(defaultProperties, "defaultProperties"); return this; } @@ -217,30 +223,8 @@ public abstract class BaseApiMetadata javaApi(Class api, Class asyncApi) { - this.api = checkNotNull(api, "api"); - this.asyncApi = checkNotNull(asyncApi, "asyncApi"); - if (context == null) - context(contextToken(TypeToken.of(checkNotNull(api, "api")), TypeToken.of(checkNotNull(asyncApi, "asyncApi")))); - return this; - } - - @SuppressWarnings("rawtypes") - protected TypeToken contextToken(TypeToken clientToken, TypeToken asyncClientToken) { - return new TypeToken>() { - private static final long serialVersionUID = 1L; - }.where(new TypeParameter() { - }, clientToken).where(new TypeParameter() { - }, asyncClientToken); - } - - /** - * {@inheritDoc} - */ - @Override - public Builder documentation(URI documentation) { + public Builder documentation(URI documentation) { this.documentation = checkNotNull(documentation, "documentation"); return this; } @@ -249,7 +233,7 @@ public abstract class BaseApiMetadata context(TypeToken context) { + public Builder context(TypeToken context) { this.context = checkNotNull(context, "context"); return this; } @@ -258,25 +242,33 @@ public abstract class BaseApiMetadata contextBuilder(TypeToken> contextBuilder) { - this.contextBuilder = checkNotNull(contextBuilder, "contextBuilder"); + public Builder defaultModule(Class defaultModule) { + return defaultModules(ImmutableSet.>of(checkNotNull(defaultModule, "defaultModule"))); + } + + /** + * {@inheritDoc} + */ + @Override + public Builder defaultModules(Set> defaultModules) { + this.defaultModules = ImmutableSet.copyOf(checkNotNull(defaultModules, "defaultModules")); return this; } - public Builder fromApiMetadata(M in) { - return id(in.getId()).type(in.getType()).name(in.getName()).endpointName(in.getEndpointName()) - .identityName(in.getIdentityName()).credentialName(in.getCredentialName().orNull()) - .version(in.getVersion()).buildVersion(in.getBuildVersion().orNull()) - .defaultEndpoint(in.getDefaultEndpoint().orNull()).defaultIdentity(in.getDefaultIdentity().orNull()) - .defaultCredential(in.getDefaultCredential().orNull()).defaultProperties(in.getDefaultProperties()) - .documentation(in.getDocumentation()).javaApi(in.getApi(), in.getAsyncApi()).context(in.getContext()) - .contextBuilder(in.getContextBuilder()); + public Builder fromApiMetadata(ApiMetadata in) { + return id(in.getId()).wrappers(in.getWrappers()).name(in.getName()).endpointName(in.getEndpointName()).identityName( + in.getIdentityName()).credentialName(in.getCredentialName().orNull()).version(in.getVersion()) + .buildVersion(in.getBuildVersion().orNull()).defaultEndpoint(in.getDefaultEndpoint().orNull()) + .defaultIdentity(in.getDefaultIdentity().orNull()).defaultCredential( + in.getDefaultCredential().orNull()).defaultProperties(in.getDefaultProperties()) + .documentation(in.getDocumentation()).context(in.getContext()).defaultModules(in.getDefaultModules()); } - @SuppressWarnings("unchecked") @Override - public M build() { - return (M) new BaseApiMetadata(this) { + public ApiMetadata build() { + return new BaseApiMetadata(this) { + /** The serialVersionUID */ + private static final long serialVersionUID = 3599854558038790678L; }; } @@ -284,7 +276,7 @@ public abstract class BaseApiMetadata> wrappers; protected final String endpointName; protected final String identityName; protected final Optional credentialName; @@ -295,29 +287,24 @@ public abstract class BaseApiMetadata defaultCredential; protected final Properties defaultProperties; protected final URI documentation; - protected final Class api; - protected final Class asyncApi; - protected final TypeToken context; - protected final TypeToken> contextBuilder; + protected final TypeToken context; + protected final Set> defaultModules; - @SuppressWarnings("unchecked") - protected BaseApiMetadata(Builder builder) { - this(builder.id, builder.name, builder.type, builder.endpointName, builder.identityName, builder.credentialName, - builder.version, builder.buildVersion, builder.defaultEndpoint, builder.defaultIdentity, - builder.defaultCredential, builder.defaultProperties, builder.documentation, Class.class.cast(builder.api), - Class.class.cast(builder.asyncApi), TypeToken.class.cast(builder.context), TypeToken.class - .cast(builder.contextBuilder)); + protected BaseApiMetadata(Builder builder) { + this(builder.id, builder.name, builder.wrappers, builder.endpointName, builder.identityName, builder.credentialName, + builder.version, builder.buildVersion, builder.defaultEndpoint, builder.defaultIdentity, + builder.defaultCredential, builder.defaultProperties, builder.documentation, builder.context, + builder.defaultModules); } - - public BaseApiMetadata(String id, String name, ApiType type, String endpointName, String identityName, - Optional credentialName, String version, Optional buildVersion, - Optional defaultEndpoint, Optional defaultIdentity, Optional defaultCredential, - Properties defaultProperties, URI documentation, Class api, Class asyncApi, TypeToken context, - TypeToken> contextBuilder) { + public BaseApiMetadata(String id, String name, Set> wrappers, String endpointName, String identityName, + Optional credentialName, String version, Optional buildVersion, + Optional defaultEndpoint, Optional defaultIdentity, Optional defaultCredential, + Properties defaultProperties, URI documentation, TypeToken context, + Set> defaultModules) { this.id = checkNotNull(id, "id"); this.name = checkNotNull(name, "name"); - this.type = checkNotNull(type, "type"); + this.wrappers = ImmutableSet.copyOf(checkNotNull(wrappers, "wrappers")); this.endpointName = checkNotNull(endpointName, "endpointName"); this.identityName = checkNotNull(identityName, "identityName"); this.credentialName = checkNotNull(credentialName, "credentialName"); @@ -328,10 +315,8 @@ public abstract class BaseApiMetadata that = ApiMetadata.class.cast(o); + ApiMetadata that = ApiMetadata.class.cast(o); return equal(this.getId(), that.getId()) && equal(this.getName(), that.getName()) - && equal(this.getType(), that.getType()); + && equal(this.getWrappers(), that.getWrappers()); } @Override public int hashCode() { - return Objects.hashCode(getId(), getName(), getType()); + return Objects.hashCode(getId(), getName(), getWrappers()); } @Override @@ -358,10 +343,9 @@ public abstract class BaseApiMetadata> getWrappers() { + return wrappers; } /** @@ -472,23 +456,7 @@ public abstract class BaseApiMetadata getApi() { - return api; - } - - /** - * {@inheritDoc} - */ - @Override - public Class getAsyncApi() { - return asyncApi; - } - - /** - * {@inheritDoc} - */ - @Override - public TypeToken getContext() { + public TypeToken getContext() { return context; } @@ -496,14 +464,13 @@ public abstract class BaseApiMetadata> getContextBuilder() { - return contextBuilder; + public Set> getDefaultModules() { + return defaultModules; } - @SuppressWarnings("unchecked") @Override - public Builder toBuilder() { - return new Builder().fromApiMetadata((M) this); + public Builder toBuilder() { + return new Builder().fromApiMetadata(this); } } \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/concurrent/DynamicExecutors.java b/core/src/main/java/org/jclouds/concurrent/DynamicExecutors.java index 71089131a2..811d32bc0d 100644 --- a/core/src/main/java/org/jclouds/concurrent/DynamicExecutors.java +++ b/core/src/main/java/org/jclouds/concurrent/DynamicExecutors.java @@ -157,7 +157,7 @@ public class DynamicExecutors { /* * Thread name: owner-pool-N-thread-M, where N is the sequence number of this factory, - * and M is the sequence number of the thread created by this factory. + * and ApiMetadata is the sequence number of the thread created by this factory. */ t.setName(o + t.getName()); diff --git a/core/src/main/java/org/jclouds/encryption/internal/Base64.java b/core/src/main/java/org/jclouds/encryption/internal/Base64.java index d20add1434..d68ef16d9d 100644 --- a/core/src/main/java/org/jclouds/encryption/internal/Base64.java +++ b/core/src/main/java/org/jclouds/encryption/internal/Base64.java @@ -199,7 +199,7 @@ public class Base64 -/* ******** E N C O D I N G M E T H O D S ******** */ +/* ******** E N C O D I N G ApiMetadata E T H O D S ******** */ /** @@ -568,7 +568,7 @@ public class Base64 -/* ******** D E C O D I N G M E T H O D S ******** */ +/* ******** D E C O D I N G ApiMetadata E T H O D S ******** */ /** @@ -1011,7 +1011,7 @@ public class Base64 - /* ******** I N N E R C L A S S I N P U T S T R E A M ******** */ + /* ******** I N N E R C L A S S I N P U T S T R E A ApiMetadata ******** */ @@ -1241,7 +1241,7 @@ public class Base64 - /* ******** I N N E R C L A S S O U T P U T S T R E A M ******** */ + /* ******** I N N E R C L A S S O U T P U T S T R E A ApiMetadata ******** */ diff --git a/core/src/main/java/org/jclouds/internal/BaseWrapper.java b/core/src/main/java/org/jclouds/internal/BaseWrapper.java new file mode 100644 index 0000000000..b28208c5f9 --- /dev/null +++ b/core/src/main/java/org/jclouds/internal/BaseWrapper.java @@ -0,0 +1,97 @@ +/** + * 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.internal; +import static com.google.common.base.Objects.equal; +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; + +import java.io.Closeable; + +import javax.inject.Singleton; + +import org.jclouds.Wrapper; +import org.jclouds.location.Provider; + +import com.google.common.base.Objects; +import com.google.common.base.Objects.ToStringHelper; +import com.google.common.reflect.TypeToken; + +/** + * @author Adrian Cole + */ +@Singleton +public abstract class BaseWrapper implements Wrapper { + + private final Closeable wrapped; + private final TypeToken wrappedType; + + + protected BaseWrapper(@Provider Closeable wrapped, @Provider TypeToken wrappedType) { + this.wrapped = checkNotNull(wrapped, "wrapped"); + this.wrappedType = checkNotNull(wrappedType, "wrappedType"); + } + + @SuppressWarnings("unchecked") + @Override + public C unwrap(TypeToken type) { + checkArgument(checkNotNull(type, "type").isAssignableFrom(wrappedType), "wrapped type: %s not assignable from %s", wrappedType, type); + return (C) wrapped; + } + + @Override + public TypeToken getWrappedType() { + return wrappedType; + } + + @SuppressWarnings("unchecked") + @Override + public C unwrap() throws ClassCastException { + return (C) unwrap(getWrappedType()); + } + + public Closeable getWrapped() { + return wrapped; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + BaseWrapper that = BaseWrapper.class.cast(o); + return equal(this.getWrapped(), that.getWrapped()) && equal(this.getWrappedType(), that.getWrappedType()); + } + + @Override + public int hashCode() { + return Objects.hashCode(getWrapped(), getWrappedType()); + } + + @Override + public String toString() { + return string().toString(); + } + + protected ToStringHelper string() { + return Objects.toStringHelper("").add("wrapped", getWrapped()).add("wrappedType", getWrappedType()); + } + + +} diff --git a/core/src/main/java/org/jclouds/location/config/LocationModule.java b/core/src/main/java/org/jclouds/location/config/LocationModule.java index 640c872452..1a9a09648b 100644 --- a/core/src/main/java/org/jclouds/location/config/LocationModule.java +++ b/core/src/main/java/org/jclouds/location/config/LocationModule.java @@ -30,6 +30,7 @@ import javax.inject.Singleton; import org.jclouds.collect.Memoized; import org.jclouds.domain.Location; +import org.jclouds.internal.ClassMethodArgsAndReturnVal; import org.jclouds.location.Iso3166; import org.jclouds.location.Provider; import org.jclouds.location.Region; @@ -45,11 +46,15 @@ import org.jclouds.location.suppliers.RegionIdsSupplier; import org.jclouds.location.suppliers.ZoneIdToURISupplier; import org.jclouds.location.suppliers.ZoneIdsSupplier; import org.jclouds.rest.AuthorizationException; +import org.jclouds.rest.functions.ImplicitOptionalConverter; import org.jclouds.rest.suppliers.MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier; +import com.google.common.base.Function; +import com.google.common.base.Optional; import com.google.common.base.Supplier; import com.google.inject.AbstractModule; import com.google.inject.Provides; +import com.google.inject.TypeLiteral; /** * All of these are memoized as locations do not change often at runtime. Note that we take care to @@ -61,6 +66,7 @@ public class LocationModule extends AbstractModule { @Override protected void configure() { + bind(new TypeLiteral>>(){}).to(ImplicitOptionalConverter.class); } @Provides diff --git a/core/src/main/java/org/jclouds/providers/AnonymousProviderMetadata.java b/core/src/main/java/org/jclouds/providers/AnonymousProviderMetadata.java index 4713b8c3d4..d49edcb8fc 100644 --- a/core/src/main/java/org/jclouds/providers/AnonymousProviderMetadata.java +++ b/core/src/main/java/org/jclouds/providers/AnonymousProviderMetadata.java @@ -20,50 +20,47 @@ package org.jclouds.providers; import static com.google.common.base.Preconditions.checkNotNull; -import java.io.Closeable; - import org.jclouds.apis.ApiMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; import org.jclouds.rest.AnonymousRestApiMetadata; -import org.jclouds.rest.RestContext; /** * Useful in creating arbitrary clients. * * @author Adrian Cole */ -public class AnonymousProviderMetadata> extends - BaseProviderMetadata { +public class AnonymousProviderMetadata extends BaseProviderMetadata { - public static ProviderMetadata, AnonymousRestApiMetadata> forClientMappedToAsyncClientOnEndpoint(Class client, Class asyncClient, - String endpoint) { + /** The serialVersionUID */ + private static final long serialVersionUID = 3038298137724260273L; + + public static ProviderMetadata forClientMappedToAsyncClientOnEndpoint(Class client, Class asyncClient, + String endpoint) { return forApiWithEndpoint(AnonymousRestApiMetadata.forClientMappedToAsyncClient(client, asyncClient), endpoint); } - - public static > ProviderMetadata forApiWithEndpoint(M md, - String endpoint) { + + public static ProviderMetadata forApiWithEndpoint(ApiMetadata md, String endpoint) { checkNotNull(md, "api"); checkNotNull(endpoint, "endpoint (%s)", md.getEndpointName()); - return new AnonymousProviderMetadata(md, endpoint); + return new AnonymousProviderMetadata(md, endpoint); } @Override - public Builder toBuilder() { - return (Builder) new Builder(getApiMetadata(), getEndpoint()).fromProviderMetadata(this); + public Builder toBuilder() { + return (Builder) new Builder(getApiMetadata(), getEndpoint()).fromProviderMetadata(this); } - public AnonymousProviderMetadata(M apiMetadata, String endpoint) { - super(new Builder(apiMetadata, endpoint)); + public AnonymousProviderMetadata(ApiMetadata apiMetadata, String endpoint) { + super(new Builder(apiMetadata, endpoint)); } - public AnonymousProviderMetadata(Builder builder) { + public AnonymousProviderMetadata(Builder builder) { super(builder); } - public static class Builder> extends - BaseProviderMetadata.Builder { + public static class Builder extends BaseProviderMetadata.Builder { - public Builder(M apiMetadata, String endpoint) { + public Builder(ApiMetadata apiMetadata, String endpoint) { id(checkNotNull(apiMetadata, "apiMetadata").getId()) .name(apiMetadata.getName()) .apiMetadata(apiMetadata) @@ -71,8 +68,8 @@ public class AnonymousProviderMetadata build() { - return new AnonymousProviderMetadata(this); + public AnonymousProviderMetadata build() { + return new AnonymousProviderMetadata(this); } } diff --git a/core/src/main/java/org/jclouds/providers/ProviderMetadata.java b/core/src/main/java/org/jclouds/providers/ProviderMetadata.java index b4b4f25318..57d9d04f85 100644 --- a/core/src/main/java/org/jclouds/providers/ProviderMetadata.java +++ b/core/src/main/java/org/jclouds/providers/ProviderMetadata.java @@ -18,7 +18,7 @@ */ package org.jclouds.providers; -import java.io.Closeable; +import java.io.Serializable; import java.net.URI; import java.util.Properties; import java.util.Set; @@ -34,82 +34,82 @@ import com.google.common.base.Optional; * * @author Jeremy Whitlock , Adrian Cole */ -public interface ProviderMetadata> { +public interface ProviderMetadata extends Serializable { /** * * @author Adrian Cole * @since 1.5 */ - public static interface Builder> { + public static interface Builder { /** * @see ProviderMetadata#getId() */ - Builder id(String id); + Builder id(String id); /** * @see ProviderMetadata#getName() */ - Builder name(String name); + Builder name(String name); /** * @see ProviderMetadata#getApiMetadata() */ - Builder apiMetadata(M api); + Builder apiMetadata(ApiMetadata api); /** * @see ProviderMetadata#getEndpoint() */ - Builder endpoint(String endpoint); + Builder endpoint(String endpoint); /** * @see ProviderMetadata#getDefaultProperties() */ - Builder defaultProperties(Properties defaultProperties); + Builder defaultProperties(Properties defaultProperties); /** * @see ProviderMetadata#getConsole() */ - Builder console(@Nullable URI console); + Builder console(@Nullable URI console); /** * @see ProviderMetadata#getHomepage() */ - Builder homepage(@Nullable URI homepage); + Builder homepage(@Nullable URI homepage); /** * @see ProviderMetadata#getLinkedServices() */ - Builder linkedServices(Iterable linkedServices); + Builder linkedServices(Iterable linkedServices); /** * @see ProviderMetadata#getLinkedServices() */ - Builder linkedServices(String... linkedServices); + Builder linkedServices(String... linkedServices); /** * @see ProviderMetadata#getLinkedServices() */ - Builder linkedService(String linkedService); + Builder linkedService(String linkedService); /** * @see ProviderMetadata#getIso3166Code() */ - Builder iso3166Codes(Iterable iso3166Codes); + Builder iso3166Codes(Iterable iso3166Codes); /** * @see ProviderMetadata#getIso3166Code() */ - Builder iso3166Codes(String... iso3166Codes); + Builder iso3166Codes(String... iso3166Codes); /** * @see ProviderMetadata#getIso3166Code() */ - Builder iso3166Code(String iso3166Code); + Builder iso3166Code(String iso3166Code); - ProviderMetadata build(); + ProviderMetadata build(); - Builder fromProviderMetadata(ProviderMetadata in); + Builder fromProviderMetadata(ProviderMetadata in); } @@ -117,7 +117,7 @@ public interface ProviderMetadata toBuilder(); + Builder toBuilder(); /** * @@ -136,7 +136,7 @@ public interface ProviderMetadata> implements Predicate> { - private final TypeToken contextClass; + public static class ContextAssignableFrom implements Predicate { + private final TypeToken type; - public ContextAssignableFrom(TypeToken contextClass) { - Preconditions.checkNotNull(contextClass, "context must be defined"); - this.contextClass = contextClass; + public ContextAssignableFrom(TypeToken type) { + Preconditions.checkNotNull(type, "context must be defined"); + this.type = type; } /** * {@inheritDoc} */ @Override - public boolean apply(ProviderMetadata providerMetadata) { - return ApiPredicates.contextAssignableFrom(contextClass).apply(providerMetadata.getApiMetadata()); + public boolean apply(ProviderMetadata providerMetadata) { + return ApiPredicates.contextAssignableFrom(type).apply(providerMetadata.getApiMetadata()); } /** @@ -58,7 +58,32 @@ public class ProviderPredicates { */ @Override public String toString() { - return "contextAssignableFrom(" + contextClass + ")"; + return "contextAssignableFrom(" + type + ")"; + } + } + + public static class TransformableTo implements Predicate { + private final TypeToken type; + + public TransformableTo(TypeToken type) { + Preconditions.checkNotNull(type, "context must be defined"); + this.type = type; + } + + /** + * {@inheritDoc} + */ + @Override + public boolean apply(ProviderMetadata providerMetadata) { + return ApiPredicates.contextWrappableAs(type).apply(providerMetadata.getApiMetadata()); + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return "contextWrappableAs(" + type + ")"; } } @@ -67,8 +92,8 @@ public class ProviderPredicates { * * @return all available providers */ - public static Predicate> all() { - return Predicates.> alwaysTrue(); + public static Predicate all() { + return Predicates. alwaysTrue(); } /** @@ -79,14 +104,14 @@ public class ProviderPredicates { * * @return the providers with the given id */ - public static Predicate> id(final String id) { + public static Predicate id(final String id) { Preconditions2.checkNotEmpty(id, "id must be defined"); - return new Predicate>() { + return new Predicate() { /** * {@inheritDoc} */ @Override - public boolean apply(ProviderMetadata providerMetadata) { + public boolean apply(ProviderMetadata providerMetadata) { return providerMetadata.getId().equals(id); } @@ -100,43 +125,6 @@ public class ProviderPredicates { }; } - /** - * Returns all providers with the given type. - * - * @param type - * the type of the provider to return - * - * @return the providers with the given type - */ - public static Predicate> type(final ApiType type) { - Preconditions.checkNotNull(type, "type must be defined"); - return new Predicate>() { - /** - * {@inheritDoc} - */ - @Override - public boolean apply(ProviderMetadata providerMetadata) { - return providerMetadata.getApiMetadata().getType().equals(type); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return "type(" + type + ")"; - } - }; - } - - /** - * @see #type(ApiMetadata) - */ - @Deprecated - public static Predicate> type(final String type) { - return type(ApiType.fromValue(type)); - } - /** * Returns the providers that are bound to the same location as the given ISO * 3166 code. @@ -146,15 +134,15 @@ public class ProviderPredicates { * * @return the providers with the given ISO 3166 code */ - public static Predicate> boundedByIso3166Code(final String iso3166Code) { + public static Predicate boundedByIso3166Code(final String iso3166Code) { Preconditions.checkNotNull(iso3166Code, "iso3166Code must not be null"); - return new Predicate>() { + return new Predicate() { /** * {@inheritDoc} */ @Override - public boolean apply(ProviderMetadata providerMetadata) { + public boolean apply(ProviderMetadata providerMetadata) { return providerContainsIso3166Code(providerMetadata, iso3166Code); } @@ -177,16 +165,16 @@ public class ProviderPredicates { * * @return the providers that have at least one ISO 3166 code in common */ - public static Predicate> intersectingIso3166Code( - final ProviderMetadata refProviderMetadata) { + public static Predicate intersectingIso3166Code( + final ProviderMetadata refProviderMetadata) { Preconditions.checkNotNull(refProviderMetadata, "refProviderMetadata must not be null"); - return new Predicate>() { + return new Predicate() { /** * {@inheritDoc} */ @Override - public boolean apply(ProviderMetadata providerMetadata) { + public boolean apply(ProviderMetadata providerMetadata) { for (String refIso3166Code : refProviderMetadata.getIso3166Codes()) { // Return only if the potential provider contains the same ISO // 3166 code and the provider and @@ -221,7 +209,7 @@ public class ProviderPredicates { * * @return the result */ - private static boolean providerContainsIso3166Code(ProviderMetadata providerMetadata, String iso3166Code) { + private static boolean providerContainsIso3166Code(ProviderMetadata providerMetadata, String iso3166Code) { for (String availCode : providerMetadata.getIso3166Codes()) { if (iso3166Code.indexOf('-') == -1) { if (availCode.startsWith(iso3166Code + "-")) { @@ -243,15 +231,15 @@ public class ProviderPredicates { * * @return the providers with an apimetadata assignable from the given api. */ - public static > Predicate> apiMetadataAssignableFrom( - final TypeToken apiClass) { + public static Predicate apiMetadataAssignableFrom( + final TypeToken apiClass) { Preconditions.checkNotNull(apiClass, "api must be defined"); - return new Predicate>() { + return new Predicate() { /** * {@inheritDoc} */ @Override - public boolean apply(ProviderMetadata providerMetadata) { + public boolean apply(ProviderMetadata providerMetadata) { return apiClass.isAssignableFrom(providerMetadata.getApiMetadata().getClass()); } @@ -264,18 +252,29 @@ public class ProviderPredicates { } }; } - + /** - * Returns all providers with an context assignable from the given class. + * Returns all providers with an context assignable from the given type. * - * @param contextClass + * @param type * the context of the provider to return * - * @return the providers with an context assignable from the given class. + * @return the providers with an context assignable from the given type. */ - public static > Predicate> contextAssignableFrom( - final TypeToken contextClass) { - return new ContextAssignableFrom(contextClass); + public static Predicate contextAssignableFrom(final TypeToken type) { + return new ContextAssignableFrom(type); } - + + /** + * Returns all providers with an context transformable to the given type. + * + * @param type + * the context you wish to achieve ex. {@code BlobStoreContext} + * + * @return the providers with an context transformable to from the given type. + */ + public static Predicate contextWrappableAs(final TypeToken type) { + return new TransformableTo(type); + } + } \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/providers/Providers.java b/core/src/main/java/org/jclouds/providers/Providers.java index 32fb5844db..b866e699ba 100644 --- a/core/src/main/java/org/jclouds/providers/Providers.java +++ b/core/src/main/java/org/jclouds/providers/Providers.java @@ -25,8 +25,8 @@ import java.io.Closeable; import java.util.NoSuchElementException; import java.util.ServiceLoader; +import org.jclouds.Wrapper; import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.ApiType; import com.google.common.base.Function; import com.google.common.base.Preconditions; @@ -40,41 +40,39 @@ import com.google.common.reflect.TypeToken; */ public class Providers { - public static enum IdFunction implements Function, String> { + public static enum IdFunction implements Function { INSTANCE; @Override - public String apply(ProviderMetadata input) { + public String apply(ProviderMetadata input) { return input.getId(); } } - public static Function, String> idFunction() { + public static Function idFunction() { return IdFunction.INSTANCE; } - - public static class ApiMetadataFunction> implements - Function, ApiMetadata> { + + public static class ApiMetadataFunction implements Function { @Override - public ApiMetadata apply(ProviderMetadata input) { + public ApiMetadata apply(ProviderMetadata input) { return input.getApiMetadata(); } } - public static > Function, ApiMetadata> apiMetadataFunction() { - return new ApiMetadataFunction(); + public static Function apiMetadataFunction() { + return new ApiMetadataFunction(); } /** - * Returns the providers located on the classpath via - * {@link java.util.ServiceLoader}. + * Returns the providers located on the classpath via {@link java.util.ServiceLoader}. * * @return all available providers loaded from classpath via ServiceLoader */ @SuppressWarnings("unchecked") - public static Iterable> fromServiceLoader() { + public static Iterable fromServiceLoader() { return Iterable.class.cast(ServiceLoader.load(ProviderMetadata.class)); } @@ -83,7 +81,7 @@ public class Providers { * * @return all available providers */ - public static Iterable> all() { + public static Iterable all() { return fromServiceLoader(); } @@ -98,70 +96,24 @@ public class Providers { * @throws NoSuchElementException * whenever there are no providers with the provided id */ - public static ProviderMetadata withId(String id) throws NoSuchElementException { + public static ProviderMetadata withId(String id) throws NoSuchElementException { return find(all(), ProviderPredicates.id(id)); } /** - * Returns the providers that are of type - * {@link org.jclouds.providers.ProviderMetadata#BLOBSTORE}. + * Returns the providers that are of the provided contextWrappableAs. * - * @return the blobstore providers + * @param contextWrappableAs + * the contextWrappableAs to providers to return + * + * @return the providers of the provided contextWrappableAs */ - public static Iterable> allBlobStore() { - return filter(all(), ProviderPredicates.type(ApiType.BLOBSTORE)); + public static Iterable contextWrappableAs(TypeToken contextWrappableAs) { + return filter(all(), ProviderPredicates.contextWrappableAs(contextWrappableAs)); } - /** - * Returns the providers that are of type - * {@link org.jclouds.providers.ProviderMetadata#COMPUTE}. - * - * @return the compute service providers - */ - public static Iterable> allCompute() { - return filter(all(), ProviderPredicates.type(ApiType.COMPUTE)); - } - - /** - * Returns the providers that are of type - * {@link org.jclouds.providers.ProviderMetadata#QUEUE}. - * - * @return the queue service providers - */ - public static Iterable> allQueue() { - return filter(all(), ProviderPredicates.type(ApiType.QUEUE)); - } - - /** - * Returns the providers that are of type - * {@link org.jclouds.providers.ProviderMetadata#TABLE}. - * - * @return the table service providers - */ - public static Iterable> allTable() { - return filter(all(), ProviderPredicates.type(ApiType.TABLE)); - } - - /** - * Returns the providers that are of type - * {@link org.jclouds.providers.ProviderMetadata#LOADBALANCER}. - * - * @return the load balancer service providers - */ - public static Iterable> allLoadBalancer() { - return filter(all(), ProviderPredicates.type(ApiType.LOADBALANCER)); - } - - /** - * Returns the providers that are of the provided type. - * - * @param type - * the type to providers to return - * - * @return the providers of the provided type - */ - public static Iterable> ofType(ApiType type) { - return filter(all(), ProviderPredicates.type(type)); + public static Iterable contextWrappableAs(Class contextWrappableAs) { + return filter(all(), ProviderPredicates.contextWrappableAs(TypeToken.of(contextWrappableAs))); } /** @@ -172,7 +124,7 @@ public class Providers { * * @return the providers of the provided api */ - public static Iterable> apiMetadataAssignableFrom(TypeToken api) { + public static Iterable apiMetadataAssignableFrom(TypeToken api) { Preconditions.checkNotNull(api, "api must be defined"); return filter(all(), ProviderPredicates.apiMetadataAssignableFrom(api)); } @@ -185,71 +137,80 @@ public class Providers { * * @return the providers of the provided context */ - public static Iterable> contextAssignableFrom(TypeToken context) { + public static Iterable contextAssignableFrom( + TypeToken context) { Preconditions.checkNotNull(context, "context must be defined"); return filter(all(), new ProviderPredicates.ContextAssignableFrom(context)); } - /** - * Returns the providers that are bound to the same location as the given ISO - * 3166 code regardless of type. + * Returns the providers that are bound to the same location as the given ISO 3166 code + * regardless of contextWrappableAs. * * @param isoCode * the ISO 3166 code to filter providers by * * @return the providers bound by the given ISO 3166 code */ - public static Iterable> boundedByIso3166Code(String iso3166Code) { + public static Iterable boundedByIso3166Code(String iso3166Code) { return filter(all(), ProviderPredicates.boundedByIso3166Code(iso3166Code)); } /** - * Returns the providers that are bound to the same location as the given ISO - * 3166 code and of the given type. + * Returns the providers that are bound to the same location as the given ISO 3166 code and of + * the given contextWrappableAs. * * @param iso3166Code * the ISO 3166 code to filter providers by - * @param type - * the type to filter providers by + * @param contextWrappableAs + * the contextWrappableAs to filter providers by * - * @return the providers bound by the given ISO 3166 code and of the proper - * type + * @return the providers bound by the given ISO 3166 code and of the proper contextWrappableAs */ - public static Iterable> boundedByIso3166Code(String iso3166Code, ApiType type) { - return filter(all(), - Predicates.and(ProviderPredicates.boundedByIso3166Code(iso3166Code), ProviderPredicates.type(type))); + public static Iterable boundedByIso3166Code(String iso3166Code, + TypeToken contextWrappableAs) { + return filter(all(), Predicates.and(ProviderPredicates.boundedByIso3166Code(iso3166Code), ProviderPredicates + .contextWrappableAs(contextWrappableAs))); + } + + public static Iterable boundedByIso3166Code(String iso3166Code, + Class contextWrappableAs) { + return boundedByIso3166Code(iso3166Code, TypeToken.of(contextWrappableAs)); } /** - * Returns the providers that have at least one common ISO 3166 code in - * common regardless of type. + * Returns the providers that have at least one common ISO 3166 code in common regardless of + * contextWrappableAs. * * @param providerMetadata * the provider metadata to use to filter providers by * * @return the providers that share at least one common ISO 3166 code */ - public static Iterable> collocatedWith(ProviderMetadata providerMetadata) { + public static Iterable collocatedWith(ProviderMetadata providerMetadata) { return filter(all(), ProviderPredicates.intersectingIso3166Code(providerMetadata)); } /** - * Returns the providers that have at least one common ISO 3166 code and are - * of the given type. + * Returns the providers that have at least one common ISO 3166 code and are of the given + * contextWrappableAs. * * @param providerMetadata * the provider metadata to use to filter providers by - * @param type - * the type to filter providers by + * @param contextWrappableAs + * the contextWrappableAs to filter providers by * - * @return the providers that share at least one common ISO 3166 code and of - * the given type + * @return the providers that share at least one common ISO 3166 code and of the given + * contextWrappableAs */ - public static Iterable> collocatedWith(ProviderMetadata providerMetadata, - ApiType type) { - return filter(all(), - Predicates.and(ProviderPredicates.intersectingIso3166Code(providerMetadata), ProviderPredicates.type(type))); + public static Iterable collocatedWith(ProviderMetadata providerMetadata, + TypeToken contextWrappableAs) { + return filter(all(), Predicates.and(ProviderPredicates.intersectingIso3166Code(providerMetadata), + ProviderPredicates.contextWrappableAs(contextWrappableAs))); } + public static Iterable collocatedWith(ProviderMetadata providerMetadata, + Class contextWrappableAs) { + return collocatedWith(providerMetadata, TypeToken.of(contextWrappableAs)); + } } diff --git a/core/src/main/java/org/jclouds/providers/internal/BaseProviderMetadata.java b/core/src/main/java/org/jclouds/providers/internal/BaseProviderMetadata.java index 89376f9d23..3ad8d84a3c 100644 --- a/core/src/main/java/org/jclouds/providers/internal/BaseProviderMetadata.java +++ b/core/src/main/java/org/jclouds/providers/internal/BaseProviderMetadata.java @@ -23,7 +23,6 @@ import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.collect.Iterables.addAll; import static com.google.common.collect.Sets.newLinkedHashSet; -import java.io.Closeable; import java.net.URI; import java.util.Properties; import java.util.Set; @@ -33,32 +32,32 @@ import org.jclouds.javax.annotation.Nullable; import org.jclouds.providers.ProviderMetadata; import com.google.common.base.Objects; -import com.google.common.base.Objects.ToStringHelper; import com.google.common.base.Optional; +import com.google.common.base.Objects.ToStringHelper; import com.google.common.collect.ImmutableSet; /** - * The BaseProviderMetadata class is an abstraction of {@link ProviderMetadata} - * to be extended by those implementing ProviderMetadata. + * The BaseProviderMetadata class is an abstraction of {@link ProviderMetadata} to be extended by + * those implementing ProviderMetadata. * - * (Note: This class must be abstract to allow {@link java.util.ServiceLoader} - * to work properly. + * (Note: This class must be abstract to allow {@link java.util.ServiceLoader} to work properly. * * @author Adrian Cole */ -public abstract class BaseProviderMetadata> - implements ProviderMetadata { +public abstract class BaseProviderMetadata implements ProviderMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = -6647397371073751922L; @Override - public ProviderMetadata.Builder toBuilder() { - return new BaseProviderMetadata.Builder().fromProviderMetadata(this); + public ProviderMetadata.Builder toBuilder() { + return new BaseProviderMetadata.Builder().fromProviderMetadata(this); } - public static class Builder> implements - ProviderMetadata.Builder { + public static class Builder implements ProviderMetadata.Builder { protected String id; protected String name; - protected M api; + protected ApiMetadata api; protected String endpoint; protected Properties defaultProperties = new Properties(); protected URI console; @@ -70,7 +69,7 @@ public abstract class BaseProviderMetadata id(String id) { + public Builder id(String id) { this.id = checkNotNull(id, "id"); return linkedService(id); } @@ -79,7 +78,7 @@ public abstract class BaseProviderMetadata name(String name) { + public Builder name(String name) { this.name = checkNotNull(name, "name"); return this; } @@ -88,7 +87,7 @@ public abstract class BaseProviderMetadata apiMetadata(M api) { + public Builder apiMetadata(ApiMetadata api) { this.api = checkNotNull(api, "api"); if (this.endpoint == null) this.endpoint = api.getDefaultEndpoint().orNull(); @@ -99,7 +98,7 @@ public abstract class BaseProviderMetadata endpoint(String endpoint) { + public Builder endpoint(String endpoint) { this.endpoint = checkNotNull(endpoint, "endpoint"); return this; } @@ -108,7 +107,7 @@ public abstract class BaseProviderMetadata defaultProperties(Properties defaultProperties) { + public Builder defaultProperties(Properties defaultProperties) { this.defaultProperties = checkNotNull(defaultProperties, "defaultProperties"); return this; } @@ -117,7 +116,7 @@ public abstract class BaseProviderMetadata console(@Nullable URI console) { + public Builder console(@Nullable URI console) { this.console = console; return this; } @@ -126,7 +125,7 @@ public abstract class BaseProviderMetadata homepage(URI homepage) { + public Builder homepage(URI homepage) { this.homepage = homepage; return this; } @@ -135,7 +134,7 @@ public abstract class BaseProviderMetadata linkedServices(Iterable linkedServices) { + public Builder linkedServices(Iterable linkedServices) { addAll(this.linkedServices, checkNotNull(linkedServices, "linkedServices")); return this; } @@ -144,7 +143,7 @@ public abstract class BaseProviderMetadata linkedServices(String... linkedServices) { + public Builder linkedServices(String... linkedServices) { return linkedServices(ImmutableSet.copyOf(checkNotNull(linkedServices, "linkedServices"))); } @@ -152,7 +151,7 @@ public abstract class BaseProviderMetadata linkedService(String linkedService) { + public Builder linkedService(String linkedService) { this.linkedServices.add(checkNotNull(linkedService, "linkedService")); return this; } @@ -161,7 +160,7 @@ public abstract class BaseProviderMetadata iso3166Codes(Iterable iso3166Codes) { + public Builder iso3166Codes(Iterable iso3166Codes) { addAll(this.iso3166Codes, checkNotNull(iso3166Codes, "iso3166Codes")); return this; } @@ -170,7 +169,7 @@ public abstract class BaseProviderMetadata iso3166Codes(String... iso3166Codes) { + public Builder iso3166Codes(String... iso3166Codes) { return iso3166Codes(ImmutableSet.copyOf(checkNotNull(iso3166Codes, "iso3166Codes"))); } @@ -178,7 +177,7 @@ public abstract class BaseProviderMetadata iso3166Code(String iso3166Code) { + public Builder iso3166Code(String iso3166Code) { this.iso3166Codes.add(checkNotNull(iso3166Code, "iso3166Code")); return this; } @@ -187,22 +186,25 @@ public abstract class BaseProviderMetadata fromProviderMetadata(ProviderMetadata in) { + public Builder fromProviderMetadata(ProviderMetadata in) { return id(in.getId()).name(in.getName()).apiMetadata(in.getApiMetadata()).endpoint(in.getEndpoint()) - .defaultProperties(in.getDefaultProperties()).console(in.getConsole().orNull()) - .homepage(in.getHomepage().orNull()).linkedServices(in.getLinkedServices()) - .iso3166Codes(in.getIso3166Codes()); + .defaultProperties(in.getDefaultProperties()).console(in.getConsole().orNull()).homepage( + in.getHomepage().orNull()).linkedServices(in.getLinkedServices()).iso3166Codes( + in.getIso3166Codes()); } @Override - public ProviderMetadata build() { - return new BaseProviderMetadata(this){}; + public ProviderMetadata build() { + return new BaseProviderMetadata(this) { + /** The serialVersionUID */ + private static final long serialVersionUID = 562451792167711326L; + }; } } protected final String id; protected final String name; - protected final M api; + protected final ApiMetadata api; protected final String endpoint; protected final Properties defaultProperties; protected final Optional homepage; @@ -210,14 +212,14 @@ public abstract class BaseProviderMetadata linkedServices; protected final Set iso3166Codes; - public BaseProviderMetadata(Builder builder) { + public BaseProviderMetadata(Builder builder) { this(builder.id, builder.name, builder.api, builder.endpoint, builder.defaultProperties, Optional - .fromNullable(builder.homepage), Optional.fromNullable(builder.console), builder.linkedServices, - builder.iso3166Codes); + .fromNullable(builder.homepage), Optional.fromNullable(builder.console), builder.linkedServices, + builder.iso3166Codes); } - public BaseProviderMetadata(String id, String name, M api, String endpoint, Properties defaultProperties, - Optional homepage, Optional console, Set linkedServices, Set iso3166Codes) { + public BaseProviderMetadata(String id, String name, ApiMetadata api, String endpoint, Properties defaultProperties, + Optional homepage, Optional console, Set linkedServices, Set iso3166Codes) { this.id = checkNotNull(id, "id"); this.name = checkNotNull(name, "name"); this.api = checkNotNull(api, "api"); @@ -237,9 +239,9 @@ public abstract class BaseProviderMetadata that = ProviderMetadata.class.cast(o); + ProviderMetadata that = ProviderMetadata.class.cast(o); return equal(this.getId(), that.getId()) && equal(this.getName(), that.getName()) - && equal(this.getApiMetadata(), that.getApiMetadata()) && equal(this.getEndpoint(), that.getEndpoint()); + && equal(this.getApiMetadata(), that.getApiMetadata()) && equal(this.getEndpoint(), that.getEndpoint()); } @Override @@ -253,9 +255,9 @@ public abstract class BaseProviderMetadata extends BaseRestApiMetadata, AnonymousRestApiMetadata> { +public class AnonymousRestApiMetadata extends BaseRestApiMetadata { - public static AnonymousRestApiMetadata forClientMappedToAsyncClient(Class client, Class asyncClient) { - return new AnonymousRestApiMetadata(client, asyncClient); + /** The serialVersionUID */ + private static final long serialVersionUID = 5297549599879474202L; + + public static AnonymousRestApiMetadata forClientMappedToAsyncClient(Class client, Class asyncClient) { + return new AnonymousRestApiMetadata(client, asyncClient); } @Override - public Builder toBuilder() { - return new Builder(getApi(), getAsyncApi()).fromApiMetadata(this); + public Builder toBuilder() { + return new Builder(getApi(), getAsyncApi()).fromApiMetadata(this); } - public AnonymousRestApiMetadata(Class client, Class asyncClient) { - super(new Builder(client, asyncClient)); + public AnonymousRestApiMetadata(Class client, Class asyncClient) { + super(new Builder(client, asyncClient)); } - protected AnonymousRestApiMetadata(Builder builder) { + protected AnonymousRestApiMetadata(Builder builder) { super(builder); } - public static class Builder extends BaseRestApiMetadata.Builder, AnonymousRestApiMetadata> { + public static class Builder extends BaseRestApiMetadata.Builder { - public Builder(Class client, Class asyncClient) { + public Builder(Class client, Class asyncClient) { super(client, asyncClient); id(client.getSimpleName()) - .type(ApiType.UNRECOGNIZED) - .name(String.format("%s->%s", client.getSimpleName(), asyncClient.getSimpleName())) .identityName("unused") .defaultIdentity("foo") .version("1") @@ -64,12 +65,12 @@ public class AnonymousRestApiMetadata extends BaseRestApiMetadata build() { - return new AnonymousRestApiMetadata(this); + public AnonymousRestApiMetadata build() { + return new AnonymousRestApiMetadata(this); } @Override - public Builder fromApiMetadata(AnonymousRestApiMetadata in) { + public Builder fromApiMetadata(ApiMetadata in) { super.fromApiMetadata(in); return this; } diff --git a/core/src/main/java/org/jclouds/rest/Providers.java b/core/src/main/java/org/jclouds/rest/Providers.java index fe395b9374..7056cfceec 100644 --- a/core/src/main/java/org/jclouds/rest/Providers.java +++ b/core/src/main/java/org/jclouds/rest/Providers.java @@ -20,11 +20,12 @@ package org.jclouds.rest; import java.io.Closeable; +import org.jclouds.Wrapper; import org.jclouds.apis.Apis; import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSet.Builder; import com.google.common.collect.Iterables; +import com.google.common.collect.ImmutableSet.Builder; import com.google.common.reflect.TypeToken; /** @@ -39,7 +40,7 @@ public class Providers { * Gets a set of supported providers. Idea stolen from pallets (supported-clouds). */ public static Iterable getSupportedProviders() { - return getSupportedProvidersOfType(TypeToken.of(Closeable.class)); + return getSupportedProvidersOfType(TypeToken.of(Wrapper.class)); } /** @@ -47,10 +48,10 @@ public class Providers { * (supported-clouds). * */ - public static Iterable getSupportedProvidersOfType(TypeToken type) { + public static Iterable getSupportedProvidersOfType(TypeToken type) { Builder builder = ImmutableSet. builder(); - builder.addAll(Iterables.transform(Apis.contextAssignableFrom(type), Apis.idFunction())); - builder.addAll(Iterables.transform(org.jclouds.providers.Providers.contextAssignableFrom(type), + builder.addAll(Iterables.transform(Apis.contextWrappableAs(type), Apis.idFunction())); + builder.addAll(Iterables.transform(org.jclouds.providers.Providers.contextWrappableAs(type), org.jclouds.providers.Providers.idFunction())); return builder.build(); } diff --git a/core/src/main/java/org/jclouds/rest/RestApiMetadata.java b/core/src/main/java/org/jclouds/rest/RestApiMetadata.java index 84bd50d2f0..0fb450b674 100644 --- a/core/src/main/java/org/jclouds/rest/RestApiMetadata.java +++ b/core/src/main/java/org/jclouds/rest/RestApiMetadata.java @@ -21,6 +21,7 @@ package org.jclouds.rest; import org.jclouds.apis.ApiMetadata; import com.google.common.annotations.Beta; +import com.google.common.util.concurrent.ListenableFuture; /** * @@ -28,11 +29,27 @@ import com.google.common.annotations.Beta; * @since 1.5 */ @Beta -public interface RestApiMetadata, M extends RestApiMetadata> extends - ApiMetadata { +public interface RestApiMetadata extends ApiMetadata { - public static interface Builder, M extends RestApiMetadata> extends - ApiMetadata.Builder { + public static interface Builder extends ApiMetadata.Builder { + + /** + * @see ApiMetadata#getApi() + * @see ApiMetadata#getAsyncApi() + */ + Builder javaApi(Class api, Class asyncApi); } + /** + * + * @return the type of the api which blocks on all requests + */ + Class getApi(); + + /** + * + * @return the type of the api, which is the same as {@link #getApi}, except + * all methods return {@link ListenableFuture} + */ + Class getAsyncApi(); } \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/rest/RestContextBuilder.java b/core/src/main/java/org/jclouds/rest/RestContextBuilder.java deleted file mode 100644 index 7d5475b244..0000000000 --- a/core/src/main/java/org/jclouds/rest/RestContextBuilder.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.jclouds.rest; -import static com.google.common.base.Preconditions.checkArgument; - -import java.util.NoSuchElementException; - -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.rest.internal.ContextBuilder; - -/** - * @author Adrian Cole - */ -public class RestContextBuilder, M extends RestApiMetadata> - extends ContextBuilder { - - /** - * looks up a provider or api with the given id - * - * @param providerOrApi - * id of the provider or api - * @return means to build a context to that provider - * @throws NoSuchElementException - * if the id was not configured. - * @throws IllegalArgumentException - * if the api or provider isn't assignable from RestContext - */ - public static RestContextBuilder newBuilder(String providerOrApi) throws NoSuchElementException { - ContextBuilder builder = ContextBuilder.newBuilder(providerOrApi); - checkArgument(builder instanceof RestContextBuilder, - "type of providerOrApi[%s] is not RestContextBuilder: %s", providerOrApi, builder); - return RestContextBuilder.class.cast(builder); - } - - public RestContextBuilder(ProviderMetadata providerMetadata) { - super(providerMetadata); - } - - public RestContextBuilder(M apiMetadata) { - super(apiMetadata); - } -} \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/rest/RestContextFactory.java b/core/src/main/java/org/jclouds/rest/RestContextFactory.java index fbdf38ee09..b1f3ff0f98 100644 --- a/core/src/main/java/org/jclouds/rest/RestContextFactory.java +++ b/core/src/main/java/org/jclouds/rest/RestContextFactory.java @@ -21,13 +21,15 @@ package org.jclouds.rest; import java.util.NoSuchElementException; import java.util.Properties; +import org.jclouds.ContextBuilder; +import org.jclouds.Wrapper; import org.jclouds.apis.Apis; import org.jclouds.javax.annotation.Nullable; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.Providers; -import org.jclouds.rest.internal.ContextBuilder; import com.google.common.collect.ImmutableSet; +import com.google.common.reflect.TypeToken; import com.google.inject.Module; /** @@ -106,9 +108,9 @@ public class RestContextFactory { @SuppressWarnings("unchecked") public RestContext createContext(String providerOrApi, @Nullable String identity, @Nullable String credential, Iterable wiring, Properties overrides) { - ContextBuilder builder = null; + ContextBuilder builder = null; try { - ProviderMetadata pm = Providers.withId(providerOrApi); + ProviderMetadata pm = Providers.withId(providerOrApi); builder = ContextBuilder.newBuilder(pm); } catch (NoSuchElementException e) { builder = ContextBuilder.newBuilder(Apis.withId(providerOrApi)); @@ -120,8 +122,9 @@ public class RestContextFactory { Object context = builder.build(); if (context instanceof RestContext) { return RestContext.class.cast(context); - } else if (context instanceof BackedByRestContext) { - return BackedByRestContext.class.cast(context).getProviderSpecificContext(); + } else if (context instanceof Wrapper) { + Wrapper tctx = Wrapper.class.cast(context); + return (RestContext) tctx.unwrap(TypeToken.of(RestContext.class)); } else { throw new IllegalArgumentException("provider " + providerOrApi + " contains an unknown context type: " + context.getClass().getSimpleName()); diff --git a/core/src/main/java/org/jclouds/rest/config/AsyncClientProvider.java b/core/src/main/java/org/jclouds/rest/config/AsyncClientProvider.java index bec37c601c..658c8581f5 100644 --- a/core/src/main/java/org/jclouds/rest/config/AsyncClientProvider.java +++ b/core/src/main/java/org/jclouds/rest/config/AsyncClientProvider.java @@ -34,10 +34,10 @@ import com.google.inject.Provider; public class AsyncClientProvider implements Provider { @Inject Injector injector; - private final Class asyncClientType; + private final Class asyncClientType; @Inject - AsyncClientProvider(Class asyncClientType) { + AsyncClientProvider(Class asyncClientType) { this.asyncClientType = asyncClientType; } diff --git a/core/src/main/java/org/jclouds/rest/config/BinderUtils.java b/core/src/main/java/org/jclouds/rest/config/BinderUtils.java index d64723f6b8..e3741f5b97 100644 --- a/core/src/main/java/org/jclouds/rest/config/BinderUtils.java +++ b/core/src/main/java/org/jclouds/rest/config/BinderUtils.java @@ -52,7 +52,7 @@ public class BinderUtils { * @param asyncClientType * interface for the async client */ - public static void bindClientAndAsyncClient(Binder binder, Class syncClientType, Class asyncClientType) { + public static void bindClientAndAsyncClient(Binder binder, Class syncClientType, Class asyncClientType) { bindClientAndAsyncClient(binder, syncClientType, asyncClientType, ImmutableMap., Class> of()); } @@ -75,7 +75,7 @@ public class BinderUtils { * presuming your clients are annotated with @Delegate, contains the sync to async * classes relating to these methods */ - public static void bindClientAndAsyncClient(Binder binder, Class syncClientType, Class asyncClientType, + public static void bindClientAndAsyncClient(Binder binder, Class syncClientType, Class asyncClientType, Map, Class> sync2Async) { bindClient(binder, syncClientType, asyncClientType, sync2Async); bindAsyncClient(binder, asyncClientType); diff --git a/core/src/main/java/org/jclouds/rest/config/ClientProvider.java b/core/src/main/java/org/jclouds/rest/config/ClientProvider.java index 86bf395ecd..7c52f37108 100644 --- a/core/src/main/java/org/jclouds/rest/config/ClientProvider.java +++ b/core/src/main/java/org/jclouds/rest/config/ClientProvider.java @@ -47,12 +47,12 @@ import com.google.inject.name.Names; public class ClientProvider implements Provider { @Inject Injector injector; - private final Class syncClientType; - private final Class asyncClientType; + private final Class syncClientType; + private final Class asyncClientType; private final Map, Class> sync2Async; @Inject - ClientProvider(Class syncClientType, Class asyncClientType, Map, Class> sync2Async) { + ClientProvider(Class syncClientType, Class asyncClientType, Map, Class> sync2Async) { this.asyncClientType = asyncClientType; this.syncClientType = syncClientType; this.sync2Async = sync2Async; diff --git a/core/src/main/java/org/jclouds/rest/config/RestClientModule.java b/core/src/main/java/org/jclouds/rest/config/RestClientModule.java index 6622bfeed5..cf0cc4b3ac 100644 --- a/core/src/main/java/org/jclouds/rest/config/RestClientModule.java +++ b/core/src/main/java/org/jclouds/rest/config/RestClientModule.java @@ -18,31 +18,13 @@ */ package org.jclouds.rest.config; -import java.net.URI; import java.util.Map; -import java.util.concurrent.atomic.AtomicReference; -import javax.inject.Named; -import javax.inject.Singleton; - -import org.jclouds.http.RequiresHttp; -import org.jclouds.internal.ClassMethodArgs; -import org.jclouds.internal.ClassMethodArgsAndReturnVal; -import org.jclouds.location.config.LocationModule; -import org.jclouds.rest.AuthorizationException; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.RestContext; -import org.jclouds.rest.functions.ImplicitOptionalConverter; import org.jclouds.rest.internal.RestContextImpl; -import com.google.common.base.Function; -import com.google.common.base.Optional; -import com.google.common.base.Supplier; -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; import com.google.inject.Scopes; import com.google.inject.TypeLiteral; import com.google.inject.util.Types; @@ -52,38 +34,26 @@ import com.google.inject.util.Types; * @author Adrian Cole */ @ConfiguresRestClient -@RequiresHttp -public class RestClientModule extends AbstractModule { - public final static TypeLiteral> URI_SUPPLIER_TYPE = new TypeLiteral>() { - }; - +public class RestClientModule extends RestModule { protected final Class asyncClientType; protected final Class syncClientType; - protected final Map, Class> sync2Async; - protected final AtomicReference authException = new AtomicReference(); - + public RestClientModule(Class syncClientType, Class asyncClientType, Map, Class> sync2Async) { + super(sync2Async); this.asyncClientType = asyncClientType; this.syncClientType = syncClientType; - this.sync2Async = sync2Async; } public RestClientModule(Class syncClientType, Class asyncClientType) { this(syncClientType, asyncClientType, ImmutableMap ., Class> of(syncClientType, asyncClientType)); } - - protected void installLocations() { - install(new LocationModule()); - } - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings( { "unchecked", "rawtypes" }) @Override protected void configure() { - bind(new TypeLiteral>>(){}).to(ImplicitOptionalConverter.class); - // this will help short circuit scenarios that can otherwise lock out users - bind(new TypeLiteral>(){}).toInstance(authException); + super.configure(); // Ensures the restcontext can be looked up without generic types. bind(new TypeLiteral() { }).to( @@ -97,7 +67,6 @@ public class RestClientModule extends AbstractModule { bindClient(); bindErrorHandlers(); bindRetryHandlers(); - installLocations(); } /** @@ -144,14 +113,4 @@ public class RestClientModule extends AbstractModule { sync2Async); } - - @Provides - @Singleton - @Named("sync") - LoadingCache provideSyncDelegateMap( - CreateClientForCaller createClientForCaller) { - createClientForCaller.sync2Async = sync2Async; - return CacheBuilder.newBuilder().build(createClientForCaller); - } - } \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/rest/config/RestModule.java b/core/src/main/java/org/jclouds/rest/config/RestModule.java index d2f69384b3..429fd59571 100644 --- a/core/src/main/java/org/jclouds/rest/config/RestModule.java +++ b/core/src/main/java/org/jclouds/rest/config/RestModule.java @@ -18,6 +18,10 @@ */ package org.jclouds.rest.config; +import java.net.URI; +import java.util.Map; +import java.util.concurrent.atomic.AtomicReference; + import javax.inject.Named; import javax.inject.Singleton; import javax.ws.rs.core.UriBuilder; @@ -31,7 +35,9 @@ import org.jclouds.http.TransformingHttpCommandImpl; import org.jclouds.http.functions.config.SaxParserModule; import org.jclouds.internal.ClassMethodArgs; import org.jclouds.json.config.GsonModule; +import org.jclouds.location.config.LocationModule; import org.jclouds.rest.AsyncClientFactory; +import org.jclouds.rest.AuthorizationException; import org.jclouds.rest.HttpAsyncClient; import org.jclouds.rest.HttpClient; import org.jclouds.rest.binders.BindToJsonPayloadWrappedWith; @@ -40,6 +46,7 @@ import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.rest.internal.SeedAnnotationCache; import com.google.common.base.Function; +import com.google.common.base.Supplier; import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; @@ -56,12 +63,25 @@ import com.google.inject.name.Names; import com.google.inject.util.Types; import com.sun.jersey.api.uri.UriBuilderImpl; -/** - * - * @author Adrian Cole - */ public class RestModule extends AbstractModule { + public static final TypeLiteral> URI_SUPPLIER_TYPE = new TypeLiteral>() { + }; + protected final Map, Class> sync2Async; + protected final AtomicReference authException = new AtomicReference(); + + public RestModule() { + this(ImmutableMap., Class> of()); + } + + public RestModule(Map, Class> sync2Async) { + this.sync2Async = sync2Async; + } + + protected void installLocations() { + install(new LocationModule()); + } + @Override protected void configure() { install(new SaxParserModule()); @@ -73,6 +93,10 @@ public class RestModule extends AbstractModule { BinderUtils.bindAsyncClient(binder(), HttpAsyncClient.class); BinderUtils.bindClient(binder(), HttpClient.class, HttpAsyncClient.class, ImmutableMap., Class> of( HttpClient.class, HttpAsyncClient.class)); + // this will help short circuit scenarios that can otherwise lock out users + bind(new TypeLiteral>() { + }).toInstance(authException); + installLocations(); } @Provides @@ -129,4 +153,12 @@ public class RestModule extends AbstractModule { } + @Provides + @Singleton + @Named("sync") + LoadingCache provideSyncDelegateMap(CreateClientForCaller createClientForCaller) { + createClientForCaller.sync2Async = sync2Async; + return CacheBuilder.newBuilder().build(createClientForCaller); + } + } \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/rest/internal/BaseRestApiMetadata.java b/core/src/main/java/org/jclouds/rest/internal/BaseRestApiMetadata.java index bc0e52fef1..2f2478a8c4 100644 --- a/core/src/main/java/org/jclouds/rest/internal/BaseRestApiMetadata.java +++ b/core/src/main/java/org/jclouds/rest/internal/BaseRestApiMetadata.java @@ -20,55 +20,121 @@ package org.jclouds.rest.internal; import static com.google.common.base.Preconditions.checkNotNull; +import java.util.Properties; + +import org.jclouds.apis.ApiMetadata; import org.jclouds.apis.internal.BaseApiMetadata; import org.jclouds.rest.RestApiMetadata; import org.jclouds.rest.RestContext; import com.google.common.annotations.Beta; +import com.google.common.base.Objects.ToStringHelper; +import com.google.common.reflect.TypeParameter; +import com.google.common.reflect.TypeToken; /** - * Useful in creating rest clients. + * Useful in creating rest apis. * * @author Adrian Cole */ @Beta -public class BaseRestApiMetadata, M extends RestApiMetadata> extends BaseApiMetadata - implements RestApiMetadata { +public class BaseRestApiMetadata extends BaseApiMetadata implements RestApiMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = 564135477427872712L; + + protected final Class api; + protected final Class asyncApi; - @SuppressWarnings("unchecked") @Override - public Builder toBuilder() { - return new Builder(getApi(), getAsyncApi()).fromApiMetadata((M) this); + public Builder toBuilder() { + return new Builder(getApi(), getAsyncApi()).fromApiMetadata(this); } - public BaseRestApiMetadata(Class client, Class asyncClient) { - super(new Builder(client, asyncClient)); + public BaseRestApiMetadata(Class api, Class asyncApi) { + super(new Builder(api, asyncApi)); + this.api = checkNotNull(api, "api"); + this.asyncApi = checkNotNull(asyncApi, "asyncApi"); } - protected BaseRestApiMetadata(Builder builder) { + protected BaseRestApiMetadata(Builder builder) { super(builder); + this.api = checkNotNull(builder.api, "api"); + this.asyncApi = checkNotNull(builder.asyncApi, "asyncApi"); } + + public static Properties defaultProperties() { + Properties props = BaseApiMetadata.defaultProperties(); + return props; + } + + public static class Builder extends BaseApiMetadata.Builder implements RestApiMetadata.Builder { + protected Class api; + protected Class asyncApi; - public static class Builder, M extends RestApiMetadata > extends - BaseApiMetadata.Builder implements RestApiMetadata.Builder { - - public Builder(Class client, Class asyncClient) { - checkNotNull(client, "client"); - checkNotNull(asyncClient, "asyncClient"); - javaApi(client, asyncClient); - } - - @SuppressWarnings("unchecked") - @Override - public M build() { - return (M) new BaseRestApiMetadata(this); + + public Builder(Class api, Class asyncApi) { + checkNotNull(api, "api"); + checkNotNull(asyncApi, "asyncApi"); + javaApi(api, asyncApi) + .name(String.format("%s->%s", api.getSimpleName(), asyncApi.getSimpleName())) + .context(contextToken(TypeToken.of(api), TypeToken.of(asyncApi))) + .defaultProperties(BaseRestApiMetadata.defaultProperties()); } + protected TypeToken> contextToken(TypeToken apiToken, TypeToken asyncApiToken) { + return new TypeToken>() { + private static final long serialVersionUID = 1L; + }.where(new TypeParameter() { + }, apiToken).where(new TypeParameter() { + }, asyncApiToken); + } + + /** + * {@inheritDoc} + */ @Override - public Builder fromApiMetadata(M in) { + public Builder javaApi(Class api, Class asyncApi) { + this.api = checkNotNull(api, "api"); + this.asyncApi = checkNotNull(asyncApi, "asyncApi"); + return this; + } + + + @Override + public ApiMetadata build() { + return new BaseRestApiMetadata(this); + } + + @Override + public Builder fromApiMetadata(ApiMetadata in) { + if (in instanceof RestApiMetadata) { + RestApiMetadata rest = RestApiMetadata.class.cast(in); + javaApi(rest.getApi(), rest.getAsyncApi()); + } super.fromApiMetadata(in); return this; } + } + /** + * {@inheritDoc} + */ + @Override + public Class getApi() { + return api; + } + + /** + * {@inheritDoc} + */ + @Override + public Class getAsyncApi() { + return asyncApi; + } + + @Override + protected ToStringHelper string() { + return super.string().add("api", getApi()).add("asyncApi", getAsyncApi()); + } } diff --git a/core/src/main/resources/rest.properties b/core/src/main/resources/rest.properties deleted file mode 100644 index d46966ddcc..0000000000 --- a/core/src/main/resources/rest.properties +++ /dev/null @@ -1,244 +0,0 @@ - -azurequeue.contextbuilder=org.jclouds.azure.storage.AzureStorageContextBuilder -azurequeue.sync=org.jclouds.azurequeue.AzureQueueClient -azurequeue.async=org.jclouds.azurequeue.AzureQueueAsyncClient -azurequeue.api-version=2009-09-19 -azurequeue.endpoint=https://${jclouds.identity}.queue.core.windows.net - -azureblob.contextbuilder=org.jclouds.azureblob.AzureBlobContextBuilder -azureblob.propertiesbuilder=org.jclouds.azureblob.AzureBlobPropertiesBuilder - -pcs.contextbuilder=org.jclouds.mezeo.pcs.PCSContextBuilder -pcs.propertiesbuilder=org.jclouds.mezeo.pcs.PCSPropertiesBuilder - -sdn.contextbuilder=org.jclouds.nirvanix.sdn.SDNContextBuilder -sdn.propertiesbuilder=org.jclouds.nirvanix.sdn.SDNPropertiesBuilder - -aws-simpledb.contextbuilder=org.jclouds.simpledb.SimpleDBContextBuilder -aws-simpledb.propertiesbuilder=org.jclouds.aws.simpledb.AWSSimpleDBPropertiesBuilder - -aws-sqs.contextbuilder=org.jclouds.sqs.SQSContextBuilder -aws-sqs.propertiesbuilder=org.jclouds.aws.sqs.AWSSQSPropertiesBuilder - -elb.contextbuilder=org.jclouds.elb.ELBContextBuilder -elb.propertiesbuilder=org.jclouds.elb.ELBPropertiesBuilder - -aws-elb.contextbuilder=org.jclouds.elb.ELBContextBuilder -aws-elb.propertiesbuilder=org.jclouds.aws.elb.AWSELBPropertiesBuilder - -cloudwatch.contextbuilder=org.jclouds.cloudwatch.CloudWatchContextBuilder -cloudwatch.propertiesbuilder=org.jclouds.cloudwatch.CloudWatchPropertiesBuilder - -aws-cloudwatch.contextbuilder=org.jclouds.cloudwatch.CloudWatchContextBuilder -aws-cloudwatch.propertiesbuilder=org.jclouds.aws.cloudwatch.AWSCloudWatchPropertiesBuilder - -aws-s3.contextbuilder=org.jclouds.aws.s3.AWSS3ContextBuilder -aws-s3.propertiesbuilder=org.jclouds.aws.s3.AWSS3PropertiesBuilder - -rimuhosting.contextbuilder=org.jclouds.rimuhosting.miro.RimuHostingContextBuilder -rimuhosting.propertiesbuilder=org.jclouds.rimuhosting.miro.RimuHostingPropertiesBuilder - -slicehost.contextbuilder=org.jclouds.slicehost.SlicehostContextBuilder -slicehost.propertiesbuilder=org.jclouds.slicehost.SlicehostPropertiesBuilder - -trmk-vcloudexpress.contextbuilder=org.jclouds.trmk.vcloudexpress.TerremarkVCloudExpressContextBuilder -trmk-vcloudexpress.propertiesbuilder=org.jclouds.trmk.vcloudexpress.TerremarkVCloudExpressPropertiesBuilder - -trmk-ecloud.contextbuilder=org.jclouds.trmk.ecloud.TerremarkECloudContextBuilder -trmk-ecloud.propertiesbuilder=org.jclouds.trmk.ecloud.TerremarkECloudPropertiesBuilder - -chef.contextbuilder=org.jclouds.chef.ChefContextBuilder -chef.propertiesbuilder=org.jclouds.chef.ChefPropertiesBuilder - -transientchef.contextbuilder=org.jclouds.chef.test.TransientChefContextBuilder -transientchef.propertiesbuilder=org.jclouds.chef.ChefPropertiesBuilder - -opscodeplatform.contextbuilder=org.jclouds.opscodeplatform.OpscodePlatformContextBuilder -opscodeplatform.propertiesbuilder=org.jclouds.opscodeplatform.OpscodePlatformPropertiesBuilder - -vcloud.contextbuilder=org.jclouds.vcloud.VCloudContextBuilder -vcloud.propertiesbuilder=org.jclouds.vcloud.VCloudPropertiesBuilder - -vcloud-director.contextbuilder=org.jclouds.vcloud.director.v1_5.VCloudDirectorContextBuilder -vcloud-director.propertiesbuilder=org.jclouds.vcloud.director.v1_5.VCloudDirectorPropertiesBuilder - -eucalyptus.contextbuilder=org.jclouds.ec2.EC2ContextBuilder -eucalyptus.propertiesbuilder=org.jclouds.eucalyptus.EucalyptusPropertiesBuilder - -openstack-nova-ec2.contextbuilder=org.jclouds.openstack.nova.ec2.NovaEC2ContextBuilder -openstack-nova-ec2.propertiesbuilder=org.jclouds.openstack.nova.ec2.NovaEC2PropertiesBuilder - -eucalyptus-partnercloud-ec2.contextbuilder=org.jclouds.epc.EucalyptusPartnerCloudContextBuilder -eucalyptus-partnercloud-ec2.propertiesbuilder=org.jclouds.epc.EucalyptusPartnerCloudPropertiesBuilder - -nova.contextbuilder=org.jclouds.openstack.nova.NovaContextBuilder -nova.propertiesbuilder=org.jclouds.openstack.nova.NovaPropertiesBuilder - -openstack-nova.contextbuilder=org.jclouds.openstack.nova.v1_1.NovaContextBuilder -openstack-nova.propertiesbuilder=org.jclouds.openstack.nova.v1_1.NovaPropertiesBuilder - -cloudservers.contextbuilder=org.jclouds.cloudservers.CloudServersContextBuilder -cloudservers.propertiesbuilder=org.jclouds.cloudservers.CloudServersPropertiesBuilder - -cloudservers-uk.contextbuilder=org.jclouds.cloudservers.CloudServersContextBuilder -cloudservers-uk.propertiesbuilder=org.jclouds.rackspace.cloudservers.CloudServersUKPropertiesBuilder - -cloudservers-us.contextbuilder=org.jclouds.cloudservers.CloudServersContextBuilder -cloudservers-us.propertiesbuilder=org.jclouds.rackspace.cloudservers.CloudServersUSPropertiesBuilder - -bluelock-vcloud-zone01.contextbuilder=org.jclouds.bluelock.vcloud.zone01.BluelockVCloudZone01ContextBuilder -bluelock-vcloud-zone01.propertiesbuilder=org.jclouds.bluelock.vcloud.zone01.BluelockVCloudZone01PropertiesBuilder - -stratogen-vcloud-mycloud.contextbuilder=org.jclouds.stratogen.vcloud.mycloud.StratoGenVCloudMyCloudContextBuilder -stratogen-vcloud-mycloud.propertiesbuilder=org.jclouds.stratogen.vcloud.mycloud.StratoGenVCloudMyCloudPropertiesBuilder - -greenhousedata-element-vcloud.contextbuilder=org.jclouds.greenhousedata.element.vcloud.GreenHouseDataElementVCloudContextBuilder -greenhousedata-element-vcloud.propertiesbuilder=org.jclouds.greenhousedata.element.vcloud.GreenHouseDataElementVCloudPropertiesBuilder - -gogrid.propertiesbuilder=org.jclouds.gogrid.GoGridPropertiesBuilder -gogrid.contextbuilder=org.jclouds.gogrid.GoGridContextBuilder - -deltacloud.propertiesbuilder=org.jclouds.deltacloud.DeltacloudPropertiesBuilder -deltacloud.contextbuilder=org.jclouds.deltacloud.DeltacloudContextBuilder - -elasticstack.propertiesbuilder=org.jclouds.elasticstack.ElasticStackPropertiesBuilder -elasticstack.contextbuilder=org.jclouds.elasticstack.ElasticStackContextBuilder -elasticstack.api-version=1.0 - -elastichosts-lon-p.propertiesbuilder=org.jclouds.elastichosts.ElasticHostsPeer1LondonPropertiesBuilder -elastichosts-lon-p.contextbuilder=org.jclouds.elasticstack.ElasticStackContextBuilder - -elastichosts-lon-b.propertiesbuilder=org.jclouds.elastichosts.ElasticHostsBlueSquareLondonPropertiesBuilder -elastichosts-lon-b.contextbuilder=org.jclouds.elasticstack.ElasticStackContextBuilder - -elastichosts-sat-p.propertiesbuilder=org.jclouds.elastichosts.ElasticHostsPeer1SanAntonioPropertiesBuilder -elastichosts-sat-p.contextbuilder=org.jclouds.elasticstack.ElasticStackContextBuilder - -elastichosts-tor-p.propertiesbuilder=org.jclouds.elastichosts.ElasticHostsPeer1TorontoPropertiesBuilder -elastichosts-tor-p.contextbuilder=org.jclouds.elasticstack.ElasticStackContextBuilder - -elastichosts-lax-p.propertiesbuilder=org.jclouds.elastichosts.ElasticHostsPeer1LosAngelesPropertiesBuilder -elastichosts-lax-p.contextbuilder=org.jclouds.elasticstack.ElasticStackContextBuilder - -skalicloud-sdg-my.propertiesbuilder=org.jclouds.skalicloud.SkaliCloudMalaysiaPropertiesBuilder -skalicloud-sdg-my.contextbuilder=org.jclouds.skalicloud.SkaliCloudMalaysiaContextBuilder - -serverlove-z1-man.propertiesbuilder=org.jclouds.serverlove.ServerloveManchesterPropertiesBuilder -serverlove-z1-man.contextbuilder=org.jclouds.serverlove.ServerloveManchesterContextBuilder - -openhosting-east1.propertiesbuilder=org.jclouds.openhosting.OpenHostingEast1PropertiesBuilder -openhosting-east1.contextbuilder=org.jclouds.openhosting.OpenHostingEast1ContextBuilder - -go2cloud-jhb1.propertiesbuilder=org.jclouds.go2cloud.Go2CloudJohannesburg1PropertiesBuilder -go2cloud-jhb1.contextbuilder=org.jclouds.go2cloud.Go2CloudJohannesburg1ContextBuilder - -cloudsigma.propertiesbuilder=org.jclouds.cloudsigma.CloudSigmaPropertiesBuilder -cloudsigma.contextbuilder=org.jclouds.cloudsigma.CloudSigmaContextBuilder - -cloudsigma-zrh.propertiesbuilder=org.jclouds.cloudsigma.CloudSigmaZurichPropertiesBuilder -cloudsigma-zrh.contextbuilder=org.jclouds.cloudsigma.CloudSigmaZurichContextBuilder - -cloudsigma-lvs.propertiesbuilder=org.jclouds.cloudsigma.CloudSigmaLasVegasPropertiesBuilder -cloudsigma-lvs.contextbuilder=org.jclouds.cloudsigma.CloudSigmaContextBuilder - -ibm-smartcloud.propertiesbuilder=org.jclouds.ibm.smartcloud.IBMSmartCloudPropertiesBuilder -ibm-smartcloud.contextbuilder=org.jclouds.ibm.smartcloud.IBMSmartCloudContextBuilder - -virtacore-publiccloud-lax.propertiesbuilder=org.jclouds.virtacore.publiccloud.VirtacorePublicCloudLAXPropertiesBuilder -virtacore-publiccloud-lax.contextbuilder=org.jclouds.virtacore.publiccloud.VirtacorePublicCloudLAXContextBuilder - -dunkel-vcd.propertiesbuilder=org.jclouds.dunkel.vcd.DunkelVCloudDirectorPropertiesBuilder -dunkel-vcd.contextbuilder=org.jclouds.dunkel.vcd.DunkelVCloudDirectorContextBuilder - -# example of where to change your endpoint -# bluelock.endpoint=https://express3.bluelock.com/api - -atmos.contextbuilder=org.jclouds.atmos.AtmosContextBuilder -atmos.endpoint=https://accesspoint.atmosonline.com -atmos.api-version=1.3.0 - -synaptic-storage.contextbuilder=org.jclouds.atmos.AtmosContextBuilder -synaptic-storage.propertiesbuilder=org.jclouds.synaptic.storage.SynapticStoragePropertiesBuilder - -ninefold-storage.contextbuilder=org.jclouds.atmos.AtmosContextBuilder -ninefold-storage.propertiesbuilder=org.jclouds.ninefold.storage.NinefoldStoragePropertiesBuilder - -ninefold-compute.contextbuilder=org.jclouds.ninefold.compute.NinefoldComputeContextBuilder -ninefold-compute.propertiesbuilder=org.jclouds.ninefold.compute.NinefoldComputePropertiesBuilder - -cloudonestorage.contextbuilder=org.jclouds.atmos.AtmosContextBuilder -cloudonestorage.propertiesbuilder=org.jclouds.cloudonestorage.CloudOneStoragePropertiesBuilder - -# TODO hostedsolutions use atmos - -swift.contextbuilder=org.jclouds.openstack.swift.SwiftContextBuilder -swift.propertiesbuilder=org.jclouds.openstack.swift.SwiftPropertiesBuilder - -cloudstack.contextbuilder=org.jclouds.cloudstack.CloudStackContextBuilder -cloudstack.propertiesbuilder=org.jclouds.cloudstack.CloudStackPropertiesBuilder - -softlayer.contextbuilder=org.jclouds.softlayer.SoftLayerContextBuilder -softlayer.propertiesbuilder=org.jclouds.softlayer.SoftLayerPropertiesBuilder - -glesys.contextbuilder=org.jclouds.glesys.GleSYSContextBuilder -glesys.propertiesbuilder=org.jclouds.glesys.GleSYSPropertiesBuilder - -opsource-servers.contextbuilder=org.jclouds.opsource.servers.OpSourceServersContextBuilder -opsource-servers.propertiesbuilder=org.jclouds.opsource.servers.OpSourceServersPropertiesBuilder - -savvis-symphonyvpdc.contextbuilder=org.jclouds.savvis.vpdc.VPDCContextBuilder -savvis-symphonyvpdc.propertiesbuilder=org.jclouds.savvis.vpdc.VPDCPropertiesBuilder - -cloudloadbalancers.contextbuilder=org.jclouds.cloudloadbalancers.CloudLoadBalancersContextBuilder -cloudloadbalancers.propertiesbuilder=org.jclouds.cloudloadbalancers.CloudLoadBalancersPropertiesBuilder - -cloudloadbalancers-us.contextbuilder=org.jclouds.cloudloadbalancers.CloudLoadBalancersContextBuilder -cloudloadbalancers-us.propertiesbuilder=org.jclouds.rackspace.cloudloadbalancers.CloudLoadBalancersUSPropertiesBuilder - -cloudloadbalancers-uk.contextbuilder=org.jclouds.cloudloadbalancers.CloudLoadBalancersContextBuilder -cloudloadbalancers-uk.propertiesbuilder=org.jclouds.rackspace.cloudloadbalancers.CloudLoadBalancersUKPropertiesBuilder - -cloudfiles.contextbuilder=org.jclouds.cloudfiles.CloudFilesContextBuilder -cloudfiles.propertiesbuilder=org.jclouds.cloudfiles.CloudFilesPropertiesBuilder - -cloudfiles-us.contextbuilder=org.jclouds.cloudfiles.CloudFilesContextBuilder -cloudfiles-us.propertiesbuilder=org.jclouds.rackspace.cloudfiles.CloudFilesUSPropertiesBuilder - -cloudfiles-uk.contextbuilder=org.jclouds.cloudfiles.CloudFilesContextBuilder -cloudfiles-uk.propertiesbuilder=org.jclouds.rackspace.cloudfiles.CloudFilesUKPropertiesBuilder - -walrus.contextbuilder=org.jclouds.walrus.WalrusContextBuilder -walrus.propertiesbuilder=org.jclouds.walrus.WalrusPropertiesBuilder - -eucalyptus-partnercloud-s3.contextbuilder=org.jclouds.walrus.WalrusContextBuilder -eucalyptus-partnercloud-s3.propertiesbuilder=org.jclouds.epc.EucalyptusPartnerCloudWalrusPropertiesBuilder - -googlestorage.contextbuilder=org.jclouds.googlestorage.GoogleStorageContextBuilder -googlestorage.propertiesbuilder=org.jclouds.googlestorage.GoogleStoragePropertiesBuilder - -scality-rs2.contextbuilder=org.jclouds.scality.rs2.ScalityRS2ContextBuilder -scality-rs2.propertiesbuilder=org.jclouds.scality.rs2.ScalityRS2PropertiesBuilder - -scaleup-storage.contextbuilder=org.jclouds.scality.rs2.ScalityRS2ContextBuilder -scaleup-storage.propertiesbuilder=org.jclouds.scaleup.storage.ScaleUpStoragePropertiesBuilder - -hosteurope-storage.contextbuilder=org.jclouds.scality.rs2.ScalityRS2ContextBuilder -hosteurope-storage.propertiesbuilder=org.jclouds.hosteurope.storage.HostEuropeStoragePropertiesBuilder - -tiscali-storage.contextbuilder=org.jclouds.scality.rs2.ScalityRS2ContextBuilder -tiscali-storage.propertiesbuilder=org.jclouds.tiscali.storage.TiscaliStoragePropertiesBuilder - -virtualbox.contextbuilder=org.jclouds.virtualbox.VirtualBoxContextBuilder -virtualbox.propertiesbuilder=org.jclouds.virtualbox.VirtualBoxPropertiesBuilder - -filesystem.contextbuilder=org.jclouds.filesystem.FilesystemBlobStoreContextBuilder -filesystem.propertiesbuilder=org.jclouds.filesystem.FilesystemBlobStorePropertiesBuilder - -hpcloud-objectstorage.contextbuilder=org.jclouds.hpcloud.objectstorage.HPCloudObjectStorageContextBuilder -hpcloud-objectstorage.propertiesbuilder=org.jclouds.hpcloud.objectstorage.HPCloudObjectStoragePropertiesBuilder - -hpcloud-compute.contextbuilder=org.jclouds.hpcloud.compute.HPCloudComputeContextBuilder -hpcloud-compute.propertiesbuilder=org.jclouds.hpcloud.compute.HPCloudComputePropertiesBuilder - -trystack-nova.contextbuilder=org.jclouds.trystack.nova.TryStackNovaContextBuilder -trystack-nova.propertiesbuilder=org.jclouds.trystack.nova.TryStackNovaPropertiesBuilder diff --git a/core/src/test/java/org/jclouds/rest/internal/ContextBuilderTest.java b/core/src/test/java/org/jclouds/ContextBuilderTest.java similarity index 83% rename from core/src/test/java/org/jclouds/rest/internal/ContextBuilderTest.java rename to core/src/test/java/org/jclouds/ContextBuilderTest.java index f8884dc320..3d2d4a2ae0 100644 --- a/core/src/test/java/org/jclouds/rest/internal/ContextBuilderTest.java +++ b/core/src/test/java/org/jclouds/ContextBuilderTest.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.rest.internal; +package org.jclouds; import static org.testng.Assert.assertEquals; @@ -28,7 +28,6 @@ import org.jclouds.concurrent.config.ExecutorServiceModule; import org.jclouds.events.config.EventBusModule; import org.jclouds.http.IntegrationTestAsyncClient; import org.jclouds.http.IntegrationTestClient; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.config.ConfiguresHttpCommandExecutorService; import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; import org.jclouds.logging.config.LoggingModule; @@ -60,7 +59,7 @@ public class ContextBuilderTest { } } - private ContextBuilder testContextBuilder() { + private ContextBuilder testContextBuilder() { return ContextBuilder.newBuilder(AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint( IntegrationTestClient.class, IntegrationTestAsyncClient.class, "http://localhost")); } @@ -122,7 +121,7 @@ public class ContextBuilderTest { modules.add(loggingModule); HttpModule httpModule = new HttpModule(); modules.add(httpModule); - ContextBuilder builder = testContextBuilder(); + ContextBuilder builder = testContextBuilder(); builder.addHttpModuleIfNeededAndNotPresent(modules); builder.addLoggingModuleIfNotPresent(modules); assertEquals(modules.size(), 2); @@ -130,18 +129,6 @@ public class ContextBuilderTest { assertEquals(modules.remove(0), httpModule); } - @Test - public void testAddBothWhenDoesntRequireHttp() { - List modules = new ArrayList(); - modules.add(new ConfiguresClientModule()); - ContextBuilder builder = testContextBuilder(); - builder.addHttpModuleIfNeededAndNotPresent(modules); - builder.addLoggingModuleIfNotPresent(modules); - assertEquals(modules.size(), 2); - assert modules.remove(0) instanceof ConfiguresClientModule; - assert modules.remove(0) instanceof JDKLoggingModule; - } - @ConfiguresRestClient static class ConfiguresClientModule implements Module { @@ -153,7 +140,7 @@ public class ContextBuilderTest { @Test public void testAddBothWhenDefault() { List modules = new ArrayList(); - ContextBuilder builder = testContextBuilder(); + ContextBuilder builder = testContextBuilder(); builder.addHttpModuleIfNeededAndNotPresent(modules); builder.addLoggingModuleIfNotPresent(modules); assertEquals(modules.size(), 2); @@ -161,23 +148,13 @@ public class ContextBuilderTest { assert modules.remove(0) instanceof JDKLoggingModule; } - @RequiresHttp - class RequiresHttpModule implements Module { - - public void configure(Binder arg0) { - } - - } - @Test public void testAddBothWhenLive() { List modules = new ArrayList(); - modules.add(new RequiresHttpModule()); - ContextBuilder builder = testContextBuilder(); + ContextBuilder builder = testContextBuilder(); builder.addHttpModuleIfNeededAndNotPresent(modules); builder.addLoggingModuleIfNotPresent(modules); - assertEquals(modules.size(), 3); - assert modules.remove(0) instanceof RequiresHttpModule; + assertEquals(modules.size(), 2); assert modules.remove(0) instanceof JavaUrlHttpCommandExecutorServiceModule; assert modules.remove(0) instanceof JDKLoggingModule; } @@ -196,7 +173,7 @@ public class ContextBuilderTest { protected void configure() { } }; - ContextBuilder builder = testContextBuilder(); + ContextBuilder builder = testContextBuilder(); builder.modules(Arrays.asList(module1, module2)); } diff --git a/core/src/test/java/org/jclouds/apis/ApisTest.java b/core/src/test/java/org/jclouds/apis/ApisTest.java index ba6d2f5e35..211837360c 100644 --- a/core/src/test/java/org/jclouds/apis/ApisTest.java +++ b/core/src/test/java/org/jclouds/apis/ApisTest.java @@ -40,7 +40,7 @@ public class ApisTest { @Test public void testWithId() { - ApiMetadata apiMetadata; + ApiMetadata apiMetadata; try { apiMetadata = Apis.withId("fake-id"); fail("Looking for a api with an id that doesn't exist should " + "throw an exceptoin."); @@ -54,16 +54,16 @@ public class ApisTest { } @Test - public void testOfType() { - Iterable> apisMetadata = Apis.ofType(ApiType.BLOBSTORE); + public void testTransformableTo() { + Iterable apisMetadata = Apis.contextWrappableAs(Storage.class); - for (ApiMetadata apiMetadata : apisMetadata) { + for (ApiMetadata apiMetadata : apisMetadata) { assertEquals(testBlobstoreApi, apiMetadata); } - apisMetadata = Apis.ofType(ApiType.COMPUTE); + apisMetadata = Apis.contextWrappableAs(Compute.class); - for (ApiMetadata apiMetadata : apisMetadata) { + for (ApiMetadata apiMetadata : apisMetadata) { if (apiMetadata.getName().equals(testComputeApi.getName())) { assertEquals(testComputeApi, apiMetadata); } else { @@ -71,16 +71,16 @@ public class ApisTest { } } - apisMetadata = Apis.ofType(ApiType.UNRECOGNIZED); + apisMetadata = Apis.contextWrappableAs(Balancer.class); assertEquals(false, apisMetadata.iterator().hasNext()); } @Test public void testAll() { - Iterable> apisMetadata = Apis.all(); + Iterable apisMetadata = Apis.all(); - for (ApiMetadata apiMetadata : apisMetadata) { + for (ApiMetadata apiMetadata : apisMetadata) { if (apiMetadata.getName().equals(testBlobstoreApi.getName())) { assertEquals(testBlobstoreApi, apiMetadata); } else if (apiMetadata.getName().equals(testComputeApi.getName())) { diff --git a/providers/bluelock-vcloud-zone01/src/main/java/org/jclouds/bluelock/vcloud/zone01/config/BluelockVCloudZone01RestClientModule.java b/core/src/test/java/org/jclouds/apis/Balancer.java similarity index 64% rename from providers/bluelock-vcloud-zone01/src/main/java/org/jclouds/bluelock/vcloud/zone01/config/BluelockVCloudZone01RestClientModule.java rename to core/src/test/java/org/jclouds/apis/Balancer.java index 07478f8f96..1b6fe0be48 100644 --- a/providers/bluelock-vcloud-zone01/src/main/java/org/jclouds/bluelock/vcloud/zone01/config/BluelockVCloudZone01RestClientModule.java +++ b/core/src/test/java/org/jclouds/apis/Balancer.java @@ -16,19 +16,23 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.bluelock.vcloud.zone01.config; +package org.jclouds.apis; -import org.jclouds.http.RequiresHttp; -import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.vcloud.config.VCloudRestClientModule; +import java.io.Closeable; + +import org.jclouds.internal.BaseWrapper; +import org.jclouds.location.Provider; + +import com.google.common.reflect.TypeToken; +import com.google.inject.Inject; /** - * Configures the VCloud authentication service connection, including logging and http transport. - * - * @author Adrian Cole + * For tests */ -@RequiresHttp -@ConfiguresRestClient -public class BluelockVCloudZone01RestClientModule extends VCloudRestClientModule { +public class Balancer extends BaseWrapper { + @Inject + public Balancer(@Provider Closeable ctx, @Provider TypeToken inputType) { + super(ctx, inputType); + } } diff --git a/core/src/test/java/org/jclouds/rest/internal/BaseContextLiveTest.java b/core/src/test/java/org/jclouds/apis/BaseContextLiveTest.java similarity index 86% rename from core/src/test/java/org/jclouds/rest/internal/BaseContextLiveTest.java rename to core/src/test/java/org/jclouds/apis/BaseContextLiveTest.java index edb136f225..f71ac1e121 100644 --- a/core/src/test/java/org/jclouds/rest/internal/BaseContextLiveTest.java +++ b/core/src/test/java/org/jclouds/apis/BaseContextLiveTest.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.rest.internal; +package org.jclouds.apis; import static com.google.common.base.Preconditions.checkNotNull; @@ -26,6 +26,7 @@ import java.util.Properties; import java.util.logging.Logger; import org.jclouds.Constants; +import org.jclouds.ContextBuilder; import org.jclouds.apis.ApiMetadata; import org.jclouds.apis.Apis; import org.jclouds.logging.LoggingModules; @@ -37,6 +38,7 @@ import org.testng.annotations.BeforeClass; import com.google.common.collect.ImmutableSet; import com.google.common.io.Closeables; +import com.google.common.reflect.TypeToken; import com.google.inject.Module; /** @@ -96,10 +98,9 @@ public abstract class BaseContextLiveTest { /** * @see org.jclouds.providers.Providers#withId */ - @SuppressWarnings("unchecked") - protected ProviderMetadata createProviderMetadata() { + protected ProviderMetadata createProviderMetadata() { try { - return (ProviderMetadata) Providers.withId(provider); + return Providers.withId(provider); } catch (NoSuchElementException e) { return null; } @@ -108,24 +109,24 @@ public abstract class BaseContextLiveTest { /** * @see org.jclouds.apis.Apis#withId */ - @SuppressWarnings("unchecked") - protected ApiMetadata createApiMetadata() { + protected ApiMetadata createApiMetadata() { try { - return (ApiMetadata) Apis.withId(provider); + return (ApiMetadata) Apis.withId(provider); } catch (NoSuchElementException e) { return null; } } + protected abstract TypeToken contextType(); + protected C createContext(Properties props, Iterable modules) { - return newBuilder().modules(modules).overrides(props).build(); + return newBuilder().modules(modules).overrides(props).build(contextType()); } - @SuppressWarnings("unchecked") - protected ContextBuilder newBuilder() { + protected ContextBuilder newBuilder() { if (provider != null) try { - return (ContextBuilder) ContextBuilder.newBuilder(provider); + return (ContextBuilder) ContextBuilder.newBuilder(provider); } catch (NoSuchElementException e){ Logger.getAnonymousLogger() .warning("provider [" @@ -133,9 +134,9 @@ public abstract class BaseContextLiveTest { + "] is not setup as META-INF/services/org.jclouds.apis.ApiMetadata or META-INF/services/org.jclouds.providers.ProviderMetadata"); } - ProviderMetadata pm = createProviderMetadata(); + ProviderMetadata pm = createProviderMetadata(); - ContextBuilder builder = pm != null ? ContextBuilder.newBuilder(pm) : ContextBuilder + ContextBuilder builder = pm != null ? ContextBuilder.newBuilder(pm) : ContextBuilder .newBuilder(ApiMetadata.class.cast(checkNotNull(createApiMetadata(), "either createApiMetadata or createProviderMetadata must be overridden"))); return builder; diff --git a/core/src/main/java/org/jclouds/rest/BackedByRestContext.java b/core/src/test/java/org/jclouds/apis/Compute.java similarity index 68% rename from core/src/main/java/org/jclouds/rest/BackedByRestContext.java rename to core/src/test/java/org/jclouds/apis/Compute.java index a595b334dc..41bbc31787 100644 --- a/core/src/main/java/org/jclouds/rest/BackedByRestContext.java +++ b/core/src/test/java/org/jclouds/apis/Compute.java @@ -16,22 +16,21 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.rest; +package org.jclouds.apis; -import com.google.common.annotations.Beta; +import java.io.Closeable; + +import org.jclouds.internal.BaseWrapper; +import org.jclouds.location.Provider; + +import com.google.common.reflect.TypeToken; /** - * - * - * @author Adrian Cole - * + * For tests */ -@Beta -public interface BackedByRestContext { - /** - * - * @return a context you can use to the access provider or vendor specific - * api underlying this context. - */ - RestContext getProviderSpecificContext(); -} \ No newline at end of file +public class Compute extends BaseWrapper { + + public Compute(@Provider Closeable ctx, @Provider TypeToken inputType) { + super(ctx, inputType); + } +} diff --git a/core/src/test/java/org/jclouds/apis/JcloudsTestBlobStoreApiMetadata.java b/core/src/test/java/org/jclouds/apis/JcloudsTestBlobStoreApiMetadata.java index 21d2c88e4a..ad9fab58cd 100644 --- a/core/src/test/java/org/jclouds/apis/JcloudsTestBlobStoreApiMetadata.java +++ b/core/src/test/java/org/jclouds/apis/JcloudsTestBlobStoreApiMetadata.java @@ -20,19 +20,19 @@ package org.jclouds.apis; import java.net.URI; -import org.jclouds.apis.internal.BaseApiMetadata; import org.jclouds.http.IntegrationTestAsyncClient; import org.jclouds.http.IntegrationTestClient; -import org.jclouds.rest.RestContext; +import org.jclouds.rest.internal.BaseRestApiMetadata; /** * Implementation of @ link org.jclouds.types.ApiMetadata} for testing. * * @author Jeremy Whitlock , Adrian Cole */ -public class JcloudsTestBlobStoreApiMetadata - extends - BaseApiMetadata, JcloudsTestBlobStoreApiMetadata> { +public class JcloudsTestBlobStoreApiMetadata extends BaseRestApiMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = -1178177610797635012L; public static Builder builder() { return new Builder(); @@ -53,13 +53,13 @@ public class JcloudsTestBlobStoreApiMetadata public static class Builder extends - BaseApiMetadata.Builder, JcloudsTestBlobStoreApiMetadata> { + BaseRestApiMetadata.Builder { protected Builder(){ + super(IntegrationTestClient.class, IntegrationTestAsyncClient.class); id("test-blobstore-api") - .type(ApiType.BLOBSTORE) + .wrapper(Storage.class) .name("Test Blobstore Api") - .javaApi(IntegrationTestClient.class, IntegrationTestAsyncClient.class) .identityName("user") .credentialName("password") .documentation(URI.create("http://jclouds.org/documentation")); diff --git a/core/src/test/java/org/jclouds/apis/JcloudsTestComputeApiMetadata.java b/core/src/test/java/org/jclouds/apis/JcloudsTestComputeApiMetadata.java index 99addc6a57..990ca48d01 100644 --- a/core/src/test/java/org/jclouds/apis/JcloudsTestComputeApiMetadata.java +++ b/core/src/test/java/org/jclouds/apis/JcloudsTestComputeApiMetadata.java @@ -20,17 +20,19 @@ package org.jclouds.apis; import java.net.URI; -import org.jclouds.apis.internal.BaseApiMetadata; import org.jclouds.http.IntegrationTestAsyncClient; import org.jclouds.http.IntegrationTestClient; -import org.jclouds.rest.RestContext; +import org.jclouds.rest.internal.BaseRestApiMetadata; /** * Implementation of @ link org.jclouds.types.ApiMetadata} for testing. * * @author Jeremy Whitlock , Adrian Cole */ -public class JcloudsTestComputeApiMetadata extends BaseApiMetadata, JcloudsTestComputeApiMetadata>{ +public class JcloudsTestComputeApiMetadata extends BaseRestApiMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 4781483190708679197L; public static Builder builder() { return new Builder(); @@ -49,15 +51,13 @@ public class JcloudsTestComputeApiMetadata extends BaseApiMetadata, JcloudsTestComputeApiMetadata> { + public static class Builder extends BaseRestApiMetadata.Builder { protected Builder(){ + super(IntegrationTestClient.class, IntegrationTestAsyncClient.class); id("test-compute-api") - .type(ApiType.COMPUTE) + .wrapper(Compute.class) .name("Test Compute Api") - .javaApi(IntegrationTestClient.class, IntegrationTestAsyncClient.class) .identityName("user") .credentialName("password") .documentation(URI.create("http://jclouds.org/documentation")); diff --git a/core/src/test/java/org/jclouds/apis/JcloudsTestYetAnotherComputeApiMetadata.java b/core/src/test/java/org/jclouds/apis/JcloudsTestYetAnotherComputeApiMetadata.java index ad36f40fe4..530629d212 100644 --- a/core/src/test/java/org/jclouds/apis/JcloudsTestYetAnotherComputeApiMetadata.java +++ b/core/src/test/java/org/jclouds/apis/JcloudsTestYetAnotherComputeApiMetadata.java @@ -20,19 +20,19 @@ package org.jclouds.apis; import java.net.URI; -import org.jclouds.apis.internal.BaseApiMetadata; import org.jclouds.http.IntegrationTestAsyncClient; import org.jclouds.http.IntegrationTestClient; -import org.jclouds.rest.RestContext; +import org.jclouds.rest.internal.BaseRestApiMetadata; /** * Implementation of @ link org.jclouds.types.ApiMetadata} for testing. * * @author Jeremy Whitlock */ -public class JcloudsTestYetAnotherComputeApiMetadata - extends - BaseApiMetadata, JcloudsTestYetAnotherComputeApiMetadata> { +public class JcloudsTestYetAnotherComputeApiMetadata extends BaseRestApiMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 3142126601795295510L; public static Builder builder() { return new Builder(); @@ -51,13 +51,13 @@ public class JcloudsTestYetAnotherComputeApiMetadata super(builder); } - public static class Builder extends BaseApiMetadata.Builder, JcloudsTestYetAnotherComputeApiMetadata> { + public static class Builder extends BaseRestApiMetadata.Builder { protected Builder(){ + super(IntegrationTestClient.class, IntegrationTestAsyncClient.class); id("test-yet-another-compute-api") - .type(ApiType.COMPUTE) + .wrapper(Compute.class) .name("Test Yet Another Compute Api") - .javaApi(IntegrationTestClient.class, IntegrationTestAsyncClient.class) .identityName("user") .credentialName("password") .documentation(URI.create("http://jclouds.org/documentation")); diff --git a/providers/stratogen-vcloud-mycloud/src/main/java/org/jclouds/stratogen/vcloud/mycloud/config/StratoGenVCloudMyCloudRestClientModule.java b/core/src/test/java/org/jclouds/apis/Storage.java similarity index 64% rename from providers/stratogen-vcloud-mycloud/src/main/java/org/jclouds/stratogen/vcloud/mycloud/config/StratoGenVCloudMyCloudRestClientModule.java rename to core/src/test/java/org/jclouds/apis/Storage.java index 27ffdbfd33..b16df9976e 100644 --- a/providers/stratogen-vcloud-mycloud/src/main/java/org/jclouds/stratogen/vcloud/mycloud/config/StratoGenVCloudMyCloudRestClientModule.java +++ b/core/src/test/java/org/jclouds/apis/Storage.java @@ -16,19 +16,23 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.stratogen.vcloud.mycloud.config; +package org.jclouds.apis; -import org.jclouds.http.RequiresHttp; -import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.vcloud.config.VCloudRestClientModule; +import java.io.Closeable; + +import org.jclouds.internal.BaseWrapper; +import org.jclouds.location.Provider; + +import com.google.common.reflect.TypeToken; +import com.google.inject.Inject; /** - * Configures the VCloud authentication service connection, including logging and http transport. - * - * @author Adrian Cole + * For tests */ -@RequiresHttp -@ConfiguresRestClient -public class StratoGenVCloudMyCloudRestClientModule extends VCloudRestClientModule { +public class Storage extends BaseWrapper { + @Inject + public Storage(@Provider Closeable ctx, @Provider TypeToken inputType) { + super(ctx, inputType); + } } diff --git a/core/src/test/java/org/jclouds/apis/internal/BaseApiMetadataTest.java b/core/src/test/java/org/jclouds/apis/internal/BaseApiMetadataTest.java index 95addda38b..e8c95de2ed 100644 --- a/core/src/test/java/org/jclouds/apis/internal/BaseApiMetadataTest.java +++ b/core/src/test/java/org/jclouds/apis/internal/BaseApiMetadataTest.java @@ -20,46 +20,51 @@ package org.jclouds.apis.internal; import static org.testng.Assert.assertEquals; +import java.util.Set; + +import org.jclouds.Wrapper; import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.ApiType; import org.jclouds.apis.Apis; import org.testng.annotations.Test; import com.google.common.collect.ImmutableSet; +import com.google.common.reflect.TypeToken; /** * * @author Adrian Cole */ -@SuppressWarnings("rawtypes") @Test(groups = "unit") public abstract class BaseApiMetadataTest { protected final ApiMetadata toTest; - protected final ApiType expectedType; + protected final Set> wrappers; - public BaseApiMetadataTest(ApiMetadata toTest, ApiType expectedType) { + public BaseApiMetadataTest(ApiMetadata toTest, Set> wrappers) { this.toTest = toTest; - this.expectedType = expectedType; + this.wrappers = wrappers; } @Test public void testWithId() { - ApiMetadata apiMetadata = Apis.withId(toTest.getId()); + ApiMetadata apiMetadata = Apis.withId(toTest.getId()); assertEquals(toTest, apiMetadata); } // it is ok to have multiple services in the same classpath (ex. ec2 vs elb) @Test - public void testOfTypeContains() { - ImmutableSet> ofType = ImmutableSet.copyOf(Apis.ofType(expectedType)); - assert ofType.contains(toTest) : String.format("%s not found in %s", toTest, ofType); + public void testTransformableToContains() { + for (TypeToken wrapper : wrappers) { + ImmutableSet ofType = ImmutableSet.copyOf(Apis.contextWrappableAs(wrapper)); + assert ofType.contains(toTest) : String.format("%s not found in %s for %s", toTest, ofType, + wrapper); + } } @Test public void testAllContains() { - ImmutableSet> all = ImmutableSet.copyOf(Apis.all()); + ImmutableSet all = ImmutableSet.copyOf(Apis.all()); assert all.contains(toTest) : String.format("%s not found in %s", toTest, all); } diff --git a/core/src/test/java/org/jclouds/http/BaseJettyTest.java b/core/src/test/java/org/jclouds/http/BaseJettyTest.java index c08596437d..efff2057df 100644 --- a/core/src/test/java/org/jclouds/http/BaseJettyTest.java +++ b/core/src/test/java/org/jclouds/http/BaseJettyTest.java @@ -51,11 +51,11 @@ import org.eclipse.jetty.server.handler.AbstractHandler; import org.eclipse.jetty.server.ssl.SslSelectChannelConnector; import org.eclipse.jetty.util.ssl.SslContextFactory; import org.jclouds.Constants; +import org.jclouds.ContextBuilder; import org.jclouds.crypto.CryptoStreams; import org.jclouds.io.InputSuppliers; import org.jclouds.providers.AnonymousProviderMetadata; import org.jclouds.rest.RestContext; -import org.jclouds.rest.internal.ContextBuilder; import org.jclouds.util.Strings2; import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeTest; @@ -280,12 +280,10 @@ public abstract class BaseJettyTest { return temp; } - public static ContextBuilder, ?> newBuilder( - int testPort, Properties properties, Module... connectionModules) { + public static ContextBuilder newBuilder(int testPort, Properties properties, Module... connectionModules) { properties.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "true"); properties.setProperty(Constants.PROPERTY_RELAX_HOSTNAME, "true"); - return ContextBuilder - .newBuilder( + return ContextBuilder.newBuilder( AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint(IntegrationTestClient.class, IntegrationTestAsyncClient.class, "http://localhost:" + testPort)) .modules(ImmutableSet. copyOf(connectionModules)) diff --git a/core/src/test/java/org/jclouds/http/HttpPropertiesBuilderTest.java b/core/src/test/java/org/jclouds/http/HttpPropertiesBuilderTest.java deleted file mode 100644 index ded537cd9c..0000000000 --- a/core/src/test/java/org/jclouds/http/HttpPropertiesBuilderTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * 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.http; - -import java.util.Properties; - -import org.jclouds.PropertiesBuilder; -import org.testng.annotations.Test; - -/** - * Tests behavior of modules configured in HttpPropertiesBuilder - * - * @author Adrian Cole - */ -@Test(groups = "unit") -public class HttpPropertiesBuilderTest { - - public void testBuilder() { - int httpMaxRetries = 9875; - int poolIoWorkerThreads = 2727; - int poolMaxClientReuse = 3932; - int poolMaxClients = 3382; - int poolMaxSessionFailures = 857; - - PropertiesBuilder builder = new PropertiesBuilder(new Properties()); - builder.withMaxRetries(httpMaxRetries); - - builder.limitIoWorkerThreadsTo(poolIoWorkerThreads); - builder.withMaxClientReuse(poolMaxClientReuse); - builder.limitConnectionsPerHostTo(poolMaxClients); - builder.withMaxSessionFailures(poolMaxSessionFailures); - } -} diff --git a/core/src/test/java/org/jclouds/http/IntegrationTestClientExpectTest.java b/core/src/test/java/org/jclouds/http/IntegrationTestClientExpectTest.java index 1eed674207..989eaa25d4 100644 --- a/core/src/test/java/org/jclouds/http/IntegrationTestClientExpectTest.java +++ b/core/src/test/java/org/jclouds/http/IntegrationTestClientExpectTest.java @@ -89,7 +89,7 @@ public class IntegrationTestClientExpectTest extends BaseRestClientExpectTest createProviderMetadata() { + public ProviderMetadata createProviderMetadata() { return new JcloudsTestBlobStoreProviderMetadata(); } } diff --git a/core/src/test/java/org/jclouds/http/handlers/RedirectionRetryHandlerTest.java b/core/src/test/java/org/jclouds/http/handlers/RedirectionRetryHandlerTest.java index db921672db..0ddaa4d482 100644 --- a/core/src/test/java/org/jclouds/http/handlers/RedirectionRetryHandlerTest.java +++ b/core/src/test/java/org/jclouds/http/handlers/RedirectionRetryHandlerTest.java @@ -25,24 +25,22 @@ import static org.easymock.EasyMock.verify; import java.net.URI; -import javax.inject.Named; -import javax.inject.Singleton; import javax.ws.rs.core.HttpHeaders; +import org.jclouds.ContextBuilder; import org.jclouds.http.HttpCommand; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; -import org.jclouds.rest.config.RestModule; +import org.jclouds.http.IntegrationTestAsyncClient; +import org.jclouds.http.IntegrationTestClient; +import org.jclouds.providers.AnonymousProviderMetadata; import org.jclouds.rest.internal.BaseRestClientTest.MockModule; import org.testng.annotations.Test; import com.google.common.collect.ImmutableMultimap; -import com.google.common.collect.LinkedHashMultimap; -import com.google.common.collect.Multimap; -import com.google.inject.AbstractModule; -import com.google.inject.Guice; +import com.google.common.collect.ImmutableSet; import com.google.inject.Injector; -import com.google.inject.Provides; +import com.google.inject.Module; /** * Tests behavior of {@code RedirectionRetryHandler} @@ -51,19 +49,10 @@ import com.google.inject.Provides; */ @Test(groups = "unit") public class RedirectionRetryHandlerTest { - Injector injector = Guice.createInjector(new MockModule(), new RestModule(), new AbstractModule() { - @SuppressWarnings("unused") - @Provides - @Singleton - @Named("CONSTANTS") - protected Multimap constants() { - return LinkedHashMultimap.create(); - } - - @Override - protected void configure() { - } - }); + Injector injector = ContextBuilder.newBuilder( + AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint(IntegrationTestClient.class, + IntegrationTestAsyncClient.class, "http://localhost")).modules( + ImmutableSet. of(new MockModule())).buildInjector(); @Test public void test302DoesNotRetry() { diff --git a/core/src/test/java/org/jclouds/internal/BaseWrapperTest.java b/core/src/test/java/org/jclouds/internal/BaseWrapperTest.java new file mode 100644 index 0000000000..ebda6dfbbe --- /dev/null +++ b/core/src/test/java/org/jclouds/internal/BaseWrapperTest.java @@ -0,0 +1,79 @@ +/** + * 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.internal; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNotEquals; + +import java.io.Closeable; + +import org.testng.annotations.Test; + +import com.google.common.base.Objects; +import com.google.common.reflect.TypeToken; + +/** + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "BaseWrapperTest") +public class BaseWrapperTest { + private static class Water implements Closeable { + + @Override + public void close() { + } + @Override + public boolean equals(Object in){ + return Objects.equal(in.getClass(), getClass()); + } + } + + private static interface PeanutButter extends Closeable { + + @Override + void close(); + } + + private static class Wine extends BaseWrapper { + + protected Wine() { + super(new Water(), TypeToken.of(Water.class)); + } + } + + public void testWaterTurnedIntoWine() { + Wine wine = new Wine(); + assertEquals(wine.getWrappedType(), TypeToken.of(Water.class)); + assertEquals(wine.unwrap(TypeToken.of(Water.class)), new Water()); + assertEquals(wine.unwrap(), new Water()); + } + + public void testPeanutButterDidntTurnIntoWine() { + Wine wine = new Wine(); + assertNotEquals(wine.getWrappedType(), TypeToken.of(PeanutButter.class)); + try { + wine.unwrap(TypeToken.of(PeanutButter.class)); + assertFalse(true); + } catch (IllegalArgumentException e) { + assertEquals(e.getMessage(), "wrapped type: org.jclouds.internal.BaseWrapperTest$Water not assignable from org.jclouds.internal.BaseWrapperTest$PeanutButter"); + } + } + +} diff --git a/core/src/test/java/org/jclouds/providers/JcloudsTestBlobStoreProviderMetadata.java b/core/src/test/java/org/jclouds/providers/JcloudsTestBlobStoreProviderMetadata.java index c04305de97..17e9eb6150 100644 --- a/core/src/test/java/org/jclouds/providers/JcloudsTestBlobStoreProviderMetadata.java +++ b/core/src/test/java/org/jclouds/providers/JcloudsTestBlobStoreProviderMetadata.java @@ -21,10 +21,7 @@ package org.jclouds.providers; import java.net.URI; import org.jclouds.apis.JcloudsTestBlobStoreApiMetadata; -import org.jclouds.http.IntegrationTestAsyncClient; -import org.jclouds.http.IntegrationTestClient; import org.jclouds.providers.internal.BaseProviderMetadata; -import org.jclouds.rest.RestContext; import com.google.common.collect.ImmutableSet; @@ -33,9 +30,10 @@ import com.google.common.collect.ImmutableSet; * * @author Jeremy Whitlock */ -public class JcloudsTestBlobStoreProviderMetadata - extends - BaseProviderMetadata, JcloudsTestBlobStoreApiMetadata> { +public class JcloudsTestBlobStoreProviderMetadata extends BaseProviderMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = -3444555273226423853L; public static Builder builder() { return new Builder(); @@ -54,9 +52,7 @@ public class JcloudsTestBlobStoreProviderMetadata super(builder); } - public static class Builder - extends - BaseProviderMetadata.Builder, JcloudsTestBlobStoreApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder(){ id("test-blobstore-api") diff --git a/core/src/test/java/org/jclouds/providers/JcloudsTestComputeProviderMetadata.java b/core/src/test/java/org/jclouds/providers/JcloudsTestComputeProviderMetadata.java index 60fc513520..36f02db52a 100644 --- a/core/src/test/java/org/jclouds/providers/JcloudsTestComputeProviderMetadata.java +++ b/core/src/test/java/org/jclouds/providers/JcloudsTestComputeProviderMetadata.java @@ -21,10 +21,7 @@ package org.jclouds.providers; import java.net.URI; import org.jclouds.apis.JcloudsTestComputeApiMetadata; -import org.jclouds.http.IntegrationTestAsyncClient; -import org.jclouds.http.IntegrationTestClient; import org.jclouds.providers.internal.BaseProviderMetadata; -import org.jclouds.rest.RestContext; import com.google.common.collect.ImmutableSet; @@ -33,10 +30,11 @@ import com.google.common.collect.ImmutableSet; * * @author Jeremy Whitlock */ -public class JcloudsTestComputeProviderMetadata - extends - BaseProviderMetadata, JcloudsTestComputeApiMetadata> { +public class JcloudsTestComputeProviderMetadata extends BaseProviderMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = 424799830416415960L; + public static Builder builder() { return new Builder(); } @@ -54,9 +52,7 @@ public class JcloudsTestComputeProviderMetadata super(builder); } - public static class Builder - extends - BaseProviderMetadata.Builder, JcloudsTestComputeApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder(){ id("test-compute-api") diff --git a/core/src/test/java/org/jclouds/providers/JcloudsTestYetAnotherComputeProviderMetadata.java b/core/src/test/java/org/jclouds/providers/JcloudsTestYetAnotherComputeProviderMetadata.java index 388ebc9cc1..f72285fe9e 100644 --- a/core/src/test/java/org/jclouds/providers/JcloudsTestYetAnotherComputeProviderMetadata.java +++ b/core/src/test/java/org/jclouds/providers/JcloudsTestYetAnotherComputeProviderMetadata.java @@ -21,10 +21,7 @@ package org.jclouds.providers; import java.net.URI; import org.jclouds.apis.JcloudsTestComputeApiMetadata; -import org.jclouds.http.IntegrationTestAsyncClient; -import org.jclouds.http.IntegrationTestClient; import org.jclouds.providers.internal.BaseProviderMetadata; -import org.jclouds.rest.RestContext; import com.google.common.collect.ImmutableSet; @@ -33,10 +30,11 @@ import com.google.common.collect.ImmutableSet; * * @author Jeremy Whitlock */ -public class JcloudsTestYetAnotherComputeProviderMetadata - extends - BaseProviderMetadata, JcloudsTestComputeApiMetadata> { +public class JcloudsTestYetAnotherComputeProviderMetadata extends BaseProviderMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = 1L; + public static Builder builder() { return new Builder(); } @@ -54,9 +52,7 @@ public class JcloudsTestYetAnotherComputeProviderMetadata super(builder); } - public static class Builder - extends - BaseProviderMetadata.Builder, JcloudsTestComputeApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder(){ id("test-yet-another-compute-provider") diff --git a/core/src/test/java/org/jclouds/providers/ProvidersTest.java b/core/src/test/java/org/jclouds/providers/ProvidersTest.java index 5f6f841d75..465421ee62 100644 --- a/core/src/test/java/org/jclouds/providers/ProvidersTest.java +++ b/core/src/test/java/org/jclouds/providers/ProvidersTest.java @@ -24,7 +24,9 @@ import static org.testng.Assert.fail; import java.util.NoSuchElementException; -import org.jclouds.apis.ApiType; +import org.jclouds.apis.Balancer; +import org.jclouds.apis.Compute; +import org.jclouds.apis.Storage; import org.testng.annotations.Test; import com.google.common.collect.Iterables; @@ -43,7 +45,7 @@ public class ProvidersTest { @Test public void testWithId() { - ProviderMetadata providerMetadata; + ProviderMetadata providerMetadata; try { providerMetadata = Providers.withId("fake-id"); @@ -60,16 +62,16 @@ public class ProvidersTest { } @Test - public void testOfType() { - Iterable> providersMetadata = Providers.ofType(ApiType.BLOBSTORE); + public void testTransformableTo() { + Iterable providersMetadata = Providers.contextWrappableAs(Storage.class); - for (ProviderMetadata providerMetadata : providersMetadata) { + for (ProviderMetadata providerMetadata : providersMetadata) { assertEquals(testBlobstoreProvider, providerMetadata); } - providersMetadata = Providers.ofType(ApiType.COMPUTE); + providersMetadata = Providers.contextWrappableAs(Compute.class); - for (ProviderMetadata providerMetadata : providersMetadata) { + for (ProviderMetadata providerMetadata : providersMetadata) { if (providerMetadata.getName().equals(testComputeProvider.getName())) { assertEquals(testComputeProvider, providerMetadata); } else { @@ -77,16 +79,16 @@ public class ProvidersTest { } } - providersMetadata = Providers.ofType(ApiType.UNRECOGNIZED); + providersMetadata = Providers.contextWrappableAs(Balancer.class); assertEquals(false, providersMetadata.iterator().hasNext()); } - + @Test public void testAll() { - Iterable> providersMetadata = Providers.all(); + Iterable providersMetadata = Providers.all(); - for (ProviderMetadata providerMetadata : providersMetadata) { + for (ProviderMetadata providerMetadata : providersMetadata) { if (providerMetadata.getName().equals(testBlobstoreProvider.getName())) { assertEquals(testBlobstoreProvider, providerMetadata); } else if (providerMetadata.getName().equals(testComputeProvider.getName())) { @@ -108,14 +110,14 @@ public class ProvidersTest { assertEquals(Iterables.size(Providers.boundedByIso3166Code("FAKE-CODE")), 0); // Test filtering by ISO 3166 code and type - assertEquals(Iterables.size(Providers.boundedByIso3166Code("US-CA", ApiType.BLOBSTORE)), 1); - assertEquals(Iterables.size(Providers.boundedByIso3166Code("US-CA", ApiType.COMPUTE)), 1); - assertEquals(Iterables.size(Providers.boundedByIso3166Code("US-FL", ApiType.BLOBSTORE)), 1); - assertEquals(Iterables.size(Providers.boundedByIso3166Code("US-FL", ApiType.COMPUTE)), 0); - assertEquals(Iterables.size(Providers.boundedByIso3166Code("US", ApiType.BLOBSTORE)), 1); - assertEquals(Iterables.size(Providers.boundedByIso3166Code("US", ApiType.COMPUTE)), 1); - assertEquals(Iterables.size(Providers.boundedByIso3166Code("FAKE-CODE", ApiType.BLOBSTORE)), 0); - assertEquals(Iterables.size(Providers.boundedByIso3166Code("FAKE-CODE", ApiType.COMPUTE)), 0); + assertEquals(Iterables.size(Providers.boundedByIso3166Code("US-CA", Storage.class)), 1); + assertEquals(Iterables.size(Providers.boundedByIso3166Code("US-CA", Compute.class)), 1); + assertEquals(Iterables.size(Providers.boundedByIso3166Code("US-FL", Storage.class)), 1); + assertEquals(Iterables.size(Providers.boundedByIso3166Code("US-FL", Compute.class)), 0); + assertEquals(Iterables.size(Providers.boundedByIso3166Code("US", Storage.class)), 1); + assertEquals(Iterables.size(Providers.boundedByIso3166Code("US", Compute.class)), 1); + assertEquals(Iterables.size(Providers.boundedByIso3166Code("FAKE-CODE", Storage.class)), 0); + assertEquals(Iterables.size(Providers.boundedByIso3166Code("FAKE-CODE", Compute.class)), 0); } @Test @@ -127,12 +129,12 @@ public class ProvidersTest { assertEquals(Iterables.size(Providers.collocatedWith(testYetAnotherComputeProvider)), 0); // Test filtering by collocation and type - assertEquals(Iterables.size(Providers.collocatedWith(testBlobstoreProvider, ApiType.BLOBSTORE)), 0); - assertEquals(Iterables.size(Providers.collocatedWith(testBlobstoreProvider, ApiType.COMPUTE)), 1); - assertEquals(Iterables.size(Providers.collocatedWith(testComputeProvider, ApiType.COMPUTE)), 0); - assertEquals(Iterables.size(Providers.collocatedWith(testComputeProvider, ApiType.BLOBSTORE)), 1); - assertEquals(Iterables.size(Providers.collocatedWith(testYetAnotherComputeProvider, ApiType.COMPUTE)), 0); - assertEquals(Iterables.size(Providers.collocatedWith(testYetAnotherComputeProvider, ApiType.BLOBSTORE)), 0); + assertEquals(Iterables.size(Providers.collocatedWith(testBlobstoreProvider, Storage.class)), 0); + assertEquals(Iterables.size(Providers.collocatedWith(testBlobstoreProvider, Compute.class)), 1); + assertEquals(Iterables.size(Providers.collocatedWith(testComputeProvider, Compute.class)), 0); + assertEquals(Iterables.size(Providers.collocatedWith(testComputeProvider, Storage.class)), 1); + assertEquals(Iterables.size(Providers.collocatedWith(testYetAnotherComputeProvider, Compute.class)), 0); + assertEquals(Iterables.size(Providers.collocatedWith(testYetAnotherComputeProvider, Storage.class)), 0); } } diff --git a/core/src/test/java/org/jclouds/providers/internal/BaseProviderMetadataTest.java b/core/src/test/java/org/jclouds/providers/internal/BaseProviderMetadataTest.java index 23ba372edf..70d0e1d412 100644 --- a/core/src/test/java/org/jclouds/providers/internal/BaseProviderMetadataTest.java +++ b/core/src/test/java/org/jclouds/providers/internal/BaseProviderMetadataTest.java @@ -21,16 +21,16 @@ package org.jclouds.providers.internal; import static com.google.common.base.Preconditions.checkNotNull; import static org.testng.Assert.assertEquals; +import java.util.Set; import java.util.logging.Logger; +import org.jclouds.Wrapper; import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.ApiType; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.Providers; import org.testng.annotations.Test; import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; import com.google.common.reflect.TypeToken; /** @@ -38,22 +38,21 @@ import com.google.common.reflect.TypeToken; * @author Jeremy Whitlock */ @Test(groups = "unit") -@SuppressWarnings("rawtypes") public abstract class BaseProviderMetadataTest { private final ProviderMetadata toTest; - private final ApiType expectedType; private final ApiMetadata expectedApi; + private final Set> wrappers; public BaseProviderMetadataTest(ProviderMetadata toTest, ApiMetadata expectedApi) { this.toTest = checkNotNull(toTest, "toTest must be defined"); this.expectedApi = checkNotNull(expectedApi, "expectedApi must be defined"); - this.expectedType = expectedApi.getType(); + this.wrappers = expectedApi.getWrappers(); } @Test public void testWithId() { - ProviderMetadata providerMetadata = Providers.withId(toTest.getId()); + ProviderMetadata providerMetadata = Providers.withId(toTest.getId()); assertEquals(toTest, providerMetadata); assert providerMetadata.getLinkedServices().contains(toTest.getId()); @@ -63,27 +62,23 @@ public abstract class BaseProviderMetadataTest { public void testOfApiContains() { if (expectedApi == null) Logger.getAnonymousLogger().warning("please update your test class"); - ImmutableSet> ofApi = ImmutableSet.copyOf(Providers.apiMetadataAssignableFrom(TypeToken.of(expectedApi.getClass()))); + ImmutableSet ofApi = ImmutableSet.copyOf(Providers.apiMetadataAssignableFrom(TypeToken.of(expectedApi.getClass()))); assert ofApi.contains(toTest) : String.format("%s not found in %s", toTest, ofApi); } - // it is ok to have multiple services in the same classpath (ex. ec2 vs elb) @Test - public void testOfTypeContains() { - ImmutableSet> ofType = ImmutableSet.copyOf(Providers.ofType(expectedType)); - assert ofType.contains(toTest) : String.format("%s not found in %s", toTest, ofType); + public void testTransformableToContains() { + for (TypeToken wrapper : wrappers) { + ImmutableSet ofType = ImmutableSet.copyOf(Providers.contextWrappableAs(wrapper)); + assert ofType.contains(toTest) : String.format("%s not found in %s for %s", toTest, ofType, + wrapper); + } } @Test public void testAllContains() { - ImmutableSet> all = ImmutableSet.copyOf(Providers.all()); + ImmutableSet all = ImmutableSet.copyOf(Providers.all()); assert all.contains(toTest) : String.format("%s not found in %s", toTest, all); } - @Test - @Deprecated - public void testInRestProperties() { - Iterable providers = org.jclouds.rest.Providers.getSupportedProviders(); - assert Iterables.contains(providers, toTest.getId()) : providers; - } } \ No newline at end of file diff --git a/core/src/test/java/org/jclouds/rest/InputParamValidatorTest.java b/core/src/test/java/org/jclouds/rest/InputParamValidatorTest.java index 2859bb17da..81f051abf0 100644 --- a/core/src/test/java/org/jclouds/rest/InputParamValidatorTest.java +++ b/core/src/test/java/org/jclouds/rest/InputParamValidatorTest.java @@ -24,6 +24,7 @@ import java.util.concurrent.TimeUnit; import javax.ws.rs.POST; import javax.ws.rs.PathParam; +import org.jclouds.ContextBuilder; import org.jclouds.concurrent.Timeout; import org.jclouds.http.IntegrationTestAsyncClient; import org.jclouds.http.IntegrationTestClient; @@ -31,7 +32,6 @@ import org.jclouds.predicates.validators.AllLowerCaseValidator; import org.jclouds.providers.AnonymousProviderMetadata; import org.jclouds.rest.annotations.ParamValidators; import org.jclouds.rest.annotations.SkipEncoding; -import org.jclouds.rest.internal.ContextBuilder; import org.jclouds.rest.internal.RestAnnotationProcessor; import org.testng.TestException; import org.testng.annotations.BeforeClass; diff --git a/core/src/test/java/org/jclouds/rest/internal/BaseAsyncClientTest.java b/core/src/test/java/org/jclouds/rest/internal/BaseAsyncClientTest.java index 712785970a..ea1b76fa66 100644 --- a/core/src/test/java/org/jclouds/rest/internal/BaseAsyncClientTest.java +++ b/core/src/test/java/org/jclouds/rest/internal/BaseAsyncClientTest.java @@ -23,6 +23,7 @@ import static com.google.common.base.Preconditions.checkNotNull; import java.io.IOException; import java.util.Properties; +import org.jclouds.ContextBuilder; import org.jclouds.apis.ApiMetadata; import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ParseSax; @@ -75,22 +76,21 @@ public abstract class BaseAsyncClientTest extends BaseRestClientTest { /** * @see org.jclouds.providers.Providers#withId */ - protected ProviderMetadata createProviderMetadata() { + protected ProviderMetadata createProviderMetadata() { return null; } /** * @see org.jclouds.apis.Apis#withId */ - protected ApiMetadata createApiMetadata() { + protected ApiMetadata createApiMetadata() { return null; } protected Injector createInjector() { - ProviderMetadata pm = createProviderMetadata(); + ProviderMetadata pm = createProviderMetadata(); - @SuppressWarnings("unchecked") - ContextBuilder builder = pm != null ? ContextBuilder.newBuilder(pm) : ContextBuilder + ContextBuilder builder = pm != null ? ContextBuilder.newBuilder(pm) : ContextBuilder .newBuilder(ApiMetadata.class.cast(checkNotNull(createApiMetadata(), "either createApiMetadata or createProviderMetadata must be overridden"))); diff --git a/core/src/test/java/org/jclouds/apis/internal/BaseRestApiMetadataTest.java b/core/src/test/java/org/jclouds/rest/internal/BaseRestApiMetadataTest.java similarity index 79% rename from core/src/test/java/org/jclouds/apis/internal/BaseRestApiMetadataTest.java rename to core/src/test/java/org/jclouds/rest/internal/BaseRestApiMetadataTest.java index a6a3bec92b..702e9fe873 100644 --- a/core/src/test/java/org/jclouds/apis/internal/BaseRestApiMetadataTest.java +++ b/core/src/test/java/org/jclouds/rest/internal/BaseRestApiMetadataTest.java @@ -16,13 +16,14 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.apis.internal; +package org.jclouds.rest.internal; import java.util.Set; +import org.jclouds.Wrapper; import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.ApiType; import org.jclouds.apis.Apis; +import org.jclouds.apis.internal.BaseApiMetadataTest; import org.jclouds.rest.RestApiMetadata; import org.jclouds.rest.RestContext; import org.testng.annotations.Test; @@ -37,14 +38,13 @@ import com.google.common.reflect.TypeToken; @Test(groups = "unit") public abstract class BaseRestApiMetadataTest extends BaseApiMetadataTest { - @SuppressWarnings("rawtypes") - public BaseRestApiMetadataTest(RestApiMetadata toTest, ApiType type) { - super(toTest, type); + public BaseRestApiMetadataTest(RestApiMetadata toTest, Set> wrappers) { + super(toTest, wrappers); } @Test public void testContextAssignableFromRestContext() { - Set> all = ImmutableSet.copyOf(Apis.contextAssignableFrom(TypeToken.of(RestContext.class))); + Set all = ImmutableSet.copyOf(Apis.contextAssignableFrom(TypeToken.of(RestContext.class))); assert all.contains(toTest) : String.format("%s not found in %s", toTest, all); } diff --git a/core/src/test/java/org/jclouds/rest/internal/BaseRestClientExpectTest.java b/core/src/test/java/org/jclouds/rest/internal/BaseRestClientExpectTest.java index 21c0f2e7c7..88e6758087 100644 --- a/core/src/test/java/org/jclouds/rest/internal/BaseRestClientExpectTest.java +++ b/core/src/test/java/org/jclouds/rest/internal/BaseRestClientExpectTest.java @@ -25,8 +25,8 @@ import java.io.IOException; import java.util.List; import java.util.Map; import java.util.NoSuchElementException; -import java.util.Map.Entry; import java.util.Properties; +import java.util.Map.Entry; import java.util.concurrent.ExecutorService; import java.util.concurrent.atomic.AtomicInteger; import java.util.logging.Logger; @@ -42,6 +42,7 @@ import org.custommonkey.xmlunit.DifferenceListener; import org.custommonkey.xmlunit.NodeDetail; import org.custommonkey.xmlunit.XMLUnit; import org.jclouds.Constants; +import org.jclouds.ContextBuilder; import org.jclouds.apis.ApiMetadata; import org.jclouds.concurrent.MoreExecutors; import org.jclouds.concurrent.SingleThreaded; @@ -60,6 +61,7 @@ import org.jclouds.io.Payload; import org.jclouds.io.Payloads; import org.jclouds.logging.config.NullLoggingModule; import org.jclouds.providers.ProviderMetadata; +import org.jclouds.rest.RestApiMetadata; import org.jclouds.util.Strings2; import org.testng.annotations.Test; import org.w3c.dom.Node; @@ -355,7 +357,8 @@ public abstract class BaseRestClientExpectTest { } /** - * Compare two requests as instructed by {@link #compareHttpRequestAsType(HttpRequest)} - default is to compare using Objects.equal + * Compare two requests as instructed by {@link #compareHttpRequestAsType(HttpRequest)} - default + * is to compare using Objects.equal */ public boolean httpRequestsAreEqual(HttpRequest a, HttpRequest b) { try { @@ -365,21 +368,22 @@ public abstract class BaseRestClientExpectTest { return false; } - Diff diff = XMLUnit.compareXML(Strings2.toStringAndClose(a.getPayload().getInput()), - Strings2.toStringAndClose(b.getPayload().getInput())); - - // Ignoring whitespace in elements that have other children, xsi:schemaLocation and differences in namespace prefixes + Diff diff = XMLUnit.compareXML(Strings2.toStringAndClose(a.getPayload().getInput()), Strings2 + .toStringAndClose(b.getPayload().getInput())); + + // Ignoring whitespace in elements that have other children, xsi:schemaLocation and + // differences in namespace prefixes diff.overrideDifferenceListener(new DifferenceListener() { @Override public int differenceFound(Difference diff) { - if (diff.getId() == DifferenceConstants.SCHEMA_LOCATION_ID || - diff.getId() == DifferenceConstants.NAMESPACE_PREFIX_ID) { + if (diff.getId() == DifferenceConstants.SCHEMA_LOCATION_ID + || diff.getId() == DifferenceConstants.NAMESPACE_PREFIX_ID) { return RETURN_IGNORE_DIFFERENCE_NODES_IDENTICAL; } if (diff.getId() == DifferenceConstants.TEXT_VALUE_ID) { for (NodeDetail detail : ImmutableSet.of(diff.getControlNodeDetail(), diff.getTestNodeDetail())) { - if (detail.getNode().getParentNode().getChildNodes().getLength() < 2 || - !detail.getValue().trim().isEmpty()) { + if (detail.getNode().getParentNode().getChildNodes().getLength() < 2 + || !detail.getValue().trim().isEmpty()) { return RETURN_ACCEPT_DIFFERENCE; } } @@ -392,7 +396,7 @@ public abstract class BaseRestClientExpectTest { public void skippedComparison(Node node, Node node1) { } }); - + return diff.identical() && Objects.equal(a.getHeaders(), b.getHeaders()); } case JSON: { @@ -416,8 +420,9 @@ public abstract class BaseRestClientExpectTest { public S requestsSendResponses(final Map requestToResponse, Module module) { return requestsSendResponses(requestToResponse, module, setupProperties()); } - - public S requestsSendResponses(final Map requestToResponse, Module module, Properties props) { + + public S requestsSendResponses(final Map requestToResponse, Module module, + Properties props) { return createClient(new Function() { ImmutableBiMap bimap = ImmutableBiMap.copyOf(requestToResponse); @@ -442,7 +447,7 @@ public abstract class BaseRestClientExpectTest { payload.append(renderRequest(request)); } response = HttpResponse.builder().statusCode(500).message("no response configured for request").payload( - Payloads.newStringPayload(payload.toString())).build(); + Payloads.newStringPayload(payload.toString())).build(); } else if (compareHttpRequestAsType(input) == HttpRequestComparisonType.DEFAULT) { // in case hashCode/equals doesn't do a full content check @@ -501,52 +506,51 @@ public abstract class BaseRestClientExpectTest { /** * @see org.jclouds.providers.Providers#withId */ - protected ProviderMetadata createProviderMetadata() { + protected ProviderMetadata createProviderMetadata() { return null; } - + /** * @see org.jclouds.apis.Apis#withId */ - protected ApiMetadata createApiMetadata() { + protected ApiMetadata createApiMetadata() { return null; } - - @SuppressWarnings("unchecked") + protected Injector createInjector(Function fn, Module module, Properties props) { - ContextBuilder builder = null; + ContextBuilder builder = null; if (provider != null) try { - builder = ContextBuilder.newBuilder(provider).credentials(identity, credential); - } catch (NoSuchElementException e){ - Logger.getAnonymousLogger() - .warning("provider [" - + provider - + "] is not setup as META-INF/services/org.jclouds.apis.ApiMetadata or META-INF/services/org.jclouds.providers.ProviderMetadata"); + builder = ContextBuilder.newBuilder(provider).credentials(identity, credential); + } catch (NoSuchElementException e) { + Logger + .getAnonymousLogger() + .warning( + "provider [" + + provider + + "] is not setup as META-INF/services/org.jclouds.apis.ApiMetadata or META-INF/services/org.jclouds.providers.ProviderMetadata"); } - if (builder == null){ - ProviderMetadata pm = createProviderMetadata(); - ApiMetadata am = (pm != null) ? pm.getApiMetadata() : checkNotNull(createApiMetadata(), - "either createApiMetadata or createProviderMetadata must be overridden"); - - builder = pm != null ? ContextBuilder.newBuilder(pm) : ContextBuilder - .newBuilder(ApiMetadata.class.cast(am)); - } - - this.api = builder.getApiMetadata().getApi(); - - return builder.credentials(identity, credential) - .modules(ImmutableSet.of(new ExpectModule(fn), new NullLoggingModule(), module)) - .overrides(setupProperties()).buildInjector(); - } + if (builder == null) { + ProviderMetadata pm = createProviderMetadata(); + ApiMetadata am = (pm != null) ? pm.getApiMetadata() : checkNotNull(createApiMetadata(), + "either createApiMetadata or createProviderMetadata must be overridden"); + builder = pm != null ? ContextBuilder.newBuilder(pm) : ContextBuilder.newBuilder(RestApiMetadata.class.cast(am)); + } + + this.api = RestApiMetadata.class.cast(builder.getApiMetadata()).getApi(); + + return builder.credentials(identity, credential).modules( + ImmutableSet.of(new ExpectModule(fn), new NullLoggingModule(), module)).overrides(setupProperties()) + .buildInjector(); + } /** * override this to supply context-specific parameters during tests. */ protected Properties setupProperties() { - Properties props = new Properties(); - props.put(Constants.PROPERTY_MAX_RETRIES, 1); - return props; + Properties props = new Properties(); + props.put(Constants.PROPERTY_MAX_RETRIES, 1); + return props; } } \ No newline at end of file diff --git a/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java b/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java index 92e4375380..1a97fda1a6 100644 --- a/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java +++ b/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java @@ -69,6 +69,7 @@ import javax.ws.rs.core.UriBuilder; import javax.xml.bind.annotation.XmlRootElement; import org.eclipse.jetty.http.HttpHeaders; +import org.jclouds.ContextBuilder; import org.jclouds.concurrent.Timeout; import org.jclouds.crypto.Crypto; import org.jclouds.date.DateService; @@ -80,7 +81,6 @@ import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequestFilter; import org.jclouds.http.HttpResponse; import org.jclouds.http.IOExceptionRetryHandler; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.functions.ParseFirstJsonValueNamed; import org.jclouds.http.functions.ParseJson; import org.jclouds.http.functions.ParseSax; @@ -173,7 +173,6 @@ import com.sun.jersey.api.uri.UriBuilderImpl; @Test(groups = "unit", testName = "RestAnnotationProcessorTest") public class RestAnnotationProcessorTest extends BaseRestClientTest { - @RequiresHttp @ConfiguresRestClient protected static class CallerModule extends RestClientModule { CallerModule() { diff --git a/core/src/test/java/org/jclouds/util/PatternsTest.java b/core/src/test/java/org/jclouds/util/PatternsTest.java index e10ae7e719..c34739e3a8 100644 --- a/core/src/test/java/org/jclouds/util/PatternsTest.java +++ b/core/src/test/java/org/jclouds/util/PatternsTest.java @@ -77,9 +77,9 @@ public class PatternsTest { public void testREST_CONTEXT_BUILDER() { Matcher matcher = Patterns.REST_CONTEXT_BUILDER - .matcher("org.jclouds.rest.RestContextBuilder"); + .matcher("org.jclouds.rest.ContextBuilder"); assert (matcher.find()); - assertEquals(matcher.group(1), "org.jclouds.rest.RestContextBuilder"); + assertEquals(matcher.group(1), "org.jclouds.rest.ContextBuilder"); assertEquals(matcher.group(2), "java.lang.String"); assertEquals(matcher.group(3), "java.lang.Integer"); @@ -87,9 +87,9 @@ public class PatternsTest { public void testREST_CONTEXT_BUILDERwithSpace() { Matcher matcher = Patterns.REST_CONTEXT_BUILDER - .matcher("org.jclouds.rest.RestContextBuilder"); + .matcher("org.jclouds.rest.ContextBuilder"); assert (matcher.find()); - assertEquals(matcher.group(1), "org.jclouds.rest.RestContextBuilder"); + assertEquals(matcher.group(1), "org.jclouds.rest.ContextBuilder"); assertEquals(matcher.group(2), "java.lang.String"); assertEquals(matcher.group(3), "java.lang.Integer"); } diff --git a/drivers/gae/src/test/java/org/jclouds/gae/config/GoogleAppEngineConfigurationModuleTest.java b/drivers/gae/src/test/java/org/jclouds/gae/config/GoogleAppEngineConfigurationModuleTest.java index a87df3ad1b..c3da90894b 100644 --- a/drivers/gae/src/test/java/org/jclouds/gae/config/GoogleAppEngineConfigurationModuleTest.java +++ b/drivers/gae/src/test/java/org/jclouds/gae/config/GoogleAppEngineConfigurationModuleTest.java @@ -24,11 +24,11 @@ import java.util.concurrent.ExecutorService; import javax.ws.rs.core.UriBuilder; import org.jclouds.Constants; -import org.jclouds.PropertiesBuilder; import org.jclouds.gae.GaeHttpCommandExecutorService; import org.jclouds.http.HttpCommandExecutorService; import org.jclouds.logging.Logger; import org.jclouds.logging.Logger.LoggerFactory; +import org.jclouds.rest.internal.BaseRestApiMetadata; import org.testng.annotations.Test; import com.google.inject.Guice; @@ -46,7 +46,7 @@ import com.sun.jersey.api.uri.UriBuilderImpl; public class GoogleAppEngineConfigurationModuleTest { public void testConfigureBindsClient() { - final Properties properties = new PropertiesBuilder().build(); + final Properties properties = BaseRestApiMetadata.defaultProperties(); Injector i = Guice.createInjector(new GoogleAppEngineConfigurationModule() { @Override diff --git a/labs/aws-elb/src/main/java/org/jclouds/aws/elb/AWSELBProviderMetadata.java b/labs/aws-elb/src/main/java/org/jclouds/aws/elb/AWSELBProviderMetadata.java index 7878225240..5acb74a98a 100644 --- a/labs/aws-elb/src/main/java/org/jclouds/aws/elb/AWSELBProviderMetadata.java +++ b/labs/aws-elb/src/main/java/org/jclouds/aws/elb/AWSELBProviderMetadata.java @@ -33,9 +33,6 @@ import java.util.Properties; import org.jclouds.aws.domain.Region; import org.jclouds.elb.ELBApiMetadata; -import org.jclouds.elb.ELBAsyncClient; -import org.jclouds.elb.ELBClient; -import org.jclouds.loadbalancer.LoadBalancerServiceContext; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -45,8 +42,11 @@ import org.jclouds.providers.internal.BaseProviderMetadata; * * @author Adrian Cole */ -public class AWSELBProviderMetadata extends BaseProviderMetadata, ELBApiMetadata> { +public class AWSELBProviderMetadata extends BaseProviderMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = 7750012233546655021L; + public static Builder builder() { return new Builder(); } @@ -64,7 +64,7 @@ public class AWSELBProviderMetadata extends BaseProviderMetadata, ELBApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder(){ id("aws-elb") @@ -95,13 +95,13 @@ public class AWSELBProviderMetadata extends BaseProviderMetadata()) + .apiMetadata(new ELBApiMetadata()) .defaultProperties(AWSELBProviderMetadata.defaultProperties()); } @Override public Builder fromProviderMetadata( - ProviderMetadata, ELBApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/labs/aws-elb/src/test/java/org/jclouds/aws/elb/AWSELBAsyncClientTest.java b/labs/aws-elb/src/test/java/org/jclouds/aws/elb/AWSELBAsyncClientTest.java index d7d92addb9..8ada4959d7 100644 --- a/labs/aws-elb/src/test/java/org/jclouds/aws/elb/AWSELBAsyncClientTest.java +++ b/labs/aws-elb/src/test/java/org/jclouds/aws/elb/AWSELBAsyncClientTest.java @@ -44,7 +44,7 @@ public class AWSELBAsyncClientTest extends ELBAsyncClientTest { } @Override - public ProviderMetadata createProviderMetadata() { + public ProviderMetadata createProviderMetadata() { return new AWSELBProviderMetadata(); } diff --git a/labs/aws-elb/src/test/java/org/jclouds/aws/elb/AWSELBProviderTest.java b/labs/aws-elb/src/test/java/org/jclouds/aws/elb/AWSELBProviderTest.java index 13a922b5d6..0eac0f13b0 100644 --- a/labs/aws-elb/src/test/java/org/jclouds/aws/elb/AWSELBProviderTest.java +++ b/labs/aws-elb/src/test/java/org/jclouds/aws/elb/AWSELBProviderTest.java @@ -19,8 +19,6 @@ package org.jclouds.aws.elb; import org.jclouds.elb.ELBApiMetadata; -import org.jclouds.elb.ELBAsyncClient; -import org.jclouds.elb.ELBClient; import org.jclouds.providers.internal.BaseProviderMetadataTest; import org.testng.annotations.Test; @@ -33,6 +31,6 @@ import org.testng.annotations.Test; public class AWSELBProviderTest extends BaseProviderMetadataTest { public AWSELBProviderTest() { - super(new AWSELBProviderMetadata(), new ELBApiMetadata()); + super(new AWSELBProviderMetadata(), new ELBApiMetadata()); } } \ No newline at end of file diff --git a/labs/aws-elb/src/test/java/org/jclouds/aws/elb/config/AWSELBLoadBalancerServiceLiveTest.java b/labs/aws-elb/src/test/java/org/jclouds/aws/elb/config/AWSELBLoadBalancerServiceLiveTest.java index 690cfec465..0653d8022e 100644 --- a/labs/aws-elb/src/test/java/org/jclouds/aws/elb/config/AWSELBLoadBalancerServiceLiveTest.java +++ b/labs/aws-elb/src/test/java/org/jclouds/aws/elb/config/AWSELBLoadBalancerServiceLiveTest.java @@ -18,8 +18,6 @@ */ package org.jclouds.aws.elb.config; -import org.jclouds.elb.ELBAsyncClient; -import org.jclouds.elb.ELBClient; import org.jclouds.elb.loadbalancer.ELBLoadBalancerServiceLiveTest; import org.testng.annotations.Test; @@ -28,7 +26,7 @@ import org.testng.annotations.Test; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "AWSELBLoadBalancerServiceLiveTest") -public class AWSELBLoadBalancerServiceLiveTest extends ELBLoadBalancerServiceLiveTest { +public class AWSELBLoadBalancerServiceLiveTest extends ELBLoadBalancerServiceLiveTest { public AWSELBLoadBalancerServiceLiveTest() { provider = "aws-elb"; diff --git a/labs/carrenza-vcloud-director/src/main/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorContextBuilder.java b/labs/carrenza-vcloud-director/src/main/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorContextBuilder.java deleted file mode 100644 index 59fc2c56b9..0000000000 --- a/labs/carrenza-vcloud-director/src/main/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorContextBuilder.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * 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.carrenza.vcloud.director; - -import java.util.List; - -import org.jclouds.carrenza.vcloud.director.config.CarrenzaVCloudDirectorRestClientModule; -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.vcloud.director.v1_5.VCloudDirectorApiMetadata; -import org.jclouds.vcloud.director.v1_5.VCloudDirectorContext; -import org.jclouds.vcloud.director.v1_5.VCloudDirectorContextBuilder; -import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorAsyncClient; -import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorClient; - -import com.google.inject.Module; - -/** - * {@inheritDoc} - * - * @author danikov - */ -public class CarrenzaVCloudDirectorContextBuilder extends VCloudDirectorContextBuilder { - - public CarrenzaVCloudDirectorContextBuilder( - ProviderMetadata providerMetadata) { - super(providerMetadata); - } - - public CarrenzaVCloudDirectorContextBuilder(VCloudDirectorApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { -// modules.add(new CarrenzaVCloudDirectorComputeServiceContextModule()); FIXME: enable when compute service done - } - - @Override - protected void addClientModule(List modules) { - modules.add(new CarrenzaVCloudDirectorRestClientModule()); - } - -} diff --git a/labs/carrenza-vcloud-director/src/main/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorProviderMetadata.java b/labs/carrenza-vcloud-director/src/main/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorProviderMetadata.java index 27745f8cc0..604a30ff45 100644 --- a/labs/carrenza-vcloud-director/src/main/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorProviderMetadata.java +++ b/labs/carrenza-vcloud-director/src/main/java/org/jclouds/carrenza/vcloud/director/CarrenzaVCloudDirectorProviderMetadata.java @@ -19,19 +19,19 @@ package org.jclouds.carrenza.vcloud.director; import static org.jclouds.Constants.PROPERTY_BUILD_VERSION; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.*; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.PROPERTY_VCLOUD_DIRECTOR_DEFAULT_NETWORK; import java.net.URI; import java.util.Properties; +import org.jclouds.carrenza.vcloud.director.config.CarrenzaVCloudDirectorComputeServiceContextModule; +import org.jclouds.carrenza.vcloud.director.config.CarrenzaVCloudDirectorRestClientModule; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; import org.jclouds.vcloud.director.v1_5.VCloudDirectorApiMetadata; -import org.jclouds.vcloud.director.v1_5.VCloudDirectorContext; -import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorAsyncClient; -import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorClient; -import com.google.common.reflect.TypeToken; +import com.google.common.collect.ImmutableSet; +import com.google.inject.Module; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for Carrenza vCloud hosting @@ -39,9 +39,8 @@ import com.google.common.reflect.TypeToken; * @author Adrian Cole * @author grkvlt@apache.org */ -public class CarrenzaVCloudDirectorProviderMetadata - extends - BaseProviderMetadata { +@SuppressWarnings("serial") +public class CarrenzaVCloudDirectorProviderMetadata extends BaseProviderMetadata { public static Builder builder() { return new Builder(); @@ -60,21 +59,21 @@ public class CarrenzaVCloudDirectorProviderMetadata super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = new Properties(); properties.setProperty(PROPERTY_BUILD_VERSION, "1.5.0.464915"); properties.setProperty(PROPERTY_VCLOUD_DIRECTOR_DEFAULT_NETWORK, "orgNet-.*-External"); return properties; } - public static class Builder extends BaseProviderMetadata.Builder { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder() { id("carrenza-vcloud-director") .name("Carrenza vCloud Director") .apiMetadata(new VCloudDirectorApiMetadata().toBuilder() .buildVersion("1.5.0.464915") - .contextBuilder(TypeToken.of(CarrenzaVCloudDirectorContextBuilder.class)) + .defaultModules(ImmutableSet.>of(CarrenzaVCloudDirectorRestClientModule.class, CarrenzaVCloudDirectorComputeServiceContextModule.class)) .build()) .homepage(URI.create("http://carrenza.com/")) .console(URI.create("https://myvdc.carrenza.net/cloud/org/YOUR_ORG_HERE")) @@ -90,7 +89,7 @@ public class CarrenzaVCloudDirectorProviderMetadata @Override public Builder fromProviderMetadata( - ProviderMetadata in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/labs/carrenza-vcloud-director/src/main/java/org/jclouds/carrenza/vcloud/director/config/CarrenzaVCloudDirectorComputeServiceContextModule.java b/labs/carrenza-vcloud-director/src/main/java/org/jclouds/carrenza/vcloud/director/config/CarrenzaVCloudDirectorComputeServiceContextModule.java index 9f1e72b0a7..6077df1516 100644 --- a/labs/carrenza-vcloud-director/src/main/java/org/jclouds/carrenza/vcloud/director/config/CarrenzaVCloudDirectorComputeServiceContextModule.java +++ b/labs/carrenza-vcloud-director/src/main/java/org/jclouds/carrenza/vcloud/director/config/CarrenzaVCloudDirectorComputeServiceContextModule.java @@ -18,13 +18,20 @@ */ package org.jclouds.carrenza.vcloud.director.config; +import com.google.inject.AbstractModule; + /** * per docs, we are to use pool mode. * * @author danikov */ -public class CarrenzaVCloudDirectorComputeServiceContextModule { // FIXME: enable when compute serivce done +public class CarrenzaVCloudDirectorComputeServiceContextModule extends AbstractModule { + + @Override + protected void configure() { + + } // FIXME: enable when compute serivce done //extends VCloudDirectorComputeServiceContextModule { // // @Override diff --git a/labs/carrenza-vcloud-director/src/main/java/org/jclouds/carrenza/vcloud/director/config/CarrenzaVCloudDirectorRestClientModule.java b/labs/carrenza-vcloud-director/src/main/java/org/jclouds/carrenza/vcloud/director/config/CarrenzaVCloudDirectorRestClientModule.java index 52d3647458..da74a8fea6 100644 --- a/labs/carrenza-vcloud-director/src/main/java/org/jclouds/carrenza/vcloud/director/config/CarrenzaVCloudDirectorRestClientModule.java +++ b/labs/carrenza-vcloud-director/src/main/java/org/jclouds/carrenza/vcloud/director/config/CarrenzaVCloudDirectorRestClientModule.java @@ -18,7 +18,6 @@ */ package org.jclouds.carrenza.vcloud.director.config; -import org.jclouds.http.RequiresHttp; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.vcloud.director.v1_5.config.VCloudDirectorRestClientModule; @@ -27,7 +26,6 @@ import org.jclouds.vcloud.director.v1_5.config.VCloudDirectorRestClientModule; * * @author danikov */ -@RequiresHttp @ConfiguresRestClient public class CarrenzaVCloudDirectorRestClientModule extends VCloudDirectorRestClientModule { diff --git a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/SectionType.java b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/SectionType.java index 7b03911274..b8b203be2d 100644 --- a/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/SectionType.java +++ b/labs/dmtf/src/main/java/org/jclouds/dmtf/ovf/SectionType.java @@ -23,7 +23,6 @@ import static org.jclouds.dmtf.DMTFConstants.OVF_NS; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlSeeAlso; import javax.xml.bind.annotation.XmlType; import com.google.common.base.Objects; diff --git a/labs/elb/src/main/java/org/jclouds/elb/ELBApiMetadata.java b/labs/elb/src/main/java/org/jclouds/elb/ELBApiMetadata.java index c0c9df2ecf..53ed7685f9 100644 --- a/labs/elb/src/main/java/org/jclouds/elb/ELBApiMetadata.java +++ b/labs/elb/src/main/java/org/jclouds/elb/ELBApiMetadata.java @@ -25,53 +25,54 @@ import java.net.URI; import java.util.Properties; import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.internal.BaseApiMetadata; +import org.jclouds.elb.config.ELBRestClientModule; +import org.jclouds.elb.loadbalancer.config.ELBLoadBalancerContextModule; import org.jclouds.loadbalancer.LoadBalancerServiceContext; -import org.jclouds.loadbalancer.internal.BaseLoadBalancerServiceApiMetadata; +import org.jclouds.rest.RestContext; +import org.jclouds.rest.internal.BaseRestApiMetadata; +import com.google.common.collect.ImmutableSet; import com.google.common.reflect.TypeToken; +import com.google.inject.Module; /** * Implementation of {@link ApiMetadata} for Amazon's Elastic Load Balancing api. - *

note

- *

- * This class allows overriding of types {@code S}(client) and {@code A}(asyncClient), so that - * children can add additional methods not declared here, such as new features - * from AWS. - *

- * - * This class is not setup to allow a different context than {@link LoadBalancerServiceContext} - * . By doing so, it reduces the type complexity. * * @author Adrian Cole */ -public class ELBApiMetadata extends - BaseLoadBalancerServiceApiMetadata, ELBApiMetadata> { +public class ELBApiMetadata extends BaseRestApiMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = -7077953935392202824L; + + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; @Override - public Builder toBuilder() { - return new Builder(getApi(), getAsyncApi()).fromApiMetadata(this); + public Builder toBuilder() { + return new Builder(getApi(), getAsyncApi()).fromApiMetadata(this); } public ELBApiMetadata() { - this(new Builder(ELBClient.class, ELBAsyncClient.class)); + this(new Builder(ELBClient.class, ELBAsyncClient.class)); } - protected ELBApiMetadata(Builder builder) { + protected ELBApiMetadata(Builder builder) { super(builder); } - protected static Properties defaultProperties() { - Properties properties = BaseApiMetadata.Builder.defaultProperties(); + public static Properties defaultProperties() { + Properties properties = BaseRestApiMetadata.defaultProperties(); properties.setProperty(PROPERTY_AUTH_TAG, "AWS"); properties.setProperty(PROPERTY_HEADER_TAG, "amz"); return properties; } - public static class Builder extends - BaseLoadBalancerServiceApiMetadata.Builder, ELBApiMetadata> { + public static class Builder extends BaseRestApiMetadata.Builder { - protected Builder(Class client, Class asyncClient) { + protected Builder(Class client, Class asyncClient) { + super(client, asyncClient); id("elb") .name("Amazon Elastic Load Balancing Api") .identityName("Access Key ID") @@ -80,19 +81,17 @@ public class ELBApiMetadata exten .defaultProperties(ELBApiMetadata.defaultProperties()) .defaultEndpoint("https://elasticloadbalancing.us-east-1.amazonaws.com") .documentation(URI.create("http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference")) - .javaApi(client, asyncClient) - .contextBuilder(new TypeToken>(getClass()){ - private static final long serialVersionUID = 1L; - }); + .wrapper(LoadBalancerServiceContext.class) + .defaultModules(ImmutableSet.>of(ELBRestClientModule.class, ELBLoadBalancerContextModule.class)); } @Override - public ELBApiMetadata build() { - return new ELBApiMetadata(this); + public ELBApiMetadata build() { + return new ELBApiMetadata(this); } @Override - public Builder fromApiMetadata(ELBApiMetadata in) { + public Builder fromApiMetadata(ApiMetadata in) { super.fromApiMetadata(in); return this; } diff --git a/labs/elb/src/main/java/org/jclouds/elb/ELBContextBuilder.java b/labs/elb/src/main/java/org/jclouds/elb/ELBContextBuilder.java deleted file mode 100644 index 256bd88f51..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/ELBContextBuilder.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * 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.elb; - -import java.util.List; - -import org.jclouds.elb.config.ELBRestClientModule; -import org.jclouds.elb.loadbalancer.config.ELBLoadBalancerContextModule; -import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; -import org.jclouds.loadbalancer.LoadBalancerServiceContext; -import org.jclouds.loadbalancer.LoadBalancerServiceContextBuilder; -import org.jclouds.logging.jdk.config.JDKLoggingModule; -import org.jclouds.providers.ProviderMetadata; - -import com.google.inject.Injector; -import com.google.inject.Module; - -/** - * Creates {@link ELBContext} or {@link Injector} instances based on the most commonly requested - * arguments. - *

- * Note that Threadsafe objects will be bound as singletons to the Injector or Context provided. - *

- *

- * If no Modules are specified, the default {@link JDKLoggingModule logging} and - * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be installed. - * - * @author Adrian Cole - * @see ELBContext - */ -public class ELBContextBuilder extends - LoadBalancerServiceContextBuilder, ELBApiMetadata> { - - public ELBContextBuilder(ProviderMetadata, ELBApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public ELBContextBuilder(ELBApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new ELBLoadBalancerContextModule()); - } - - @Override - protected void addClientModule(List modules) { - modules.add(new ELBRestClientModule()); - } -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/ELBPropertiesBuilder.java b/labs/elb/src/main/java/org/jclouds/elb/ELBPropertiesBuilder.java deleted file mode 100644 index 34766fe0a0..0000000000 --- a/labs/elb/src/main/java/org/jclouds/elb/ELBPropertiesBuilder.java +++ /dev/null @@ -1,51 +0,0 @@ -/** - * 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.elb; - -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AUTH_TAG; -import static org.jclouds.aws.reference.AWSConstants.PROPERTY_HEADER_TAG; - -import java.util.Properties; - -import org.jclouds.PropertiesBuilder; - -/** - * Builds properties used in ELB Clients - * - * @author Adrian Cole - */ -public class ELBPropertiesBuilder extends PropertiesBuilder { - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_AUTH_TAG, "AWS"); - properties.setProperty(PROPERTY_HEADER_TAG, "amz"); - properties.setProperty(PROPERTY_API_VERSION, ELBAsyncClient.VERSION); - properties.setProperty(PROPERTY_ENDPOINT, "https://elasticloadbalancing.us-east-1.amazonaws.com"); - return properties; - } - - - public ELBPropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/labs/elb/src/main/java/org/jclouds/elb/config/ELBRestClientModule.java b/labs/elb/src/main/java/org/jclouds/elb/config/ELBRestClientModule.java index f52fec0e0c..8319a6904c 100644 --- a/labs/elb/src/main/java/org/jclouds/elb/config/ELBRestClientModule.java +++ b/labs/elb/src/main/java/org/jclouds/elb/config/ELBRestClientModule.java @@ -21,7 +21,6 @@ package org.jclouds.elb.config; import org.jclouds.aws.config.FormSigningRestClientModule; import org.jclouds.elb.ELBAsyncClient; import org.jclouds.elb.ELBClient; -import org.jclouds.http.RequiresHttp; import org.jclouds.rest.ConfiguresRestClient; /** @@ -29,7 +28,6 @@ import org.jclouds.rest.ConfiguresRestClient; * * @author Adrian Cole */ -@RequiresHttp @ConfiguresRestClient public class ELBRestClientModule extends FormSigningRestClientModule { public ELBRestClientModule() { diff --git a/labs/elb/src/test/java/org/jclouds/elb/ELBApiMetadataTest.java b/labs/elb/src/test/java/org/jclouds/elb/ELBApiMetadataTest.java index feb103b5b5..b0fc95098e 100644 --- a/labs/elb/src/test/java/org/jclouds/elb/ELBApiMetadataTest.java +++ b/labs/elb/src/test/java/org/jclouds/elb/ELBApiMetadataTest.java @@ -28,7 +28,6 @@ import org.testng.annotations.Test; @Test(groups = "unit", testName = "ELBApiMetadataTest") public class ELBApiMetadataTest extends BaseLoadBalancerServiceApiMetadataTest { - @SuppressWarnings("rawtypes") public ELBApiMetadataTest() { super(new ELBApiMetadata()); } diff --git a/labs/elb/src/test/java/org/jclouds/elb/ELBAsyncClientTest.java b/labs/elb/src/test/java/org/jclouds/elb/ELBAsyncClientTest.java index dcb425dcb2..bd9a10a5e8 100644 --- a/labs/elb/src/test/java/org/jclouds/elb/ELBAsyncClientTest.java +++ b/labs/elb/src/test/java/org/jclouds/elb/ELBAsyncClientTest.java @@ -34,7 +34,6 @@ import org.jclouds.elb.xml.CreateLoadBalancerResponseHandler; import org.jclouds.elb.xml.DescribeLoadBalancersResponseHandler; import org.jclouds.elb.xml.RegisterInstancesWithLoadBalancerResponseHandler; import org.jclouds.http.HttpRequest; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ReleasePayloadAndReturn; import org.jclouds.rest.ConfiguresRestClient; @@ -155,7 +154,6 @@ public class ELBAsyncClientTest extends BaseAsyncClientTest { }; } - @RequiresHttp @ConfiguresRestClient private static final class TestELBRestClientModule extends ELBRestClientModule { @Override @@ -176,8 +174,8 @@ public class ELBAsyncClientTest extends BaseAsyncClientTest { } @Override - public ApiMetadata createApiMetadata() { - return new ELBApiMetadata(); + public ApiMetadata createApiMetadata() { + return new ELBApiMetadata(); } @Override diff --git a/labs/elb/src/test/java/org/jclouds/elb/ELBClientLiveTest.java b/labs/elb/src/test/java/org/jclouds/elb/ELBClientLiveTest.java index 4ac5556e31..effd8e5171 100644 --- a/labs/elb/src/test/java/org/jclouds/elb/ELBClientLiveTest.java +++ b/labs/elb/src/test/java/org/jclouds/elb/ELBClientLiveTest.java @@ -23,33 +23,36 @@ import static org.testng.Assert.assertNotNull; import java.util.Set; +import org.jclouds.apis.BaseContextLiveTest; import org.jclouds.elb.domain.LoadBalancer; -import org.jclouds.loadbalancer.LoadBalancerServiceContext; -import org.jclouds.rest.internal.BaseContextLiveTest; -import org.testng.annotations.AfterGroups; +import org.jclouds.rest.RestContext; +import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import com.google.common.reflect.TypeParameter; +import com.google.common.reflect.TypeToken; + /** * Tests behavior of {@code ELBClient} * * @author Lili Nader */ @Test(groups = "live", singleThreaded = true, testName = "ELBClientLiveTest") -public class ELBClientLiveTest extends BaseContextLiveTest> { +public class ELBClientLiveTest extends BaseContextLiveTest> { public ELBClientLiveTest() { provider = "elb"; } - private ELBClient client; + protected S client; protected String name = "TestLoadBalancer"; @Override @BeforeClass(groups = { "integration", "live" }) public void setupContext() { super.setupContext(); - client = context.getProviderSpecificContext().getApi(); + client = context.getApi(); } @Test @@ -84,12 +87,21 @@ public class ELBClientLiveTest ex client.deleteLoadBalancerInRegion(region, name); } - @AfterGroups(groups = "live") - public void shutdown() { + @AfterClass(groups = { "integration", "live" }) + protected void tearDownContext() { try { testDeleteLoadBalancer(); } finally { - context.close(); + super.tearDownContext(); } } + + @SuppressWarnings({ "serial", "unchecked" }) + @Override + protected TypeToken> contextType() { + return new TypeToken>() { + }.where(new TypeParameter() { + }, (TypeToken) TypeToken.of(ELBClient.class)).where(new TypeParameter() { + }, (TypeToken) TypeToken.of(ELBAsyncClient.class)); + } } diff --git a/labs/elb/src/test/java/org/jclouds/elb/loadbalancer/ELBLoadBalancerServiceLiveTest.java b/labs/elb/src/test/java/org/jclouds/elb/loadbalancer/ELBLoadBalancerServiceLiveTest.java index 4ef29b2ae8..89334a26a1 100644 --- a/labs/elb/src/test/java/org/jclouds/elb/loadbalancer/ELBLoadBalancerServiceLiveTest.java +++ b/labs/elb/src/test/java/org/jclouds/elb/loadbalancer/ELBLoadBalancerServiceLiveTest.java @@ -29,7 +29,6 @@ import org.jclouds.elb.ELBAsyncClient; import org.jclouds.elb.ELBClient; import org.jclouds.elb.domain.LoadBalancer; import org.jclouds.loadbalancer.BaseLoadBalancerServiceLiveTest; -import org.jclouds.loadbalancer.LoadBalancerServiceContext; import org.jclouds.rest.RestContext; import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.Test; @@ -39,7 +38,7 @@ import org.testng.annotations.Test; * @author Lili Nadar */ @Test(groups = "live", singleThreaded = true, testName = "ELBLoadBalancerServiceLiveTest") -public class ELBLoadBalancerServiceLiveTest extends BaseLoadBalancerServiceLiveTest> { +public class ELBLoadBalancerServiceLiveTest extends BaseLoadBalancerServiceLiveTest { public ELBLoadBalancerServiceLiveTest() { provider = "elb"; @@ -53,7 +52,7 @@ public class ELBLoadBalancerServiceLiveTest elbContext = context.getProviderSpecificContext(); + RestContext elbContext = context.unwrap(); // TODO create a LoadBalancer object and an appropriate list method so that this // does not have to be EC2 specific code ELBClient elbClient = elbContext.getApi(); @@ -69,4 +68,6 @@ public class ELBLoadBalancerServiceLiveTest, GleSYSApiMetadata> { +public class GleSYSApiMetadata extends BaseRestApiMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 6725672099385580694L; + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; + @Override public Builder toBuilder() { return new Builder().fromApiMetadata(this); @@ -49,8 +59,8 @@ public class GleSYSApiMetadata super(builder); } - protected static Properties defaultProperties() { - Properties properties = BaseComputeServiceApiMetadata.Builder.defaultProperties(); + public static Properties defaultProperties() { + Properties properties = BaseRestApiMetadata.defaultProperties(); properties.setProperty("jclouds.ssh.max-retries", "5"); properties.setProperty("jclouds.ssh.retry-auth", "true"); return properties; @@ -58,9 +68,10 @@ public class GleSYSApiMetadata public static class Builder extends - BaseComputeServiceApiMetadata.Builder, GleSYSApiMetadata> { + BaseRestApiMetadata.Builder { protected Builder() { + super(GleSYSClient.class, GleSYSAsyncClient.class); id("glesys") .name("GleSYS API") .identityName("Username") @@ -69,8 +80,8 @@ public class GleSYSApiMetadata .version("1") .defaultEndpoint("https://api.glesys.com") .defaultProperties(GleSYSApiMetadata.defaultProperties()) - .javaApi(GleSYSClient.class, GleSYSAsyncClient.class) - .contextBuilder(TypeToken.of(GleSYSContextBuilder.class)); + .wrapper(TypeToken.of(ComputeServiceContext.class)) + .defaultModules(ImmutableSet.>of(GleSYSComputeServiceContextModule.class, GleSYSRestClientModule.class)); } @Override @@ -79,7 +90,7 @@ public class GleSYSApiMetadata } @Override - public Builder fromApiMetadata(GleSYSApiMetadata in) { + public Builder fromApiMetadata(ApiMetadata in) { super.fromApiMetadata(in); return this; } diff --git a/labs/glesys/src/main/java/org/jclouds/glesys/GleSYSContextBuilder.java b/labs/glesys/src/main/java/org/jclouds/glesys/GleSYSContextBuilder.java deleted file mode 100644 index 0f648dfe63..0000000000 --- a/labs/glesys/src/main/java/org/jclouds/glesys/GleSYSContextBuilder.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * 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.glesys; - -import java.util.List; - -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextBuilder; -import org.jclouds.glesys.compute.config.GleSYSComputeServiceContextModule; -import org.jclouds.glesys.config.GleSYSRestClientModule; -import org.jclouds.providers.ProviderMetadata; - -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class GleSYSContextBuilder - extends - ComputeServiceContextBuilder, GleSYSApiMetadata> { - - public GleSYSContextBuilder( - ProviderMetadata, GleSYSApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public GleSYSContextBuilder(GleSYSApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new GleSYSComputeServiceContextModule()); - } - - protected void addClientModule(List modules) { - modules.add(new GleSYSRestClientModule()); - } - -} diff --git a/labs/glesys/src/main/java/org/jclouds/glesys/GleSYSProviderMetadata.java b/labs/glesys/src/main/java/org/jclouds/glesys/GleSYSProviderMetadata.java index 871fe47d79..b2e3b56df6 100644 --- a/labs/glesys/src/main/java/org/jclouds/glesys/GleSYSProviderMetadata.java +++ b/labs/glesys/src/main/java/org/jclouds/glesys/GleSYSProviderMetadata.java @@ -26,7 +26,6 @@ import static org.jclouds.location.reference.LocationConstants.PROPERTY_ZONES; import java.net.URI; import java.util.Properties; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -34,9 +33,10 @@ import org.jclouds.providers.internal.BaseProviderMetadata; * Implementation of {@link org.jclouds.types.ProviderMetadata} for GleSYS. * @author Adrian Cole */ -public class GleSYSProviderMetadata - extends - BaseProviderMetadata, GleSYSApiMetadata> { +public class GleSYSProviderMetadata extends BaseProviderMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 539076518401969165L; public static Builder builder() { return new Builder(); @@ -55,7 +55,7 @@ public class GleSYSProviderMetadata super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = new Properties(); properties.setProperty(PROPERTY_ZONES, "Amsterdam,Falkenberg,New York City,Stockholm"); properties.setProperty(PROPERTY_ZONE + ".Amsterdam." + ISO3166_CODES, "NL-NH"); @@ -66,9 +66,7 @@ public class GleSYSProviderMetadata return properties; } - public static class Builder - extends - BaseProviderMetadata.Builder, GleSYSApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder() { id("glesys") @@ -87,8 +85,7 @@ public class GleSYSProviderMetadata } @Override - public Builder fromProviderMetadata( - ProviderMetadata, GleSYSApiMetadata> in) { + public Builder fromProviderMetadata(ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/labs/glesys/src/main/java/org/jclouds/glesys/compute/GleSYSComputeServiceAdapter.java b/labs/glesys/src/main/java/org/jclouds/glesys/compute/GleSYSComputeServiceAdapter.java index 8027a90676..1fc9e28cea 100644 --- a/labs/glesys/src/main/java/org/jclouds/glesys/compute/GleSYSComputeServiceAdapter.java +++ b/labs/glesys/src/main/java/org/jclouds/glesys/compute/GleSYSComputeServiceAdapter.java @@ -22,8 +22,8 @@ import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import static org.jclouds.concurrent.FutureIterables.transformParallel; -import java.util.Map.Entry; import java.util.Set; +import java.util.Map.Entry; import java.util.concurrent.ExecutorService; import java.util.concurrent.Future; diff --git a/labs/glesys/src/main/java/org/jclouds/glesys/compute/config/GleSYSComputeServiceContextModule.java b/labs/glesys/src/main/java/org/jclouds/glesys/compute/config/GleSYSComputeServiceContextModule.java index 7affeedb3f..162a84e8a2 100644 --- a/labs/glesys/src/main/java/org/jclouds/glesys/compute/config/GleSYSComputeServiceContextModule.java +++ b/labs/glesys/src/main/java/org/jclouds/glesys/compute/config/GleSYSComputeServiceContextModule.java @@ -34,8 +34,6 @@ import org.jclouds.compute.domain.TemplateBuilder; import org.jclouds.compute.options.TemplateOptions; import org.jclouds.domain.Location; import org.jclouds.functions.IdentityFunction; -import org.jclouds.glesys.GleSYSAsyncClient; -import org.jclouds.glesys.GleSYSClient; import org.jclouds.glesys.compute.GleSYSComputeServiceAdapter; import org.jclouds.glesys.compute.functions.DatacenterToLocation; import org.jclouds.glesys.compute.functions.OSTemplateToImage; @@ -55,13 +53,8 @@ import com.google.inject.name.Names; * * @author Adrian Cole */ -public class GleSYSComputeServiceContextModule - extends - ComputeServiceAdapterContextModule { - - public GleSYSComputeServiceContextModule() { - super(GleSYSClient.class, GleSYSAsyncClient.class); - } +public class GleSYSComputeServiceContextModule extends + ComputeServiceAdapterContextModule { @SuppressWarnings({ "unchecked", "rawtypes" }) @Override diff --git a/labs/glesys/src/main/java/org/jclouds/glesys/compute/functions/OSTemplateToImage.java b/labs/glesys/src/main/java/org/jclouds/glesys/compute/functions/OSTemplateToImage.java index 8a10df36e7..3815ddef8f 100644 --- a/labs/glesys/src/main/java/org/jclouds/glesys/compute/functions/OSTemplateToImage.java +++ b/labs/glesys/src/main/java/org/jclouds/glesys/compute/functions/OSTemplateToImage.java @@ -26,8 +26,8 @@ import javax.inject.Singleton; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.ImageBuilder; import org.jclouds.compute.domain.OperatingSystem; -import org.jclouds.compute.domain.OperatingSystem.Builder; import org.jclouds.compute.domain.OsFamilyVersion64Bit; +import org.jclouds.compute.domain.OperatingSystem.Builder; import org.jclouds.glesys.domain.OSTemplate; import com.google.common.base.Function; diff --git a/labs/glesys/src/main/java/org/jclouds/glesys/config/GleSYSRestClientModule.java b/labs/glesys/src/main/java/org/jclouds/glesys/config/GleSYSRestClientModule.java index 5d66ddb4c1..a069b43876 100644 --- a/labs/glesys/src/main/java/org/jclouds/glesys/config/GleSYSRestClientModule.java +++ b/labs/glesys/src/main/java/org/jclouds/glesys/config/GleSYSRestClientModule.java @@ -35,7 +35,6 @@ import org.jclouds.glesys.features.ServerClient; import org.jclouds.glesys.handlers.GleSYSErrorHandler; 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; @@ -53,7 +52,6 @@ import com.google.inject.Scopes; * * @author Adrian Cole */ -@RequiresHttp @ConfiguresRestClient public class GleSYSRestClientModule extends RestClientModule { diff --git a/labs/glesys/src/test/java/org/jclouds/glesys/compute/GleSYSComputeServiceLiveTest.java b/labs/glesys/src/test/java/org/jclouds/glesys/compute/GleSYSComputeServiceLiveTest.java index 3ddec09ef4..d71b9386f2 100644 --- a/labs/glesys/src/test/java/org/jclouds/glesys/compute/GleSYSComputeServiceLiveTest.java +++ b/labs/glesys/src/test/java/org/jclouds/glesys/compute/GleSYSComputeServiceLiveTest.java @@ -18,11 +18,8 @@ */ package org.jclouds.glesys.compute; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.internal.BaseComputeServiceLiveTest; -import org.jclouds.glesys.GleSYSAsyncClient; -import org.jclouds.glesys.GleSYSClient; import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.Test; @@ -36,9 +33,7 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", enabled = true, singleThreaded = true) -public class GleSYSComputeServiceLiveTest - extends - BaseComputeServiceLiveTest> { +public class GleSYSComputeServiceLiveTest extends BaseComputeServiceLiveTest { public GleSYSComputeServiceLiveTest() { provider = "glesys"; diff --git a/labs/glesys/src/test/java/org/jclouds/glesys/compute/GleSYSExperimentExpectTest.java b/labs/glesys/src/test/java/org/jclouds/glesys/compute/GleSYSExperimentExpectTest.java index 34824b495f..1dc7ca53e4 100644 --- a/labs/glesys/src/test/java/org/jclouds/glesys/compute/GleSYSExperimentExpectTest.java +++ b/labs/glesys/src/test/java/org/jclouds/glesys/compute/GleSYSExperimentExpectTest.java @@ -33,7 +33,7 @@ public class GleSYSExperimentExpectTest extends BaseGleSYSComputeServiceExpectTe @Test public void testAndExperiment() { - ComputeServiceContext context = null; + ComputeServiceContext context = null; try { context = computeContextForKnownArgumentsAndConstantPassword(); diff --git a/labs/glesys/src/test/java/org/jclouds/glesys/compute/GleSYSExperimentLiveTest.java b/labs/glesys/src/test/java/org/jclouds/glesys/compute/GleSYSExperimentLiveTest.java index 357ad48039..6a7eb4f2ab 100644 --- a/labs/glesys/src/test/java/org/jclouds/glesys/compute/GleSYSExperimentLiveTest.java +++ b/labs/glesys/src/test/java/org/jclouds/glesys/compute/GleSYSExperimentLiveTest.java @@ -20,11 +20,9 @@ package org.jclouds.glesys.compute; import static org.testng.Assert.assertEquals; +import org.jclouds.ContextBuilder; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextBuilder; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; -import org.jclouds.glesys.GleSYSAsyncClient; -import org.jclouds.glesys.GleSYSClient; import org.jclouds.glesys.GleSYSProviderMetadata; import org.testng.annotations.Test; @@ -35,9 +33,7 @@ import com.google.common.io.Closeables; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "GleSYSExperimentLiveTest") -public class GleSYSExperimentLiveTest - extends - BaseComputeServiceContextLiveTest> { +public class GleSYSExperimentLiveTest extends BaseComputeServiceContextLiveTest { public GleSYSExperimentLiveTest() { provider = "glesys"; @@ -45,13 +41,13 @@ public class GleSYSExperimentLiveTest @Test public void testAndExperiment() { - ComputeServiceContext context = null; + ComputeServiceContext context = null; try { - context = ComputeServiceContextBuilder + context = ContextBuilder .newBuilder(new GleSYSProviderMetadata()) .overrides(setupProperties()) - .modules(setupModules()).build(); + .modules(setupModules()).build(ComputeServiceContext.class); assertEquals(context.getComputeService().listAssignableLocations().size(), 4); diff --git a/labs/glesys/src/test/java/org/jclouds/glesys/compute/GleSYSTemplateBuilderLiveTest.java b/labs/glesys/src/test/java/org/jclouds/glesys/compute/GleSYSTemplateBuilderLiveTest.java index 55f19450e1..5f5844e624 100644 --- a/labs/glesys/src/test/java/org/jclouds/glesys/compute/GleSYSTemplateBuilderLiveTest.java +++ b/labs/glesys/src/test/java/org/jclouds/glesys/compute/GleSYSTemplateBuilderLiveTest.java @@ -25,14 +25,11 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.util.Set; -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.compute.domain.Volume; import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; -import org.jclouds.glesys.GleSYSAsyncClient; -import org.jclouds.glesys.GleSYSClient; import org.jclouds.glesys.compute.options.GleSYSTemplateOptions; import org.testng.annotations.Test; @@ -45,9 +42,7 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live", testName = "GleSYSTemplateBuilderLiveTest") -public class GleSYSTemplateBuilderLiveTest - extends - BaseTemplateBuilderLiveTest> { +public class GleSYSTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { public GleSYSTemplateBuilderLiveTest() { provider = "glesys"; diff --git a/labs/glesys/src/test/java/org/jclouds/glesys/compute/functions/ServerSpecToHardwareTest.java b/labs/glesys/src/test/java/org/jclouds/glesys/compute/functions/ServerSpecToHardwareTest.java index 52a047fd53..bfb8500798 100644 --- a/labs/glesys/src/test/java/org/jclouds/glesys/compute/functions/ServerSpecToHardwareTest.java +++ b/labs/glesys/src/test/java/org/jclouds/glesys/compute/functions/ServerSpecToHardwareTest.java @@ -31,7 +31,7 @@ public class ServerSpecToHardwareTest extends BaseGleSYSComputeServiceExpectTest @Test public void testHardwareRequest() { - ServerSpecToHardware toTest = injectorForKnownArgumentsAndConstantPassword().getInstance(ServerSpecToHardware.class); + injectorForKnownArgumentsAndConstantPassword().getInstance(ServerSpecToHardware.class); } diff --git a/labs/glesys/src/test/java/org/jclouds/glesys/compute/internal/BaseGleSYSComputeServiceExpectTest.java b/labs/glesys/src/test/java/org/jclouds/glesys/compute/internal/BaseGleSYSComputeServiceExpectTest.java index 4e7ee5251e..516d4342bd 100644 --- a/labs/glesys/src/test/java/org/jclouds/glesys/compute/internal/BaseGleSYSComputeServiceExpectTest.java +++ b/labs/glesys/src/test/java/org/jclouds/glesys/compute/internal/BaseGleSYSComputeServiceExpectTest.java @@ -50,7 +50,7 @@ public abstract class BaseGleSYSComputeServiceExpectTest extends BaseRestClientE } @Override - protected ApiMetadata createApiMetadata() { + protected ApiMetadata createApiMetadata() { return new GleSYSApiMetadata(); } @@ -76,7 +76,7 @@ public abstract class BaseGleSYSComputeServiceExpectTest extends BaseRestClientE return computeContextForKnownArgumentsAndConstantPassword(requestsResponses).utils().injector(); } - protected ComputeServiceContext computeContextForKnownArgumentsAndConstantPassword( + protected ComputeServiceContext computeContextForKnownArgumentsAndConstantPassword( Map requestsResponses) { return requestsSendResponses( ImmutableMap @@ -109,7 +109,7 @@ public abstract class BaseGleSYSComputeServiceExpectTest extends BaseRestClientE }).getContext(); } - protected ComputeServiceContext computeContextForKnownArgumentsAndConstantPassword() { + protected ComputeServiceContext computeContextForKnownArgumentsAndConstantPassword() { return computeContextForKnownArgumentsAndConstantPassword(ImmutableMap. of()); } } diff --git a/labs/glesys/src/test/java/org/jclouds/glesys/features/ArchiveClientExpectTest.java b/labs/glesys/src/test/java/org/jclouds/glesys/features/ArchiveClientExpectTest.java index cd284e7c16..b7d165ff4f 100644 --- a/labs/glesys/src/test/java/org/jclouds/glesys/features/ArchiveClientExpectTest.java +++ b/labs/glesys/src/test/java/org/jclouds/glesys/features/ArchiveClientExpectTest.java @@ -33,8 +33,8 @@ import org.jclouds.glesys.domain.ArchiveDetails; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; import org.jclouds.http.HttpResponseException; -import org.jclouds.rest.internal.BaseRestClientExpectTest; import org.jclouds.rest.ResourceNotFoundException; +import org.jclouds.rest.internal.BaseRestClientExpectTest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; diff --git a/labs/glesys/src/test/java/org/jclouds/glesys/features/DomainClientExpectTest.java b/labs/glesys/src/test/java/org/jclouds/glesys/features/DomainClientExpectTest.java index 50de7966df..f03e3ada48 100644 --- a/labs/glesys/src/test/java/org/jclouds/glesys/features/DomainClientExpectTest.java +++ b/labs/glesys/src/test/java/org/jclouds/glesys/features/DomainClientExpectTest.java @@ -33,8 +33,8 @@ import org.jclouds.glesys.domain.DomainRecord; import org.jclouds.glesys.options.AddDomainOptions; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; -import org.jclouds.rest.internal.BaseRestClientExpectTest; import org.jclouds.rest.ResourceNotFoundException; +import org.jclouds.rest.internal.BaseRestClientExpectTest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableMultimap; diff --git a/labs/glesys/src/test/java/org/jclouds/glesys/features/EmailClientExpectTest.java b/labs/glesys/src/test/java/org/jclouds/glesys/features/EmailClientExpectTest.java index 17b3a01f73..c27bf7dd0d 100644 --- a/labs/glesys/src/test/java/org/jclouds/glesys/features/EmailClientExpectTest.java +++ b/labs/glesys/src/test/java/org/jclouds/glesys/features/EmailClientExpectTest.java @@ -36,8 +36,8 @@ import org.jclouds.glesys.domain.EmailOverviewSummary; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; import org.jclouds.rest.AuthorizationException; -import org.jclouds.rest.internal.BaseRestClientExpectTest; import org.jclouds.rest.ResourceNotFoundException; +import org.jclouds.rest.internal.BaseRestClientExpectTest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableMultimap; diff --git a/labs/glesys/src/test/java/org/jclouds/glesys/features/ServerClientExpectTest.java b/labs/glesys/src/test/java/org/jclouds/glesys/features/ServerClientExpectTest.java index 53b2261dde..c6d591d19a 100644 --- a/labs/glesys/src/test/java/org/jclouds/glesys/features/ServerClientExpectTest.java +++ b/labs/glesys/src/test/java/org/jclouds/glesys/features/ServerClientExpectTest.java @@ -47,8 +47,8 @@ import org.jclouds.glesys.options.ServerStatusOptions; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; import org.jclouds.rest.AuthorizationException; -import org.jclouds.rest.internal.BaseRestClientExpectTest; import org.jclouds.rest.ResourceNotFoundException; +import org.jclouds.rest.internal.BaseRestClientExpectTest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableMultimap; diff --git a/labs/glesys/src/test/java/org/jclouds/glesys/internal/BaseGleSYSAsyncClientTest.java b/labs/glesys/src/test/java/org/jclouds/glesys/internal/BaseGleSYSAsyncClientTest.java index ae89a53dcc..eb767553ef 100644 --- a/labs/glesys/src/test/java/org/jclouds/glesys/internal/BaseGleSYSAsyncClientTest.java +++ b/labs/glesys/src/test/java/org/jclouds/glesys/internal/BaseGleSYSAsyncClientTest.java @@ -38,7 +38,7 @@ public abstract class BaseGleSYSAsyncClientTest extends BaseAsyncClientTest createProviderMetadata() { + public ProviderMetadata createProviderMetadata() { return new GleSYSProviderMetadata(); } } diff --git a/labs/glesys/src/test/java/org/jclouds/glesys/internal/BaseGleSYSClientLiveTest.java b/labs/glesys/src/test/java/org/jclouds/glesys/internal/BaseGleSYSClientLiveTest.java index 753d78c6cb..9c826505a0 100644 --- a/labs/glesys/src/test/java/org/jclouds/glesys/internal/BaseGleSYSClientLiveTest.java +++ b/labs/glesys/src/test/java/org/jclouds/glesys/internal/BaseGleSYSClientLiveTest.java @@ -26,7 +26,6 @@ import static org.testng.Assert.assertTrue; import java.util.UUID; import java.util.concurrent.TimeUnit; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.glesys.GleSYSAsyncClient; import org.jclouds.glesys.GleSYSClient; @@ -50,9 +49,7 @@ import com.google.common.base.Predicate; * @author Adrian Cole, Adam Lowe */ @Test(groups = "live") -public class BaseGleSYSClientLiveTest - extends - BaseComputeServiceContextLiveTest> { +public class BaseGleSYSClientLiveTest extends BaseComputeServiceContextLiveTest { protected RestContext gleContext; @@ -64,7 +61,7 @@ public class BaseGleSYSClientLiveTest @Override public void setupContext() { super.setupContext(); - gleContext = context.getProviderSpecificContext(); + gleContext = context.unwrap(); } protected void createDomain(String domain) { diff --git a/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/OpSourceServersApiMetadata.java b/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/OpSourceServersApiMetadata.java index b94c0faac3..c96b3d3beb 100644 --- a/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/OpSourceServersApiMetadata.java +++ b/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/OpSourceServersApiMetadata.java @@ -22,21 +22,24 @@ import java.net.URI; import java.util.Properties; import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.ApiType; +import org.jclouds.opsource.servers.config.OpSourceServersRestClientModule; import org.jclouds.rest.RestContext; import org.jclouds.rest.internal.BaseRestApiMetadata; import com.google.common.reflect.TypeToken; /** - * Implementation of {@link ApiMetadata} for API + * Implementation of {@link ApiMetadata} for API * * @author Adrian Cole */ -public class OpSourceServersApiMetadata - extends - BaseRestApiMetadata, OpSourceServersApiMetadata> { +public class OpSourceServersApiMetadata extends BaseRestApiMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = 6725672099385580694L; + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; @Override public Builder toBuilder() { return new Builder().fromApiMetadata(this); @@ -50,14 +53,14 @@ public class OpSourceServersApiMetadata super(builder); } - protected static Properties defaultProperties() { - Properties properties = BaseRestApiMetadata.Builder.defaultProperties(); + public static Properties defaultProperties() { + Properties properties = BaseRestApiMetadata.defaultProperties(); return properties; } public static class Builder extends - BaseRestApiMetadata.Builder, OpSourceServersApiMetadata> { + BaseRestApiMetadata.Builder { protected Builder() { super(OpSourceServersClient.class, OpSourceServersAsyncClient.class); @@ -68,8 +71,10 @@ public class OpSourceServersApiMetadata .documentation(URI.create("http://www.opsource.net/Services/Cloud-Hosting/Open-API")) .version("0.9") .defaultEndpoint("https://api.opsourcecloud.net/oec/${jclouds.api-version}") - .type(ApiType.COMPUTE) - .contextBuilder(TypeToken.of(OpSourceServersContextBuilder.class)); + .defaultProperties(OpSourceServersApiMetadata.defaultProperties()) + .defaultModule(OpSourceServersRestClientModule.class); +// .wrapper(TypeToken.of(ComputeServiceContext.class)) +// .defaultModules(ImmutableSet.>of(OpSourceServersRestClientModule.class, OpSourceServersComputeServiceContextModule.class)); } @Override @@ -78,7 +83,7 @@ public class OpSourceServersApiMetadata } @Override - public Builder fromApiMetadata(OpSourceServersApiMetadata in) { + public Builder fromApiMetadata(ApiMetadata in) { super.fromApiMetadata(in); return this; } diff --git a/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/OpSourceServersContextBuilder.java b/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/OpSourceServersContextBuilder.java deleted file mode 100644 index ab7ef8b6e9..0000000000 --- a/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/OpSourceServersContextBuilder.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * 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.opsource.servers; - -import java.util.List; - -import org.jclouds.opsource.servers.config.OpSourceServersRestClientModule; -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.rest.RestContext; -import org.jclouds.rest.RestContextBuilder; - -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class OpSourceServersContextBuilder - extends - RestContextBuilder, OpSourceServersApiMetadata> { - - public OpSourceServersContextBuilder( - ProviderMetadata, OpSourceServersApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public OpSourceServersContextBuilder(OpSourceServersApiMetadata apiMetadata) { - super(apiMetadata); - } -// -// @Override -// protected void addContextModule(List modules) { -// modules.add(new OpSourceServersComputeServiceContextModule()); -// } - - protected void addClientModule(List modules) { - modules.add(new OpSourceServersRestClientModule()); - } - -} diff --git a/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/config/OpSourceServersRestClientModule.java b/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/config/OpSourceServersRestClientModule.java index 98449c91a6..99cd087b7f 100644 --- a/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/config/OpSourceServersRestClientModule.java +++ b/labs/opsource-servers/src/main/java/org/jclouds/opsource/servers/config/OpSourceServersRestClientModule.java @@ -20,7 +20,6 @@ package org.jclouds.opsource.servers.config; import java.util.Map; import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.ServerError; @@ -46,7 +45,6 @@ import com.google.inject.Scopes; * * @author Adrian Cole */ -@RequiresHttp @ConfiguresRestClient public class OpSourceServersRestClientModule extends RestClientModule { diff --git a/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/internal/BaseOpSourceServersClientLiveTest.java b/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/internal/BaseOpSourceServersClientLiveTest.java index 3d6ee073f0..e3fef3bcf1 100644 --- a/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/internal/BaseOpSourceServersClientLiveTest.java +++ b/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/internal/BaseOpSourceServersClientLiveTest.java @@ -18,24 +18,24 @@ */ package org.jclouds.opsource.servers.internal; -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; +import org.jclouds.apis.BaseContextLiveTest; +import org.jclouds.opsource.servers.OpSourceServersApiMetadata; import org.jclouds.opsource.servers.OpSourceServersAsyncClient; import org.jclouds.opsource.servers.OpSourceServersClient; import org.jclouds.rest.RestContext; import org.testng.annotations.BeforeGroups; import org.testng.annotations.Test; +import com.google.common.reflect.TypeToken; + /** - * Tests behavior of {@link OpSourceServersClient} and acts as parent for other - * client live tests. + * Tests behavior of {@link OpSourceServersClient} and acts as parent for other client live tests. * * @author Adrian Cole */ @Test(groups = "live") -public abstract class BaseOpSourceServersClientLiveTest - extends - BaseComputeServiceContextLiveTest> { +public abstract class BaseOpSourceServersClientLiveTest extends + BaseContextLiveTest> { protected BaseOpSourceServersClientLiveTest() { provider = "opsource-servers"; @@ -47,7 +47,12 @@ public abstract class BaseOpSourceServersClientLiveTest @Override public void setupContext() { super.setupContext(); - restContext = context.getProviderSpecificContext(); + restContext = context; + } + + @Override + protected TypeToken> contextType() { + return OpSourceServersApiMetadata.CONTEXT_TOKEN; } } diff --git a/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/internal/BaseOpSourceServersRestClientExpectTest.java b/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/internal/BaseOpSourceServersRestClientExpectTest.java index 217fedf1e6..5ff428ffbf 100644 --- a/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/internal/BaseOpSourceServersRestClientExpectTest.java +++ b/labs/opsource-servers/src/test/java/org/jclouds/opsource/servers/internal/BaseOpSourceServersRestClientExpectTest.java @@ -37,7 +37,7 @@ public class BaseOpSourceServersRestClientExpectTest extends BaseRestClientExpec } @Override - protected ApiMetadata createApiMetadata() { + protected ApiMetadata createApiMetadata() { return new OpSourceServersApiMetadata(); } } diff --git a/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCApiMetadata.java b/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCApiMetadata.java index cf25f6862e..912297047c 100644 --- a/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCApiMetadata.java +++ b/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCApiMetadata.java @@ -23,21 +23,31 @@ import static org.jclouds.savvis.vpdc.reference.VPDCConstants.PROPERTY_VPDC_TIME import java.net.URI; import java.util.Properties; -import org.jclouds.apis.ApiType; +import org.jclouds.apis.ApiMetadata; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; +import org.jclouds.rest.RestContext; +import org.jclouds.rest.internal.BaseRestApiMetadata; +import org.jclouds.savvis.vpdc.compute.config.VPDCComputeServiceContextModule; +import org.jclouds.savvis.vpdc.config.VPDCRestClientModule; +import com.google.common.collect.ImmutableSet; import com.google.common.reflect.TypeToken; +import com.google.inject.Module; /** * Implementation of {@link org.jclouds.types.ApiMetadata} for Savvis Symphony VPDC services. * * @author Kedar Dave */ -public class VPDCApiMetadata - extends - BaseComputeServiceApiMetadata, VPDCApiMetadata> { +public class VPDCApiMetadata extends BaseRestApiMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 6725672099385580694L; + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; + @Override public Builder toBuilder() { return new Builder().fromApiMetadata(this); @@ -51,19 +61,19 @@ public class VPDCApiMetadata super(builder); } - protected static Properties defaultProperties() { - Properties properties = BaseComputeServiceApiMetadata.Builder.defaultProperties(); + public static Properties defaultProperties() { + Properties properties = BaseRestApiMetadata.defaultProperties(); properties.setProperty(PROPERTY_VPDC_TIMEOUT_TASK_COMPLETED, 600l * 1000l + ""); return properties; } public static class Builder extends - BaseComputeServiceApiMetadata.Builder, VPDCApiMetadata> { + BaseRestApiMetadata.Builder { protected Builder() { + super(VPDCClient.class, VPDCAsyncClient.class); id("savvis-symphonyvpdc") - .type(ApiType.COMPUTE) .name("Savvis Symphony VPDC API") .identityName("Username") .credentialName("Password") @@ -72,8 +82,9 @@ public class VPDCApiMetadata .buildVersion("2.3") .defaultEndpoint("https://api.savvis.net/vpdc") .defaultProperties(VPDCApiMetadata.defaultProperties()) - .javaApi(VPDCClient.class, VPDCAsyncClient.class) - .contextBuilder(TypeToken.of(VPDCContextBuilder.class)); + .wrapper(TypeToken.of(ComputeServiceContext.class)) + .defaultModules(ImmutableSet.>of(VPDCRestClientModule.class, VPDCComputeServiceContextModule.class)); + } @Override @@ -82,7 +93,7 @@ public class VPDCApiMetadata } @Override - public Builder fromApiMetadata(VPDCApiMetadata in) { + public Builder fromApiMetadata(ApiMetadata in) { super.fromApiMetadata(in); return this; } diff --git a/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCContextBuilder.java b/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCContextBuilder.java deleted file mode 100644 index 6934caea2e..0000000000 --- a/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCContextBuilder.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * 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.savvis.vpdc; - -import java.util.List; - -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextBuilder; -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.savvis.vpdc.compute.config.VPDCComputeServiceContextModule; -import org.jclouds.savvis.vpdc.config.VPDCRestClientModule; - -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class VPDCContextBuilder - extends - ComputeServiceContextBuilder, VPDCApiMetadata> { - - public VPDCContextBuilder( - ProviderMetadata, VPDCApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public VPDCContextBuilder(VPDCApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new VPDCComputeServiceContextModule()); - } - - protected void addClientModule(List modules) { - modules.add(new VPDCRestClientModule()); - } - -} diff --git a/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCPropertiesBuilder.java b/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCPropertiesBuilder.java deleted file mode 100644 index d2a678d286..0000000000 --- a/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCPropertiesBuilder.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * 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.savvis.vpdc; - -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_BUILD_VERSION; -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.savvis.vpdc.reference.VPDCConstants.PROPERTY_VPDC_TIMEOUT_TASK_COMPLETED; - -import java.util.Properties; - -import org.jclouds.PropertiesBuilder; - -/** - * Builds properties used in Symphony VPDC Clients - * - * @author Adrian Cole - */ -public class VPDCPropertiesBuilder extends PropertiesBuilder { - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_API_VERSION, "1.0"); - properties.setProperty(PROPERTY_BUILD_VERSION, "2.3"); - properties.setProperty(PROPERTY_ENDPOINT, "https://api.savvis.net/vpdc"); - properties.setProperty(PROPERTY_VPDC_TIMEOUT_TASK_COMPLETED, 600l * 1000l + ""); - return properties; - } - - public VPDCPropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCProviderMetadata.java b/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCProviderMetadata.java index 31bbf4ccc7..ad762aa89c 100644 --- a/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCProviderMetadata.java +++ b/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/VPDCProviderMetadata.java @@ -21,7 +21,6 @@ package org.jclouds.savvis.vpdc; import java.net.URI; import java.util.Properties; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -30,9 +29,10 @@ import org.jclouds.providers.internal.BaseProviderMetadata; * * @author Kedar Dave */ -public class VPDCProviderMetadata - extends - BaseProviderMetadata, VPDCApiMetadata> { +public class VPDCProviderMetadata extends BaseProviderMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = -3438042651384066520L; public static Builder builder() { return new Builder(); @@ -51,14 +51,12 @@ public class VPDCProviderMetadata super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = new Properties(); return properties; } - public static class Builder - extends - BaseProviderMetadata.Builder, VPDCApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder() { id("savvis-symphonyvpdc") @@ -113,8 +111,7 @@ public class VPDCProviderMetadata } @Override - public Builder fromProviderMetadata( - ProviderMetadata, VPDCApiMetadata> in) { + public Builder fromProviderMetadata(ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/compute/config/VPDCComputeServiceContextModule.java b/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/compute/config/VPDCComputeServiceContextModule.java index 6a7cd4b9b6..8eabbc9101 100644 --- a/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/compute/config/VPDCComputeServiceContextModule.java +++ b/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/compute/config/VPDCComputeServiceContextModule.java @@ -26,8 +26,6 @@ import org.jclouds.compute.domain.CIMOperatingSystem; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.TemplateBuilder; import org.jclouds.domain.Location; -import org.jclouds.savvis.vpdc.VPDCAsyncClient; -import org.jclouds.savvis.vpdc.VPDCClient; import org.jclouds.savvis.vpdc.compute.functions.CIMOperatingSystemToImage; import org.jclouds.savvis.vpdc.compute.functions.NetworkToLocation; import org.jclouds.savvis.vpdc.compute.functions.VMSpecToHardware; @@ -46,11 +44,7 @@ import com.google.inject.TypeLiteral; * @author Adrian Cole */ public class VPDCComputeServiceContextModule extends - ComputeServiceAdapterContextModule { - - public VPDCComputeServiceContextModule() { - super(VPDCClient.class, VPDCAsyncClient.class); - } + ComputeServiceAdapterContextModule { @Override protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) { diff --git a/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/config/VPDCRestClientModule.java b/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/config/VPDCRestClientModule.java index 68a0778e4f..98bd9e08fe 100644 --- a/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/config/VPDCRestClientModule.java +++ b/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/config/VPDCRestClientModule.java @@ -41,6 +41,7 @@ import org.jclouds.json.Json; import org.jclouds.location.Provider; import org.jclouds.location.suppliers.ImplicitLocationSupplier; import org.jclouds.predicates.RetryablePredicate; +import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.config.RestClientModule; import org.jclouds.rest.suppliers.MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier; import org.jclouds.savvis.vpdc.VPDCAsyncClient; @@ -78,6 +79,7 @@ import com.google.inject.TypeLiteral; * @author Adrian Cole * */ +@ConfiguresRestClient public class VPDCRestClientModule extends RestClientModule { @Override protected void configure() { diff --git a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/compute/VPDCComputeServiceLiveTestDisabled.java b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/compute/VPDCComputeServiceLiveTestDisabled.java index 2c56d36d61..d2fddffa66 100644 --- a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/compute/VPDCComputeServiceLiveTestDisabled.java +++ b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/compute/VPDCComputeServiceLiveTestDisabled.java @@ -21,11 +21,8 @@ package org.jclouds.savvis.vpdc.compute; import java.util.Properties; import org.jclouds.Constants; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.internal.BaseComputeServiceLiveTest; -import org.jclouds.savvis.vpdc.VPDCAsyncClient; -import org.jclouds.savvis.vpdc.VPDCClient; import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.Test; @@ -41,9 +38,7 @@ import com.google.inject.Module; * */ @Test(enabled = true, groups = "live") -public class VPDCComputeServiceLiveTestDisabled - extends - BaseComputeServiceLiveTest> { +public class VPDCComputeServiceLiveTestDisabled extends BaseComputeServiceLiveTest { public VPDCComputeServiceLiveTestDisabled() { provider = "savvis-symphonyvpdc"; diff --git a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/compute/VPDCTemplateBuilderLiveTest.java b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/compute/VPDCTemplateBuilderLiveTest.java index f545316887..d37882e876 100644 --- a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/compute/VPDCTemplateBuilderLiveTest.java +++ b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/compute/VPDCTemplateBuilderLiveTest.java @@ -26,14 +26,11 @@ import java.io.IOException; import java.util.Properties; import java.util.Set; -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.compute.internal.BaseTemplateBuilderLiveTest; import org.jclouds.domain.LocationScope; -import org.jclouds.savvis.vpdc.VPDCAsyncClient; -import org.jclouds.savvis.vpdc.VPDCClient; import org.jclouds.savvis.vpdc.reference.VPDCConstants; import org.testng.annotations.Test; @@ -45,8 +42,7 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live") -public class VPDCTemplateBuilderLiveTest extends - BaseTemplateBuilderLiveTest> { +public class VPDCTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { public VPDCTemplateBuilderLiveTest() { provider = "savvis-symphonyvpdc"; diff --git a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BaseVPDCAsyncClientTest.java b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BaseVPDCAsyncClientTest.java index 6d3674979e..f8d9d4f297 100644 --- a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BaseVPDCAsyncClientTest.java +++ b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BaseVPDCAsyncClientTest.java @@ -28,7 +28,6 @@ import java.util.Set; import javax.inject.Named; import org.jclouds.http.HttpRequest; -import org.jclouds.http.RequiresHttp; import org.jclouds.providers.ProviderMetadata; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.internal.BaseAsyncClientTest; @@ -53,7 +52,7 @@ import com.google.inject.Module; public abstract class BaseVPDCAsyncClientTest extends BaseAsyncClientTest { @Override - public ProviderMetadata createProviderMetadata() { + public ProviderMetadata createProviderMetadata() { return new VPDCProviderMetadata(); } @@ -68,7 +67,6 @@ public abstract class BaseVPDCAsyncClientTest extends BaseAsyncClientTest return new VPDCRestClientModuleExtension(); } - @RequiresHttp @ConfiguresRestClient public static class VPDCRestClientModuleExtension extends VPDCRestClientModule { diff --git a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BaseVPDCClientLiveTest.java b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BaseVPDCClientLiveTest.java index 9219137347..b4929beedb 100644 --- a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BaseVPDCClientLiveTest.java +++ b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BaseVPDCClientLiveTest.java @@ -23,7 +23,6 @@ import static com.google.common.base.Preconditions.checkNotNull; import java.util.Properties; import java.util.concurrent.TimeUnit; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.predicates.RetryablePredicate; import org.jclouds.rest.RestContext; @@ -40,9 +39,7 @@ import org.testng.annotations.Test; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "BaseVPDCClientLiveTest") -public class BaseVPDCClientLiveTest - extends - BaseComputeServiceContextLiveTest> { +public class BaseVPDCClientLiveTest extends BaseComputeServiceContextLiveTest { public BaseVPDCClientLiveTest() { provider = "savvis-symphonyvpdc"; diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiMetadata.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiMetadata.java index 3d2e32edac..a4d70cd388 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiMetadata.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiMetadata.java @@ -28,9 +28,8 @@ import java.net.URI; import java.util.Properties; import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.ApiType; -import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; import org.jclouds.rest.internal.BaseRestApiMetadata; +import org.jclouds.vcloud.director.v1_5.config.VCloudDirectorRestClientModule; import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorAsyncClient; import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorClient; @@ -41,11 +40,13 @@ import com.google.common.reflect.TypeToken; * * @author Adrian Cole */ -public class VCloudDirectorApiMetadata - extends -// BaseComputeServiceApiMetadata { - BaseRestApiMetadata { +public class VCloudDirectorApiMetadata extends BaseRestApiMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = 6725672099385580694L; + + public static final TypeToken CONTEXT_TOKEN = TypeToken.of(VCloudDirectorContext.class); + @Override public Builder toBuilder() { return new Builder().fromApiMetadata(this); @@ -59,8 +60,8 @@ public class VCloudDirectorApiMetadata super(builder); } - protected static Properties defaultProperties() { - Properties properties = BaseComputeServiceApiMetadata.Builder.defaultProperties(); + public static Properties defaultProperties() { + Properties properties = BaseRestApiMetadata.defaultProperties(); /** FIXME this should not be the default */ properties.setProperty(PROPERTY_SESSION_INTERVAL, Integer.toString(30 * 60)); @@ -78,21 +79,21 @@ public class VCloudDirectorApiMetadata public static class Builder extends -// BaseComputeServiceApiMetadata.Builder { - BaseRestApiMetadata.Builder { + BaseRestApiMetadata.Builder { protected Builder() { super(VCloudDirectorClient.class, VCloudDirectorAsyncClient.class); id("vcloud-director") .name("vCloud Director 1.5 API") - .type(ApiType.COMPUTE) .identityName("User at Organization (user@org)") .credentialName("Password") .documentation(URI.create("http://www.vmware.com/support/pubs/vcd_pubs.html")) .version("1.5") .defaultProperties(VCloudDirectorApiMetadata.defaultProperties()) .context(TypeToken.of(VCloudDirectorContext.class)) - .contextBuilder(TypeToken.of(VCloudDirectorContextBuilder.class)); + .defaultModule(VCloudDirectorRestClientModule.class); +// .wrapper(TypeToken.of(ComputeServiceContext.class)) +// .defaultModules(ImmutableSet.>of(VCloudDirectorRestClientModule.class, VCloudDirectorComputeServiceContextModule.class)); } @Override @@ -101,7 +102,7 @@ public class VCloudDirectorApiMetadata } @Override - public Builder fromApiMetadata(VCloudDirectorApiMetadata in) { + public Builder fromApiMetadata(ApiMetadata in) { super.fromApiMetadata(in); return this; } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorContextBuilder.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorContextBuilder.java deleted file mode 100644 index 1417074df4..0000000000 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorContextBuilder.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * 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.vcloud.director.v1_5; - -import java.util.List; - -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.rest.RestContextBuilder; -import org.jclouds.vcloud.director.v1_5.config.VCloudDirectorRestClientModule; -import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorAsyncClient; -import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorClient; - -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class VCloudDirectorContextBuilder - extends - // ComputeServiceContextBuilder { - RestContextBuilder { - - public VCloudDirectorContextBuilder( - ProviderMetadata providerMetadata) { - super(providerMetadata); - } - - public VCloudDirectorContextBuilder(VCloudDirectorApiMetadata apiMetadata) { - super(apiMetadata); - } - - // TODO - // @Override - // protected void addContextModule(List modules) { - // modules.add(new VCloudDirectorComputeServiceContextModule()); - // } - - @Override - protected void addClientModule(List modules) { - modules.add(new VCloudDirectorRestClientModule()); - } - -} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorPropertiesBuilder.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorPropertiesBuilder.java deleted file mode 100644 index 67bbbfc732..0000000000 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorPropertiesBuilder.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * 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.vcloud.director.v1_5; - -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.PROPERTY_VCLOUD_DIRECTOR_TIMEOUT_TASK_COMPLETED; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.PROPERTY_VCLOUD_DIRECTOR_VERSION_SCHEMA; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.PROPERTY_VCLOUD_DIRECTOR_XML_NAMESPACE; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.PROPERTY_VCLOUD_DIRECTOR_XML_SCHEMA; - -import java.util.Properties; - -import org.jclouds.PropertiesBuilder; - -/** - * Builds properties used in VCloudDirector clients - * - * @author Adrian Cole - */ -public class VCloudDirectorPropertiesBuilder extends PropertiesBuilder { - - @Override - public Properties defaultProperties() { - Properties properties = super.defaultProperties(); - - /** FIXME this should not be the default */ - properties.setProperty(PROPERTY_ENDPOINT, "https://vcloudbeta.bluelock.com/api"); - properties.setProperty(PROPERTY_SESSION_INTERVAL, Integer.toString(30 * 60)); - properties.setProperty(PROPERTY_API_VERSION, "1.5"); - - properties.setProperty(PROPERTY_VCLOUD_DIRECTOR_XML_NAMESPACE, - String.format("http://www.vmware.com/vcloud/v${%s}", PROPERTY_VCLOUD_DIRECTOR_VERSION_SCHEMA)); - properties.setProperty(PROPERTY_SESSION_INTERVAL, Integer.toString(8 * 60)); - properties.setProperty(PROPERTY_VCLOUD_DIRECTOR_XML_SCHEMA, PROPERTY_ENDPOINT + "/v1.5/schema/master.xsd"); - - // TODO integrate these with the {@link ComputeTimeouts} instead of having a single timeout for everything. - properties.setProperty(PROPERTY_SESSION_INTERVAL, Integer.toString(300)); - properties.setProperty(PROPERTY_VCLOUD_DIRECTOR_TIMEOUT_TASK_COMPLETED, Long.toString(1200l * 1000l)); - - return properties; - } - - public VCloudDirectorPropertiesBuilder() { - super(); - } - - public VCloudDirectorPropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/config/VCloudDirectorRestClientModule.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/config/VCloudDirectorRestClientModule.java index 0e1b0dc750..f1826f900f 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/config/VCloudDirectorRestClientModule.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/config/VCloudDirectorRestClientModule.java @@ -31,7 +31,6 @@ import org.jclouds.concurrent.RetryOnTimeOutExceptionFunction; import org.jclouds.domain.Credentials; 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; @@ -107,7 +106,6 @@ import com.google.inject.name.Named; * * @author Adrian Cole */ -@RequiresHttp @ConfiguresRestClient public class VCloudDirectorRestClientModule extends RestClientModule { diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/HttpClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/HttpClientLiveTest.java index 01a27187df..d924ddb906 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/HttpClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/HttpClientLiveTest.java @@ -32,6 +32,7 @@ import org.jclouds.http.HttpResponse; import org.jclouds.util.Strings2; import org.jclouds.vcloud.director.v1_5.domain.SessionWithToken; import org.jclouds.vcloud.director.v1_5.domain.org.OrgList; +import org.jclouds.vcloud.director.v1_5.features.admin.AdminCatalogClient; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest; import org.jclouds.xml.internal.JAXBParser; import org.testng.annotations.Test; @@ -110,4 +111,5 @@ public class HttpClientLiveTest extends BaseVCloudDirectorClientLiveTest { // TODO: asserting something about the schema } + } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiMetadataTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiMetadataTest.java index 0b90278dca..75b501fd07 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiMetadataTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiMetadataTest.java @@ -18,18 +18,22 @@ */ package org.jclouds.vcloud.director.v1_5; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.internal.BaseApiMetadataTest; +import org.jclouds.Wrapper; +import org.jclouds.rest.internal.BaseRestApiMetadataTest; import org.testng.annotations.Test; +import com.google.common.collect.ImmutableSet; +import com.google.common.reflect.TypeToken; + /** * * @author Adrian Cole */ @Test(groups = "unit", testName = "VCloudDirectorApiMetadataTest") -public class VCloudDirectorApiMetadataTest extends BaseApiMetadataTest { +//TODO: BaseComputeServiceApiMetadataTest +public class VCloudDirectorApiMetadataTest extends BaseRestApiMetadataTest { public VCloudDirectorApiMetadataTest() { - super(new VCloudDirectorApiMetadata(), ApiType.COMPUTE); + super(new VCloudDirectorApiMetadata(), ImmutableSet.>of()); } } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClientLiveTest.java index fbe9820376..e00957b263 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogClientLiveTest.java @@ -23,25 +23,19 @@ import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.N import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_DEL; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_EQ; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_UPDATABLE; -import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkError; -import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; import java.util.Collections; -import org.jclouds.vcloud.director.v1_5.VCloudDirectorException; import org.jclouds.vcloud.director.v1_5.domain.AdminCatalog; import org.jclouds.vcloud.director.v1_5.domain.Checks; -import org.jclouds.vcloud.director.v1_5.domain.Error; import org.jclouds.vcloud.director.v1_5.domain.Link; import org.jclouds.vcloud.director.v1_5.domain.Owner; import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.jclouds.vcloud.director.v1_5.domain.User; import org.jclouds.vcloud.director.v1_5.domain.params.PublishCatalogParams; -import org.jclouds.vcloud.director.v1_5.features.admin.AdminCatalogClient; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorClientLiveTest.java index 4f66774cb0..12b093af8e 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorClientLiveTest.java @@ -35,13 +35,13 @@ import java.util.Set; import javax.annotation.Resource; import javax.inject.Inject; -import org.jclouds.Constants; +import org.jclouds.apis.BaseContextLiveTest; import org.jclouds.date.DateService; import org.jclouds.logging.Logger; import org.jclouds.predicates.RetryablePredicate; import org.jclouds.rest.RestContext; -import org.jclouds.rest.internal.BaseContextLiveTest; import org.jclouds.vcloud.director.testng.FormatApiResultsListener; +import org.jclouds.vcloud.director.v1_5.VCloudDirectorApiMetadata; import org.jclouds.vcloud.director.v1_5.VCloudDirectorContext; import org.jclouds.vcloud.director.v1_5.VCloudDirectorException; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; @@ -49,8 +49,6 @@ import org.jclouds.vcloud.director.v1_5.admin.VCloudDirectorAdminAsyncClient; import org.jclouds.vcloud.director.v1_5.admin.VCloudDirectorAdminClient; import org.jclouds.vcloud.director.v1_5.domain.Link; import org.jclouds.vcloud.director.v1_5.domain.Reference; -import org.jclouds.vcloud.director.v1_5.domain.ResourceEntity.Status; -import org.jclouds.vcloud.director.v1_5.domain.Role.DefaultRoles; import org.jclouds.vcloud.director.v1_5.domain.RoleReferences; import org.jclouds.vcloud.director.v1_5.domain.Session; import org.jclouds.vcloud.director.v1_5.domain.Task; @@ -58,6 +56,8 @@ import org.jclouds.vcloud.director.v1_5.domain.User; import org.jclouds.vcloud.director.v1_5.domain.VApp; import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate; import org.jclouds.vcloud.director.v1_5.domain.Vdc; +import org.jclouds.vcloud.director.v1_5.domain.ResourceEntity.Status; +import org.jclouds.vcloud.director.v1_5.domain.Role.DefaultRoles; import org.jclouds.vcloud.director.v1_5.domain.network.Network; import org.jclouds.vcloud.director.v1_5.domain.network.NetworkConfiguration; import org.jclouds.vcloud.director.v1_5.domain.network.VAppNetworkConfiguration; @@ -90,6 +90,7 @@ import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import com.google.common.io.Closeables; +import com.google.common.reflect.TypeToken; import com.google.inject.Guice; /** @@ -492,4 +493,10 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseContextLiveTe public static String name(String prefix) { return prefix + Integer.toString(random.nextInt(Integer.MAX_VALUE)); } + + @Override + protected TypeToken contextType() { + return VCloudDirectorApiMetadata.CONTEXT_TOKEN; + } + } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/VCloudDirectorTestSession.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/VCloudDirectorTestSession.java index 0c9746dedd..858e98d7db 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/VCloudDirectorTestSession.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/VCloudDirectorTestSession.java @@ -9,9 +9,9 @@ import java.io.Closeable; import java.net.URI; import java.util.Properties; +import org.jclouds.ContextBuilder; import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.rest.RestContext; -import org.jclouds.rest.internal.ContextBuilder; import org.jclouds.sshj.config.SshjSshClientModule; import org.jclouds.vcloud.director.v1_5.VCloudDirectorContext; import org.jclouds.vcloud.director.v1_5.admin.VCloudDirectorAdminAsyncClient; @@ -80,7 +80,7 @@ public class VCloudDirectorTestSession implements Closeable { private User createdUser; private VCloudDirectorTestSession(String provider, String identity, String credential, Properties overrides, String endpoint) { - ContextBuilder builder = ContextBuilder.newBuilder(provider) + ContextBuilder builder = ContextBuilder.newBuilder(provider) .credentials(identity, credential) .endpoint(endpoint) .modules(ImmutableSet. of(new Log4JLoggingModule(), new SshjSshClientModule())) diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/login/SessionClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/login/SessionClientExpectTest.java index 0a30ccd8c3..9e6c86a46c 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/login/SessionClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/login/SessionClientExpectTest.java @@ -123,7 +123,7 @@ public class SessionClientExpectTest extends BaseRestClientExpectTest createApiMetadata() { + protected ApiMetadata createApiMetadata() { return AnonymousRestApiMetadata.forClientMappedToAsyncClient(SessionClient.class, SessionAsyncClient.class) .toBuilder().defaultEndpoint("https://vcloudbeta.bluelock.com/api").build(); } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/login/SessionClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/login/SessionClientLiveTest.java index 78ab4aff81..f733e733d4 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/login/SessionClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/login/SessionClientLiveTest.java @@ -27,15 +27,17 @@ import java.util.Properties; import org.jclouds.Constants; import org.jclouds.apis.ApiMetadata; +import org.jclouds.apis.BaseContextLiveTest; import org.jclouds.rest.AnonymousRestApiMetadata; import org.jclouds.rest.RestContext; -import org.jclouds.rest.internal.BaseContextLiveTest; import org.jclouds.vcloud.director.testng.FormatApiResultsListener; import org.jclouds.vcloud.director.v1_5.domain.SessionWithToken; import org.testng.annotations.BeforeGroups; import org.testng.annotations.Listeners; import org.testng.annotations.Test; +import com.google.common.reflect.TypeToken; + /** * Tests behavior of {@code SessionClient}. Note this class is tested completely independently of * VCloudClient as it is a dependency of the VCloud context working. @@ -103,7 +105,15 @@ public class SessionClientLiveTest extends BaseContextLiveTest, ?> createApiMetadata() { + protected ApiMetadata createApiMetadata() { return AnonymousRestApiMetadata.forClientMappedToAsyncClient(SessionClient.class, SessionAsyncClient.class); } + + @Override + protected TypeToken> contextType() { + return new TypeToken>(){ + + /** The serialVersionUID */ + private static final long serialVersionUID = -3625362618882122604L;}; + } } diff --git a/labs/virtualbox/src/main/java/org/jclouds/virtualbox/VirtualBoxApiMetadata.java b/labs/virtualbox/src/main/java/org/jclouds/virtualbox/VirtualBoxApiMetadata.java index dd9f02fada..7a6d3cdec3 100644 --- a/labs/virtualbox/src/main/java/org/jclouds/virtualbox/VirtualBoxApiMetadata.java +++ b/labs/virtualbox/src/main/java/org/jclouds/virtualbox/VirtualBoxApiMetadata.java @@ -31,25 +31,23 @@ import java.net.URI; import java.util.Properties; import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.ApiType; +import org.jclouds.apis.internal.BaseApiMetadata; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; +import org.jclouds.virtualbox.config.DefaultCacheNodeStoreModule; +import org.jclouds.virtualbox.config.VirtualBoxComputeServiceContextModule; -import com.google.common.base.Supplier; -import com.google.common.reflect.TypeToken; +import com.google.common.collect.ImmutableSet; +import com.google.inject.Module; /** * Implementation of {@link ApiMetadata} for VirtualBox API - * - *

note

- * - * This class is not setup to allow a subclasses to override the type of api, - * asyncapi, or context. This is an optimization for simplicity. - * + * @author Adrian Cole */ -@SuppressWarnings("rawtypes") -public class VirtualBoxApiMetadata extends BaseComputeServiceApiMetadata, VirtualBoxApiMetadata> { +public class VirtualBoxApiMetadata extends BaseApiMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = -7039233043408808289L; @Override public Builder toBuilder() { @@ -64,8 +62,8 @@ public class VirtualBoxApiMetadata extends BaseComputeServiceApiMetadata, VirtualBoxApiMetadata> { + public static class Builder extends BaseApiMetadata.Builder { protected Builder() { id("virtualbox") - .type(ApiType.COMPUTE) .name("VirtualBox API") .identityName("User") .credentialName("Password") @@ -108,8 +105,8 @@ public class VirtualBoxApiMetadata extends BaseComputeServiceApiMetadata>of(DefaultCacheNodeStoreModule.class, VirtualBoxComputeServiceContextModule.class)); } @Override @@ -118,7 +115,7 @@ public class VirtualBoxApiMetadata extends BaseComputeServiceApiMetadata, VirtualBoxApiMetadata> { - - public VirtualBoxContextBuilder( - ProviderMetadata, VirtualBoxApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public VirtualBoxContextBuilder(VirtualBoxApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new VirtualBoxComputeServiceContextModule()); - addHostModuleIfNotPresent(modules); - } - - protected void addHostModuleIfNotPresent(List modules) { - if (!Iterables.any(modules, new Predicate() { - public boolean apply(Module input) { - return input instanceof CacheNodeStoreModule; - } - })) { - CacheNodeStoreModule hostModule = new CacheNodeStoreModule(ImmutableMap.of( - "host", - Node.builder().id("host").name("host installing virtualbox").hostname("localhost") - .osFamily(OsFamily.LINUX.toString()).osDescription(System.getProperty("os.name")) - .osVersion(System.getProperty("os.version")).group("ssh") - .username(System.getProperty("user.name")) - .credentialUrl(URI.create("file://" + System.getProperty("user.home") + "/.ssh/id_rsa")) - .build())); - modules.add(hostModule); - } - } - -} diff --git a/apis/nova/src/main/java/org/jclouds/openstack/nova/NovaPropertiesBuilder.java b/labs/virtualbox/src/main/java/org/jclouds/virtualbox/config/DefaultCacheNodeStoreModule.java similarity index 50% rename from apis/nova/src/main/java/org/jclouds/openstack/nova/NovaPropertiesBuilder.java rename to labs/virtualbox/src/main/java/org/jclouds/virtualbox/config/DefaultCacheNodeStoreModule.java index 3b443dca18..14b2165d6a 100644 --- a/apis/nova/src/main/java/org/jclouds/openstack/nova/NovaPropertiesBuilder.java +++ b/labs/virtualbox/src/main/java/org/jclouds/virtualbox/config/DefaultCacheNodeStoreModule.java @@ -1,47 +1,36 @@ -/** - * 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.openstack.nova; - -import static org.jclouds.Constants.PROPERTY_API_VERSION; - -import java.util.Properties; - -import org.jclouds.PropertiesBuilder; - -/** - * Builds properties used in Openstack Nova Clients - * - * @author Dmitri Babaev - */ -public class NovaPropertiesBuilder extends PropertiesBuilder { - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_API_VERSION, "1.1"); - return properties; - } - - public NovaPropertiesBuilder(Properties properties) { - super(properties); - } - - public NovaPropertiesBuilder() { - super(); - } -} +/** + * 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.virtualbox.config; + +import java.net.URI; + +import org.jclouds.byon.Node; +import org.jclouds.byon.config.CacheNodeStoreModule; +import org.jclouds.compute.domain.OsFamily; + +import com.google.common.collect.ImmutableMap; + +public class DefaultCacheNodeStoreModule extends CacheNodeStoreModule { + public DefaultCacheNodeStoreModule() { + super(ImmutableMap.of("host", Node.builder().id("host").name("host installing virtualbox").hostname("localhost") + .osFamily(OsFamily.LINUX.toString()).osDescription(System.getProperty("os.name")).osVersion( + System.getProperty("os.version")).group("ssh").username(System.getProperty("user.name")) + .credentialUrl(URI.create("file://" + System.getProperty("user.home") + "/.ssh/id_rsa")).build())); + } +} diff --git a/labs/virtualbox/src/main/java/org/jclouds/virtualbox/config/VirtualBoxComputeServiceContextModule.java b/labs/virtualbox/src/main/java/org/jclouds/virtualbox/config/VirtualBoxComputeServiceContextModule.java index 7882a130b6..55160e8a7b 100644 --- a/labs/virtualbox/src/main/java/org/jclouds/virtualbox/config/VirtualBoxComputeServiceContextModule.java +++ b/labs/virtualbox/src/main/java/org/jclouds/virtualbox/config/VirtualBoxComputeServiceContextModule.java @@ -34,14 +34,14 @@ import java.util.concurrent.TimeUnit; import javax.inject.Singleton; import org.eclipse.jetty.server.Server; +import org.jclouds.ContextBuilder; import org.jclouds.byon.BYONApiMetadata; import org.jclouds.byon.Node; import org.jclouds.byon.functions.NodeToNodeMetadata; import org.jclouds.byon.suppliers.SupplyFromProviderURIOrNodesProperty; import org.jclouds.compute.ComputeServiceAdapter; -import org.jclouds.compute.ComputeServiceAdapter.NodeAndInitialCredentials; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextBuilder; +import org.jclouds.compute.ComputeServiceAdapter.NodeAndInitialCredentials; import org.jclouds.compute.config.ComputeServiceAdapterContextModule; import org.jclouds.compute.domain.Hardware; import org.jclouds.compute.domain.HardwareBuilder; @@ -103,13 +103,9 @@ import com.google.inject.TypeLiteral; /** * @author Mattias Holmqvist, Andrea Turli */ -@SuppressWarnings({ "unchecked", "rawtypes" }) +@SuppressWarnings("unchecked") public class VirtualBoxComputeServiceContextModule extends - ComputeServiceAdapterContextModule { - - public VirtualBoxComputeServiceContextModule() { - super(Supplier.class, Supplier.class); - } + ComputeServiceAdapterContextModule { @Override protected void configure() { @@ -170,10 +166,10 @@ public class VirtualBoxComputeServiceContextModule extends @Host @Singleton protected ComputeServiceContext provideHostController() { - return ComputeServiceContextBuilder.newBuilder(new BYONApiMetadata()) + return ContextBuilder.newBuilder(new BYONApiMetadata()) .credentials("", "") .modules(ImmutableSet. of(new SLF4JLoggingModule(), new SshjSshClientModule())) - .build(); + .build(ComputeServiceContext.class); } @Provides diff --git a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/BaseVirtualBoxClientLiveTest.java b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/BaseVirtualBoxClientLiveTest.java index 6b22c1944b..fe6cf54609 100644 --- a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/BaseVirtualBoxClientLiveTest.java +++ b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/BaseVirtualBoxClientLiveTest.java @@ -30,7 +30,6 @@ import java.util.concurrent.ExecutorService; import javax.inject.Inject; import javax.inject.Named; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.Template; @@ -39,6 +38,7 @@ import org.jclouds.compute.strategy.PrioritizeCredentialsFromTemplate; import org.jclouds.concurrent.MoreExecutors; import org.jclouds.concurrent.config.ExecutorServiceModule; import org.jclouds.config.ValueOfConfigurationKeyOrNull; +import org.jclouds.rest.annotations.BuildVersion; import org.jclouds.virtualbox.config.VirtualBoxConstants; import org.jclouds.virtualbox.domain.HardDisk; import org.jclouds.virtualbox.domain.IsoSpec; @@ -76,6 +76,7 @@ import com.google.common.cache.LoadingCache; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.inject.Injector; +import com.google.inject.Key; import com.google.inject.Module; /** @@ -84,8 +85,7 @@ import com.google.inject.Module; * @author Adrian Cole, David Alves */ @Test(groups = "live", singleThreaded = true, testName = "BaseVirtualBoxClientLiveTest") -public class BaseVirtualBoxClientLiveTest extends - BaseComputeServiceContextLiveTest> { +public class BaseVirtualBoxClientLiveTest extends BaseComputeServiceContextLiveTest { public static final String DONT_DESTROY_MASTER = "jclouds.virtualbox.keep-test-master"; @@ -144,7 +144,7 @@ public class BaseVirtualBoxClientLiveTest extends masterVmName = VIRTUALBOX_IMAGE_PREFIX + image.id; isosDir = workingDir + File.separator + "isos"; - hostVersion = Iterables.get(Splitter.on('r').split(context.getProviderSpecificContext().getBuildVersion()), 0); + hostVersion = Iterables.get(Splitter.on('r').split(context.utils().injector().getInstance(Key.get(String.class, BuildVersion.class))), 0); operatingSystemIso = String.format("%s/%s.iso", isosDir, image.name); guestAdditionsIso = String.format("%s/VBoxGuestAdditions_%s.iso", isosDir, hostVersion); diff --git a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/VirtualBoxApiMetadataTest.java b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/VirtualBoxApiMetadataTest.java index 6aec98fb30..c61d80cd64 100644 --- a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/VirtualBoxApiMetadataTest.java +++ b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/VirtualBoxApiMetadataTest.java @@ -18,8 +18,7 @@ */ package org.jclouds.virtualbox; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.internal.BaseApiMetadataTest; +import org.jclouds.compute.internal.BaseComputeServiceApiMetadataTest; import org.testng.annotations.Test; /** @@ -27,9 +26,9 @@ import org.testng.annotations.Test; * @author Adrian Cole */ @Test(groups = "unit", testName = "VirtualBoxApiMetadataTest") -public class VirtualBoxApiMetadataTest extends BaseApiMetadataTest { +public class VirtualBoxApiMetadataTest extends BaseComputeServiceApiMetadataTest { public VirtualBoxApiMetadataTest() { - super(new VirtualBoxApiMetadata(), ApiType.COMPUTE); + super(new VirtualBoxApiMetadata()); } } diff --git a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/compute/VirtualBoxExperimentLiveTest.java b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/compute/VirtualBoxExperimentLiveTest.java index a13cf5655c..e88cb47f87 100644 --- a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/compute/VirtualBoxExperimentLiveTest.java +++ b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/compute/VirtualBoxExperimentLiveTest.java @@ -27,8 +27,8 @@ import java.util.Set; import javax.annotation.Resource; import javax.inject.Named; +import org.jclouds.ContextBuilder; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.compute.RunNodesException; import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.domain.NodeMetadata; @@ -62,8 +62,9 @@ public class VirtualBoxExperimentLiveTest extends BaseVirtualBoxClientLiveTest { @BeforeClass public void setUp() { - context = new ComputeServiceContextFactory().createContext("virtualbox", "", "", - ImmutableSet. of(new SLF4JLoggingModule(), new SshjSshClientModule())); + context = ContextBuilder.newBuilder("virtualbox").modules( + ImmutableSet. of(new SLF4JLoggingModule(), new SshjSshClientModule())).build( + ComputeServiceContext.class); } @Test diff --git a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/functions/CreateAndInstallVmLiveTest.java b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/functions/CreateAndInstallVmLiveTest.java index d7c81dab49..d475cd8c14 100644 --- a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/functions/CreateAndInstallVmLiveTest.java +++ b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/functions/CreateAndInstallVmLiveTest.java @@ -27,7 +27,6 @@ import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_INSTA import java.util.Map; import org.jclouds.compute.config.BaseComputeServiceContextModule; -import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.config.ValueOfConfigurationKeyOrNull; diff --git a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/functions/RetrieveActiveBridgedInterfacesExpectTest.java b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/functions/RetrieveActiveBridgedInterfacesExpectTest.java index 3e17be9400..4933f7d5d2 100644 --- a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/functions/RetrieveActiveBridgedInterfacesExpectTest.java +++ b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/functions/RetrieveActiveBridgedInterfacesExpectTest.java @@ -20,13 +20,10 @@ package org.jclouds.virtualbox.functions; import static org.jclouds.virtualbox.functions.RetrieveActiveBridgedInterfaces.retrieveBridgedInterfaceNames; import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; import java.util.List; -import org.jclouds.virtualbox.BaseVirtualBoxClientLiveTest; import org.jclouds.virtualbox.domain.BridgedIf; -import org.jclouds.virtualbox.domain.BridgedIf.Builder; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; diff --git a/loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerService.java b/loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerService.java index 611fff821f..bbc6a1a9f5 100644 --- a/loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerService.java +++ b/loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerService.java @@ -49,7 +49,7 @@ public interface LoadBalancerService { /** * @return a reference to the context that created this LoadBalancerService. */ - LoadBalancerServiceContext getContext(); + LoadBalancerServiceContext getContext(); /** * @param location diff --git a/loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerServiceApiMetadata.java b/loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerServiceApiMetadata.java deleted file mode 100644 index 32806f5163..0000000000 --- a/loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerServiceApiMetadata.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.jclouds.loadbalancer; - -import org.jclouds.apis.ApiMetadata; - -import com.google.common.annotations.Beta; - -/** - * - * @author Adrian Cole - * @since 1.5 - */ -@Beta -public interface LoadBalancerServiceApiMetadata, M extends LoadBalancerServiceApiMetadata> - extends ApiMetadata { - - public static interface Builder, M extends LoadBalancerServiceApiMetadata> - extends ApiMetadata.Builder { - } - -} \ No newline at end of file diff --git a/loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerServiceContext.java b/loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerServiceContext.java index 4f82ccce50..4940137d9f 100644 --- a/loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerServiceContext.java +++ b/loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerServiceContext.java @@ -20,8 +20,9 @@ package org.jclouds.loadbalancer; import java.io.Closeable; +import org.jclouds.Wrapper; import org.jclouds.loadbalancer.internal.LoadBalancerServiceContextImpl; -import org.jclouds.rest.BackedByRestContext; +import org.jclouds.rest.RestContext; import org.jclouds.rest.Utils; import com.google.inject.ImplementedBy; @@ -34,7 +35,7 @@ import com.google.inject.ImplementedBy; * */ @ImplementedBy(LoadBalancerServiceContextImpl.class) -public interface LoadBalancerServiceContext extends Closeable, BackedByRestContext { +public interface LoadBalancerServiceContext extends Closeable, Wrapper { LoadBalancerService getLoadBalancerService(); @@ -45,6 +46,15 @@ public interface LoadBalancerServiceContext extends Closeable, BackedByRes * @see #getUtils */ Utils utils(); + + /** + * will be removed in jclouds 1.6 + * + * @see Wrapper#getInputType + * @see Wrapper#unwrap + */ + @Deprecated + RestContext getProviderSpecificContext(); @Override void close(); diff --git a/loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerServiceContextBuilder.java b/loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerServiceContextBuilder.java deleted file mode 100644 index cd8bee81c7..0000000000 --- a/loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerServiceContextBuilder.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * 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.loadbalancer; - -import static com.google.common.base.Preconditions.checkArgument; - -import java.util.NoSuchElementException; - -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.rest.internal.ContextBuilder; - -/** - * @author Adrian Cole - */ -public abstract class LoadBalancerServiceContextBuilder, M extends LoadBalancerServiceApiMetadata> extends - ContextBuilder { - -// TODO: -// public static ContextBuilder forTests() { -// return ContextBuilder.newBuilder(new StubApiMetadata()); -// } - - /** - * looks up a provider or api with the given id - * - * @param providerOrApi - * id of the provider or api - * @return means to build a context to that provider - * @throws NoSuchElementException - * if the id was not configured. - * @throws IllegalArgumentException - * if the api or provider isn't assignable from LoadBalancerServiceContext - */ - public static LoadBalancerServiceContextBuilder newBuilder(String providerOrApi) throws NoSuchElementException { - ContextBuilder builder = ContextBuilder.newBuilder(providerOrApi); - checkArgument(builder instanceof LoadBalancerServiceContextBuilder, - "type of providerOrApi[%s] is not LoadBalancerServiceContextBuilder: %s", providerOrApi, builder); - return LoadBalancerServiceContextBuilder.class.cast(builder); - } - - public LoadBalancerServiceContextBuilder(ProviderMetadata providerMetadata) { - super(providerMetadata); - } - - public LoadBalancerServiceContextBuilder(M apiMetadata) { - super(apiMetadata); - } - -} \ No newline at end of file diff --git a/loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerServiceContextFactory.java b/loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerServiceContextFactory.java index d42cce256b..4ddc31a067 100644 --- a/loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerServiceContextFactory.java +++ b/loadbalancer/src/main/java/org/jclouds/loadbalancer/LoadBalancerServiceContextFactory.java @@ -21,11 +21,11 @@ package org.jclouds.loadbalancer; import java.util.NoSuchElementException; import java.util.Properties; +import org.jclouds.ContextBuilder; import org.jclouds.apis.Apis; import org.jclouds.javax.annotation.Nullable; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.Providers; -import org.jclouds.rest.internal.ContextBuilder; import com.google.common.collect.ImmutableSet; import com.google.inject.Module; @@ -54,21 +54,21 @@ public class LoadBalancerServiceContextFactory { /** * @see #createContext(String, String,String, Iterable, Properties) */ - public LoadBalancerServiceContext createContext(String providerOrApi, String identity, String credential) { + public LoadBalancerServiceContext createContext(String providerOrApi, String identity, String credential) { return createContext(providerOrApi, identity, credential, ImmutableSet. of(), new Properties()); } /** * @see #createContext(String, String, String, Iterable, Properties) */ - public LoadBalancerServiceContext createContext(String providerOrApi, Properties overrides) { + public LoadBalancerServiceContext createContext(String providerOrApi, Properties overrides) { return createContext(providerOrApi, null, null, ImmutableSet. of(), overrides); } /** * @see #createContext(String, String,String, Iterable, Properties) */ - public LoadBalancerServiceContext createContext(String providerOrApi, Iterable wiring, + public LoadBalancerServiceContext createContext(String providerOrApi, Iterable wiring, Properties overrides) { return createContext(providerOrApi, null, null, wiring, overrides); } @@ -76,7 +76,7 @@ public class LoadBalancerServiceContextFactory { /** * @see #createContext(String, String,String, Iterable, Properties) */ - public LoadBalancerServiceContext createContext(String providerOrApi, @Nullable String identity, + public LoadBalancerServiceContext createContext(String providerOrApi, @Nullable String identity, @Nullable String credential, Properties overrides) { return createContext(providerOrApi, identity, credential, ImmutableSet. of(), overrides); } @@ -84,7 +84,7 @@ public class LoadBalancerServiceContextFactory { /** * @see createContext(String, String,String, Iterable, Properties) */ - public LoadBalancerServiceContext createContext(String providerOrApi, @Nullable String identity, + public LoadBalancerServiceContext createContext(String providerOrApi, @Nullable String identity, @Nullable String credential, Iterable wiring) { return createContext(providerOrApi, identity, credential, wiring, new Properties()); } @@ -104,28 +104,20 @@ public class LoadBalancerServiceContextFactory { * properties to override defaults with. * @return initialized context ready for use */ - @SuppressWarnings("unchecked") - public LoadBalancerServiceContext createContext(String providerOrApi, @Nullable String identity, + public LoadBalancerServiceContext createContext(String providerOrApi, @Nullable String identity, @Nullable String credential, Iterable wiring, Properties overrides) { - ContextBuilder builder = null; + ContextBuilder builder = null; try { - ProviderMetadata pm = Providers.withId(providerOrApi); - builder = LoadBalancerServiceContextBuilder.newBuilder(pm); + ProviderMetadata pm = Providers.withId(providerOrApi); + builder = ContextBuilder.newBuilder(pm); } catch (NoSuchElementException e) { builder = ContextBuilder.newBuilder(Apis.withId(providerOrApi)); } - builder.modules(Iterable.class.cast(wiring)); + builder.modules(wiring); builder.overrides(overrides); if (identity != null) builder.credentials(identity, credential); - Object context = builder.build(); - if (context instanceof LoadBalancerServiceContext) { - return LoadBalancerServiceContext.class.cast(context); - } else { - throw new IllegalArgumentException("provider " + providerOrApi + " contains an unknown context type: " - + context.getClass().getSimpleName()); - } - + return builder.build(LoadBalancerServiceContext.class); } } diff --git a/loadbalancer/src/main/java/org/jclouds/loadbalancer/internal/BaseLoadBalancerService.java b/loadbalancer/src/main/java/org/jclouds/loadbalancer/internal/BaseLoadBalancerService.java index b0e32f723e..1083898581 100644 --- a/loadbalancer/src/main/java/org/jclouds/loadbalancer/internal/BaseLoadBalancerService.java +++ b/loadbalancer/src/main/java/org/jclouds/loadbalancer/internal/BaseLoadBalancerService.java @@ -63,7 +63,7 @@ public class BaseLoadBalancerService implements LoadBalancerService { protected Logger logger = Logger.NULL; protected final Supplier defaultLocationSupplier; - protected final LoadBalancerServiceContext context; + protected final LoadBalancerServiceContext context; protected final LoadBalanceNodesStrategy loadBalancerStrategy; protected final GetLoadBalancerMetadataStrategy getLoadBalancerMetadataStrategy; protected final DestroyLoadBalancerStrategy destroyLoadBalancerStrategy; @@ -71,7 +71,7 @@ public class BaseLoadBalancerService implements LoadBalancerService { protected final Supplier> locations; @Inject - protected BaseLoadBalancerService(Supplier defaultLocationSupplier, @SuppressWarnings("rawtypes") LoadBalancerServiceContext context, + protected BaseLoadBalancerService(Supplier defaultLocationSupplier, LoadBalancerServiceContext context, LoadBalanceNodesStrategy loadBalancerStrategy, GetLoadBalancerMetadataStrategy getLoadBalancerMetadataStrategy, DestroyLoadBalancerStrategy destroyLoadBalancerStrategy, ListLoadBalancersStrategy listLoadBalancersStrategy, @@ -98,7 +98,7 @@ public class BaseLoadBalancerService implements LoadBalancerService { * {@inheritDoc} */ @Override - public LoadBalancerServiceContext getContext() { + public LoadBalancerServiceContext getContext() { return context; } diff --git a/loadbalancer/src/main/java/org/jclouds/loadbalancer/internal/BaseLoadBalancerServiceApiMetadata.java b/loadbalancer/src/main/java/org/jclouds/loadbalancer/internal/BaseLoadBalancerServiceApiMetadata.java deleted file mode 100644 index e4f7d3b383..0000000000 --- a/loadbalancer/src/main/java/org/jclouds/loadbalancer/internal/BaseLoadBalancerServiceApiMetadata.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * 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.loadbalancer.internal; - -import org.jclouds.apis.ApiType; -import org.jclouds.apis.internal.BaseApiMetadata; -import org.jclouds.loadbalancer.LoadBalancerServiceApiMetadata; -import org.jclouds.loadbalancer.LoadBalancerServiceContext; - -import com.google.common.annotations.Beta; -import com.google.common.reflect.TypeParameter; -import com.google.common.reflect.TypeToken; - -/** - * - * @author Adrian Cole - * @since 1.5 - */ -@Beta -public abstract class BaseLoadBalancerServiceApiMetadata, M extends LoadBalancerServiceApiMetadata> - extends BaseApiMetadata implements LoadBalancerServiceApiMetadata { - - public static class Builder, M extends LoadBalancerServiceApiMetadata> - extends BaseApiMetadata.Builder implements LoadBalancerServiceApiMetadata.Builder { - public Builder() { - type(ApiType.LOADBALANCER); - } - - /** - * {@inheritDoc} - */ - @Override - @SuppressWarnings("rawtypes") - protected TypeToken contextToken(TypeToken clientToken, TypeToken asyncClientToken) { - return new TypeToken>() { - private static final long serialVersionUID = 1L; - }.where(new TypeParameter() { - }, clientToken).where(new TypeParameter() { - }, asyncClientToken); - } - } - - protected BaseLoadBalancerServiceApiMetadata(BaseLoadBalancerServiceApiMetadata.Builder builder) { - super(builder); - } - -} \ No newline at end of file diff --git a/loadbalancer/src/main/java/org/jclouds/loadbalancer/internal/BaseLoadBalancerServiceContextBuilder.java b/loadbalancer/src/main/java/org/jclouds/loadbalancer/internal/BaseLoadBalancerServiceContextBuilder.java deleted file mode 100644 index a134d63a68..0000000000 --- a/loadbalancer/src/main/java/org/jclouds/loadbalancer/internal/BaseLoadBalancerServiceContextBuilder.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * 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.loadbalancer.internal; - -import org.jclouds.loadbalancer.LoadBalancerServiceApiMetadata; -import org.jclouds.loadbalancer.LoadBalancerServiceContext; -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.rest.internal.ContextBuilder; - -/** - * @author Adrian Cole - */ -public abstract class BaseLoadBalancerServiceContextBuilder, M extends LoadBalancerServiceApiMetadata> - extends ContextBuilder { - - public BaseLoadBalancerServiceContextBuilder(ProviderMetadata providerMetadata) { - super(providerMetadata); - } - - public BaseLoadBalancerServiceContextBuilder(M apiMetadata) { - super(apiMetadata); - } -} \ No newline at end of file diff --git a/loadbalancer/src/main/java/org/jclouds/loadbalancer/internal/LoadBalancerServiceContextImpl.java b/loadbalancer/src/main/java/org/jclouds/loadbalancer/internal/LoadBalancerServiceContextImpl.java index 4353253c15..022a7b116d 100644 --- a/loadbalancer/src/main/java/org/jclouds/loadbalancer/internal/LoadBalancerServiceContextImpl.java +++ b/loadbalancer/src/main/java/org/jclouds/loadbalancer/internal/LoadBalancerServiceContextImpl.java @@ -20,42 +20,37 @@ package org.jclouds.loadbalancer.internal; import static com.google.common.base.Preconditions.checkNotNull; +import java.io.Closeable; + import javax.inject.Inject; import javax.inject.Singleton; +import org.jclouds.internal.BaseWrapper; import org.jclouds.loadbalancer.LoadBalancerService; import org.jclouds.loadbalancer.LoadBalancerServiceContext; +import org.jclouds.location.Provider; import org.jclouds.rest.RestContext; import org.jclouds.rest.Utils; +import com.google.common.io.Closeables; +import com.google.common.reflect.TypeToken; + /** * @author Adrian Cole */ @Singleton -public class LoadBalancerServiceContextImpl implements LoadBalancerServiceContext { +public class LoadBalancerServiceContextImpl extends BaseWrapper implements LoadBalancerServiceContext { private final LoadBalancerService loadBalancerService; - private final RestContext providerSpecificContext; private final Utils utils; - @SuppressWarnings({ "unchecked" }) @Inject - public LoadBalancerServiceContextImpl(LoadBalancerService loadBalancerService, Utils utils, - @SuppressWarnings("rawtypes") RestContext providerSpecificContext) { + public LoadBalancerServiceContextImpl(@Provider Closeable wrapped, + @Provider TypeToken wrappedType, LoadBalancerService loadBalancerService, Utils utils) { + super(wrapped, wrappedType); this.utils = utils; - this.providerSpecificContext = providerSpecificContext; this.loadBalancerService = checkNotNull(loadBalancerService, "loadBalancerService"); } - @Override - public RestContext getProviderSpecificContext() { - return providerSpecificContext; - } - - @Override - public void close() { - providerSpecificContext.close(); - } - @Override public LoadBalancerService getLoadBalancerService() { return loadBalancerService; @@ -71,18 +66,29 @@ public class LoadBalancerServiceContextImpl implements LoadBalancerService return utils; } + @SuppressWarnings("unchecked") + @Override + public RestContext getProviderSpecificContext() { + return (RestContext) getWrapped(); + } + + @Override + public void close() { + Closeables.closeQuietly(getWrapped()); + } + public int hashCode() { - return providerSpecificContext.hashCode(); + return getWrapped().hashCode(); } @Override public String toString() { - return providerSpecificContext.toString(); + return getWrapped().toString(); } @Override public boolean equals(Object obj) { - return providerSpecificContext.equals(obj); + return getWrapped().equals(obj); } } diff --git a/loadbalancer/src/test/java/org/jclouds/loadbalancer/BaseLoadBalancerServiceLiveTest.java b/loadbalancer/src/test/java/org/jclouds/loadbalancer/BaseLoadBalancerServiceLiveTest.java index 9bbfdb8b9f..f814e722e8 100644 --- a/loadbalancer/src/test/java/org/jclouds/loadbalancer/BaseLoadBalancerServiceLiveTest.java +++ b/loadbalancer/src/test/java/org/jclouds/loadbalancer/BaseLoadBalancerServiceLiveTest.java @@ -29,8 +29,9 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import org.jclouds.Constants; +import org.jclouds.ContextBuilder; +import org.jclouds.apis.BaseContextLiveTest; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.compute.RunNodesException; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.Template; @@ -41,7 +42,6 @@ import org.jclouds.loadbalancer.domain.LoadBalancerMetadata; import org.jclouds.net.IPSocket; import org.jclouds.predicates.RetryablePredicate; import org.jclouds.predicates.SocketOpen; -import org.jclouds.rest.internal.BaseContextLiveTest; import org.jclouds.ssh.SshClient; import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeGroups; @@ -49,6 +49,7 @@ import org.testng.annotations.Test; import com.google.common.base.Splitter; import com.google.common.collect.Iterables; +import com.google.common.reflect.TypeToken; import com.google.inject.Guice; import com.google.inject.Module; @@ -57,7 +58,7 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true) -public abstract class BaseLoadBalancerServiceLiveTest> extends BaseContextLiveTest { +public abstract class BaseLoadBalancerServiceLiveTest extends BaseContextLiveTest { protected String imageId; protected String loginUser; @@ -100,7 +101,7 @@ public abstract class BaseLoadBalancerServiceLiveTest keyPair; protected LoadBalancerMetadata loadbalancer; - protected LoadBalancerServiceContext context; + protected LoadBalancerServiceContext context; protected String computeProvider; protected String computeIdentity; @@ -108,7 +109,7 @@ public abstract class BaseLoadBalancerServiceLiveTest computeContext; + protected ComputeServiceContext computeContext; @BeforeGroups(groups = { "integration", "live" }) @Override @@ -132,8 +133,8 @@ public abstract class BaseLoadBalancerServiceLiveTest contextType() { + return TypeToken.of(LoadBalancerServiceContext.class); + } } diff --git a/loadbalancer/src/test/java/org/jclouds/loadbalancer/internal/BaseLoadBalancerServiceApiMetadataTest.java b/loadbalancer/src/test/java/org/jclouds/loadbalancer/internal/BaseLoadBalancerServiceApiMetadataTest.java index f55b210d32..4f054772ea 100644 --- a/loadbalancer/src/test/java/org/jclouds/loadbalancer/internal/BaseLoadBalancerServiceApiMetadataTest.java +++ b/loadbalancer/src/test/java/org/jclouds/loadbalancer/internal/BaseLoadBalancerServiceApiMetadataTest.java @@ -1,12 +1,26 @@ +/** + * 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.loadbalancer.internal; -import java.util.Set; - +import org.jclouds.Wrapper; import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.ApiType; -import org.jclouds.apis.Apis; import org.jclouds.apis.internal.BaseApiMetadataTest; -import org.jclouds.loadbalancer.LoadBalancerServiceApiMetadata; import org.jclouds.loadbalancer.LoadBalancerServiceContext; import org.testng.annotations.Test; @@ -20,15 +34,8 @@ import com.google.common.reflect.TypeToken; @Test(groups = "unit") public abstract class BaseLoadBalancerServiceApiMetadataTest extends BaseApiMetadataTest { - @SuppressWarnings("rawtypes") - public BaseLoadBalancerServiceApiMetadataTest(LoadBalancerServiceApiMetadata toTest) { - super(toTest, ApiType.LOADBALANCER); - } - - @Test - public void testContextAssignableFromLoadBalancerServiceContext() { - Set> all = ImmutableSet.copyOf(Apis.contextAssignableFrom(TypeToken.of(LoadBalancerServiceContext.class))); - assert all.contains(toTest) : String.format("%s not found in %s", toTest, all); + public BaseLoadBalancerServiceApiMetadataTest(ApiMetadata toTest) { + super(toTest, ImmutableSet.>of(TypeToken.of(LoadBalancerServiceContext.class))); } } \ No newline at end of file diff --git a/providers/aws-cloudwatch/src/main/java/org/jclouds/aws/cloudwatch/AWSCloudWatchProviderMetadata.java b/providers/aws-cloudwatch/src/main/java/org/jclouds/aws/cloudwatch/AWSCloudWatchProviderMetadata.java index 56d4a634dd..7d2f8e2c48 100644 --- a/providers/aws-cloudwatch/src/main/java/org/jclouds/aws/cloudwatch/AWSCloudWatchProviderMetadata.java +++ b/providers/aws-cloudwatch/src/main/java/org/jclouds/aws/cloudwatch/AWSCloudWatchProviderMetadata.java @@ -25,11 +25,8 @@ import java.util.Properties; import org.jclouds.aws.domain.Region; import org.jclouds.cloudwatch.CloudWatchApiMetadata; -import org.jclouds.cloudwatch.CloudWatchAsyncClient; -import org.jclouds.cloudwatch.CloudWatchClient; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; -import org.jclouds.rest.RestContext; /** * Implementation of @ link org.jclouds.types.ProviderMetadata} for Amazon's CloudWatch @@ -37,8 +34,11 @@ import org.jclouds.rest.RestContext; * * @author Adrian Cole */ -public class AWSCloudWatchProviderMetadata extends BaseProviderMetadata, CloudWatchApiMetadata> { +public class AWSCloudWatchProviderMetadata extends BaseProviderMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = 2394954723306943404L; + public static Builder builder() { return new Builder(); } @@ -56,7 +56,7 @@ public class AWSCloudWatchProviderMetadata extends BaseProviderMetadata, CloudWatchApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder(){ id("aws-cloudwatch") @@ -87,7 +87,7 @@ public class AWSCloudWatchProviderMetadata extends BaseProviderMetadata().toBuilder() + new CloudWatchApiMetadata().toBuilder() .version("2010-08-01").build()) .defaultProperties(AWSCloudWatchProviderMetadata.defaultProperties()); } @@ -98,8 +98,7 @@ public class AWSCloudWatchProviderMetadata extends BaseProviderMetadata, CloudWatchApiMetadata> in) { + public Builder fromProviderMetadata(ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/aws-cloudwatch/src/test/java/org/jclouds/aws/cloudwatch/AWSCloudWatchProviderTest.java b/providers/aws-cloudwatch/src/test/java/org/jclouds/aws/cloudwatch/AWSCloudWatchProviderTest.java index 34e534042c..76b5a03b44 100644 --- a/providers/aws-cloudwatch/src/test/java/org/jclouds/aws/cloudwatch/AWSCloudWatchProviderTest.java +++ b/providers/aws-cloudwatch/src/test/java/org/jclouds/aws/cloudwatch/AWSCloudWatchProviderTest.java @@ -19,8 +19,6 @@ package org.jclouds.aws.cloudwatch; import org.jclouds.cloudwatch.CloudWatchApiMetadata; -import org.jclouds.cloudwatch.CloudWatchAsyncClient; -import org.jclouds.cloudwatch.CloudWatchClient; import org.jclouds.providers.internal.BaseProviderMetadataTest; import org.testng.annotations.Test; @@ -33,6 +31,6 @@ import org.testng.annotations.Test; public class AWSCloudWatchProviderTest extends BaseProviderMetadataTest { public AWSCloudWatchProviderTest() { - super(new AWSCloudWatchProviderMetadata(), new CloudWatchApiMetadata()); + super(new AWSCloudWatchProviderMetadata(), new CloudWatchApiMetadata()); } } diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2ApiMetadata.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2ApiMetadata.java index 8fec86622d..e89fe71a64 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2ApiMetadata.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2ApiMetadata.java @@ -24,16 +24,30 @@ import java.util.Properties; import org.jclouds.apis.ApiMetadata; import org.jclouds.aws.ec2.compute.AWSEC2ComputeServiceContext; +import org.jclouds.aws.ec2.compute.config.AWSEC2ComputeServiceContextModule; +import org.jclouds.aws.ec2.config.AWSEC2RestClientModule; import org.jclouds.ec2.EC2ApiMetadata; +import org.jclouds.ec2.compute.config.EC2ResolveImagesModule; +import org.jclouds.rest.RestContext; +import com.google.common.collect.ImmutableSet; import com.google.common.reflect.TypeToken; +import com.google.inject.Module; /** * Implementation of {@link ApiMetadata} for the Amazon-specific EC2 API * * @author Adrian Cole */ -public class AWSEC2ApiMetadata extends EC2ApiMetadata { +public class AWSEC2ApiMetadata extends EC2ApiMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = -1492951757032303845L; + + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; + private static Builder builder() { return new Builder(); } @@ -51,7 +65,7 @@ public class AWSEC2ApiMetadata extends EC2ApiMetadata { + public static class Builder extends EC2ApiMetadata.Builder { protected Builder(){ super(AWSEC2Client.class, AWSEC2AsyncClient.class); id("aws-ec2") .version(AWSEC2AsyncClient.VERSION) .name("Amazon-specific EC2 API") - .context(TypeToken.of(AWSEC2ComputeServiceContext.class)) + .wrapper(AWSEC2ComputeServiceContext.class) .defaultProperties(AWSEC2ApiMetadata.defaultProperties()) - .contextBuilder(TypeToken.of(AWSEC2ContextBuilder.class)); + .defaultModules(ImmutableSet.>of(AWSEC2RestClientModule.class, EC2ResolveImagesModule.class, AWSEC2ComputeServiceContextModule.class)); } @Override @@ -78,7 +92,7 @@ public class AWSEC2ApiMetadata extends EC2ApiMetadata { - public AWSEC2ContextBuilder() { - this(new AWSEC2ProviderMetadata()); - } - - public AWSEC2ContextBuilder( - ProviderMetadata providerMetadata) { - super(providerMetadata); - } - - public AWSEC2ContextBuilder(AWSEC2ApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - public AWSEC2ContextBuilder overrides(Properties overrides) { - super.overrides(warnAndReplaceIfUsingOldImageKey(overrides)); - return this; - } - - // TODO: determine how to do conditional manipulation w/rocoto - static Properties warnAndReplaceIfUsingOldImageKey(Properties props) { - if (props.containsKey(PROPERTY_EC2_AMI_OWNERS)) { - StringBuilder query = new StringBuilder(); - String owners = props.remove(PROPERTY_EC2_AMI_OWNERS).toString(); - if ("*".equals(owners)) - query.append("state=available;image-type=machine"); - else if (!"".equals(owners)) - query.append("owner-id=").append(owners).append(";state=available;image-type=machine"); - else if ("".equals(owners)) - query = new StringBuilder(); - props.setProperty(PROPERTY_EC2_AMI_QUERY, query.toString()); - Logger.getAnonymousLogger().warning( - String.format("Property %s is deprecated, please use new syntax: %s=%s", PROPERTY_EC2_AMI_OWNERS, - PROPERTY_EC2_AMI_QUERY, query.toString())); - } - return props; - } - - @Override - protected void addClientModule(List modules) { - modules.add(new AWSEC2RestClientModule()); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new AWSEC2ComputeServiceContextModule()); - } - - @VisibleForTesting - public Properties getOverrides() { - return overrides; - } - -} diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2ProviderMetadata.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2ProviderMetadata.java index 46a34a8212..07504d4c1e 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2ProviderMetadata.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2ProviderMetadata.java @@ -28,7 +28,6 @@ import java.net.URI; import java.util.Properties; import org.jclouds.aws.domain.Region; -import org.jclouds.aws.ec2.compute.AWSEC2ComputeServiceContext; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -38,7 +37,7 @@ import org.jclouds.providers.internal.BaseProviderMetadata; * * @author Adrian Cole */ -public class AWSEC2ProviderMetadata extends BaseProviderMetadata { +public class AWSEC2ProviderMetadata extends BaseProviderMetadata { public static Builder builder() { return new Builder(); @@ -57,7 +56,7 @@ public class AWSEC2ProviderMetadata extends BaseProviderMetadata { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder(){ id("aws-ec2") @@ -98,7 +97,7 @@ public class AWSEC2ProviderMetadata extends BaseProviderMetadata in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/binders/BindLaunchSpecificationToFormParams.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/binders/BindLaunchSpecificationToFormParams.java index 753ab0302b..758f66c13e 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/binders/BindLaunchSpecificationToFormParams.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/binders/BindLaunchSpecificationToFormParams.java @@ -34,8 +34,8 @@ import org.jclouds.rest.Binder; import com.google.common.base.Function; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMap.Builder; import com.google.common.collect.Multimaps; +import com.google.common.collect.ImmutableMap.Builder; /** * diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeService.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeService.java index 758630b61c..d54c7ed19d 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeService.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeService.java @@ -92,7 +92,7 @@ public class AWSEC2ComputeService extends EC2ComputeService { private final boolean generateInstanceNames; @Inject - protected AWSEC2ComputeService(@SuppressWarnings("rawtypes") ComputeServiceContext context, Map credentialStore, + protected AWSEC2ComputeService(ComputeServiceContext context, Map credentialStore, @Memoized Supplier> images, @Memoized Supplier> sizes, @Memoized Supplier> locations, ListNodesStrategy listNodesStrategy, GetNodeMetadataStrategy getNodeMetadataStrategy, diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceContext.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceContext.java index 2b1642a084..61507a9fe8 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceContext.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceContext.java @@ -18,8 +18,6 @@ */ package org.jclouds.aws.ec2.compute; -import org.jclouds.aws.ec2.AWSEC2AsyncClient; -import org.jclouds.aws.ec2.AWSEC2Client; import org.jclouds.aws.ec2.compute.internal.AWSEC2ComputeServiceContextImpl; import org.jclouds.ec2.compute.EC2ComputeServiceContext; @@ -29,7 +27,7 @@ import com.google.inject.ImplementedBy; * @author Adrian Cole */ @ImplementedBy(AWSEC2ComputeServiceContextImpl.class) -public interface AWSEC2ComputeServiceContext extends EC2ComputeServiceContext { +public interface AWSEC2ComputeServiceContext extends EC2ComputeServiceContext { @Override AWSEC2ComputeService getComputeService(); } \ No newline at end of file diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceContextModule.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceContextModule.java index c46cacd2ad..654078797a 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceContextModule.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceContextModule.java @@ -21,6 +21,7 @@ package org.jclouds.aws.ec2.compute.config; import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; import static org.jclouds.compute.domain.OsFamily.AMZN_LINUX; +import java.util.Map; import java.util.Set; import java.util.concurrent.ExecutionException; import java.util.concurrent.atomic.AtomicReference; @@ -38,7 +39,6 @@ import org.jclouds.aws.ec2.compute.strategy.AWSEC2ListNodesStrategy; import org.jclouds.aws.ec2.compute.strategy.AWSEC2ReviseParsedImage; import org.jclouds.aws.ec2.compute.strategy.CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions; import org.jclouds.aws.ec2.compute.suppliers.AWSEC2HardwareSupplier; -import org.jclouds.aws.ec2.reference.AWSEC2Constants; import org.jclouds.compute.config.BaseComputeServiceContextModule; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.TemplateBuilder; @@ -72,7 +72,6 @@ import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.Provides; import com.google.inject.TypeLiteral; -import com.google.inject.name.Names; /** * @@ -105,10 +104,8 @@ public class AWSEC2ComputeServiceContextModule extends BaseComputeServiceContext @Override protected boolean shouldParseImagesOnDemand(Injector injector) { // If no queries defined, then will never lookup all images - String amiQuery = injector.getInstance(Key.get(String.class, Names.named(AWSEC2Constants.PROPERTY_EC2_AMI_QUERY))); - String amiCcQuery = injector.getInstance(Key.get(String.class, Names.named(AWSEC2Constants.PROPERTY_EC2_CC_AMI_QUERY))); - - return !(amiQuery.isEmpty() && amiCcQuery.isEmpty()); + return injector.getInstance(Key.get(new TypeLiteral>() { + }, ImageQuery.class)).size() > 0; } // duplicates EC2ComputeServiceContextModule; but that's easiest thing to do with guice; could extract to common util diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceDependenciesModule.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceDependenciesModule.java index c123d18db4..e62a5c49cd 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceDependenciesModule.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceDependenciesModule.java @@ -18,14 +18,17 @@ */ package org.jclouds.aws.ec2.compute.config; +import static org.jclouds.aws.ec2.reference.AWSEC2Constants.*; +import static org.jclouds.ec2.reference.EC2Constants.PROPERTY_EC2_AMI_OWNERS; + +import java.util.Map; import java.util.Set; import java.util.concurrent.TimeUnit; +import java.util.logging.Logger; import javax.inject.Named; import javax.inject.Singleton; -import org.jclouds.aws.ec2.AWSEC2AsyncClient; -import org.jclouds.aws.ec2.AWSEC2Client; import org.jclouds.aws.ec2.compute.AWSEC2ComputeService; import org.jclouds.aws.ec2.compute.AWSEC2TemplateOptions; import org.jclouds.aws.ec2.compute.suppliers.CallForImages; @@ -36,11 +39,10 @@ import org.jclouds.aws.ec2.functions.ImportOrReturnExistingKeypair; import org.jclouds.aws.ec2.predicates.PlacementGroupAvailable; import org.jclouds.aws.ec2.predicates.PlacementGroupDeleted; import org.jclouds.compute.ComputeService; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.TemplateBuilder; -import org.jclouds.compute.internal.ComputeServiceContextImpl; import org.jclouds.compute.options.TemplateOptions; +import org.jclouds.config.ValueOfConfigurationKeyOrNull; import org.jclouds.domain.Credentials; import org.jclouds.ec2.compute.config.EC2ComputeServiceDependenciesModule; import org.jclouds.ec2.compute.domain.RegionAndName; @@ -53,17 +55,17 @@ import org.jclouds.ec2.compute.loaders.RegionAndIdToImage; import org.jclouds.ec2.domain.KeyPair; import org.jclouds.ec2.domain.RunningInstance; import org.jclouds.predicates.RetryablePredicate; -import org.jclouds.rest.RestContext; -import org.jclouds.rest.internal.RestContextImpl; import com.google.common.base.Function; import com.google.common.base.Predicate; +import com.google.common.base.Strings; import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.Sets; +import com.google.common.collect.ImmutableMap.Builder; import com.google.inject.Provides; -import com.google.inject.Scopes; import com.google.inject.TypeLiteral; import com.google.inject.assistedinject.FactoryModuleBuilder; import com.google.inject.name.Names; @@ -73,7 +75,6 @@ import com.google.inject.name.Names; * @author Adrian Cole */ public class AWSEC2ComputeServiceDependenciesModule extends EC2ComputeServiceDependenciesModule { - @SuppressWarnings("rawtypes") @Override protected void configure() { bind(TemplateBuilder.class).to(EC2TemplateBuilderImpl.class); @@ -91,15 +92,37 @@ public class AWSEC2ComputeServiceDependenciesModule extends EC2ComputeServiceDep }).to(ImportOrReturnExistingKeypair.class); bind(new TypeLiteral>() { }).to(RegionAndIdToImage.class); - bind(new TypeLiteral() { - }).to(new TypeLiteral>() { - }).in(Scopes.SINGLETON); - bind(new TypeLiteral>() { - }).to(new TypeLiteral>() { - }).in(Scopes.SINGLETON); install(new FactoryModuleBuilder().build(CallForImages.Factory.class)); } + @Provides + @Singleton + @ImageQuery + protected Map imageQuery(ValueOfConfigurationKeyOrNull config) { + String amiQuery = Strings.emptyToNull(config.apply(PROPERTY_EC2_AMI_QUERY)); + if (config.apply(PROPERTY_EC2_AMI_OWNERS) != null) { + StringBuilder query = new StringBuilder(); + String owners = config.apply(PROPERTY_EC2_AMI_OWNERS).toString(); + if ("*".equals(owners)) + query.append("state=available;image-type=machine"); + else if (!"".equals(owners)) + query.append("owner-id=").append(owners).append(";state=available;image-type=machine"); + else if ("".equals(owners)) + query = new StringBuilder(); + Logger.getAnonymousLogger().warning( + String.format("Property %s is deprecated, please use new syntax: %s=%s", PROPERTY_EC2_AMI_OWNERS, + PROPERTY_EC2_AMI_QUERY, query.toString())); + amiQuery = query.toString(); + } + Builder builder = ImmutableMap. builder(); + if (amiQuery != null) + builder.put(PROPERTY_EC2_AMI_QUERY, amiQuery); + String ccQuery = Strings.emptyToNull(config.apply(PROPERTY_EC2_CC_AMI_QUERY)); + if (ccQuery != null) + builder.put(PROPERTY_EC2_CC_AMI_QUERY, ccQuery); + return builder.build(); + } + @Provides @Singleton @Named("AVAILABLE") diff --git a/core/src/main/java/org/jclouds/http/RequiresHttp.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/config/ImageQuery.java similarity index 71% rename from core/src/main/java/org/jclouds/http/RequiresHttp.java rename to providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/config/ImageQuery.java index 21f188bd39..18f84958ea 100644 --- a/core/src/main/java/org/jclouds/http/RequiresHttp.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/config/ImageQuery.java @@ -16,22 +16,24 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.http; - -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; +package org.jclouds.aws.ec2.compute.config; +import java.lang.annotation.ElementType; import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import javax.inject.Qualifier; + /** - * designates the cloud has an HTTP API + * Related to an Image Query * * @author Adrian Cole * */ -@Retention(RUNTIME) -@Target(TYPE) -public @interface RequiresHttp { +@Retention(value = RetentionPolicy.RUNTIME) +@Target(value = { ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) +@Qualifier +public @interface ImageQuery { -} +} \ No newline at end of file diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/internal/AWSEC2ComputeServiceContextImpl.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/internal/AWSEC2ComputeServiceContextImpl.java index 4ed9c3fba1..bdff743e5d 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/internal/AWSEC2ComputeServiceContextImpl.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/internal/AWSEC2ComputeServiceContextImpl.java @@ -18,29 +18,30 @@ */ package org.jclouds.aws.ec2.compute.internal; +import java.io.Closeable; import java.util.Map; import javax.inject.Inject; import javax.inject.Singleton; -import org.jclouds.aws.ec2.AWSEC2AsyncClient; -import org.jclouds.aws.ec2.AWSEC2Client; import org.jclouds.aws.ec2.compute.AWSEC2ComputeService; import org.jclouds.aws.ec2.compute.AWSEC2ComputeServiceContext; import org.jclouds.compute.Utils; import org.jclouds.domain.Credentials; import org.jclouds.ec2.compute.internal.EC2ComputeServiceContextImpl; -import org.jclouds.rest.RestContext; +import org.jclouds.location.Provider; + +import com.google.common.reflect.TypeToken; /** * @author Adrian Cole */ @Singleton -public class AWSEC2ComputeServiceContextImpl extends EC2ComputeServiceContextImpl implements AWSEC2ComputeServiceContext { +public class AWSEC2ComputeServiceContextImpl extends EC2ComputeServiceContextImpl implements AWSEC2ComputeServiceContext { @Inject - public AWSEC2ComputeServiceContextImpl(AWSEC2ComputeService computeService, Map credentialStore, - Utils utils, @SuppressWarnings("rawtypes") RestContext providerSpecificContext) { - super(computeService, credentialStore, utils, providerSpecificContext); + public AWSEC2ComputeServiceContextImpl(@Provider Closeable wrapped, @Provider TypeToken wrappedType, + AWSEC2ComputeService computeService, Map credentialStore, Utils utils){ + super(wrapped, wrappedType, computeService, credentialStore, utils); } @Override diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/suppliers/AWSEC2ImageSupplier.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/suppliers/AWSEC2ImageSupplier.java index 277bc0a18c..e4cf5b0618 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/suppliers/AWSEC2ImageSupplier.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/suppliers/AWSEC2ImageSupplier.java @@ -36,6 +36,7 @@ import javax.inject.Singleton; import org.jclouds.Constants; import org.jclouds.aws.ec2.compute.config.ClusterCompute; +import org.jclouds.aws.ec2.compute.config.ImageQuery; import org.jclouds.compute.domain.Image; import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.ec2.compute.domain.RegionAndName; @@ -73,31 +74,31 @@ public class AWSEC2ImageSupplier implements Supplier> { private final ExecutorService executor; private final Supplier> regions; - private final String amiQuery; + private final Map queries; private final Iterable clusterRegions; - private final String ccAmiQuery; private final Supplier> cache; @Inject protected AWSEC2ImageSupplier(@Region Supplier> regions, - @Named(PROPERTY_EC2_AMI_QUERY) String amiQuery, @Named(PROPERTY_EC2_CC_REGIONS) String clusterRegions, - @Named(PROPERTY_EC2_CC_AMI_QUERY) String ccAmiQuery, + @ImageQuery Map queries, @Named(PROPERTY_EC2_CC_REGIONS) String clusterRegions, Supplier> cache, CallForImages.Factory factory, @ClusterCompute Set clusterComputeIds, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) { this.factory = factory; this.regions = regions; - this.amiQuery = amiQuery; + this.queries = queries; this.clusterRegions = Splitter.on(',').split(clusterRegions); - this.ccAmiQuery = ccAmiQuery; this.cache = cache; this.clusterComputeIds = clusterComputeIds; this.executor = executor; } - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings("unchecked") @Override public Set get() { + String amiQuery = queries.get(PROPERTY_EC2_AMI_QUERY); + String ccAmiQuery= queries.get(PROPERTY_EC2_CC_AMI_QUERY); + Future> normalImages = images(regions.get(), amiQuery, PROPERTY_EC2_AMI_QUERY); ImmutableSet clusterImages; try { @@ -124,7 +125,7 @@ public class AWSEC2ImageSupplier implements Supplier> { final Map imageMap = ImagesToRegionAndIdMap.imagesToMap(parsedImages); cache.get().invalidateAll(); - cache.get().asMap().putAll((Map)imageMap); + cache.get().asMap().putAll((Map) imageMap); logger.debug("<< images(%d)", imageMap.size()); // TODO Used to be mutable; was this assumed anywhere? @@ -136,7 +137,7 @@ public class AWSEC2ImageSupplier implements Supplier> { } private Future> images(Iterable regions, String query, String tag) { - if (query.equals("")) { + if (query == null) { logger.debug(">> no %s specified, skipping image parsing", tag); return Futures.> immediateFuture(ImmutableSet. of()); } else { diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/suppliers/CallForImages.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/suppliers/CallForImages.java index fa4559c7d1..9fb8b9cf19 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/suppliers/CallForImages.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/suppliers/CallForImages.java @@ -39,9 +39,9 @@ import org.jclouds.logging.Logger; import com.google.common.base.Predicates; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMap.Builder; import com.google.common.collect.Iterables; import com.google.common.collect.Multimap; +import com.google.common.collect.ImmutableMap.Builder; import com.google.inject.assistedinject.Assisted; /** diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/config/AWSEC2RestClientModule.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/config/AWSEC2RestClientModule.java index a5b4c7105f..90072be664 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/config/AWSEC2RestClientModule.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/config/AWSEC2RestClientModule.java @@ -61,7 +61,6 @@ import org.jclouds.ec2.services.SecurityGroupAsyncClient; import org.jclouds.ec2.services.SecurityGroupClient; import org.jclouds.ec2.services.WindowsAsyncClient; import org.jclouds.ec2.services.WindowsClient; -import org.jclouds.http.RequiresHttp; import org.jclouds.rest.ConfiguresRestClient; import com.google.common.collect.ImmutableMap; @@ -72,7 +71,6 @@ import com.google.inject.Provides; * * @author Adrian Cole */ -@RequiresHttp @ConfiguresRestClient public class AWSEC2RestClientModule extends EC2RestClientModule { diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/AWSEC2ContextBuilderTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/AWSEC2ContextBuilderTest.java index cd2d12c99a..bd2e719c94 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/AWSEC2ContextBuilderTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/AWSEC2ContextBuilderTest.java @@ -22,38 +22,50 @@ import static org.jclouds.aws.ec2.reference.AWSEC2Constants.PROPERTY_EC2_AMI_QUE import static org.jclouds.ec2.reference.EC2Constants.PROPERTY_EC2_AMI_OWNERS; import static org.testng.Assert.assertEquals; +import java.util.Map; import java.util.Properties; +import org.jclouds.ContextBuilder; +import org.jclouds.aws.ec2.compute.config.ImageQuery; import org.testng.annotations.Test; +import com.google.inject.Key; +import com.google.inject.TypeLiteral; + /** * @author Adrian Cole */ @Test(groups = "unit", testName = "AWSEC2ContextBuilderTest") public class AWSEC2ContextBuilderTest { + private Map queriesForProperties(Properties input) { + return ContextBuilder.newBuilder(new AWSEC2ProviderMetadata()).overrides(input).credentials("foo", "bar") + .buildInjector().getInstance(Key.get(new TypeLiteral>() { + }, ImageQuery.class)); + } public void testConvertImageSyntax() { Properties input = new Properties(); input.setProperty(PROPERTY_EC2_AMI_OWNERS, "137112412989,063491364108,099720109477,411009282317"); - Properties props = new AWSEC2ContextBuilder().overrides(input).getOverrides(); - assertEquals(props.getProperty(PROPERTY_EC2_AMI_OWNERS), null); - assertEquals(props.getProperty(PROPERTY_EC2_AMI_QUERY), + Map queries = queriesForProperties(input); + assertEquals(queries.get(PROPERTY_EC2_AMI_OWNERS), null); + assertEquals(queries.get(PROPERTY_EC2_AMI_QUERY), "owner-id=137112412989,063491364108,099720109477,411009282317;state=available;image-type=machine"); } public void testConvertImageSyntaxWhenStar() { Properties input = new Properties(); input.setProperty(PROPERTY_EC2_AMI_OWNERS, "*"); - Properties props = new AWSEC2ContextBuilder().overrides(input).getOverrides(); - assertEquals(props.getProperty(PROPERTY_EC2_AMI_OWNERS), null); - assertEquals(props.getProperty(PROPERTY_EC2_AMI_QUERY), "state=available;image-type=machine"); + Map queries = queriesForProperties(input); + assertEquals(queries.get(PROPERTY_EC2_AMI_OWNERS), null); + assertEquals(queries.get(PROPERTY_EC2_AMI_QUERY), "state=available;image-type=machine"); } - public void testConvertImageSyntaxWhenBlank() { + public void testStaysPutWhenBlank() { Properties input = new Properties(); input.setProperty(PROPERTY_EC2_AMI_OWNERS, ""); - Properties props = new AWSEC2ContextBuilder().overrides(input).getOverrides(); - assertEquals(props.getProperty(PROPERTY_EC2_AMI_OWNERS), null); - assertEquals(props.getProperty(PROPERTY_EC2_AMI_QUERY), ""); + Map queries = queriesForProperties(input); + assertEquals(queries.get(PROPERTY_EC2_AMI_OWNERS), null); + assertEquals(queries.get(PROPERTY_EC2_AMI_QUERY), new AWSEC2ProviderMetadata().getDefaultProperties() + .getProperty(PROPERTY_EC2_AMI_QUERY)); } } diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceLiveTest.java index 8ebe24b440..a57c2801a5 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceLiveTest.java @@ -31,8 +31,9 @@ import java.util.Date; import java.util.Set; import java.util.concurrent.TimeUnit; +import org.jclouds.ContextBuilder; import org.jclouds.aws.cloudwatch.AWSCloudWatchProviderMetadata; -import org.jclouds.aws.ec2.AWSEC2AsyncClient; +import org.jclouds.aws.ec2.AWSEC2ApiMetadata; import org.jclouds.aws.ec2.AWSEC2Client; import org.jclouds.aws.ec2.domain.AWSRunningInstance; import org.jclouds.aws.ec2.domain.MonitoringState; @@ -56,7 +57,6 @@ import org.jclouds.ec2.domain.SecurityGroup; import org.jclouds.ec2.services.InstanceClient; import org.jclouds.ec2.services.KeyPairClient; import org.jclouds.rest.RestContext; -import org.jclouds.rest.internal.ContextBuilder; import org.jclouds.scriptbuilder.domain.Statements; import org.testng.annotations.Test; @@ -73,7 +73,7 @@ import com.google.common.util.concurrent.ListenableFuture; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "AWSEC2ComputeServiceLiveTest") -public class AWSEC2ComputeServiceLiveTest extends EC2ComputeServiceLiveTest { +public class AWSEC2ComputeServiceLiveTest extends EC2ComputeServiceLiveTest { public AWSEC2ComputeServiceLiveTest() { provider = "aws-ec2"; @@ -93,12 +93,12 @@ public class AWSEC2ComputeServiceLiveTest extends EC2ComputeServiceLiveTest destroyer) throws Exception { - AWSSecurityGroupClient securityGroupClient = AWSEC2Client.class.cast(context.getProviderSpecificContext().getApi()) + AWSSecurityGroupClient securityGroupClient = AWSEC2Client.class.cast(context.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi()) .getSecurityGroupServices(); - KeyPairClient keyPairClient = EC2Client.class.cast(context.getProviderSpecificContext().getApi()) + KeyPairClient keyPairClient = EC2Client.class.cast(context.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi()) .getKeyPairServices(); - InstanceClient instanceClient = EC2Client.class.cast(context.getProviderSpecificContext().getApi()) + InstanceClient instanceClient = EC2Client.class.cast(context.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi()) .getInstanceServices(); String group = this.group + "incidental"; diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java index f32ff4875e..b02b379c7f 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java @@ -28,8 +28,6 @@ import java.util.Properties; import java.util.Set; import org.jclouds.aws.domain.Region; -import org.jclouds.aws.ec2.AWSEC2AsyncClient; -import org.jclouds.aws.ec2.AWSEC2Client; import org.jclouds.aws.ec2.reference.AWSEC2Constants; import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; @@ -60,7 +58,7 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live") -public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest { +public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest { public AWSEC2TemplateBuilderLiveTest() { provider = "aws-ec2"; @@ -239,7 +237,7 @@ public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest context = null; + ComputeServiceContext context = null; try { Properties overrides = setupProperties(); // set owners to nothing @@ -273,7 +271,7 @@ public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest context = null; + ComputeServiceContext context = null; try { Properties overrides = setupProperties(); // set owners to nothing @@ -307,7 +305,7 @@ public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest context = null; + ComputeServiceContext context = null; try { Properties overrides = setupProperties(); // set regions to only 1 diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AMIClientLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AMIClientLiveTest.java index fd7ece9fa4..556426ad44 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AMIClientLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AMIClientLiveTest.java @@ -29,9 +29,7 @@ import java.util.Iterator; import java.util.Set; import org.jclouds.aws.domain.Region; -import org.jclouds.aws.ec2.AWSEC2AsyncClient; -import org.jclouds.aws.ec2.AWSEC2Client; -import org.jclouds.aws.ec2.compute.AWSEC2ComputeServiceContext; +import org.jclouds.aws.ec2.AWSEC2ApiMetadata; import org.jclouds.compute.ComputeService; import org.jclouds.compute.RunNodesException; import org.jclouds.compute.domain.NodeMetadata; @@ -40,11 +38,11 @@ import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.compute.predicates.ImagePredicates; import org.jclouds.ec2.domain.BlockDevice; import org.jclouds.ec2.domain.Image; -import org.jclouds.ec2.domain.Image.ImageType; import org.jclouds.ec2.domain.Reservation; import org.jclouds.ec2.domain.RootDeviceType; import org.jclouds.ec2.domain.RunningInstance; import org.jclouds.ec2.domain.Snapshot; +import org.jclouds.ec2.domain.Image.ImageType; import org.jclouds.ec2.services.AMIClient; import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeClass; @@ -63,7 +61,7 @@ import com.google.common.collect.Sets; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true) -public class AMIClientLiveTest extends BaseComputeServiceContextLiveTest { +public class AMIClientLiveTest extends BaseComputeServiceContextLiveTest { public AMIClientLiveTest() { provider = "aws-ec2"; // TODO: parameterize this. @@ -81,7 +79,7 @@ public class AMIClientLiveTest extends BaseComputeServiceContextLiveTest allResults = client.describeImagesInRegion(region); assertNotNull(allResults); assert allResults.size() >= 2 : allResults.size(); @@ -186,10 +184,10 @@ public class AMIClientLiveTest extends BaseComputeServiceContextLiveTest nodes = computeService.createNodesInGroup("jcloudstest", 1, options); try { String instanceId = Iterables.getOnlyElement(nodes).getProviderId(); - Reservation reservation = Iterables.getOnlyElement(context.getProviderSpecificContext().getApi().getInstanceServices().describeInstancesInRegion(null, instanceId)); + Reservation reservation = Iterables.getOnlyElement(context.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi().getInstanceServices().describeInstancesInRegion(null, instanceId)); RunningInstance instance = Iterables.getOnlyElement(reservation); BlockDevice device = instance.getEbsBlockDevices().get("/dev/sda1"); - Snapshot snapshot = context.getProviderSpecificContext().getApi().getElasticBlockStoreServices().createSnapshotInRegion(null, device.getVolumeId()); + Snapshot snapshot = context.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi().getElasticBlockStoreServices().createSnapshotInRegion(null, device.getVolumeId()); snapshotsToDelete.add(snapshot.getId()); return snapshot; } finally { @@ -271,7 +269,7 @@ public class AMIClientLiveTest extends BaseComputeServiceContextLiveTest { +public class AWSAMIClientLiveTest extends BaseComputeServiceContextLiveTest { public AWSAMIClientLiveTest() { provider = "aws-ec2"; // TODO: parameterize this. @@ -65,7 +63,7 @@ public class AWSAMIClientLiveTest extends BaseComputeServiceContextLiveTest allResults = Sets.newLinkedHashSet(client.describeImagesInRegion(region)); assertNotNull(allResults); assert allResults.size() >= 2 : allResults.size(); diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSInstanceClientLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSInstanceClientLiveTest.java index 068e7dec17..de125a3107 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSInstanceClientLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSInstanceClientLiveTest.java @@ -22,9 +22,7 @@ import static org.testng.Assert.assertNotNull; import java.util.Set; -import org.jclouds.aws.ec2.AWSEC2AsyncClient; -import org.jclouds.aws.ec2.AWSEC2Client; -import org.jclouds.aws.ec2.compute.AWSEC2ComputeServiceContext; +import org.jclouds.aws.ec2.AWSEC2ApiMetadata; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.ec2.domain.Reservation; import org.jclouds.ec2.domain.RunningInstance; @@ -37,7 +35,7 @@ import org.testng.annotations.Test; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true) -public class AWSInstanceClientLiveTest extends BaseComputeServiceContextLiveTest { +public class AWSInstanceClientLiveTest extends BaseComputeServiceContextLiveTest { public AWSInstanceClientLiveTest() { provider = "aws-ec2"; } @@ -50,12 +48,12 @@ public class AWSInstanceClientLiveTest extends BaseComputeServiceContextLiveTest @BeforeClass(groups = { "integration", "live" }) public void setupContext() { super.setupContext(); - client = context.getProviderSpecificContext().getApi().getInstanceServices(); + client = context.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi().getInstanceServices(); } @Test void testDescribeInstances() { - for (String region : context.getProviderSpecificContext().getApi().getAvailabilityZoneAndRegionServices().describeRegions().keySet()) { + for (String region : context.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi().getAvailabilityZoneAndRegionServices().describeRegions().keySet()) { Set> allResults = client.describeInstancesInRegion(region); assertNotNull(allResults); assert allResults.size() >= 0 : allResults.size(); diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSKeyPairClientLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSKeyPairClientLiveTest.java index 5a915fb7aa..3ba56147d3 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSKeyPairClientLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSKeyPairClientLiveTest.java @@ -35,9 +35,8 @@ import java.util.Set; import java.util.SortedSet; import org.jclouds.aws.domain.Region; -import org.jclouds.aws.ec2.AWSEC2AsyncClient; +import org.jclouds.aws.ec2.AWSEC2ApiMetadata; import org.jclouds.aws.ec2.AWSEC2Client; -import org.jclouds.aws.ec2.compute.AWSEC2ComputeServiceContext; import org.jclouds.aws.ec2.compute.AWSEC2TemplateOptions; import org.jclouds.aws.ec2.domain.AWSRunningInstance; import org.jclouds.compute.ComputeServiceContext; @@ -61,7 +60,7 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true) -public class AWSKeyPairClientLiveTest extends BaseComputeServiceContextLiveTest { +public class AWSKeyPairClientLiveTest extends BaseComputeServiceContextLiveTest { public AWSKeyPairClientLiveTest() { provider = "aws-ec2"; } @@ -72,14 +71,14 @@ public class AWSKeyPairClientLiveTest extends BaseComputeServiceContextLiveTest< @BeforeClass(groups = { "integration", "live" }) public void setupContext() { super.setupContext(); - client = context.getProviderSpecificContext().getApi().getKeyPairServices(); + client = context.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi().getKeyPairServices(); } public void testNoSsh() throws Exception { Map keyPair = ComputeTestUtils.setupKeyPair(); - AWSInstanceClient instanceClient = AWSEC2Client.class.cast(context.getProviderSpecificContext().getApi()).getInstanceServices(); + AWSInstanceClient instanceClient = AWSEC2Client.class.cast(context.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi()).getInstanceServices(); String group = PREFIX + "unssh"; context.getComputeService().destroyNodesMatching(inGroup(group)); @@ -88,7 +87,7 @@ public class AWSKeyPairClientLiveTest extends BaseComputeServiceContextLiveTest< options.authorizePublicKey(keyPair.get("public")).as(AWSEC2TemplateOptions.class); - ComputeServiceContext noSshContext = null; + ComputeServiceContext noSshContext = null; try { noSshContext = createContext(setupProperties(), ImmutableSet. of(new Log4JLoggingModule())); diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSSecurityGroupClientLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSSecurityGroupClientLiveTest.java index fc3b2a0966..7c86695f43 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSSecurityGroupClientLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSSecurityGroupClientLiveTest.java @@ -23,9 +23,6 @@ import static org.testng.Assert.assertNotNull; import java.util.Set; -import org.jclouds.aws.ec2.AWSEC2AsyncClient; -import org.jclouds.aws.ec2.AWSEC2Client; -import org.jclouds.aws.ec2.compute.AWSEC2ComputeServiceContext; import org.jclouds.ec2.domain.IpPermission; import org.jclouds.ec2.domain.IpProtocol; import org.jclouds.ec2.domain.SecurityGroup; @@ -41,7 +38,7 @@ import com.google.common.collect.ImmutableMultimap; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true) -public class AWSSecurityGroupClientLiveTest extends SecurityGroupClientLiveTest { +public class AWSSecurityGroupClientLiveTest extends SecurityGroupClientLiveTest { public AWSSecurityGroupClientLiveTest() { provider = "aws-ec2"; } diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/BaseAWSEC2AsyncClientTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/BaseAWSEC2AsyncClientTest.java index 3e184ba397..add38e4eca 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/BaseAWSEC2AsyncClientTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/BaseAWSEC2AsyncClientTest.java @@ -36,7 +36,6 @@ import org.jclouds.compute.domain.Image; import org.jclouds.date.DateService; import org.jclouds.ec2.compute.domain.RegionAndName; import org.jclouds.http.HttpRequest; -import org.jclouds.http.RequiresHttp; import org.jclouds.location.config.LocationModule; import org.jclouds.location.suppliers.RegionIdToURISupplier; import org.jclouds.location.suppliers.RegionIdToZoneIdsSupplier; @@ -61,8 +60,7 @@ import com.google.inject.Provides; @Test(groups = "unit") public abstract class BaseAWSEC2AsyncClientTest extends BaseAsyncClientTest { - @RequiresHttp - @ConfiguresRestClient + @ConfiguresRestClient protected static class StubAWSEC2RestClientModule extends AWSEC2RestClientModule { @Override diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/MonitoringClientLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/MonitoringClientLiveTest.java index a1333fa1bb..595dec84b6 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/MonitoringClientLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/MonitoringClientLiveTest.java @@ -22,9 +22,7 @@ import static org.testng.Assert.assertEquals; import java.util.Map; -import org.jclouds.aws.ec2.AWSEC2AsyncClient; -import org.jclouds.aws.ec2.AWSEC2Client; -import org.jclouds.aws.ec2.compute.AWSEC2ComputeServiceContext; +import org.jclouds.aws.ec2.AWSEC2ApiMetadata; import org.jclouds.aws.ec2.domain.MonitoringState; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.testng.annotations.BeforeClass; @@ -36,7 +34,7 @@ import org.testng.annotations.Test; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true) -public class MonitoringClientLiveTest extends BaseComputeServiceContextLiveTest { +public class MonitoringClientLiveTest extends BaseComputeServiceContextLiveTest { public MonitoringClientLiveTest() { provider = "aws-ec2"; } @@ -49,7 +47,7 @@ public class MonitoringClientLiveTest extends BaseComputeServiceContextLiveTest< @BeforeClass(groups = { "integration", "live" }) public void setupContext() { super.setupContext(); - client = context.getProviderSpecificContext().getApi().getMonitoringServices(); + client = context.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi().getMonitoringServices(); } @Test(enabled = false) diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/PlacementGroupClientLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/PlacementGroupClientLiveTest.java index 0899b6ce28..1e5662434a 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/PlacementGroupClientLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/PlacementGroupClientLiveTest.java @@ -29,9 +29,8 @@ import java.util.SortedSet; import java.util.concurrent.TimeUnit; import org.jclouds.aws.domain.Region; -import org.jclouds.aws.ec2.AWSEC2AsyncClient; +import org.jclouds.aws.ec2.AWSEC2ApiMetadata; import org.jclouds.aws.ec2.AWSEC2Client; -import org.jclouds.aws.ec2.compute.AWSEC2ComputeServiceContext; import org.jclouds.aws.ec2.domain.PlacementGroup; import org.jclouds.aws.ec2.domain.PlacementGroup.State; import org.jclouds.aws.ec2.predicates.PlacementGroupAvailable; @@ -59,7 +58,7 @@ import com.google.common.base.Throwables; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "PlacementGroupClientLiveTest") -public class PlacementGroupClientLiveTest extends BaseComputeServiceContextLiveTest { +public class PlacementGroupClientLiveTest extends BaseComputeServiceContextLiveTest { public PlacementGroupClientLiveTest() { provider = "aws-ec2"; } @@ -73,7 +72,7 @@ public class PlacementGroupClientLiveTest extends BaseComputeServiceContextLiveT @BeforeClass(groups = { "integration", "live" }) public void setupContext() { super.setupContext(); - client = context.getProviderSpecificContext().getApi(); + client = context.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi(); availableTester = new RetryablePredicate(new PlacementGroupAvailable(client), 60, 1, TimeUnit.SECONDS); diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/SpotInstanceClientLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/SpotInstanceClientLiveTest.java index 32c895b320..36726832a7 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/SpotInstanceClientLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/SpotInstanceClientLiveTest.java @@ -31,9 +31,8 @@ import java.util.SortedSet; import java.util.concurrent.TimeUnit; import org.jclouds.aws.domain.Region; -import org.jclouds.aws.ec2.AWSEC2AsyncClient; +import org.jclouds.aws.ec2.AWSEC2ApiMetadata; import org.jclouds.aws.ec2.AWSEC2Client; -import org.jclouds.aws.ec2.compute.AWSEC2ComputeServiceContext; import org.jclouds.aws.ec2.domain.AWSRunningInstance; import org.jclouds.aws.ec2.domain.LaunchSpecification; import org.jclouds.aws.ec2.domain.Spot; @@ -55,7 +54,7 @@ import com.google.common.collect.ImmutableSortedSet; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true) -public class SpotInstanceClientLiveTest extends BaseComputeServiceContextLiveTest { +public class SpotInstanceClientLiveTest extends BaseComputeServiceContextLiveTest { public SpotInstanceClientLiveTest() { provider = "aws-ec2"; } @@ -71,7 +70,7 @@ public class SpotInstanceClientLiveTest extends BaseComputeServiceContextLiveTe @BeforeClass(groups = { "integration", "live" }) public void setupContext() { super.setupContext(); - client = context.getProviderSpecificContext().getApi(); + client = context.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi(); activeTester = new RetryablePredicate(new SpotInstanceRequestActive(client), SPOT_DELAY_SECONDS, 1, 1, TimeUnit.SECONDS); } diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/TagClientLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/TagClientLiveTest.java index 3f554f7f34..13723dc0e8 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/TagClientLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/TagClientLiveTest.java @@ -24,9 +24,7 @@ import static org.testng.Assert.assertNotNull; import java.util.Set; -import org.jclouds.aws.ec2.AWSEC2AsyncClient; -import org.jclouds.aws.ec2.AWSEC2Client; -import org.jclouds.aws.ec2.compute.AWSEC2ComputeServiceContext; +import org.jclouds.aws.ec2.AWSEC2ApiMetadata; import org.jclouds.aws.ec2.domain.AWSRunningInstance; import org.jclouds.aws.ec2.domain.Tag; import org.jclouds.aws.ec2.util.TagFilters; @@ -46,7 +44,7 @@ import com.google.common.collect.Iterables; * @author grkvlt@apache.org */ @Test(groups = "live", singleThreaded = true) -public class TagClientLiveTest extends BaseComputeServiceContextLiveTest { +public class TagClientLiveTest extends BaseComputeServiceContextLiveTest { public TagClientLiveTest() { provider = "aws-ec2"; } @@ -58,22 +56,22 @@ public class TagClientLiveTest extends BaseComputeServiceContextLiveTest { +public class AWSS3ApiMetadata extends S3ApiMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = -1572520638079261710L; + + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; + private static Builder builder() { return new Builder(); } @@ -49,19 +62,19 @@ public class AWSS3ApiMetadata extends S3ApiMetadata { + public static class Builder extends S3ApiMetadata.Builder { protected Builder(){ super(AWSS3Client.class, AWSS3AsyncClient.class); id("aws-s3") .name("Amazon-specific S3 API") .defaultProperties(AWSS3ApiMetadata.defaultProperties()) - .context(TypeToken.of(AWSS3BlobStoreContext.class)) - .contextBuilder(TypeToken.of(AWSS3ContextBuilder.class)); + .wrapper(TypeToken.of(AWSS3BlobStoreContext.class)) + .defaultModules(ImmutableSet.>of(AWSS3RestClientModule.class, AWSS3BlobStoreContextModule.class)); } @Override @@ -70,7 +83,7 @@ public class AWSS3ApiMetadata extends S3ApiMetadata { - public AWSS3ContextBuilder() { - this(new AWSS3ProviderMetadata()); - } - - public AWSS3ContextBuilder( - ProviderMetadata providerMetadata) { - super(providerMetadata); - } - - public AWSS3ContextBuilder(AWSS3ApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new AWSS3BlobStoreContextModule()); - } - - @Override - protected void addClientModule(List modules) { - modules.add(new AWSS3RestClientModule()); - } - -} diff --git a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/AWSS3ProviderMetadata.java b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/AWSS3ProviderMetadata.java index 7dafc9d487..24e9d6234c 100644 --- a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/AWSS3ProviderMetadata.java +++ b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/AWSS3ProviderMetadata.java @@ -32,7 +32,6 @@ import java.net.URI; import java.util.Properties; import org.jclouds.aws.domain.Region; -import org.jclouds.aws.s3.blobstore.AWSS3BlobStoreContext; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -42,8 +41,11 @@ import org.jclouds.providers.internal.BaseProviderMetadata; * * @author Adrian Cole */ -public class AWSS3ProviderMetadata extends BaseProviderMetadata { +public class AWSS3ProviderMetadata extends BaseProviderMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = 3727028894286338406L; + public static Builder builder() { return new Builder(); } @@ -61,7 +63,7 @@ public class AWSS3ProviderMetadata extends BaseProviderMetadata { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder(){ id("aws-s3") @@ -97,7 +99,7 @@ public class AWSS3ProviderMetadata extends BaseProviderMetadata in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/AWSS3AsyncBlobStore.java b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/AWSS3AsyncBlobStore.java index 7f8476d7c8..6d54d71953 100644 --- a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/AWSS3AsyncBlobStore.java +++ b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/AWSS3AsyncBlobStore.java @@ -28,6 +28,7 @@ import javax.inject.Named; import javax.inject.Provider; import org.jclouds.Constants; +import org.jclouds.aws.s3.AWSS3ApiMetadata; import org.jclouds.aws.s3.AWSS3AsyncClient; import org.jclouds.aws.s3.AWSS3Client; import org.jclouds.aws.s3.blobstore.options.AWSS3PutObjectOptions; @@ -41,7 +42,6 @@ import org.jclouds.blobstore.strategy.internal.FetchBlobMetadata; import org.jclouds.blobstore.util.BlobUtils; import org.jclouds.collect.Memoized; import org.jclouds.domain.Location; -import org.jclouds.s3.S3AsyncClient; import org.jclouds.s3.blobstore.S3AsyncBlobStore; import org.jclouds.s3.blobstore.functions.BlobToObject; import org.jclouds.s3.blobstore.functions.BucketToResourceList; @@ -69,7 +69,7 @@ public class AWSS3AsyncBlobStore extends S3AsyncBlobStore { private final BlobToObject blob2Object; @Inject - public AWSS3AsyncBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, + public AWSS3AsyncBlobStore(BlobStoreContext context, BlobUtils blobUtils, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService service, Supplier defaultLocation, @Memoized Supplier> locations, AWSS3AsyncClient async, AWSS3Client sync, BucketToResourceMetadata bucket2ResourceMd, ContainerToBucketListOptions container2BucketListOptions, @@ -112,8 +112,8 @@ public class AWSS3AsyncBlobStore extends S3AsyncBlobStore { } catch (CacheLoader.InvalidCacheLoadException e) { // nulls not permitted from cache loader } - return S3AsyncClient.class.cast(getContext().getProviderSpecificContext().getApi()) - .putObject(container, blob2Object.apply(blob), options); - } + return getContext().unwrap(AWSS3ApiMetadata.CONTEXT_TOKEN).getAsyncApi().putObject(container, + blob2Object.apply(blob), options); + } } diff --git a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/AWSS3BlobStore.java b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/AWSS3BlobStore.java index 8fc842687d..89cc7e5ac1 100644 --- a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/AWSS3BlobStore.java +++ b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/AWSS3BlobStore.java @@ -25,6 +25,7 @@ import java.util.Set; import javax.inject.Inject; import javax.inject.Provider; +import org.jclouds.aws.s3.AWSS3ApiMetadata; import org.jclouds.aws.s3.AWSS3Client; import org.jclouds.aws.s3.blobstore.options.AWSS3PutObjectOptions; import org.jclouds.aws.s3.blobstore.options.AWSS3PutOptions; @@ -37,7 +38,6 @@ import org.jclouds.blobstore.strategy.internal.FetchBlobMetadata; import org.jclouds.blobstore.util.BlobUtils; import org.jclouds.collect.Memoized; import org.jclouds.domain.Location; -import org.jclouds.s3.S3Client; import org.jclouds.s3.blobstore.S3BlobStore; import org.jclouds.s3.blobstore.functions.BlobToObject; import org.jclouds.s3.blobstore.functions.BucketToResourceList; @@ -65,7 +65,7 @@ public class AWSS3BlobStore extends S3BlobStore { private final BlobToObject blob2Object; @Inject - AWSS3BlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, Supplier defaultLocation, + AWSS3BlobStore(BlobStoreContext context, BlobUtils blobUtils, Supplier defaultLocation, @Memoized Supplier> locations, AWSS3Client sync, BucketToResourceMetadata bucket2ResourceMd, ContainerToBucketListOptions container2BucketListOptions, BucketToResourceList bucket2ResourceList, ObjectToBlob object2Blob, @@ -108,7 +108,7 @@ public class AWSS3BlobStore extends S3BlobStore { } catch (CacheLoader.InvalidCacheLoadException e) { // nulls not permitted from cache loader } - return S3Client.class.cast(getContext().getProviderSpecificContext().getApi()) - .putObject(container, blob2Object.apply(blob), options); + return getContext().unwrap(AWSS3ApiMetadata.CONTEXT_TOKEN).getApi().putObject(container, blob2Object.apply(blob), + options); } } diff --git a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/AWSS3BlobStoreContext.java b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/AWSS3BlobStoreContext.java index a95e175ab0..ed1c859440 100644 --- a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/AWSS3BlobStoreContext.java +++ b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/AWSS3BlobStoreContext.java @@ -18,8 +18,6 @@ */ package org.jclouds.aws.s3.blobstore; -import org.jclouds.aws.s3.AWSS3AsyncClient; -import org.jclouds.aws.s3.AWSS3Client; import org.jclouds.aws.s3.blobstore.internal.AWSS3BlobStoreContextImpl; import org.jclouds.s3.blobstore.S3BlobStoreContext; @@ -29,7 +27,7 @@ import com.google.inject.ImplementedBy; * @author Adrian Cole */ @ImplementedBy(AWSS3BlobStoreContextImpl.class) -public interface AWSS3BlobStoreContext extends S3BlobStoreContext { +public interface AWSS3BlobStoreContext extends S3BlobStoreContext { @Override AWSS3BlobStore getBlobStore(); diff --git a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/config/AWSS3BlobStoreContextModule.java b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/config/AWSS3BlobStoreContextModule.java index 71c85e2eec..4b8a2f5316 100644 --- a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/config/AWSS3BlobStoreContextModule.java +++ b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/config/AWSS3BlobStoreContextModule.java @@ -18,22 +18,17 @@ */ package org.jclouds.aws.s3.blobstore.config; -import org.jclouds.aws.s3.AWSS3AsyncClient; -import org.jclouds.aws.s3.AWSS3Client; import org.jclouds.aws.s3.blobstore.AWSS3AsyncBlobStore; import org.jclouds.aws.s3.blobstore.AWSS3BlobStore; import org.jclouds.aws.s3.blobstore.strategy.AsyncMultipartUploadStrategy; import org.jclouds.aws.s3.blobstore.strategy.MultipartUploadStrategy; import org.jclouds.aws.s3.blobstore.strategy.internal.ParallelMultipartUploadStrategy; import org.jclouds.aws.s3.blobstore.strategy.internal.SequentialMultipartUploadStrategy; -import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.internal.BlobStoreContextImpl; import org.jclouds.s3.blobstore.S3AsyncBlobStore; import org.jclouds.s3.blobstore.S3BlobStore; import org.jclouds.s3.blobstore.config.S3BlobStoreContextModule; import com.google.inject.Scopes; -import com.google.inject.TypeLiteral; /** * @@ -51,10 +46,4 @@ public class AWSS3BlobStoreContextModule extends S3BlobStoreContextModule { bind(AsyncMultipartUploadStrategy.class).to(ParallelMultipartUploadStrategy.class); } - @Override - protected void bindContext() { - bind(BlobStoreContext.class).to(new TypeLiteral>() { - }).in(Scopes.SINGLETON); - } - } diff --git a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/internal/AWSS3BlobStoreContextImpl.java b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/internal/AWSS3BlobStoreContextImpl.java index 640f7431d1..4ba96d14a2 100644 --- a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/internal/AWSS3BlobStoreContextImpl.java +++ b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/internal/AWSS3BlobStoreContextImpl.java @@ -18,35 +18,39 @@ */ package org.jclouds.aws.s3.blobstore.internal; +import java.io.Closeable; + import javax.inject.Inject; import javax.inject.Singleton; -import org.jclouds.aws.s3.AWSS3AsyncClient; -import org.jclouds.aws.s3.AWSS3Client; import org.jclouds.aws.s3.blobstore.AWSS3AsyncBlobStore; import org.jclouds.aws.s3.blobstore.AWSS3BlobStore; import org.jclouds.aws.s3.blobstore.AWSS3BlobStoreContext; +import org.jclouds.blobstore.AsyncBlobStore; import org.jclouds.blobstore.BlobMap; import org.jclouds.blobstore.BlobRequestSigner; +import org.jclouds.blobstore.BlobStore; import org.jclouds.blobstore.InputStreamMap; import org.jclouds.blobstore.attr.ConsistencyModel; -import org.jclouds.rest.RestContext; +import org.jclouds.location.Provider; import org.jclouds.rest.Utils; import org.jclouds.s3.blobstore.internal.S3BlobStoreContextImpl; +import com.google.common.reflect.TypeToken; + /** * @author Adrian Cole */ @Singleton -public class AWSS3BlobStoreContextImpl extends S3BlobStoreContextImpl implements - AWSS3BlobStoreContext { +public class AWSS3BlobStoreContextImpl extends S3BlobStoreContextImpl implements AWSS3BlobStoreContext { @Inject - public AWSS3BlobStoreContextImpl(BlobMap.Factory blobMapFactory, Utils utils, ConsistencyModel consistencyModel, - InputStreamMap.Factory inputStreamMapFactory, AWSS3AsyncBlobStore ablobStore, AWSS3BlobStore blobStore, - @SuppressWarnings("rawtypes") RestContext providerSpecificContext, BlobRequestSigner blobRequestSigner) { - super(blobMapFactory, utils, consistencyModel, inputStreamMapFactory, ablobStore, blobStore, providerSpecificContext, - blobRequestSigner); + public AWSS3BlobStoreContextImpl(@Provider Closeable wrapped, @Provider TypeToken wrappedType, + BlobMap.Factory blobMapFactory, Utils utils, ConsistencyModel consistencyModel, + InputStreamMap.Factory inputStreamMapFactory, AsyncBlobStore ablobStore, BlobStore blobStore, + BlobRequestSigner blobRequestSigner) { + super(wrapped, wrappedType, blobMapFactory, utils, consistencyModel, inputStreamMapFactory, ablobStore, + blobStore, blobRequestSigner); } @Override diff --git a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/strategy/internal/ParallelMultipartUploadStrategy.java b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/strategy/internal/ParallelMultipartUploadStrategy.java index fdfbcfc48b..d16cca3c5d 100644 --- a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/strategy/internal/ParallelMultipartUploadStrategy.java +++ b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/strategy/internal/ParallelMultipartUploadStrategy.java @@ -39,6 +39,7 @@ import javax.annotation.Resource; import javax.inject.Named; import org.jclouds.Constants; +import org.jclouds.aws.s3.AWSS3ApiMetadata; import org.jclouds.aws.s3.AWSS3AsyncClient; import org.jclouds.aws.s3.AWSS3Client; import org.jclouds.aws.s3.blobstore.AWSS3AsyncBlobStore; @@ -118,8 +119,7 @@ public class ParallelMultipartUploadStrategy implements AsyncMultipartUploadStra latch.countDown(); return; } - final AWSS3AsyncClient client = (AWSS3AsyncClient) ablobstore.getContext() - .getProviderSpecificContext().getAsyncApi(); + final AWSS3AsyncClient client = ablobstore.getContext().unwrap(AWSS3ApiMetadata.CONTEXT_TOKEN).getAsyncApi(); Payload chunkedPart = slicer.slice(payload, offset, size); logger.debug(String.format("async uploading part %s of %s to container %s with uploadId %s", part, key, container, uploadId)); final long start = System.currentTimeMillis(); @@ -169,7 +169,7 @@ public class ParallelMultipartUploadStrategy implements AsyncMultipartUploadStra long remaining = algorithm.getRemaining(); if (parts > 0) { AWSS3Client client = (AWSS3Client) ablobstore - .getContext().getProviderSpecificContext().getApi(); + .getContext().unwrap(AWSS3ApiMetadata.CONTEXT_TOKEN).getApi(); String uploadId = null; final Map> futureParts = new ConcurrentHashMap>(); diff --git a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/strategy/internal/SequentialMultipartUploadStrategy.java b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/strategy/internal/SequentialMultipartUploadStrategy.java index b7bd47030a..e262186854 100644 --- a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/strategy/internal/SequentialMultipartUploadStrategy.java +++ b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/strategy/internal/SequentialMultipartUploadStrategy.java @@ -25,6 +25,7 @@ import java.util.SortedMap; import javax.annotation.Resource; import javax.inject.Named; +import org.jclouds.aws.s3.AWSS3ApiMetadata; import org.jclouds.aws.s3.AWSS3Client; import org.jclouds.aws.s3.blobstore.AWSS3BlobStore; import org.jclouds.aws.s3.blobstore.strategy.MultipartUploadStrategy; @@ -69,8 +70,7 @@ public class SequentialMultipartUploadStrategy implements MultipartUploadStrateg protected void prepareUploadPart(String container, String key, String uploadId, int part, Payload payload, long offset, long size, SortedMap etags) { - AWSS3Client client = (AWSS3Client) ablobstore.getContext() - .getProviderSpecificContext().getApi(); + AWSS3Client client = ablobstore.getContext().unwrap(AWSS3ApiMetadata.CONTEXT_TOKEN).getApi(); Payload chunkedPart = slicer.slice(payload, offset, size); String eTag = null; try { @@ -100,7 +100,7 @@ public class SequentialMultipartUploadStrategy implements MultipartUploadStrateg long chunkSize = algorithm.getChunkSize(); if (parts > 0) { AWSS3Client client = (AWSS3Client) ablobstore.getContext() - .getProviderSpecificContext().getApi(); + .unwrap(AWSS3ApiMetadata.CONTEXT_TOKEN).getApi(); String uploadId = client.initiateMultipartUpload(container, ObjectMetadataBuilder.create().key(key).build()); // TODO md5 try { diff --git a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/config/AWSS3RestClientModule.java b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/config/AWSS3RestClientModule.java index f003e5c57d..f46844114d 100644 --- a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/config/AWSS3RestClientModule.java +++ b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/config/AWSS3RestClientModule.java @@ -30,7 +30,6 @@ import javax.inject.Singleton; import org.jclouds.aws.s3.AWSS3AsyncClient; import org.jclouds.aws.s3.AWSS3Client; import org.jclouds.aws.s3.binders.AssignCorrectHostnameAndBindAsHostPrefixIfConfigured; -import org.jclouds.http.RequiresHttp; import org.jclouds.location.Region; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.RestContext; @@ -49,7 +48,6 @@ import com.google.inject.Provides; * * @author Adrian Cole */ -@RequiresHttp @ConfiguresRestClient public class AWSS3RestClientModule extends S3RestClientModule { diff --git a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3AsyncClientTest.java b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3AsyncClientTest.java index 70020caa99..6a2aa034bc 100644 --- a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3AsyncClientTest.java +++ b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3AsyncClientTest.java @@ -29,7 +29,6 @@ import org.jclouds.aws.s3.functions.UploadIdFromHttpResponseViaRegex; import org.jclouds.blobstore.binders.BindBlobToMultipartFormTest; import org.jclouds.date.TimeStamp; import org.jclouds.http.HttpRequest; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.functions.ParseETagHeader; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ReleasePayloadAndReturn; @@ -40,6 +39,7 @@ import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions; import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; import org.jclouds.rest.internal.RestAnnotationProcessor; +import org.jclouds.s3.S3AsyncClientTest; import org.jclouds.s3.domain.ObjectMetadata; import org.jclouds.s3.domain.ObjectMetadataBuilder; import org.jclouds.s3.domain.S3Object; @@ -61,7 +61,7 @@ import com.google.inject.TypeLiteral; // NOTE:without testName, this will not call @Before* and fail w/NPE during // surefire @Test(groups = "unit", testName = "AWSS3AsyncClientTest") -public class AWSS3AsyncClientTest extends org.jclouds.s3.S3AsyncClientTest { +public class AWSS3AsyncClientTest extends S3AsyncClientTest { public void testGetBucketLocationEU() throws SecurityException, NoSuchMethodException, IOException { Method method = AWSS3AsyncClient.class.getMethod("getBucketLocation", String.class); @@ -250,8 +250,7 @@ public class AWSS3AsyncClientTest extends org.jclouds.s3.S3AsyncClientTest psc = createMock(RestContextImpl.class); + RestContext psc = createMock(RestContextImpl.class); AWSS3Client client = createMock(AWSS3Client.class); ObjectMetadata ometa = createMock(ObjectMetadata.class); String uploadId = "uploadId"; @@ -83,7 +84,7 @@ public class SequentialMultipartUploadStrategyTest { expect(payload.getContentMetadata()).andReturn(contentMeta).atLeastOnce(); expect(contentMeta.getContentLength()).andReturn(new Long(chunkSize + remaining)); expect(ablobStore.getContext()).andReturn(context).atLeastOnce(); - expect(context.getProviderSpecificContext()).andReturn(psc).atLeastOnce(); + expect(context.unwrap(AWSS3ApiMetadata.CONTEXT_TOKEN)).andReturn(psc).atLeastOnce(); expect(psc.getApi()).andReturn(client).atLeastOnce(); expect(client.initiateMultipartUpload(container, new ObjectMetadataBuilder().key(key).build())).andReturn("uploadId").atLeastOnce(); expect(slicer.slice(payload, 0, chunkSize)).andReturn(payload).atLeastOnce(); @@ -129,9 +130,8 @@ public class SequentialMultipartUploadStrategyTest { MutableBlobMetadata blobMeta = createMock(MutableBlobMetadata.class); Payload payload = createMock(Payload.class); MutableContentMetadata contentMeta = createMock(MutableContentMetadata.class); - @SuppressWarnings("rawtypes") BlobStoreContext context = createMock(BlobStoreContext.class); - RestContext psc = createMock(RestContextImpl.class); + RestContext psc = createMock(RestContextImpl.class); AWSS3Client client = createMock(AWSS3Client.class); ObjectMetadata ometa = createMock(ObjectMetadata.class); String uploadId = "uploadId"; @@ -147,7 +147,7 @@ public class SequentialMultipartUploadStrategyTest { expect(payload.getContentMetadata()).andReturn(contentMeta).atLeastOnce(); expect(contentMeta.getContentLength()).andReturn(new Long(chunkSize + remaining)); expect(ablobStore.getContext()).andReturn(context).atLeastOnce(); - expect(context.getProviderSpecificContext()).andReturn(psc).atLeastOnce(); + expect(context.unwrap(AWSS3ApiMetadata.CONTEXT_TOKEN)).andReturn(psc).atLeastOnce(); expect(psc.getApi()).andReturn(client).atLeastOnce(); expect(client.initiateMultipartUpload(container, new ObjectMetadataBuilder().key(key).build())).andReturn("uploadId").atLeastOnce(); expect(slicer.slice(payload, 0, chunkSize)).andReturn(payload).atLeastOnce(); diff --git a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/internal/BaseAWSS3ClientExpectTest.java b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/internal/BaseAWSS3ClientExpectTest.java index 671c1712b8..30fe827560 100644 --- a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/internal/BaseAWSS3ClientExpectTest.java +++ b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/internal/BaseAWSS3ClientExpectTest.java @@ -22,7 +22,6 @@ import org.jclouds.aws.s3.AWSS3Client; import org.jclouds.aws.s3.AWSS3ProviderMetadata; import org.jclouds.aws.s3.config.AWSS3RestClientModule; import org.jclouds.date.TimeStamp; -import org.jclouds.http.RequiresHttp; import org.jclouds.providers.ProviderMetadata; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.internal.BaseRestClientExpectTest; @@ -45,12 +44,11 @@ public class BaseAWSS3ClientExpectTest extends BaseRestClientExpectTest createProviderMetadata() { + public ProviderMetadata createProviderMetadata() { return new AWSS3ProviderMetadata(); } - @RequiresHttp - @ConfiguresRestClient + @ConfiguresRestClient private static final class TestAWSS3RestClientModule extends AWSS3RestClientModule { @Override protected String provideTimeStamp(@TimeStamp Supplier cache) { diff --git a/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobApiMetadata.java b/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobApiMetadata.java index e0d21bee2a..4dcf4de114 100644 --- a/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobApiMetadata.java +++ b/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobApiMetadata.java @@ -24,19 +24,29 @@ import java.net.URI; import java.util.Properties; import org.jclouds.apis.ApiMetadata; +import org.jclouds.azureblob.blobstore.config.AzureBlobStoreContextModule; +import org.jclouds.azureblob.config.AzureBlobRestClientModule; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.internal.BaseBlobStoreApiMetadata; +import org.jclouds.rest.RestContext; +import org.jclouds.rest.internal.BaseRestApiMetadata; +import com.google.common.collect.ImmutableSet; import com.google.common.reflect.TypeToken; +import com.google.inject.Module; /** * Implementation of {@link ApiMetadata} for Microsoft Azure Blob Service API * * @author Adrian Cole */ -public class AzureBlobApiMetadata - extends - BaseBlobStoreApiMetadata, AzureBlobApiMetadata> { +public class AzureBlobApiMetadata extends BaseRestApiMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = 8067252472547486854L; + + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; + private static Builder builder() { return new Builder(); } @@ -54,25 +64,26 @@ public class AzureBlobApiMetadata super(builder); } - protected static Properties defaultProperties() { - Properties properties = BaseBlobStoreApiMetadata.Builder.defaultProperties(); + public static Properties defaultProperties() { + Properties properties = BaseRestApiMetadata.defaultProperties(); properties.setProperty(PROPERTY_USER_METADATA_PREFIX, "x-ms-meta-"); return properties; } - public static class Builder extends BaseBlobStoreApiMetadata.Builder, AzureBlobApiMetadata> { + public static class Builder extends BaseRestApiMetadata.Builder { protected Builder(){ - id("azureblob") - .name("Microsoft Azure Blob Service API") - .identityName("Account Name") - .credentialName("Access Key") - .version("2009-09-19") - .defaultEndpoint("https://${jclouds.identity}.blob.core.windows.net") - .documentation(URI.create("http://msdn.microsoft.com/en-us/library/dd135733.aspx")) - .contextBuilder(TypeToken.of(AzureBlobContextBuilder.class)) - .javaApi(AzureBlobClient.class, AzureBlobAsyncClient.class) - .defaultProperties(AzureBlobApiMetadata.defaultProperties()); - } + super(AzureBlobClient.class, AzureBlobAsyncClient.class); + id("azureblob") + .name("Microsoft Azure Blob Service API") + .identityName("Account Name") + .credentialName("Access Key") + .version("2009-09-19") + .defaultEndpoint("https://${jclouds.identity}.blob.core.windows.net") + .documentation(URI.create("http://msdn.microsoft.com/en-us/library/dd135733.aspx")) + .defaultProperties(AzureBlobApiMetadata.defaultProperties()) + .wrapper(TypeToken.of(BlobStoreContext.class)) + .defaultModules(ImmutableSet.>of(AzureBlobRestClientModule.class, AzureBlobStoreContextModule.class)); + } @Override public AzureBlobApiMetadata build() { @@ -80,7 +91,7 @@ public class AzureBlobApiMetadata } @Override - public Builder fromApiMetadata(AzureBlobApiMetadata in) { + public Builder fromApiMetadata(ApiMetadata in) { super.fromApiMetadata(in); return this; } diff --git a/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobContextBuilder.java b/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobContextBuilder.java deleted file mode 100644 index e3492de627..0000000000 --- a/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobContextBuilder.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * 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.azureblob; - -import java.util.List; - -import org.jclouds.azureblob.blobstore.config.AzureBlobStoreContextModule; -import org.jclouds.azureblob.config.AzureBlobRestClientModule; -import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextBuilder; -import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; -import org.jclouds.logging.jdk.config.JDKLoggingModule; -import org.jclouds.providers.ProviderMetadata; - -import com.google.inject.Injector; -import com.google.inject.Module; - -/** - * Creates {@link AzureBlobStoreContext} or {@link Injector} instances based on - * the most commonly requested arguments. - *

- * Note that Threadsafe objects will be bound as singletons to the Injector or - * Context provided. - *

- *

- * If no Modules are specified, the default - * {@link JDKLoggingModule logging} and - * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be - * installed. - * - * @author Adrian Cole, Andrew Newdigate - * @see AzureBlobStoreContext - */ -public class AzureBlobContextBuilder - extends - BlobStoreContextBuilder, AzureBlobApiMetadata> { - - public AzureBlobContextBuilder() { - this(new AzureBlobProviderMetadata()); - } - - public AzureBlobContextBuilder( - ProviderMetadata, AzureBlobApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public AzureBlobContextBuilder(AzureBlobApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new AzureBlobStoreContextModule()); - } - - @Override - protected void addClientModule(List modules) { - modules.add(new AzureBlobRestClientModule()); - } -} diff --git a/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobProviderMetadata.java b/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobProviderMetadata.java index 446b44aabb..7a12bd5851 100644 --- a/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobProviderMetadata.java +++ b/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobProviderMetadata.java @@ -21,7 +21,6 @@ package org.jclouds.azureblob; import java.net.URI; import java.util.Properties; -import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -30,7 +29,10 @@ import org.jclouds.providers.internal.BaseProviderMetadata; * * @author Adrian Cole */ -public class AzureBlobProviderMetadata extends BaseProviderMetadata, AzureBlobApiMetadata> { +public class AzureBlobProviderMetadata extends BaseProviderMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 8271570736207734777L; public static Builder builder() { return new Builder(); @@ -49,11 +51,11 @@ public class AzureBlobProviderMetadata extends BaseProviderMetadata, AzureBlobApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder(){ id("azureblob") @@ -74,7 +76,7 @@ public class AzureBlobProviderMetadata extends BaseProviderMetadata, AzureBlobApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/azureblob/src/main/java/org/jclouds/azureblob/binders/BindAzureBlobMetadataToRequest.java b/providers/azureblob/src/main/java/org/jclouds/azureblob/binders/BindAzureBlobMetadataToRequest.java index 43b85e60b2..3b2d41242a 100644 --- a/providers/azureblob/src/main/java/org/jclouds/azureblob/binders/BindAzureBlobMetadataToRequest.java +++ b/providers/azureblob/src/main/java/org/jclouds/azureblob/binders/BindAzureBlobMetadataToRequest.java @@ -33,8 +33,8 @@ import org.jclouds.http.utils.ModifyRequest; import org.jclouds.rest.Binder; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMap.Builder; import com.google.common.collect.Multimaps; +import com.google.common.collect.ImmutableMap.Builder; @Singleton public class BindAzureBlobMetadataToRequest implements Binder { diff --git a/providers/azureblob/src/main/java/org/jclouds/azureblob/blobstore/AzureAsyncBlobStore.java b/providers/azureblob/src/main/java/org/jclouds/azureblob/blobstore/AzureAsyncBlobStore.java index 10adc18057..dc8980bae4 100644 --- a/providers/azureblob/src/main/java/org/jclouds/azureblob/blobstore/AzureAsyncBlobStore.java +++ b/providers/azureblob/src/main/java/org/jclouds/azureblob/blobstore/AzureAsyncBlobStore.java @@ -80,7 +80,7 @@ public class AzureAsyncBlobStore extends BaseAsyncBlobStore { private final BlobToHttpGetOptions blob2ObjectGetOptions; @Inject - AzureAsyncBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, + AzureAsyncBlobStore(BlobStoreContext context, BlobUtils blobUtils, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService service, Supplier defaultLocation, @Memoized Supplier> locations, AzureBlobAsyncClient async, ContainerToResourceMetadata container2ResourceMd, diff --git a/providers/azureblob/src/main/java/org/jclouds/azureblob/blobstore/AzureBlobStore.java b/providers/azureblob/src/main/java/org/jclouds/azureblob/blobstore/AzureBlobStore.java index bc51aa5b22..629f176ca7 100644 --- a/providers/azureblob/src/main/java/org/jclouds/azureblob/blobstore/AzureBlobStore.java +++ b/providers/azureblob/src/main/java/org/jclouds/azureblob/blobstore/AzureBlobStore.java @@ -72,7 +72,7 @@ public class AzureBlobStore extends BaseBlobStore { private final BlobToHttpGetOptions blob2ObjectGetOptions; @Inject - AzureBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, Supplier defaultLocation, + AzureBlobStore(BlobStoreContext context, BlobUtils blobUtils, Supplier defaultLocation, @Memoized Supplier> locations, AzureBlobClient sync, ContainerToResourceMetadata container2ResourceMd, ListOptionsToListBlobsOptions blobStore2AzureContainerListOptions, diff --git a/providers/azureblob/src/main/java/org/jclouds/azureblob/blobstore/config/AzureBlobStoreContextModule.java b/providers/azureblob/src/main/java/org/jclouds/azureblob/blobstore/config/AzureBlobStoreContextModule.java index ff30670a2c..1dc34215b9 100644 --- a/providers/azureblob/src/main/java/org/jclouds/azureblob/blobstore/config/AzureBlobStoreContextModule.java +++ b/providers/azureblob/src/main/java/org/jclouds/azureblob/blobstore/config/AzureBlobStoreContextModule.java @@ -22,7 +22,6 @@ import java.util.concurrent.TimeUnit; import javax.inject.Singleton; -import org.jclouds.azureblob.AzureBlobAsyncClient; import org.jclouds.azureblob.AzureBlobClient; import org.jclouds.azureblob.blobstore.AzureAsyncBlobStore; import org.jclouds.azureblob.blobstore.AzureBlobRequestSigner; @@ -32,10 +31,8 @@ import org.jclouds.azureblob.domain.PublicAccess; import org.jclouds.blobstore.AsyncBlobStore; import org.jclouds.blobstore.BlobRequestSigner; import org.jclouds.blobstore.BlobStore; -import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.blobstore.attr.ConsistencyModel; import org.jclouds.blobstore.config.BlobStoreMapModule; -import org.jclouds.blobstore.internal.BlobStoreContextImpl; import org.jclouds.blobstore.strategy.ContainsValueInListStrategy; import com.google.common.cache.CacheBuilder; @@ -44,7 +41,6 @@ import com.google.common.cache.LoadingCache; import com.google.inject.AbstractModule; import com.google.inject.Provides; import com.google.inject.Scopes; -import com.google.inject.TypeLiteral; /** * Configures the {@link AzureBlobStoreContext}; requires {@link AzureAsyncBlobStore} bound. @@ -59,8 +55,6 @@ public class AzureBlobStoreContextModule extends AbstractModule { bind(ConsistencyModel.class).toInstance(ConsistencyModel.STRICT); bind(AsyncBlobStore.class).to(AzureAsyncBlobStore.class).in(Scopes.SINGLETON); bind(BlobStore.class).to(AzureBlobStore.class).in(Scopes.SINGLETON); - bind(BlobStoreContext.class).to(new TypeLiteral>() { - }).in(Scopes.SINGLETON); bind(ContainsValueInListStrategy.class).to(FindMD5InBlobProperties.class); bind(BlobRequestSigner.class).to(AzureBlobRequestSigner.class); } diff --git a/providers/azureblob/src/main/java/org/jclouds/azureblob/config/AzureBlobRestClientModule.java b/providers/azureblob/src/main/java/org/jclouds/azureblob/config/AzureBlobRestClientModule.java index a0862b3bd5..c94667f515 100644 --- a/providers/azureblob/src/main/java/org/jclouds/azureblob/config/AzureBlobRestClientModule.java +++ b/providers/azureblob/src/main/java/org/jclouds/azureblob/config/AzureBlobRestClientModule.java @@ -23,7 +23,6 @@ import org.jclouds.azureblob.AzureBlobAsyncClient; import org.jclouds.azureblob.AzureBlobClient; import org.jclouds.azureblob.handlers.ParseAzureBlobErrorFromXmlContent; import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.ServerError; @@ -35,7 +34,6 @@ import org.jclouds.rest.ConfiguresRestClient; * @author Adrian Cole */ @ConfiguresRestClient -@RequiresHttp public class AzureBlobRestClientModule extends AzureStorageRestClientModule { public AzureBlobRestClientModule() { diff --git a/providers/azureblob/src/test/java/org/jclouds/azureblob/AzureBlobClientLiveTest.java b/providers/azureblob/src/test/java/org/jclouds/azureblob/AzureBlobClientLiveTest.java index cded63bf98..d010bf7332 100644 --- a/providers/azureblob/src/test/java/org/jclouds/azureblob/AzureBlobClientLiveTest.java +++ b/providers/azureblob/src/test/java/org/jclouds/azureblob/AzureBlobClientLiveTest.java @@ -65,7 +65,7 @@ public class AzureBlobClientLiveTest extends BaseBlobStoreIntegrationTest { } public AzureBlobClient getApi() { - return (AzureBlobClient) context.getProviderSpecificContext().getApi(); + return context.unwrap(AzureBlobApiMetadata.CONTEXT_TOKEN).getApi(); } @Test @@ -99,8 +99,8 @@ public class AzureBlobClientLiveTest extends BaseBlobStoreIntegrationTest { long containerCount = response.size(); assertTrue(containerCount >= 1); ListBlobsResponse list = getApi().listBlobs(privateContainer); - assertEquals(list.getUrl(), URI.create(String.format("https://%s.blob.core.windows.net/%s", context - .getProviderSpecificContext().getIdentity(), privateContainer))); + assertEquals(list.getUrl(), URI.create(String.format("https://%s.blob.core.windows.net/%s", context.unwrap( + AzureBlobApiMetadata.CONTEXT_TOKEN).getIdentity(), privateContainer))); // TODO .. check to see the container actually exists } @@ -155,8 +155,8 @@ public class AzureBlobClientLiveTest extends BaseBlobStoreIntegrationTest { } } ListBlobsResponse list = getApi().listBlobs(); - assertEquals(list.getUrl(), URI.create(String.format("https://%s.blob.core.windows.net/$root", context - .getProviderSpecificContext().getIdentity()))); + assertEquals(list.getUrl(), URI.create(String.format("https://%s.blob.core.windows.net/$root", context.unwrap( + AzureBlobApiMetadata.CONTEXT_TOKEN).getIdentity()))); } @Test diff --git a/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/AzureBlobRequestSignerTest.java b/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/AzureBlobRequestSignerTest.java index d8d54451b8..03036714cc 100644 --- a/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/AzureBlobRequestSignerTest.java +++ b/providers/azureblob/src/test/java/org/jclouds/azureblob/blobstore/AzureBlobRequestSignerTest.java @@ -30,7 +30,6 @@ import org.jclouds.blobstore.domain.Blob; import org.jclouds.blobstore.domain.Blob.Factory; import org.jclouds.date.TimeStamp; import org.jclouds.http.HttpRequest; -import org.jclouds.http.RequiresHttp; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.internal.BaseAsyncClientTest; import org.jclouds.rest.internal.RestAnnotationProcessor; @@ -121,8 +120,7 @@ public class AzureBlobRequestSignerTest extends BaseAsyncClientTest - * Note that Threadsafe objects will be bound as singletons to the Injector or - * Context provided. - *

- *

- * If no Modules are specified, the default - * {@link JDKLoggingModule logging} and - * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be - * installed. - * - * @author Adrian Cole - */ -public class BluelockVCloudZone01ContextBuilder extends VCloudContextBuilder { - public BluelockVCloudZone01ContextBuilder( - ProviderMetadata, VCloudApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public BluelockVCloudZone01ContextBuilder(VCloudApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new VCloudComputeServiceContextModule()); - } - - @Override - protected void addClientModule(List modules) { - modules.add(new BluelockVCloudZone01RestClientModule()); - } - -} diff --git a/providers/bluelock-vcloud-zone01/src/main/java/org/jclouds/bluelock/vcloud/zone01/BluelockVCloudZone01ProviderMetadata.java b/providers/bluelock-vcloud-zone01/src/main/java/org/jclouds/bluelock/vcloud/zone01/BluelockVCloudZone01ProviderMetadata.java index eca1705bbf..f040b048f8 100644 --- a/providers/bluelock-vcloud-zone01/src/main/java/org/jclouds/bluelock/vcloud/zone01/BluelockVCloudZone01ProviderMetadata.java +++ b/providers/bluelock-vcloud-zone01/src/main/java/org/jclouds/bluelock/vcloud/zone01/BluelockVCloudZone01ProviderMetadata.java @@ -23,23 +23,19 @@ import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAU import java.net.URI; import java.util.Properties; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; import org.jclouds.vcloud.VCloudApiMetadata; -import org.jclouds.vcloud.VCloudAsyncClient; -import org.jclouds.vcloud.VCloudClient; - -import com.google.common.reflect.TypeToken; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for Bluelock vCloud Zone 1. * * @author Adrian Cole */ -public class BluelockVCloudZone01ProviderMetadata - extends - BaseProviderMetadata, VCloudApiMetadata> { +public class BluelockVCloudZone01ProviderMetadata extends BaseProviderMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = -2931858111365760610L; public static Builder builder() { return new Builder(); @@ -58,21 +54,19 @@ public class BluelockVCloudZone01ProviderMetadata super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = new Properties(); properties.setProperty(PROPERTY_VCLOUD_DEFAULT_NETWORK, "internet01-.*"); return properties; } - public static class Builder extends BaseProviderMetadata.Builder, VCloudApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder(){ id("bluelock-vcloud-zone01") .name("Bluelock vCloud Zone 1") .apiMetadata( - new VCloudApiMetadata().toBuilder() - .buildVersion("1.5.0.464915") - .contextBuilder(TypeToken.of(BluelockVCloudZone01ContextBuilder.class)).build()) + new VCloudApiMetadata().toBuilder().buildVersion("1.5.0.464915").build()) .homepage(URI.create("http://www.bluelock.com/bluelock-cloud-hosting")) .console(URI.create("https://zone01.bluelock.com/cloud/org/YOUR_ORG_HERE")) .iso3166Codes("US-IN") @@ -86,8 +80,7 @@ public class BluelockVCloudZone01ProviderMetadata } @Override - public Builder fromProviderMetadata( - ProviderMetadata, VCloudApiMetadata> in) { + public Builder fromProviderMetadata(ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/bluelock-vcloud-zone01/src/test/java/org/jclouds/bluelock/vcloud/zone01/compute/BluelockVCloudZone01TemplateBuilderLiveTest.java b/providers/bluelock-vcloud-zone01/src/test/java/org/jclouds/bluelock/vcloud/zone01/compute/BluelockVCloudZone01TemplateBuilderLiveTest.java index ce95f91059..2c3a037763 100644 --- a/providers/bluelock-vcloud-zone01/src/test/java/org/jclouds/bluelock/vcloud/zone01/compute/BluelockVCloudZone01TemplateBuilderLiveTest.java +++ b/providers/bluelock-vcloud-zone01/src/test/java/org/jclouds/bluelock/vcloud/zone01/compute/BluelockVCloudZone01TemplateBuilderLiveTest.java @@ -24,13 +24,10 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.util.Set; -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.compute.internal.BaseTemplateBuilderLiveTest; -import org.jclouds.vcloud.VCloudAsyncClient; -import org.jclouds.vcloud.VCloudClient; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -41,9 +38,7 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live", testName = "BluelockVCloudZone01TemplateBuilderLiveTest") -public class BluelockVCloudZone01TemplateBuilderLiveTest - extends - BaseTemplateBuilderLiveTest> { +public class BluelockVCloudZone01TemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { public BluelockVCloudZone01TemplateBuilderLiveTest() { provider = "bluelock-vcloud-zone01"; diff --git a/providers/cloudfiles-uk/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKProviderMetadata.java b/providers/cloudfiles-uk/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKProviderMetadata.java index 53be4911e0..65c9722d26 100644 --- a/providers/cloudfiles-uk/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKProviderMetadata.java +++ b/providers/cloudfiles-uk/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKProviderMetadata.java @@ -23,10 +23,7 @@ import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; import java.net.URI; import java.util.Properties; -import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.cloudfiles.CloudFilesApiMetadata; -import org.jclouds.cloudfiles.CloudFilesAsyncClient; -import org.jclouds.cloudfiles.CloudFilesClient; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -35,7 +32,10 @@ import org.jclouds.providers.internal.BaseProviderMetadata; * * @author Adrian Cole */ -public class CloudFilesUKProviderMetadata extends BaseProviderMetadata, CloudFilesApiMetadata> { +public class CloudFilesUKProviderMetadata extends BaseProviderMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 7285715683919401020L; public static Builder builder() { return new Builder(); @@ -54,12 +54,12 @@ public class CloudFilesUKProviderMetadata extends BaseProviderMetadata, CloudFilesApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder(){ id("cloudfiles-uk") @@ -79,7 +79,7 @@ public class CloudFilesUKProviderMetadata extends BaseProviderMetadata, CloudFilesApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKClientLiveTest.java b/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKClientLiveTest.java index 703c3a3d00..b774ef1f4e 100644 --- a/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKClientLiveTest.java +++ b/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKClientLiveTest.java @@ -20,6 +20,7 @@ package org.jclouds.rackspace.cloudfiles; import static org.testng.Assert.assertEquals; +import org.jclouds.cloudfiles.CloudFilesApiMetadata; import org.jclouds.cloudfiles.CloudFilesClient; import org.jclouds.cloudfiles.CloudFilesClientLiveTest; import org.jclouds.openstack.swift.domain.SwiftObject; @@ -40,7 +41,7 @@ public class CloudFilesUKClientLiveTest extends CloudFilesClientLiveTest { @Override public CloudFilesClient getApi() { - return (CloudFilesClient) context.getProviderSpecificContext().getApi(); + return context.unwrap(CloudFilesApiMetadata.CONTEXT_TOKEN).getApi(); } @Override diff --git a/providers/cloudfiles-us/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesUSProviderMetadata.java b/providers/cloudfiles-us/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesUSProviderMetadata.java index 2b5c581e9a..6075e97252 100644 --- a/providers/cloudfiles-us/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesUSProviderMetadata.java +++ b/providers/cloudfiles-us/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesUSProviderMetadata.java @@ -23,10 +23,7 @@ import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; import java.net.URI; import java.util.Properties; -import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.cloudfiles.CloudFilesApiMetadata; -import org.jclouds.cloudfiles.CloudFilesAsyncClient; -import org.jclouds.cloudfiles.CloudFilesClient; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -35,8 +32,11 @@ import org.jclouds.providers.internal.BaseProviderMetadata; * * @author Adrian Cole */ -public class CloudFilesUSProviderMetadata extends BaseProviderMetadata, CloudFilesApiMetadata> { +public class CloudFilesUSProviderMetadata extends BaseProviderMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = -106955085607133771L; + public static Builder builder() { return new Builder(); } @@ -54,13 +54,13 @@ public class CloudFilesUSProviderMetadata extends BaseProviderMetadata, CloudFilesApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder(){ id("cloudfiles-us") @@ -80,7 +80,7 @@ public class CloudFilesUSProviderMetadata extends BaseProviderMetadata, CloudFilesApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/cloudloadbalancers-uk/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKProviderMetadata.java b/providers/cloudloadbalancers-uk/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKProviderMetadata.java index f211ad45c8..7867c833fb 100644 --- a/providers/cloudloadbalancers-uk/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKProviderMetadata.java +++ b/providers/cloudloadbalancers-uk/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKProviderMetadata.java @@ -31,9 +31,6 @@ import java.net.URI; import java.util.Properties; import org.jclouds.cloudloadbalancers.CloudLoadBalancersApiMetadata; -import org.jclouds.cloudloadbalancers.CloudLoadBalancersAsyncClient; -import org.jclouds.cloudloadbalancers.CloudLoadBalancersClient; -import org.jclouds.loadbalancer.LoadBalancerServiceContext; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -42,7 +39,7 @@ import org.jclouds.providers.internal.BaseProviderMetadata; * * @author Adrian Cole */ -public class CloudLoadBalancersUKProviderMetadata extends BaseProviderMetadata, CloudLoadBalancersApiMetadata> { +public class CloudLoadBalancersUKProviderMetadata extends BaseProviderMetadata { public static Builder builder() { return new Builder(); @@ -61,7 +58,7 @@ public class CloudLoadBalancersUKProviderMetadata extends BaseProviderMetadata, CloudLoadBalancersApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder(){ id("cloudloadbalancers-uk") @@ -91,7 +88,7 @@ public class CloudLoadBalancersUKProviderMetadata extends BaseProviderMetadata, CloudLoadBalancersApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/cloudloadbalancers-us/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSProviderMetadata.java b/providers/cloudloadbalancers-us/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSProviderMetadata.java index 04f2018d5e..1a7164ed8c 100644 --- a/providers/cloudloadbalancers-us/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSProviderMetadata.java +++ b/providers/cloudloadbalancers-us/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSProviderMetadata.java @@ -32,9 +32,6 @@ import java.net.URI; import java.util.Properties; import org.jclouds.cloudloadbalancers.CloudLoadBalancersApiMetadata; -import org.jclouds.cloudloadbalancers.CloudLoadBalancersAsyncClient; -import org.jclouds.cloudloadbalancers.CloudLoadBalancersClient; -import org.jclouds.loadbalancer.LoadBalancerServiceContext; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -45,7 +42,7 @@ import com.google.common.base.Joiner; * * @author Adrian Cole */ -public class CloudLoadBalancersUSProviderMetadata extends BaseProviderMetadata, CloudLoadBalancersApiMetadata> { +public class CloudLoadBalancersUSProviderMetadata extends BaseProviderMetadata { public static Builder builder() { return new Builder(); @@ -65,7 +62,7 @@ public class CloudLoadBalancersUSProviderMetadata extends BaseProviderMetadata, CloudLoadBalancersApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder(){ id("cloudloadbalancers-us") @@ -101,7 +98,7 @@ public class CloudLoadBalancersUSProviderMetadata extends BaseProviderMetadata, CloudLoadBalancersApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/cloudonestorage/src/main/java/org/jclouds/cloudonestorage/CloudOneStorageProviderMetadata.java b/providers/cloudonestorage/src/main/java/org/jclouds/cloudonestorage/CloudOneStorageProviderMetadata.java index 55e5452be9..cfb4fcef46 100644 --- a/providers/cloudonestorage/src/main/java/org/jclouds/cloudonestorage/CloudOneStorageProviderMetadata.java +++ b/providers/cloudonestorage/src/main/java/org/jclouds/cloudonestorage/CloudOneStorageProviderMetadata.java @@ -22,9 +22,6 @@ import java.net.URI; import java.util.Properties; import org.jclouds.atmos.AtmosApiMetadata; -import org.jclouds.atmos.AtmosAsyncClient; -import org.jclouds.atmos.AtmosClient; -import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -34,7 +31,7 @@ import org.jclouds.providers.internal.BaseProviderMetadata; * * @author Jeremy Whitlock */ -public class CloudOneStorageProviderMetadata extends BaseProviderMetadata, AtmosApiMetadata> { +public class CloudOneStorageProviderMetadata extends BaseProviderMetadata { public static Builder builder() { return new Builder(); @@ -53,12 +50,12 @@ public class CloudOneStorageProviderMetadata extends BaseProviderMetadata, AtmosApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder(){ id("cloudonestorage") @@ -78,7 +75,7 @@ public class CloudOneStorageProviderMetadata extends BaseProviderMetadata, AtmosApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/cloudservers-uk/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersUKProviderMetadata.java b/providers/cloudservers-uk/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersUKProviderMetadata.java index 0bed8a3b5d..fcfb0f0808 100644 --- a/providers/cloudservers-uk/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersUKProviderMetadata.java +++ b/providers/cloudservers-uk/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersUKProviderMetadata.java @@ -24,9 +24,6 @@ import java.net.URI; import java.util.Properties; import org.jclouds.cloudservers.CloudServersApiMetadata; -import org.jclouds.cloudservers.CloudServersAsyncClient; -import org.jclouds.cloudservers.CloudServersClient; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -35,7 +32,10 @@ import org.jclouds.providers.internal.BaseProviderMetadata; * * @author Adrian Cole */ -public class CloudServersUKProviderMetadata extends BaseProviderMetadata, CloudServersApiMetadata> { +public class CloudServersUKProviderMetadata extends BaseProviderMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 4295911433196692746L; public static Builder builder() { return new Builder(); @@ -54,12 +54,12 @@ public class CloudServersUKProviderMetadata extends BaseProviderMetadata, CloudServersApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder(){ id("cloudservers-uk") @@ -78,7 +78,7 @@ public class CloudServersUKProviderMetadata extends BaseProviderMetadata, CloudServersApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/cloudservers-uk/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUKTemplateBuilderLiveTest.java b/providers/cloudservers-uk/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUKTemplateBuilderLiveTest.java index da6f4a3450..82af2d5621 100644 --- a/providers/cloudservers-uk/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUKTemplateBuilderLiveTest.java +++ b/providers/cloudservers-uk/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUKTemplateBuilderLiveTest.java @@ -23,9 +23,6 @@ import static org.testng.Assert.assertEquals; import java.util.Set; -import org.jclouds.cloudservers.CloudServersAsyncClient; -import org.jclouds.cloudservers.CloudServersClient; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; @@ -41,9 +38,7 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live") -public class CloudServersUKTemplateBuilderLiveTest - extends - BaseTemplateBuilderLiveTest> { +public class CloudServersUKTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { public CloudServersUKTemplateBuilderLiveTest() { provider = "cloudservers-uk"; diff --git a/providers/cloudservers-us/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersUSProviderMetadata.java b/providers/cloudservers-us/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersUSProviderMetadata.java index 16f85b88ae..76791ba5e5 100644 --- a/providers/cloudservers-us/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersUSProviderMetadata.java +++ b/providers/cloudservers-us/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersUSProviderMetadata.java @@ -24,9 +24,6 @@ import java.net.URI; import java.util.Properties; import org.jclouds.cloudservers.CloudServersApiMetadata; -import org.jclouds.cloudservers.CloudServersAsyncClient; -import org.jclouds.cloudservers.CloudServersClient; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -35,8 +32,11 @@ import org.jclouds.providers.internal.BaseProviderMetadata; * * @author Adrian Cole */ -public class CloudServersUSProviderMetadata extends BaseProviderMetadata, CloudServersApiMetadata> { +public class CloudServersUSProviderMetadata extends BaseProviderMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = 8728307961498165226L; + public static Builder builder() { return new Builder(); } @@ -54,13 +54,13 @@ public class CloudServersUSProviderMetadata extends BaseProviderMetadata, CloudServersApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder(){ id("cloudservers-us") @@ -79,7 +79,7 @@ public class CloudServersUSProviderMetadata extends BaseProviderMetadata, CloudServersApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/cloudservers-us/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUSTemplateBuilderLiveTest.java b/providers/cloudservers-us/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUSTemplateBuilderLiveTest.java index 1dc74d846f..efa7594281 100644 --- a/providers/cloudservers-us/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUSTemplateBuilderLiveTest.java +++ b/providers/cloudservers-us/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUSTemplateBuilderLiveTest.java @@ -23,9 +23,6 @@ import static org.testng.Assert.assertEquals; import java.util.Set; -import org.jclouds.cloudservers.CloudServersAsyncClient; -import org.jclouds.cloudservers.CloudServersClient; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; @@ -41,9 +38,7 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live") -public class CloudServersUSTemplateBuilderLiveTest - extends - BaseTemplateBuilderLiveTest> { +public class CloudServersUSTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { public CloudServersUSTemplateBuilderLiveTest() { provider = "cloudservers-us"; diff --git a/providers/cloudsigma-lvs/src/main/java/org/jclouds/cloudsigma/CloudSigmaLasVegasProviderMetadata.java b/providers/cloudsigma-lvs/src/main/java/org/jclouds/cloudsigma/CloudSigmaLasVegasProviderMetadata.java index 83ada1c0b4..af76f6b037 100644 --- a/providers/cloudsigma-lvs/src/main/java/org/jclouds/cloudsigma/CloudSigmaLasVegasProviderMetadata.java +++ b/providers/cloudsigma-lvs/src/main/java/org/jclouds/cloudsigma/CloudSigmaLasVegasProviderMetadata.java @@ -21,7 +21,6 @@ package org.jclouds.cloudsigma; import java.net.URI; import java.util.Properties; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -33,7 +32,7 @@ import org.jclouds.providers.internal.BaseProviderMetadata; */ public class CloudSigmaLasVegasProviderMetadata extends - BaseProviderMetadata, CloudSigmaApiMetadata> { + BaseProviderMetadata { public static Builder builder() { return new Builder(); @@ -52,14 +51,14 @@ public class CloudSigmaLasVegasProviderMetadata super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = new Properties(); return properties; } public static class Builder extends - BaseProviderMetadata.Builder, CloudSigmaApiMetadata> { + BaseProviderMetadata.Builder { protected Builder() { id("cloudsigma-lvs") @@ -79,7 +78,7 @@ public class CloudSigmaLasVegasProviderMetadata @Override public Builder fromProviderMetadata( - ProviderMetadata, CloudSigmaApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/cloudsigma-lvs/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaLasVegasTemplateBuilderLiveTest.java b/providers/cloudsigma-lvs/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaLasVegasTemplateBuilderLiveTest.java index ada7600380..23ea49b737 100644 --- a/providers/cloudsigma-lvs/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaLasVegasTemplateBuilderLiveTest.java +++ b/providers/cloudsigma-lvs/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaLasVegasTemplateBuilderLiveTest.java @@ -44,7 +44,7 @@ import com.google.common.collect.ImmutableSet; @Test(groups = "live", testName = "CloudSigmaLasVegasTemplateBuilderLiveTest") public class CloudSigmaLasVegasTemplateBuilderLiveTest extends - BaseTemplateBuilderLiveTest> { + BaseTemplateBuilderLiveTest { public CloudSigmaLasVegasTemplateBuilderLiveTest() { provider = "cloudsigma-lvs"; diff --git a/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/CloudSigmaZurichProviderMetadata.java b/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/CloudSigmaZurichProviderMetadata.java index 7f18af9aa2..df6afde0e9 100644 --- a/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/CloudSigmaZurichProviderMetadata.java +++ b/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/CloudSigmaZurichProviderMetadata.java @@ -21,7 +21,6 @@ package org.jclouds.cloudsigma; import java.net.URI; import java.util.Properties; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -33,7 +32,7 @@ import org.jclouds.providers.internal.BaseProviderMetadata; */ public class CloudSigmaZurichProviderMetadata extends - BaseProviderMetadata, CloudSigmaApiMetadata> { + BaseProviderMetadata { public static Builder builder() { return new Builder(); @@ -52,14 +51,14 @@ public class CloudSigmaZurichProviderMetadata super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = new Properties(); return properties; } public static class Builder extends - BaseProviderMetadata.Builder, CloudSigmaApiMetadata> { + BaseProviderMetadata.Builder { protected Builder() { id("cloudsigma-zrh") @@ -79,7 +78,7 @@ public class CloudSigmaZurichProviderMetadata @Override public Builder fromProviderMetadata( - ProviderMetadata, CloudSigmaApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaZurichTemplateBuilderLiveTest.java b/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaZurichTemplateBuilderLiveTest.java index b85002b3b9..79391351c9 100644 --- a/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaZurichTemplateBuilderLiveTest.java +++ b/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaZurichTemplateBuilderLiveTest.java @@ -44,7 +44,7 @@ import com.google.common.collect.ImmutableSet; @Test(groups = "live", singleThreaded = true, testName = "CloudSigmaZurichTemplateBuilderLiveTest") public class CloudSigmaZurichTemplateBuilderLiveTest extends - BaseTemplateBuilderLiveTest> { + BaseTemplateBuilderLiveTest { public CloudSigmaZurichTemplateBuilderLiveTest() { provider = "cloudsigma-zrh"; diff --git a/providers/elastichosts-lax-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesProviderMetadata.java b/providers/elastichosts-lax-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesProviderMetadata.java index 3082c24b96..0d7b1caeea 100644 --- a/providers/elastichosts-lax-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesProviderMetadata.java +++ b/providers/elastichosts-lax-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesProviderMetadata.java @@ -21,10 +21,7 @@ package org.jclouds.elastichosts; import java.net.URI; import java.util.Properties; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.elasticstack.ElasticStackApiMetadata; -import org.jclouds.elasticstack.ElasticStackAsyncClient; -import org.jclouds.elasticstack.ElasticStackClient; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -36,7 +33,7 @@ import org.jclouds.providers.internal.BaseProviderMetadata; */ public class ElasticHostsPeer1LosAngelesProviderMetadata extends - BaseProviderMetadata, ElasticStackApiMetadata> { + BaseProviderMetadata { public static Builder builder() { return new Builder(); @@ -55,14 +52,14 @@ public class ElasticHostsPeer1LosAngelesProviderMetadata super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = new Properties(); return properties; } public static class Builder extends - BaseProviderMetadata.Builder, ElasticStackApiMetadata> { + BaseProviderMetadata.Builder { protected Builder() { id("elastichosts-lax-p") @@ -82,7 +79,7 @@ public class ElasticHostsPeer1LosAngelesProviderMetadata @Override public Builder fromProviderMetadata( - ProviderMetadata, ElasticStackApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/elastichosts-lax-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1LosAngelesTemplateBuilderLiveTest.java b/providers/elastichosts-lax-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1LosAngelesTemplateBuilderLiveTest.java index ca8d2a2d37..c62a93e7f3 100644 --- a/providers/elastichosts-lax-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1LosAngelesTemplateBuilderLiveTest.java +++ b/providers/elastichosts-lax-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1LosAngelesTemplateBuilderLiveTest.java @@ -43,7 +43,7 @@ import com.google.common.collect.ImmutableSet; @Test(groups = "live") public class ElasticHostsPeer1LosAngelesTemplateBuilderLiveTest extends - BaseTemplateBuilderLiveTest> { + BaseTemplateBuilderLiveTest { public ElasticHostsPeer1LosAngelesTemplateBuilderLiveTest() { provider = "elastichosts-lax-p"; diff --git a/providers/elastichosts-lon-b/src/main/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonProviderMetadata.java b/providers/elastichosts-lon-b/src/main/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonProviderMetadata.java index 337650cc65..0174d908c0 100644 --- a/providers/elastichosts-lon-b/src/main/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonProviderMetadata.java +++ b/providers/elastichosts-lon-b/src/main/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonProviderMetadata.java @@ -21,10 +21,7 @@ package org.jclouds.elastichosts; import java.net.URI; import java.util.Properties; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.elasticstack.ElasticStackApiMetadata; -import org.jclouds.elasticstack.ElasticStackAsyncClient; -import org.jclouds.elasticstack.ElasticStackClient; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -34,7 +31,7 @@ import org.jclouds.providers.internal.BaseProviderMetadata; */ public class ElasticHostsBlueSquareLondonProviderMetadata extends - BaseProviderMetadata, ElasticStackApiMetadata> { + BaseProviderMetadata { public static Builder builder() { return new Builder(); @@ -53,14 +50,14 @@ public class ElasticHostsBlueSquareLondonProviderMetadata super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = new Properties(); return properties; } public static class Builder extends - BaseProviderMetadata.Builder, ElasticStackApiMetadata> { + BaseProviderMetadata.Builder { protected Builder() { id("elastichosts-lon-b") @@ -80,7 +77,7 @@ public class ElasticHostsBlueSquareLondonProviderMetadata @Override public Builder fromProviderMetadata( - ProviderMetadata, ElasticStackApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/elastichosts-lon-b/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsBlueSquareLondonTemplateBuilderLiveTest.java b/providers/elastichosts-lon-b/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsBlueSquareLondonTemplateBuilderLiveTest.java index c530f30205..9285774c86 100644 --- a/providers/elastichosts-lon-b/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsBlueSquareLondonTemplateBuilderLiveTest.java +++ b/providers/elastichosts-lon-b/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsBlueSquareLondonTemplateBuilderLiveTest.java @@ -43,7 +43,7 @@ import com.google.common.collect.ImmutableSet; @Test(groups = "live") public class ElasticHostsBlueSquareLondonTemplateBuilderLiveTest extends - BaseTemplateBuilderLiveTest> { + BaseTemplateBuilderLiveTest { public ElasticHostsBlueSquareLondonTemplateBuilderLiveTest() { provider = "elastichosts-lon-b"; diff --git a/providers/elastichosts-lon-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonProviderMetadata.java b/providers/elastichosts-lon-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonProviderMetadata.java index 2987ee2cab..c8dc1ccce5 100644 --- a/providers/elastichosts-lon-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonProviderMetadata.java +++ b/providers/elastichosts-lon-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonProviderMetadata.java @@ -21,10 +21,7 @@ package org.jclouds.elastichosts; import java.net.URI; import java.util.Properties; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.elasticstack.ElasticStackApiMetadata; -import org.jclouds.elasticstack.ElasticStackAsyncClient; -import org.jclouds.elasticstack.ElasticStackClient; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -35,7 +32,7 @@ import org.jclouds.providers.internal.BaseProviderMetadata; */ public class ElasticHostsPeer1LondonProviderMetadata extends - BaseProviderMetadata, ElasticStackApiMetadata> { + BaseProviderMetadata { public static Builder builder() { return new Builder(); @@ -54,14 +51,14 @@ public class ElasticHostsPeer1LondonProviderMetadata super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = new Properties(); return properties; } public static class Builder extends - BaseProviderMetadata.Builder, ElasticStackApiMetadata> { + BaseProviderMetadata.Builder { protected Builder() { id("elastichosts-lon-p") @@ -81,7 +78,7 @@ public class ElasticHostsPeer1LondonProviderMetadata @Override public Builder fromProviderMetadata( - ProviderMetadata, ElasticStackApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/elastichosts-lon-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1LondonTemplateBuilderLiveTest.java b/providers/elastichosts-lon-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1LondonTemplateBuilderLiveTest.java index 32dbc5fcc4..c8a12e0f30 100644 --- a/providers/elastichosts-lon-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1LondonTemplateBuilderLiveTest.java +++ b/providers/elastichosts-lon-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1LondonTemplateBuilderLiveTest.java @@ -43,7 +43,7 @@ import com.google.common.collect.ImmutableSet; @Test(groups = "live") public class ElasticHostsPeer1LondonTemplateBuilderLiveTest extends - BaseTemplateBuilderLiveTest> { + BaseTemplateBuilderLiveTest { public ElasticHostsPeer1LondonTemplateBuilderLiveTest() { provider = "elastichosts-lon-p"; diff --git a/providers/elastichosts-sat-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1SanAntonioProviderMetadata.java b/providers/elastichosts-sat-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1SanAntonioProviderMetadata.java index b79332d3f0..e338b24980 100644 --- a/providers/elastichosts-sat-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1SanAntonioProviderMetadata.java +++ b/providers/elastichosts-sat-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1SanAntonioProviderMetadata.java @@ -21,10 +21,7 @@ package org.jclouds.elastichosts; import java.net.URI; import java.util.Properties; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.elasticstack.ElasticStackApiMetadata; -import org.jclouds.elasticstack.ElasticStackAsyncClient; -import org.jclouds.elasticstack.ElasticStackClient; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -33,9 +30,10 @@ import org.jclouds.providers.internal.BaseProviderMetadata; * * @author Adrian Cole */ -public class ElasticHostsPeer1SanAntonioProviderMetadata - extends - BaseProviderMetadata, ElasticStackApiMetadata> { +public class ElasticHostsPeer1SanAntonioProviderMetadata extends BaseProviderMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = -8914180153534735692L; public static Builder builder() { return new Builder(); @@ -54,14 +52,12 @@ public class ElasticHostsPeer1SanAntonioProviderMetadata super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = new Properties(); return properties; } - public static class Builder - extends - BaseProviderMetadata.Builder, ElasticStackApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder() { id("elastichosts-sat-p") @@ -80,8 +76,7 @@ public class ElasticHostsPeer1SanAntonioProviderMetadata } @Override - public Builder fromProviderMetadata( - ProviderMetadata, ElasticStackApiMetadata> in) { + public Builder fromProviderMetadata(ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/elastichosts-sat-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1SanAntonioTemplateBuilderLiveTest.java b/providers/elastichosts-sat-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1SanAntonioTemplateBuilderLiveTest.java index a33e8475ce..499dc1826d 100644 --- a/providers/elastichosts-sat-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1SanAntonioTemplateBuilderLiveTest.java +++ b/providers/elastichosts-sat-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1SanAntonioTemplateBuilderLiveTest.java @@ -23,13 +23,10 @@ import static org.testng.Assert.assertEquals; import java.util.Set; -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.compute.internal.BaseTemplateBuilderLiveTest; -import org.jclouds.elasticstack.ElasticStackAsyncClient; -import org.jclouds.elasticstack.ElasticStackClient; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -41,9 +38,7 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live") -public class ElasticHostsPeer1SanAntonioTemplateBuilderLiveTest - extends - BaseTemplateBuilderLiveTest> { +public class ElasticHostsPeer1SanAntonioTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { public ElasticHostsPeer1SanAntonioTemplateBuilderLiveTest() { provider = "elastichosts-sat-p"; diff --git a/providers/elastichosts-tor-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1TorontoProviderMetadata.java b/providers/elastichosts-tor-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1TorontoProviderMetadata.java index e857445271..901c88340b 100644 --- a/providers/elastichosts-tor-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1TorontoProviderMetadata.java +++ b/providers/elastichosts-tor-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1TorontoProviderMetadata.java @@ -21,10 +21,7 @@ package org.jclouds.elastichosts; import java.net.URI; import java.util.Properties; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.elasticstack.ElasticStackApiMetadata; -import org.jclouds.elasticstack.ElasticStackAsyncClient; -import org.jclouds.elasticstack.ElasticStackClient; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -33,9 +30,10 @@ import org.jclouds.providers.internal.BaseProviderMetadata; * * @author Adrian Cole */ -public class ElasticHostsPeer1TorontoProviderMetadata - extends - BaseProviderMetadata, ElasticStackApiMetadata> { +public class ElasticHostsPeer1TorontoProviderMetadata extends BaseProviderMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 3573428301472783315L; public static Builder builder() { return new Builder(); @@ -54,14 +52,12 @@ public class ElasticHostsPeer1TorontoProviderMetadata super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = new Properties(); return properties; } - public static class Builder - extends - BaseProviderMetadata.Builder, ElasticStackApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder() { id("elastichosts-tor-p") @@ -81,7 +77,7 @@ public class ElasticHostsPeer1TorontoProviderMetadata @Override public Builder fromProviderMetadata( - ProviderMetadata, ElasticStackApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/elastichosts-tor-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1TorontoTemplateBuilderLiveTest.java b/providers/elastichosts-tor-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1TorontoTemplateBuilderLiveTest.java index f98bb35b5d..9bce8c72a2 100644 --- a/providers/elastichosts-tor-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1TorontoTemplateBuilderLiveTest.java +++ b/providers/elastichosts-tor-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1TorontoTemplateBuilderLiveTest.java @@ -23,13 +23,10 @@ import static org.testng.Assert.assertEquals; import java.util.Set; -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.compute.internal.BaseTemplateBuilderLiveTest; -import org.jclouds.elasticstack.ElasticStackAsyncClient; -import org.jclouds.elasticstack.ElasticStackClient; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -41,9 +38,7 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live") -public class ElasticHostsPeer1TorontoTemplateBuilderLiveTest - extends - BaseTemplateBuilderLiveTest> { +public class ElasticHostsPeer1TorontoTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { public ElasticHostsPeer1TorontoTemplateBuilderLiveTest() { provider = "elastichosts-tor-p"; diff --git a/providers/eucalyptus-partnercloud-ec2/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudContextBuilder.java b/providers/eucalyptus-partnercloud-ec2/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudContextBuilder.java deleted file mode 100644 index 97b22136f1..0000000000 --- a/providers/eucalyptus-partnercloud-ec2/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudContextBuilder.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * 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.epc; - -import java.util.List; - -import org.jclouds.ec2.EC2AsyncClient; -import org.jclouds.ec2.EC2Client; -import org.jclouds.ec2.EC2ContextBuilder; -import org.jclouds.ec2.compute.EC2ComputeServiceContext; -import org.jclouds.epc.config.EucalyptusPartnerCloudComputeServiceContextModule; -import org.jclouds.eucalyptus.EucalyptusApiMetadata; -import org.jclouds.providers.ProviderMetadata; - -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class EucalyptusPartnerCloudContextBuilder extends EC2ContextBuilder, EucalyptusApiMetadata> { - - public EucalyptusPartnerCloudContextBuilder(ProviderMetadata, EucalyptusApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public EucalyptusPartnerCloudContextBuilder(EucalyptusApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new EucalyptusPartnerCloudComputeServiceContextModule()); - } - -} diff --git a/providers/eucalyptus-partnercloud-ec2/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudEC2ProviderMetadata.java b/providers/eucalyptus-partnercloud-ec2/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudEC2ProviderMetadata.java index 1f9b118e77..efe710e50b 100644 --- a/providers/eucalyptus-partnercloud-ec2/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudEC2ProviderMetadata.java +++ b/providers/eucalyptus-partnercloud-ec2/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudEC2ProviderMetadata.java @@ -25,22 +25,26 @@ import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; import java.net.URI; import java.util.Properties; -import org.jclouds.ec2.EC2AsyncClient; -import org.jclouds.ec2.EC2Client; -import org.jclouds.ec2.compute.EC2ComputeServiceContext; +import org.jclouds.ec2.compute.config.EC2ResolveImagesModule; +import org.jclouds.ec2.config.EC2RestClientModule; +import org.jclouds.epc.config.EucalyptusPartnerCloudComputeServiceContextModule; import org.jclouds.eucalyptus.EucalyptusApiMetadata; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; -import com.google.common.reflect.TypeToken; +import com.google.common.collect.ImmutableSet; +import com.google.inject.Module; /** * Implementation of {@link org.jclouds.providers.ProviderMetadata} for Eucalyptus Partner Cloud EC2. * * @author Adrian Cole */ -public class EucalyptusPartnerCloudEC2ProviderMetadata extends BaseProviderMetadata, EucalyptusApiMetadata> { +public class EucalyptusPartnerCloudEC2ProviderMetadata extends BaseProviderMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = 7625722444851538962L; + public static Builder builder() { return new Builder(); } @@ -58,7 +62,7 @@ public class EucalyptusPartnerCloudEC2ProviderMetadata extends BaseProviderMetad super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = new Properties(); properties.setProperty(PROPERTY_REGIONS, "Eucalyptus"); properties.setProperty(PROPERTY_REGION + ".Eucalyptus." + ISO3166_CODES, "US-CA"); @@ -66,14 +70,15 @@ public class EucalyptusPartnerCloudEC2ProviderMetadata extends BaseProviderMetad return properties; } - public static class Builder extends BaseProviderMetadata.Builder, EucalyptusApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder(){ id("eucalyptus-partnercloud-ec2") .name("Eucalyptus Partner Cloud (EC2)") .apiMetadata( new EucalyptusApiMetadata().toBuilder() - .contextBuilder(TypeToken.of(EucalyptusPartnerCloudContextBuilder.class)).build()) + .defaultModules(ImmutableSet.>of(EC2RestClientModule.class, EC2ResolveImagesModule.class, EucalyptusPartnerCloudComputeServiceContextModule.class)) + .build()) .homepage(URI.create("http://www.eucalyptus.com/partners")) .console(URI.create("https://partnercloud.eucalyptus.com:8443")) .linkedServices("eucalyptus-partnercloud-ec2", "eucalyptus-partnercloud-s3") @@ -89,7 +94,7 @@ public class EucalyptusPartnerCloudEC2ProviderMetadata extends BaseProviderMetad @Override public Builder fromProviderMetadata( - ProviderMetadata, EucalyptusApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/eucalyptus-partnercloud-ec2/src/test/java/org/jclouds/epc/compute/EucalyptusPartnerCloudEucalyptusTemplateBuilderLiveTest.java b/providers/eucalyptus-partnercloud-ec2/src/test/java/org/jclouds/epc/compute/EucalyptusPartnerCloudEucalyptusTemplateBuilderLiveTest.java index 8dc7b80f28..9849146e67 100644 --- a/providers/eucalyptus-partnercloud-ec2/src/test/java/org/jclouds/epc/compute/EucalyptusPartnerCloudEucalyptusTemplateBuilderLiveTest.java +++ b/providers/eucalyptus-partnercloud-ec2/src/test/java/org/jclouds/epc/compute/EucalyptusPartnerCloudEucalyptusTemplateBuilderLiveTest.java @@ -25,14 +25,11 @@ import java.io.IOException; import java.util.Set; import org.jclouds.aws.util.AWSUtils; -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.compute.internal.BaseTemplateBuilderLiveTest; import org.jclouds.domain.LocationScope; -import org.jclouds.ec2.EC2AsyncClient; -import org.jclouds.ec2.EC2Client; import org.jclouds.ec2.compute.util.EC2ComputeUtils; import org.testng.annotations.Test; @@ -45,8 +42,7 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live") -public class EucalyptusPartnerCloudEucalyptusTemplateBuilderLiveTest extends - BaseTemplateBuilderLiveTest> { +public class EucalyptusPartnerCloudEucalyptusTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { public EucalyptusPartnerCloudEucalyptusTemplateBuilderLiveTest() { provider = "eucalyptus-partnercloud-ec2"; diff --git a/providers/eucalyptus-partnercloud-s3/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudS3ProviderMetadata.java b/providers/eucalyptus-partnercloud-s3/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudS3ProviderMetadata.java index 5664afa0b5..7be125d98d 100644 --- a/providers/eucalyptus-partnercloud-s3/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudS3ProviderMetadata.java +++ b/providers/eucalyptus-partnercloud-s3/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudS3ProviderMetadata.java @@ -29,9 +29,6 @@ import java.util.Properties; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; -import org.jclouds.s3.S3AsyncClient; -import org.jclouds.s3.S3Client; -import org.jclouds.s3.blobstore.S3BlobStoreContext; import org.jclouds.walrus.WalrusApiMetadata; /** @@ -39,8 +36,11 @@ import org.jclouds.walrus.WalrusApiMetadata; * * @author Adrian Cole */ -public class EucalyptusPartnerCloudS3ProviderMetadata extends BaseProviderMetadata, WalrusApiMetadata> { +public class EucalyptusPartnerCloudS3ProviderMetadata extends BaseProviderMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = 1L; + public static Builder builder() { return new Builder(); } @@ -58,7 +58,7 @@ public class EucalyptusPartnerCloudS3ProviderMetadata extends BaseProviderMetada super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = new Properties(); properties.setProperty(PROPERTY_REGIONS, "Walrus"); properties.setProperty(PROPERTY_ISO3166_CODES, "US-CA"); @@ -67,7 +67,7 @@ public class EucalyptusPartnerCloudS3ProviderMetadata extends BaseProviderMetada return properties; } - public static class Builder extends BaseProviderMetadata.Builder, WalrusApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder(){ id("eucalyptus-partnercloud-s3") @@ -88,7 +88,7 @@ public class EucalyptusPartnerCloudS3ProviderMetadata extends BaseProviderMetada @Override public Builder fromProviderMetadata( - ProviderMetadata, WalrusApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/go2cloud-jhb1/src/main/java/org/jclouds/go2cloud/Go2CloudJohannesburg1ProviderMetadata.java b/providers/go2cloud-jhb1/src/main/java/org/jclouds/go2cloud/Go2CloudJohannesburg1ProviderMetadata.java index 9b3afed0b6..8cf42b413d 100644 --- a/providers/go2cloud-jhb1/src/main/java/org/jclouds/go2cloud/Go2CloudJohannesburg1ProviderMetadata.java +++ b/providers/go2cloud-jhb1/src/main/java/org/jclouds/go2cloud/Go2CloudJohannesburg1ProviderMetadata.java @@ -21,22 +21,20 @@ package org.jclouds.go2cloud; import java.net.URI; import java.util.Properties; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.elasticstack.ElasticStackApiMetadata; -import org.jclouds.elasticstack.ElasticStackAsyncClient; -import org.jclouds.elasticstack.ElasticStackClient; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; /** - * Implementation of {@link org.jclouds.types.ProviderMetadata} for Go2Cloud's - * Johannesburg1 provider. + * Implementation of {@link org.jclouds.types.ProviderMetadata} for Go2Cloud's Johannesburg1 + * provider. * * @author Adrian Cole */ -public class Go2CloudJohannesburg1ProviderMetadata - extends - BaseProviderMetadata, ElasticStackApiMetadata> { +public class Go2CloudJohannesburg1ProviderMetadata extends BaseProviderMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 5737728330686182812L; public static Builder builder() { return new Builder(); @@ -55,14 +53,14 @@ public class Go2CloudJohannesburg1ProviderMetadata super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = new Properties(); return properties; } public static class Builder extends - BaseProviderMetadata.Builder, ElasticStackApiMetadata> { + BaseProviderMetadata.Builder { protected Builder() { id("go2cloud-jhb1") @@ -82,7 +80,7 @@ public class Go2CloudJohannesburg1ProviderMetadata @Override public Builder fromProviderMetadata( - ProviderMetadata, ElasticStackApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/go2cloud-jhb1/src/test/java/org/jclouds/go2cloud/compute/Go2CloudJohannesburg1TemplateBuilderLiveTest.java b/providers/go2cloud-jhb1/src/test/java/org/jclouds/go2cloud/compute/Go2CloudJohannesburg1TemplateBuilderLiveTest.java index 65175537f3..0b5bc44fb3 100644 --- a/providers/go2cloud-jhb1/src/test/java/org/jclouds/go2cloud/compute/Go2CloudJohannesburg1TemplateBuilderLiveTest.java +++ b/providers/go2cloud-jhb1/src/test/java/org/jclouds/go2cloud/compute/Go2CloudJohannesburg1TemplateBuilderLiveTest.java @@ -24,13 +24,10 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.util.Set; -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.compute.internal.BaseTemplateBuilderLiveTest; -import org.jclouds.elasticstack.ElasticStackAsyncClient; -import org.jclouds.elasticstack.ElasticStackClient; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -42,9 +39,7 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live") -public class Go2CloudJohannesburg1TemplateBuilderLiveTest - extends - BaseTemplateBuilderLiveTest> { +public class Go2CloudJohannesburg1TemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { public Go2CloudJohannesburg1TemplateBuilderLiveTest() { provider = "go2cloud-jhb1"; diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridApiMetadata.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridApiMetadata.java index 7733c419de..b85d260968 100644 --- a/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridApiMetadata.java +++ b/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridApiMetadata.java @@ -23,19 +23,28 @@ import java.util.Properties; import org.jclouds.apis.ApiMetadata; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; +import org.jclouds.gogrid.compute.config.GoGridComputeServiceContextModule; +import org.jclouds.gogrid.config.GoGridRestClientModule; +import org.jclouds.rest.RestContext; +import org.jclouds.rest.internal.BaseRestApiMetadata; +import com.google.common.collect.ImmutableSet; import com.google.common.reflect.TypeToken; +import com.google.inject.Module; /** * Implementation of {@link ApiMetadata} for API * * @author Adrian Cole */ -public class GoGridApiMetadata - extends - BaseComputeServiceApiMetadata, GoGridApiMetadata> { +public class GoGridApiMetadata extends BaseRestApiMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = 6725672099385580694L; + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; + @Override public Builder toBuilder() { return new Builder().fromApiMetadata(this); @@ -49,18 +58,17 @@ public class GoGridApiMetadata super(builder); } - protected static Properties defaultProperties() { - Properties properties = BaseComputeServiceApiMetadata.Builder.defaultProperties(); + public static Properties defaultProperties() { + Properties properties = BaseRestApiMetadata.defaultProperties(); properties.setProperty("jclouds.ssh.max-retries", "5"); properties.setProperty("jclouds.ssh.retry-auth", "true"); return properties; } - public static class Builder - extends - BaseComputeServiceApiMetadata.Builder, GoGridApiMetadata> { + public static class Builder extends BaseRestApiMetadata.Builder { protected Builder() { + super(GoGridClient.class, GoGridAsyncClient.class); id("gogrid") .name("GoGrid API") .identityName("API Key") @@ -68,8 +76,9 @@ public class GoGridApiMetadata .documentation(URI.create("https://wiki.gogrid.com/wiki/index.php/API")) .version(GoGridAsyncClient.VERSION) .defaultEndpoint("https://api.gogrid.com/api") - .javaApi(GoGridClient.class, GoGridAsyncClient.class) - .contextBuilder(TypeToken.of(GoGridContextBuilder.class)); + .defaultProperties(GoGridApiMetadata.defaultProperties()) + .wrapper(TypeToken.of(ComputeServiceContext.class)) + .defaultModules(ImmutableSet.>of(GoGridRestClientModule.class, GoGridComputeServiceContextModule.class)); } @Override @@ -78,7 +87,7 @@ public class GoGridApiMetadata } @Override - public Builder fromApiMetadata(GoGridApiMetadata in) { + public Builder fromApiMetadata(ApiMetadata in) { super.fromApiMetadata(in); return this; } diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridContextBuilder.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridContextBuilder.java deleted file mode 100644 index 0318c28952..0000000000 --- a/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridContextBuilder.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * 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.gogrid; - -import java.util.List; - -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextBuilder; -import org.jclouds.gogrid.compute.config.GoGridComputeServiceContextModule; -import org.jclouds.gogrid.config.GoGridRestClientModule; -import org.jclouds.providers.ProviderMetadata; - -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class GoGridContextBuilder - extends - ComputeServiceContextBuilder, GoGridApiMetadata> { - - public GoGridContextBuilder( - ProviderMetadata, GoGridApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public GoGridContextBuilder(GoGridApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new GoGridComputeServiceContextModule()); - } - - protected void addClientModule(List modules) { - modules.add(new GoGridRestClientModule()); - } - -} diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridProviderMetadata.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridProviderMetadata.java index c78a719162..051b96eee6 100644 --- a/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridProviderMetadata.java +++ b/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridProviderMetadata.java @@ -27,7 +27,6 @@ import static org.jclouds.location.reference.LocationConstants.PROPERTY_ZONES; import java.net.URI; import java.util.Properties; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -35,9 +34,10 @@ import org.jclouds.providers.internal.BaseProviderMetadata; * Implementation of {@link org.jclouds.types.ProviderMetadata} for GoGrid. * @author Adrian Cole */ -public class GoGridProviderMetadata - extends - BaseProviderMetadata, GoGridApiMetadata> { +public class GoGridProviderMetadata extends BaseProviderMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 503149209800711396L; public static Builder builder() { return new Builder(); @@ -56,7 +56,7 @@ public class GoGridProviderMetadata super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = new Properties(); properties.setProperty(PROPERTY_ZONES, "1,2,3"); properties.setProperty(PROPERTY_ZONE + ".1." + ISO3166_CODES, "US-CA"); @@ -67,9 +67,7 @@ public class GoGridProviderMetadata return properties; } - public static class Builder - extends - BaseProviderMetadata.Builder, GoGridApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder() { id("gogrid") @@ -88,8 +86,7 @@ public class GoGridProviderMetadata } @Override - public Builder fromProviderMetadata( - ProviderMetadata, GoGridApiMetadata> in) { + public Builder fromProviderMetadata(ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/GoGridComputeService.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/GoGridComputeService.java index 879880a23d..b03aadf71d 100644 --- a/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/GoGridComputeService.java +++ b/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/GoGridComputeService.java @@ -62,7 +62,7 @@ import com.google.common.base.Supplier; @Singleton public class GoGridComputeService extends BaseComputeService { @Inject - protected GoGridComputeService(@SuppressWarnings("rawtypes") ComputeServiceContext context, Map credentialStore, + protected GoGridComputeService(ComputeServiceContext context, Map credentialStore, @Memoized Supplier> images, @Memoized Supplier> hardwareProfiles, @Memoized Supplier> locations, ListNodesStrategy listNodesStrategy, GetNodeMetadataStrategy getNodeMetadataStrategy, CreateNodesInGroupThenAddToSet runNodesAndAddToSetStrategy, diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/config/GoGridComputeServiceContextModule.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/config/GoGridComputeServiceContextModule.java index a1b7e405e4..01db87430d 100644 --- a/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/config/GoGridComputeServiceContextModule.java +++ b/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/config/GoGridComputeServiceContextModule.java @@ -36,8 +36,6 @@ import org.jclouds.compute.domain.TemplateBuilder; import org.jclouds.compute.options.TemplateOptions; import org.jclouds.domain.Location; import org.jclouds.functions.IdentityFunction; -import org.jclouds.gogrid.GoGridAsyncClient; -import org.jclouds.gogrid.GoGridClient; import org.jclouds.gogrid.compute.functions.OptionToLocation; import org.jclouds.gogrid.compute.functions.ServerImageToImage; import org.jclouds.gogrid.compute.functions.ServerToNodeMetadata; @@ -61,10 +59,7 @@ import com.google.inject.TypeLiteral; * @author Andrew Kennedy */ public class GoGridComputeServiceContextModule extends - ComputeServiceAdapterContextModule { - public GoGridComputeServiceContextModule() { - super(GoGridClient.class, GoGridAsyncClient.class); - } + ComputeServiceAdapterContextModule { @Override protected TemplateBuilder provideTemplate(Injector injector, TemplateBuilder template) { diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/config/GoGridRestClientModule.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/config/GoGridRestClientModule.java index ba34fedc33..8e97f212e1 100644 --- a/providers/gogrid/src/main/java/org/jclouds/gogrid/config/GoGridRestClientModule.java +++ b/providers/gogrid/src/main/java/org/jclouds/gogrid/config/GoGridRestClientModule.java @@ -41,7 +41,6 @@ import org.jclouds.gogrid.services.GridLoadBalancerClient; import org.jclouds.gogrid.services.GridServerAsyncClient; import org.jclouds.gogrid.services.GridServerClient; import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.ServerError; @@ -61,7 +60,6 @@ import com.google.inject.Scopes; * @author Adrian Cole * @author Oleksiy Yarmula */ -@RequiresHttp @ConfiguresRestClient public class GoGridRestClientModule extends RestClientModule { public static final Map, Class> DELEGATE_MAP = ImmutableMap., Class> builder()// diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/GoGridLiveTestDisabled.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/GoGridLiveTestDisabled.java index 31017c0ebe..5ceffc0066 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/GoGridLiveTestDisabled.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/GoGridLiveTestDisabled.java @@ -34,9 +34,9 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.TimeUnit; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.domain.Credentials; +import org.jclouds.domain.LoginCredentials; import org.jclouds.gogrid.domain.Ip; import org.jclouds.gogrid.domain.IpPortPair; import org.jclouds.gogrid.domain.Job; @@ -70,14 +70,12 @@ import com.google.common.collect.Iterables; /** * End to end live test for GoGrid *

- * Takes too long to execute. Please split into multiple tests + * Takes too long to execute. Please split into multiple tests * * @author Oleksiy Yarmula */ @Test(enabled = false, groups = "live", singleThreaded = true, testName = "GoGridLiveTestDisabled") -public class GoGridLiveTestDisabled - extends - BaseComputeServiceContextLiveTest> { +public class GoGridLiveTestDisabled extends BaseComputeServiceContextLiveTest { public GoGridLiveTestDisabled() { provider = "gogrid"; @@ -99,7 +97,7 @@ public class GoGridLiveTestDisabled @Override public void setupContext() { super.setupContext(); - gocontext = context.getProviderSpecificContext(); + gocontext = context.unwrap(); client = gocontext.getApi(); serverLatestJobCompleted = new RetryablePredicate(new ServerLatestJobCompleted(client.getJobServices()), @@ -340,7 +338,7 @@ public class GoGridLiveTestDisabled createdServer = Iterables.getOnlyElement(response); Map credsMap = client.getServerServices().getServerCredentialsList(); - Credentials instanceCredentials = credsMap.get(createdServer.getName()); + LoginCredentials instanceCredentials = LoginCredentials.fromCredentials(credsMap.get(createdServer.getName())); assertNotNull(instanceCredentials); IPSocket socket = new IPSocket(createdServer.getIp().getIp(), 22); diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridComputeServiceLiveTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridComputeServiceLiveTest.java index c2359cb42f..b633266c28 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridComputeServiceLiveTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridComputeServiceLiveTest.java @@ -25,7 +25,6 @@ import static org.testng.Assert.assertNotNull; import java.util.concurrent.TimeUnit; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.internal.BaseComputeServiceLiveTest; @@ -48,9 +47,7 @@ import com.google.inject.Module; // NOTE:without testName, this will not call @Before* and fail w/NPE during // surefire @Test(groups = "live", singleThreaded = true, testName = "GoGridComputeServiceLiveTest") -public class GoGridComputeServiceLiveTest - extends - BaseComputeServiceLiveTest> { +public class GoGridComputeServiceLiveTest extends BaseComputeServiceLiveTest { public GoGridComputeServiceLiveTest() { provider = "gogrid"; @@ -74,7 +71,7 @@ public class GoGridComputeServiceLiveTest public void testResizeRam() throws Exception { String group = this.group + "ram"; - RestContext providerContext = context.getProviderSpecificContext(); + RestContext providerContext = context.unwrap(); try { client.destroyNodesMatching(inGroup(group)); } catch (Exception e) { diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridTemplateBuilderLiveTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridTemplateBuilderLiveTest.java index 1773206435..45a751bdd1 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridTemplateBuilderLiveTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridTemplateBuilderLiveTest.java @@ -24,13 +24,10 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.util.Set; -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.compute.internal.BaseTemplateBuilderLiveTest; -import org.jclouds.gogrid.GoGridAsyncClient; -import org.jclouds.gogrid.GoGridClient; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -43,9 +40,7 @@ import com.google.common.collect.ImmutableSet; */ //NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "live", singleThreaded = true, testName = "GoGridTemplateBuilderLiveTest") -public class GoGridTemplateBuilderLiveTest - extends - BaseTemplateBuilderLiveTest> { +public class GoGridTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { public GoGridTemplateBuilderLiveTest() { provider = "gogrid"; diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridAsyncClientTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridAsyncClientTest.java index ef95d93eb5..0d40acc104 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridAsyncClientTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridAsyncClientTest.java @@ -25,7 +25,6 @@ import org.jclouds.gogrid.GoGridProviderMetadata; import org.jclouds.gogrid.config.GoGridRestClientModule; import org.jclouds.gogrid.filters.SharedKeyLiteAuthentication; import org.jclouds.http.HttpRequest; -import org.jclouds.http.RequiresHttp; import org.jclouds.providers.ProviderMetadata; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.internal.BaseAsyncClientTest; @@ -46,8 +45,7 @@ public abstract class BaseGoGridAsyncClientTest extends BaseAsyncClientTest extends BaseAsyncClientTest createProviderMetadata() { + public ProviderMetadata createProviderMetadata() { return new GoGridProviderMetadata(); } diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridClientLiveTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridClientLiveTest.java index e070cc5571..ebe8a1daa8 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridClientLiveTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridClientLiveTest.java @@ -18,7 +18,6 @@ */ package org.jclouds.gogrid.services; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.gogrid.GoGridAsyncClient; import org.jclouds.gogrid.GoGridClient; @@ -32,9 +31,7 @@ import org.testng.annotations.Test; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "BaseGoGridClientLiveTest") -public class BaseGoGridClientLiveTest - extends - BaseComputeServiceContextLiveTest> { +public class BaseGoGridClientLiveTest extends BaseComputeServiceContextLiveTest { public BaseGoGridClientLiveTest() { provider = "gogrid"; @@ -46,7 +43,7 @@ public class BaseGoGridClientLiveTest @Override public void setupContext() { super.setupContext(); - restContext = context.getProviderSpecificContext(); + restContext = context.unwrap(); } diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridRestClientExpectTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridRestClientExpectTest.java index 25fd8a968f..6700eae72e 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridRestClientExpectTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridRestClientExpectTest.java @@ -3,9 +3,8 @@ package org.jclouds.gogrid.services; import org.jclouds.date.TimeStamp; import org.jclouds.gogrid.GoGridClient; import org.jclouds.gogrid.config.GoGridRestClientModule; -import org.jclouds.http.RequiresHttp; -import org.jclouds.rest.internal.BaseRestClientExpectTest; import org.jclouds.rest.ConfiguresRestClient; +import org.jclouds.rest.internal.BaseRestClientExpectTest; import com.google.common.base.Supplier; import com.google.inject.Module; @@ -20,8 +19,7 @@ public class BaseGoGridRestClientExpectTest extends BaseRestClientExpectTest, VCloudApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public GreenHouseDataElementVCloudContextBuilder(VCloudApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new VCloudComputeServiceContextModule()); - } - - @Override - protected void addClientModule(List modules) { - modules.add(new GreenHouseDataElementVCloudRestClientModule()); - } - -} diff --git a/providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudProviderMetadata.java b/providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudProviderMetadata.java index 0bf19f4964..68315893ac 100644 --- a/providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudProviderMetadata.java +++ b/providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudProviderMetadata.java @@ -23,23 +23,24 @@ import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAU import java.net.URI; import java.util.Properties; -import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.greenhousedata.element.vcloud.config.GreenHouseDataElementVCloudComputeServiceContextModule; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; import org.jclouds.vcloud.VCloudApiMetadata; -import org.jclouds.vcloud.VCloudAsyncClient; -import org.jclouds.vcloud.VCloudClient; +import org.jclouds.vcloud.config.VCloudRestClientModule; -import com.google.common.reflect.TypeToken; +import com.google.common.collect.ImmutableSet; +import com.google.inject.Module; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for Green House Data Element vCloud * * @author Adrian Cole */ -public class GreenHouseDataElementVCloudProviderMetadata - extends - BaseProviderMetadata, VCloudApiMetadata> { +public class GreenHouseDataElementVCloudProviderMetadata extends BaseProviderMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 8503534430849704022L; public static Builder builder() { return new Builder(); @@ -58,13 +59,13 @@ public class GreenHouseDataElementVCloudProviderMetadata super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = new Properties(); properties.setProperty(PROPERTY_VCLOUD_DEFAULT_NETWORK, "orgNet-.*-External"); return properties; } - public static class Builder extends BaseProviderMetadata.Builder, VCloudApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder(){ id("greenhousedata-element-vcloud") @@ -72,7 +73,8 @@ public class GreenHouseDataElementVCloudProviderMetadata .apiMetadata( new VCloudApiMetadata().toBuilder() .buildVersion("1.5.0.464915") - .contextBuilder(TypeToken.of(GreenHouseDataElementVCloudContextBuilder.class)).build()) + .defaultModules(ImmutableSet.>of(VCloudRestClientModule.class, GreenHouseDataElementVCloudComputeServiceContextModule.class)) + .build()) .homepage(URI.create("http://www.greenhousedata.com/element-cloud-hosting/vcloud-services/")) .console(URI.create("https://mycloud.greenhousedata.com/cloud/org/YOUR_ORG_HERE")) .iso3166Codes("US-WY") @@ -87,7 +89,7 @@ public class GreenHouseDataElementVCloudProviderMetadata @Override public Builder fromProviderMetadata( - ProviderMetadata, VCloudApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/config/GreenHouseDataElementVCloudRestClientModule.java b/providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/config/GreenHouseDataElementVCloudRestClientModule.java deleted file mode 100644 index eed0785010..0000000000 --- a/providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/config/GreenHouseDataElementVCloudRestClientModule.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * 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.greenhousedata.element.vcloud.config; - -import org.jclouds.http.RequiresHttp; -import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.vcloud.config.VCloudRestClientModule; - -/** - * Configures the VCloud authentication service connection, including logging and http transport. - * - * @author Adrian Cole - */ -@RequiresHttp -@ConfiguresRestClient -public class GreenHouseDataElementVCloudRestClientModule extends VCloudRestClientModule { - -} diff --git a/providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/compute/GreenHouseDataElementVCloudTemplateBuilderLiveTest.java b/providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/compute/GreenHouseDataElementVCloudTemplateBuilderLiveTest.java index efb4394359..0276f110f9 100644 --- a/providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/compute/GreenHouseDataElementVCloudTemplateBuilderLiveTest.java +++ b/providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/compute/GreenHouseDataElementVCloudTemplateBuilderLiveTest.java @@ -24,13 +24,10 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.util.Set; -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.compute.internal.BaseTemplateBuilderLiveTest; -import org.jclouds.vcloud.VCloudAsyncClient; -import org.jclouds.vcloud.VCloudClient; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -41,9 +38,7 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live", testName = "GreenHouseDataElementVCloudTemplateBuilderLiveTest") -public class GreenHouseDataElementVCloudTemplateBuilderLiveTest - extends - BaseTemplateBuilderLiveTest> { +public class GreenHouseDataElementVCloudTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { public GreenHouseDataElementVCloudTemplateBuilderLiveTest() { provider = "greenhousedata-element-vcloud"; diff --git a/providers/hpcloud-compute/src/main/java/org/jclouds/hpcloud/compute/HPCloudComputeContextBuilder.java b/providers/hpcloud-compute/src/main/java/org/jclouds/hpcloud/compute/HPCloudComputeContextBuilder.java deleted file mode 100644 index cdaccddb03..0000000000 --- a/providers/hpcloud-compute/src/main/java/org/jclouds/hpcloud/compute/HPCloudComputeContextBuilder.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * 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.hpcloud.compute; - -import java.util.List; - -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.hpcloud.compute.config.HPCloudComputeServiceContextModule; -import org.jclouds.openstack.nova.v1_1.NovaApiMetadata; -import org.jclouds.openstack.nova.v1_1.NovaAsyncClient; -import org.jclouds.openstack.nova.v1_1.NovaClient; -import org.jclouds.openstack.nova.v1_1.NovaContextBuilder; -import org.jclouds.providers.ProviderMetadata; - -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class HPCloudComputeContextBuilder extends NovaContextBuilder { - - public HPCloudComputeContextBuilder( - ProviderMetadata, NovaApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public HPCloudComputeContextBuilder(NovaApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new HPCloudComputeServiceContextModule()); - } - -} diff --git a/providers/hpcloud-compute/src/main/java/org/jclouds/hpcloud/compute/HPCloudComputeProviderMetadata.java b/providers/hpcloud-compute/src/main/java/org/jclouds/hpcloud/compute/HPCloudComputeProviderMetadata.java index 44e48865a9..91fe9a394b 100644 --- a/providers/hpcloud-compute/src/main/java/org/jclouds/hpcloud/compute/HPCloudComputeProviderMetadata.java +++ b/providers/hpcloud-compute/src/main/java/org/jclouds/hpcloud/compute/HPCloudComputeProviderMetadata.java @@ -26,23 +26,24 @@ import static org.jclouds.openstack.nova.v1_1.config.NovaProperties.AUTO_GENERAT import java.net.URI; import java.util.Properties; -import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.hpcloud.compute.config.HPCloudComputeServiceContextModule; import org.jclouds.openstack.nova.v1_1.NovaApiMetadata; -import org.jclouds.openstack.nova.v1_1.NovaAsyncClient; -import org.jclouds.openstack.nova.v1_1.NovaClient; +import org.jclouds.openstack.nova.v1_1.config.NovaRestClientModule; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; -import com.google.common.reflect.TypeToken; +import com.google.common.collect.ImmutableSet; +import com.google.inject.Module; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for HP Cloud Compute Services. * * @author Adrian Cole */ -public class HPCloudComputeProviderMetadata - extends - BaseProviderMetadata, NovaApiMetadata> { +public class HPCloudComputeProviderMetadata extends BaseProviderMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = -300987074165012648L; public static Builder builder() { return new Builder(); @@ -61,7 +62,7 @@ public class HPCloudComputeProviderMetadata super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = new Properties(); // deallocating ip addresses can take a while properties.setProperty(TIMEOUT_NODE_TERMINATED, 60 * 1000 + ""); @@ -72,14 +73,16 @@ public class HPCloudComputeProviderMetadata return properties; } - public static class Builder extends BaseProviderMetadata.Builder, NovaApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder(){ id("hpcloud-compute") .name("HP Cloud Compute Services") - .apiMetadata(new NovaApiMetadata().toBuilder().identityName("tenantId:accessKey") - .credentialName("secretKey") - .contextBuilder(TypeToken.of(HPCloudComputeContextBuilder.class)).build()) + .apiMetadata(new NovaApiMetadata().toBuilder() + .identityName("tenantId:accessKey") + .credentialName("secretKey") + .defaultModules(ImmutableSet.>of(NovaRestClientModule.class, HPCloudComputeServiceContextModule.class)) + .build()) .homepage(URI.create("http://hpcloud.com")) .console(URI.create("https://manage.hpcloud.com/compute")) .linkedServices("hpcloud-compute", "hpcloud-objectstorage") @@ -92,10 +95,9 @@ public class HPCloudComputeProviderMetadata public HPCloudComputeProviderMetadata build() { return new HPCloudComputeProviderMetadata(this); } - + @Override - public Builder fromProviderMetadata( - ProviderMetadata, NovaApiMetadata> in) { + public Builder fromProviderMetadata(ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/hpcloud-compute/src/test/java/org/jclouds/hpcloud/compute/compute/HPCloudComputeTemplateBuilderLiveTest.java b/providers/hpcloud-compute/src/test/java/org/jclouds/hpcloud/compute/compute/HPCloudComputeTemplateBuilderLiveTest.java index 29664b45f4..23531f1a8c 100644 --- a/providers/hpcloud-compute/src/test/java/org/jclouds/hpcloud/compute/compute/HPCloudComputeTemplateBuilderLiveTest.java +++ b/providers/hpcloud-compute/src/test/java/org/jclouds/hpcloud/compute/compute/HPCloudComputeTemplateBuilderLiveTest.java @@ -23,13 +23,10 @@ import static org.testng.Assert.assertEquals; import java.util.Set; -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.compute.internal.BaseTemplateBuilderLiveTest; -import org.jclouds.openstack.nova.v1_1.NovaAsyncClient; -import org.jclouds.openstack.nova.v1_1.NovaClient; import org.jclouds.openstack.nova.v1_1.compute.options.NovaTemplateOptions; import org.testng.annotations.Test; @@ -42,8 +39,7 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "HPCloudComputeTemplateBuilderLiveTest") -public class HPCloudComputeTemplateBuilderLiveTest extends - BaseTemplateBuilderLiveTest> { +public class HPCloudComputeTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { public HPCloudComputeTemplateBuilderLiveTest() { provider = "hpcloud-compute"; diff --git a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageApiMetadata.java b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageApiMetadata.java index 8ff3b49aad..dee1981245 100644 --- a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageApiMetadata.java +++ b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageApiMetadata.java @@ -24,20 +24,32 @@ import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.SERV import java.net.URI; import java.util.Properties; +import org.jclouds.apis.ApiMetadata; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.internal.BaseBlobStoreApiMetadata; +import org.jclouds.hpcloud.objectstorage.blobstore.config.HPCloudObjectStorageBlobStoreContextModule; +import org.jclouds.hpcloud.objectstorage.config.HPCloudObjectStorageRestClientModule; import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties; import org.jclouds.openstack.services.ServiceType; +import org.jclouds.openstack.swift.SwiftApiMetadata; +import org.jclouds.rest.RestContext; +import org.jclouds.rest.internal.BaseRestApiMetadata; +import com.google.common.collect.ImmutableSet; import com.google.common.reflect.TypeToken; +import com.google.inject.Module; /** * Implementation of {@link org.jclouds.providers.ProviderMetadata} for HP Cloud Services Object Storage * * @author Jeremy Daggett */ -public class HPCloudObjectStorageApiMetadata - extends - BaseBlobStoreApiMetadata, HPCloudObjectStorageApiMetadata> { +public class HPCloudObjectStorageApiMetadata extends BaseRestApiMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 820062881469203616L; + + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; private static Builder builder() { return new Builder(); @@ -56,8 +68,8 @@ public class HPCloudObjectStorageApiMetadata super(builder); } - protected static Properties defaultProperties() { - Properties properties = BaseBlobStoreApiMetadata.Builder.defaultProperties(); + public static Properties defaultProperties() { + Properties properties = SwiftApiMetadata.defaultProperties(); properties.setProperty(SERVICE_TYPE, ServiceType.OBJECT_STORE); // TODO: this doesn't actually do anything yet. properties.setProperty(KeystoneProperties.VERSION, "2.0"); @@ -65,20 +77,19 @@ public class HPCloudObjectStorageApiMetadata return properties; } - public static class Builder - extends - BaseBlobStoreApiMetadata.Builder, HPCloudObjectStorageApiMetadata> { - + public static class Builder extends BaseRestApiMetadata.Builder { + protected Builder() { + super(HPCloudObjectStorageClient.class, HPCloudObjectStorageAsyncClient.class); id("hpcloud-objectstorage") .name("HP Cloud Services Object Storage API") .identityName("tenantId:accessKey") .credentialName("secretKey") .version("1.0") .documentation(URI.create("https://build.hpcloud.com/object-storage/api")) - .javaApi(HPCloudObjectStorageClient.class, HPCloudObjectStorageAsyncClient.class) - .contextBuilder(TypeToken.of(HPCloudObjectStorageContextBuilder.class)) - .defaultProperties(HPCloudObjectStorageApiMetadata.defaultProperties()); + .defaultProperties(HPCloudObjectStorageApiMetadata.defaultProperties()) + .wrapper(TypeToken.of(BlobStoreContext.class)) + .defaultModules(ImmutableSet.>of(HPCloudObjectStorageRestClientModule.class, HPCloudObjectStorageBlobStoreContextModule.class)); } @Override @@ -87,7 +98,7 @@ public class HPCloudObjectStorageApiMetadata } @Override - public Builder fromApiMetadata(HPCloudObjectStorageApiMetadata in) { + public Builder fromApiMetadata(ApiMetadata in) { super.fromApiMetadata(in); return this; } diff --git a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageContextBuilder.java b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageContextBuilder.java deleted file mode 100644 index f51bc37aae..0000000000 --- a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageContextBuilder.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * 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.hpcloud.objectstorage; - -import java.util.List; - -import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.blobstore.BlobStoreContextBuilder; -import org.jclouds.hpcloud.objectstorage.blobstore.config.HPCloudObjectStorageBlobStoreContextModule; -import org.jclouds.hpcloud.objectstorage.config.HPCloudObjectStorageRestClientModule; -import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; -import org.jclouds.logging.jdk.config.JDKLoggingModule; -import org.jclouds.providers.ProviderMetadata; - -import com.google.inject.Injector; -import com.google.inject.Module; - -/** - * Creates {@link HPCloudObjectStorageStoreContext} or {@link Injector} instances based on - * the most commonly requested arguments. - *

- * Note that Threadsafe objects will be bound as singletons to the Injector or - * Context provided. - *

- *

- * If no Modules are specified, the default - * {@link JDKLoggingModule logging} and - * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be - * installed. - * - * @author Adrian Cole, Andrew Newdigate - * @see HPCloudObjectStorageStoreContext - */ -public class HPCloudObjectStorageContextBuilder - extends - BlobStoreContextBuilder, HPCloudObjectStorageApiMetadata> { - - public HPCloudObjectStorageContextBuilder( - ProviderMetadata, HPCloudObjectStorageApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public HPCloudObjectStorageContextBuilder(HPCloudObjectStorageApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new HPCloudObjectStorageBlobStoreContextModule()); - } - - @Override - protected void addClientModule(List modules) { - modules.add(new HPCloudObjectStorageRestClientModule()); - } -} \ No newline at end of file diff --git a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageProviderMetadata.java b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageProviderMetadata.java index 65dea7c5a8..e464575931 100644 --- a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageProviderMetadata.java +++ b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageProviderMetadata.java @@ -23,7 +23,6 @@ import static org.jclouds.Constants.PROPERTY_BUILD_VERSION; import java.net.URI; import java.util.Properties; -import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -32,9 +31,10 @@ import org.jclouds.providers.internal.BaseProviderMetadata; * * @author Adrian Cole */ -public class HPCloudObjectStorageProviderMetadata - extends - BaseProviderMetadata, HPCloudObjectStorageApiMetadata> { +public class HPCloudObjectStorageProviderMetadata extends BaseProviderMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = -3735142654912867384L; public static Builder builder() { return new Builder(); @@ -53,14 +53,14 @@ public class HPCloudObjectStorageProviderMetadata super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = new Properties(); properties.setProperty(PROPERTY_BUILD_VERSION, "???"); //FIXME // properties.setProperty(PROPERTY_VCLOUD_DEFAULT_NETWORK, "orgNet-.*-External"); FIXME: needed? return properties; } - public static class Builder extends BaseProviderMetadata.Builder, HPCloudObjectStorageApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder(){ id("hpcloud-objectstorage") @@ -80,8 +80,7 @@ public class HPCloudObjectStorageProviderMetadata } @Override - public Builder fromProviderMetadata( - ProviderMetadata, HPCloudObjectStorageApiMetadata> in) { + public Builder fromProviderMetadata(ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/blobstore/HPCloudObjectStorageAsyncBlobStore.java b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/blobstore/HPCloudObjectStorageAsyncBlobStore.java index a9516d6f9c..ed305371de 100644 --- a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/blobstore/HPCloudObjectStorageAsyncBlobStore.java +++ b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/blobstore/HPCloudObjectStorageAsyncBlobStore.java @@ -59,7 +59,7 @@ public class HPCloudObjectStorageAsyncBlobStore extends SwiftAsyncBlobStore { private final EnableCDNAndCache enableCDNAndCache; @Inject - protected HPCloudObjectStorageAsyncBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, + protected HPCloudObjectStorageAsyncBlobStore(BlobStoreContext context, BlobUtils blobUtils, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService service, Supplier defaultLocation, @Memoized Supplier> locations, HPCloudObjectStorageClient sync, HPCloudObjectStorageAsyncClient async, ContainerToResourceMetadata container2ResourceMd, diff --git a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/blobstore/HPCloudObjectStorageBlobStore.java b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/blobstore/HPCloudObjectStorageBlobStore.java index fc9acef141..e05119ed8c 100644 --- a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/blobstore/HPCloudObjectStorageBlobStore.java +++ b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/blobstore/HPCloudObjectStorageBlobStore.java @@ -53,7 +53,7 @@ public class HPCloudObjectStorageBlobStore extends SwiftBlobStore { private EnableCDNAndCache enableCDNAndCache; @Inject - protected HPCloudObjectStorageBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, + protected HPCloudObjectStorageBlobStore(BlobStoreContext context, BlobUtils blobUtils, Supplier defaultLocation, @Memoized Supplier> locations, HPCloudObjectStorageClient sync, ContainerToResourceMetadata container2ResourceMd, BlobStoreListContainerOptionsToListContainerOptions container2ContainerListOptions, diff --git a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/config/HPCloudObjectStorageRestClientModule.java b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/config/HPCloudObjectStorageRestClientModule.java index 1a0304bd2e..a6ab3272c9 100644 --- a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/config/HPCloudObjectStorageRestClientModule.java +++ b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/config/HPCloudObjectStorageRestClientModule.java @@ -32,7 +32,6 @@ import org.jclouds.hpcloud.objectstorage.extensions.HPCloudCDNClient; import org.jclouds.hpcloud.services.HPExtensionCDN; import org.jclouds.hpcloud.services.HPExtensionServiceType; import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.ServerError; @@ -62,7 +61,6 @@ import com.google.inject.Scopes; * @author Adrian Cole */ @ConfiguresRestClient -@RequiresHttp public class HPCloudObjectStorageRestClientModule extends RestClientModule { public static final Map, Class> DELEGATE_MAP = ImmutableMap., Class> builder().put( diff --git a/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageClientLiveTest.java b/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageClientLiveTest.java index bda812354e..816d02f6d1 100644 --- a/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageClientLiveTest.java +++ b/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageClientLiveTest.java @@ -43,7 +43,7 @@ public class HPCloudObjectStorageClientLiveTest extends CommonSwiftClientLiveTes @Override public HPCloudObjectStorageClient getApi() { - return (HPCloudObjectStorageClient) context.getProviderSpecificContext().getApi(); + return context.unwrap(HPCloudObjectStorageApiMetadata.CONTEXT_TOKEN).getApi(); } @Override diff --git a/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/internal/HPCloudObjectStorageExpectTest.java b/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/internal/HPCloudObjectStorageExpectTest.java index 0e0b6fa748..352efdeafb 100644 --- a/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/internal/HPCloudObjectStorageExpectTest.java +++ b/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/internal/HPCloudObjectStorageExpectTest.java @@ -59,7 +59,7 @@ public class HPCloudObjectStorageExpectTest extends BaseRestClientExpectTest createProviderMetadata(){ + @Override public ProviderMetadata createProviderMetadata(){ return new HPCloudObjectStorageProviderMetadata(); } } diff --git a/providers/ninefold-compute/src/main/java/org/jclouds/ninefold/compute/NinefoldComputeProviderMetadata.java b/providers/ninefold-compute/src/main/java/org/jclouds/ninefold/compute/NinefoldComputeProviderMetadata.java index 46da1fbdeb..681220b4cb 100644 --- a/providers/ninefold-compute/src/main/java/org/jclouds/ninefold/compute/NinefoldComputeProviderMetadata.java +++ b/providers/ninefold-compute/src/main/java/org/jclouds/ninefold/compute/NinefoldComputeProviderMetadata.java @@ -4,9 +4,6 @@ import java.net.URI; import java.util.Properties; import org.jclouds.cloudstack.CloudStackApiMetadata; -import org.jclouds.cloudstack.CloudStackAsyncClient; -import org.jclouds.cloudstack.CloudStackClient; -import org.jclouds.cloudstack.CloudStackContext; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -15,9 +12,10 @@ import org.jclouds.providers.internal.BaseProviderMetadata; * Compute. * @author Adrian Cole */ -public class NinefoldComputeProviderMetadata - extends - BaseProviderMetadata { +public class NinefoldComputeProviderMetadata extends BaseProviderMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = -4496340915519024L; public static Builder builder() { return new Builder(); @@ -36,7 +34,7 @@ public class NinefoldComputeProviderMetadata super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = new Properties(); properties.setProperty("ninefold-compute.image-id", "1215"); properties.setProperty("ninefold-compute.image.login-user", "user:Password01"); @@ -46,7 +44,7 @@ public class NinefoldComputeProviderMetadata public static class Builder extends - BaseProviderMetadata.Builder { + BaseProviderMetadata.Builder { protected Builder() { id("ninefold-compute") @@ -66,7 +64,7 @@ public class NinefoldComputeProviderMetadata @Override public Builder fromProviderMetadata( - ProviderMetadata in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/ninefold-compute/src/test/java/org/jclouds/ninefold/compute/compute/NinefoldComputeTemplateBuilderLiveTest.java b/providers/ninefold-compute/src/test/java/org/jclouds/ninefold/compute/compute/NinefoldComputeTemplateBuilderLiveTest.java index 5368814810..7cbb42aec5 100644 --- a/providers/ninefold-compute/src/test/java/org/jclouds/ninefold/compute/compute/NinefoldComputeTemplateBuilderLiveTest.java +++ b/providers/ninefold-compute/src/test/java/org/jclouds/ninefold/compute/compute/NinefoldComputeTemplateBuilderLiveTest.java @@ -24,9 +24,6 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.util.Set; -import org.jclouds.cloudstack.CloudStackAsyncClient; -import org.jclouds.cloudstack.CloudStackClient; -import org.jclouds.cloudstack.CloudStackContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; @@ -42,9 +39,7 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live") -public class NinefoldComputeTemplateBuilderLiveTest - extends - BaseTemplateBuilderLiveTest { +public class NinefoldComputeTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { public NinefoldComputeTemplateBuilderLiveTest() { provider = "ninefold-compute"; diff --git a/providers/ninefold-storage/src/main/java/org/jclouds/ninefold/storage/NinefoldStorageProviderMetadata.java b/providers/ninefold-storage/src/main/java/org/jclouds/ninefold/storage/NinefoldStorageProviderMetadata.java index 152c46df77..55acd16933 100644 --- a/providers/ninefold-storage/src/main/java/org/jclouds/ninefold/storage/NinefoldStorageProviderMetadata.java +++ b/providers/ninefold-storage/src/main/java/org/jclouds/ninefold/storage/NinefoldStorageProviderMetadata.java @@ -22,9 +22,6 @@ import java.net.URI; import java.util.Properties; import org.jclouds.atmos.AtmosApiMetadata; -import org.jclouds.atmos.AtmosAsyncClient; -import org.jclouds.atmos.AtmosClient; -import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -34,8 +31,11 @@ import org.jclouds.providers.internal.BaseProviderMetadata; * * @author Jeremy Whitlock */ -public class NinefoldStorageProviderMetadata extends BaseProviderMetadata, AtmosApiMetadata> { +public class NinefoldStorageProviderMetadata extends BaseProviderMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = 1L; + public static Builder builder() { return new Builder(); } @@ -53,12 +53,12 @@ public class NinefoldStorageProviderMetadata extends BaseProviderMetadata, AtmosApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder(){ id("ninefold-storage") @@ -78,7 +78,7 @@ public class NinefoldStorageProviderMetadata extends BaseProviderMetadata, AtmosApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/openhosting-east1/src/main/java/org/jclouds/openhosting/OpenHostingEast1ProviderMetadata.java b/providers/openhosting-east1/src/main/java/org/jclouds/openhosting/OpenHostingEast1ProviderMetadata.java index b1e33c13ca..37c01aa1de 100644 --- a/providers/openhosting-east1/src/main/java/org/jclouds/openhosting/OpenHostingEast1ProviderMetadata.java +++ b/providers/openhosting-east1/src/main/java/org/jclouds/openhosting/OpenHostingEast1ProviderMetadata.java @@ -21,10 +21,7 @@ package org.jclouds.openhosting; import java.net.URI; import java.util.Properties; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.elasticstack.ElasticStackApiMetadata; -import org.jclouds.elasticstack.ElasticStackAsyncClient; -import org.jclouds.elasticstack.ElasticStackClient; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -33,9 +30,10 @@ import org.jclouds.providers.internal.BaseProviderMetadata; * * @author Adrian Cole */ -public class OpenHostingEast1ProviderMetadata - extends - BaseProviderMetadata, ElasticStackApiMetadata> { +public class OpenHostingEast1ProviderMetadata extends BaseProviderMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 1L; public static Builder builder() { return new Builder(); @@ -54,14 +52,14 @@ public class OpenHostingEast1ProviderMetadata super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = new Properties(); return properties; } public static class Builder extends - BaseProviderMetadata.Builder, ElasticStackApiMetadata> { + BaseProviderMetadata.Builder { protected Builder() { id("openhosting-east1") @@ -81,7 +79,7 @@ public class OpenHostingEast1ProviderMetadata @Override public Builder fromProviderMetadata( - ProviderMetadata, ElasticStackApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/openhosting-east1/src/test/java/org/jclouds/openhosting/compute/OpenHostingEast1TemplateBuilderLiveTest.java b/providers/openhosting-east1/src/test/java/org/jclouds/openhosting/compute/OpenHostingEast1TemplateBuilderLiveTest.java index 50a86d8a3a..841a737a00 100644 --- a/providers/openhosting-east1/src/test/java/org/jclouds/openhosting/compute/OpenHostingEast1TemplateBuilderLiveTest.java +++ b/providers/openhosting-east1/src/test/java/org/jclouds/openhosting/compute/OpenHostingEast1TemplateBuilderLiveTest.java @@ -24,13 +24,10 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.util.Set; -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.compute.internal.BaseTemplateBuilderLiveTest; -import org.jclouds.elasticstack.ElasticStackAsyncClient; -import org.jclouds.elasticstack.ElasticStackClient; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -42,9 +39,7 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live") -public class OpenHostingEast1TemplateBuilderLiveTest - extends - BaseTemplateBuilderLiveTest> { +public class OpenHostingEast1TemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { public OpenHostingEast1TemplateBuilderLiveTest() { provider = "openhosting-east1"; diff --git a/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingApiMetadata.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingApiMetadata.java index 1ea439a161..a18b127a65 100644 --- a/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingApiMetadata.java +++ b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingApiMetadata.java @@ -25,23 +25,32 @@ import java.net.URI; import java.util.Properties; import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.ApiType; import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.config.ComputeServiceProperties; -import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; import org.jclouds.concurrent.Timeout; +import org.jclouds.rest.RestContext; +import org.jclouds.rest.internal.BaseRestApiMetadata; +import org.jclouds.rimuhosting.miro.compute.config.RimuHostingComputeServiceContextModule; +import org.jclouds.rimuhosting.miro.config.RimuHostingRestClientModule; +import com.google.common.collect.ImmutableSet; import com.google.common.reflect.TypeToken; +import com.google.inject.Module; /** * Implementation of {@link ApiMetadata} for RimuHosting API * * @author Adrian Cole */ -public class RimuHostingApiMetadata - extends - BaseComputeServiceApiMetadata, RimuHostingApiMetadata> { +public class RimuHostingApiMetadata extends BaseRestApiMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = 6725672099385580694L; + + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; + @Override public Builder toBuilder() { return new Builder().fromApiMetadata(this); @@ -55,8 +64,8 @@ public class RimuHostingApiMetadata super(builder); } - protected static Properties defaultProperties() { - Properties properties = BaseComputeServiceApiMetadata.Builder.defaultProperties(); + public static Properties defaultProperties() { + Properties properties = BaseRestApiMetadata.defaultProperties(); Timeout timeout = RimuHostingClient.class.getAnnotation(Timeout.class); long timeoutMillis = timeout.timeUnit().toMillis(timeout.duration()); properties.setProperty(PROPERTY_SO_TIMEOUT, timeoutMillis + ""); @@ -67,18 +76,20 @@ public class RimuHostingApiMetadata public static class Builder extends - BaseComputeServiceApiMetadata.Builder, RimuHostingApiMetadata> { + BaseRestApiMetadata.Builder { protected Builder() { + super(RimuHostingClient.class, RimuHostingAsyncClient.class); id("rimuhosting") - .type(ApiType.COMPUTE) .name("RimuHosting API") .identityName("API Key") .documentation(URI.create("http://apidocs.rimuhosting.com")) .version("1") .defaultEndpoint("https://api.rimuhosting.com/r") - .javaApi(RimuHostingClient.class, RimuHostingAsyncClient.class) - .contextBuilder(TypeToken.of(RimuHostingContextBuilder.class)); + .defaultProperties(RimuHostingApiMetadata.defaultProperties()) + .wrapper(TypeToken.of(ComputeServiceContext.class)) + .defaultModules(ImmutableSet.>of(RimuHostingRestClientModule.class, RimuHostingComputeServiceContextModule.class)); + } @Override @@ -87,7 +98,7 @@ public class RimuHostingApiMetadata } @Override - public Builder fromApiMetadata(RimuHostingApiMetadata in) { + public Builder fromApiMetadata(ApiMetadata in) { super.fromApiMetadata(in); return this; } diff --git a/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingContextBuilder.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingContextBuilder.java deleted file mode 100644 index e01c11d97b..0000000000 --- a/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingContextBuilder.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * 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.rimuhosting.miro; - -import java.util.List; - -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextBuilder; -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.rimuhosting.miro.compute.config.RimuHostingComputeServiceContextModule; -import org.jclouds.rimuhosting.miro.config.RimuHostingRestClientModule; - -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class RimuHostingContextBuilder - extends - ComputeServiceContextBuilder, RimuHostingApiMetadata> { - - public RimuHostingContextBuilder( - ProviderMetadata, RimuHostingApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public RimuHostingContextBuilder(RimuHostingApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new RimuHostingComputeServiceContextModule()); - } - - protected void addClientModule(List modules) { - modules.add(new RimuHostingRestClientModule()); - } - -} diff --git a/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingProviderMetadata.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingProviderMetadata.java index 5d32459a2f..b1850e5928 100644 --- a/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingProviderMetadata.java +++ b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingProviderMetadata.java @@ -26,7 +26,6 @@ import static org.jclouds.rimuhosting.miro.reference.RimuHostingConstants.PROPER import java.net.URI; import java.util.Properties; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -34,9 +33,10 @@ import org.jclouds.providers.internal.BaseProviderMetadata; * Implementation of {@link org.jclouds.types.ProviderMetadata} for RimuHosting. * @author Adrian Cole */ -public class RimuHostingProviderMetadata - extends - BaseProviderMetadata, RimuHostingApiMetadata> { +public class RimuHostingProviderMetadata extends BaseProviderMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 8802226645589501365L; public static Builder builder() { return new Builder(); @@ -55,7 +55,7 @@ public class RimuHostingProviderMetadata super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = new Properties(); properties.setProperty(PROPERTY_ZONES, "DCAUCKLAND,DCLONDON,DCDALLAS,DCSYDNEY"); properties.setProperty(PROPERTY_ZONE + ".DCAUCKLAND." + ISO3166_CODES, "NZ-AUK"); @@ -66,9 +66,7 @@ public class RimuHostingProviderMetadata return properties; } - public static class Builder - extends - BaseProviderMetadata.Builder, RimuHostingApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder() { id("rimuhosting") @@ -87,8 +85,7 @@ public class RimuHostingProviderMetadata } @Override - public Builder fromProviderMetadata( - ProviderMetadata, RimuHostingApiMetadata> in) { + public Builder fromProviderMetadata(ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingComputeServiceDependenciesModule.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingComputeServiceDependenciesModule.java index f9142d555b..c1669347f9 100644 --- a/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingComputeServiceDependenciesModule.java +++ b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/compute/config/RimuHostingComputeServiceDependenciesModule.java @@ -22,12 +22,8 @@ import java.util.Map; import javax.inject.Singleton; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeState; -import org.jclouds.compute.internal.ComputeServiceContextImpl; -import org.jclouds.rimuhosting.miro.RimuHostingAsyncClient; -import org.jclouds.rimuhosting.miro.RimuHostingClient; import org.jclouds.rimuhosting.miro.compute.functions.ServerToNodeMetadata; import org.jclouds.rimuhosting.miro.domain.Server; import org.jclouds.rimuhosting.miro.domain.internal.RunningState; @@ -40,7 +36,6 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.inject.AbstractModule; import com.google.inject.Provides; -import com.google.inject.Scopes; import com.google.inject.TypeLiteral; /** @@ -55,12 +50,8 @@ public class RimuHostingComputeServiceDependenciesModule extends AbstractModule protected void configure() { bind(new TypeLiteral>() { }).to(ServerToNodeMetadata.class); - bind(new TypeLiteral() { - }).to(new TypeLiteral>() { - }).in(Scopes.SINGLETON); bind(new TypeLiteral>>() { }).to(ServerToPublicAddresses.class); - } @VisibleForTesting diff --git a/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/config/RimuHostingRestClientModule.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/config/RimuHostingRestClientModule.java index 56c500501a..e572fd615b 100644 --- a/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/config/RimuHostingRestClientModule.java +++ b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/config/RimuHostingRestClientModule.java @@ -25,7 +25,6 @@ import javax.inject.Inject; import javax.inject.Singleton; import org.jclouds.date.DateService; -import org.jclouds.http.RequiresHttp; import org.jclouds.json.config.GsonModule; import org.jclouds.json.config.GsonModule.DateAdapter; import org.jclouds.json.config.GsonModule.PropertiesAdapter; @@ -46,7 +45,6 @@ import com.google.inject.Scopes; * * @author Adrian Cole */ -@RequiresHttp @ConfiguresRestClient public class RimuHostingRestClientModule extends RestClientModule { diff --git a/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/location/RimuHostingLocationSupplier.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/location/RimuHostingLocationSupplier.java index f2b8b3c1c6..dd10add093 100644 --- a/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/location/RimuHostingLocationSupplier.java +++ b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/location/RimuHostingLocationSupplier.java @@ -42,8 +42,8 @@ import com.google.common.base.Function; import com.google.common.base.Predicates; import com.google.common.base.Supplier; import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSet.Builder; import com.google.common.collect.Iterables; +import com.google.common.collect.ImmutableSet.Builder; /** * diff --git a/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingAsyncClientTest.java b/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingAsyncClientTest.java index 8e08b5b83a..6fb6462581 100644 --- a/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingAsyncClientTest.java +++ b/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingAsyncClientTest.java @@ -94,7 +94,7 @@ public class RimuHostingAsyncClientTest extends BaseAsyncClientTest createProviderMetadata() { + public ProviderMetadata createProviderMetadata() { return new RimuHostingProviderMetadata(); } } diff --git a/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingClientLiveTest.java b/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingClientLiveTest.java index 22fd52dc70..46d76aa8c6 100644 --- a/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingClientLiveTest.java +++ b/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingClientLiveTest.java @@ -24,7 +24,6 @@ import static org.testng.Assert.assertTrue; import java.util.Set; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.rest.RestContext; import org.jclouds.rimuhosting.miro.domain.Image; @@ -44,7 +43,7 @@ import org.testng.annotations.Test; @Test(groups = "live", singleThreaded = true, testName = "RimuHostingClientLiveTest") public class RimuHostingClientLiveTest extends - BaseComputeServiceContextLiveTest> { + BaseComputeServiceContextLiveTest { public RimuHostingClientLiveTest() { provider = "rimuhosting"; @@ -57,7 +56,7 @@ public class RimuHostingClientLiveTest @Override public void setupContext() { super.setupContext(); - restContext = context.getProviderSpecificContext(); + restContext = context.unwrap(); this.connection = restContext.getApi(); } diff --git a/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingComputeServiceLiveTest.java b/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingComputeServiceLiveTest.java index e03c5759e1..55fbaa3046 100644 --- a/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingComputeServiceLiveTest.java +++ b/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingComputeServiceLiveTest.java @@ -18,11 +18,8 @@ */ package org.jclouds.rimuhosting.miro.compute; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.internal.BaseComputeServiceLiveTest; -import org.jclouds.rimuhosting.miro.RimuHostingAsyncClient; -import org.jclouds.rimuhosting.miro.RimuHostingClient; import org.jclouds.ssh.jsch.config.JschSshClientModule; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -33,9 +30,7 @@ import com.google.common.collect.ImmutableMap; * @author Ivan Meredith */ @Test(groups = "live", sequential = true) -public class RimuHostingComputeServiceLiveTest - extends - BaseComputeServiceLiveTest> { +public class RimuHostingComputeServiceLiveTest extends BaseComputeServiceLiveTest { public RimuHostingComputeServiceLiveTest() { provider = "rimuhosting"; diff --git a/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingTemplateBuilderLiveTest.java b/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingTemplateBuilderLiveTest.java index b67a5acc72..de99137bfd 100644 --- a/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingTemplateBuilderLiveTest.java +++ b/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingTemplateBuilderLiveTest.java @@ -23,13 +23,10 @@ import static org.testng.Assert.assertEquals; import java.util.Set; -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.compute.internal.BaseTemplateBuilderLiveTest; -import org.jclouds.rimuhosting.miro.RimuHostingAsyncClient; -import org.jclouds.rimuhosting.miro.RimuHostingClient; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -40,9 +37,7 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live") -public class RimuHostingTemplateBuilderLiveTest - extends - BaseTemplateBuilderLiveTest> { +public class RimuHostingTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { public RimuHostingTemplateBuilderLiveTest() { provider = "rimuhosting"; diff --git a/providers/serverlove-z1-man/src/main/java/org/jclouds/serverlove/ServerloveManchesterProviderMetadata.java b/providers/serverlove-z1-man/src/main/java/org/jclouds/serverlove/ServerloveManchesterProviderMetadata.java index f360e54b53..8364751353 100644 --- a/providers/serverlove-z1-man/src/main/java/org/jclouds/serverlove/ServerloveManchesterProviderMetadata.java +++ b/providers/serverlove-z1-man/src/main/java/org/jclouds/serverlove/ServerloveManchesterProviderMetadata.java @@ -21,10 +21,7 @@ package org.jclouds.serverlove; import java.net.URI; import java.util.Properties; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.elasticstack.ElasticStackApiMetadata; -import org.jclouds.elasticstack.ElasticStackAsyncClient; -import org.jclouds.elasticstack.ElasticStackClient; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -33,9 +30,10 @@ import org.jclouds.providers.internal.BaseProviderMetadata; * * @author Adrian Cole */ -public class ServerloveManchesterProviderMetadata - extends - BaseProviderMetadata, ElasticStackApiMetadata> { +public class ServerloveManchesterProviderMetadata extends BaseProviderMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = -8799752320729476294L; public static Builder builder() { return new Builder(); @@ -54,14 +52,14 @@ public class ServerloveManchesterProviderMetadata super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = new Properties(); return properties; } public static class Builder extends - BaseProviderMetadata.Builder, ElasticStackApiMetadata> { + BaseProviderMetadata.Builder { protected Builder() { id("serverlove-z1-man") @@ -81,7 +79,7 @@ public class ServerloveManchesterProviderMetadata @Override public Builder fromProviderMetadata( - ProviderMetadata, ElasticStackApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/serverlove-z1-man/src/test/java/org/jclouds/serverlove/compute/ServerloveManchesterTemplateBuilderLiveTest.java b/providers/serverlove-z1-man/src/test/java/org/jclouds/serverlove/compute/ServerloveManchesterTemplateBuilderLiveTest.java index a2bc867767..7e461a3f5e 100644 --- a/providers/serverlove-z1-man/src/test/java/org/jclouds/serverlove/compute/ServerloveManchesterTemplateBuilderLiveTest.java +++ b/providers/serverlove-z1-man/src/test/java/org/jclouds/serverlove/compute/ServerloveManchesterTemplateBuilderLiveTest.java @@ -23,13 +23,10 @@ import static org.testng.Assert.assertEquals; import java.util.Set; -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.compute.internal.BaseTemplateBuilderLiveTest; -import org.jclouds.elasticstack.ElasticStackAsyncClient; -import org.jclouds.elasticstack.ElasticStackClient; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -41,9 +38,7 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live") -public class ServerloveManchesterTemplateBuilderLiveTest - extends - BaseTemplateBuilderLiveTest> { +public class ServerloveManchesterTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { public ServerloveManchesterTemplateBuilderLiveTest() { provider = "serverlove-z1-man"; diff --git a/providers/skalicloud-sdg-my/src/main/java/org/jclouds/skalicloud/SkaliCloudMalaysiaProviderMetadata.java b/providers/skalicloud-sdg-my/src/main/java/org/jclouds/skalicloud/SkaliCloudMalaysiaProviderMetadata.java index ba9e4c69c3..8063fac0b3 100644 --- a/providers/skalicloud-sdg-my/src/main/java/org/jclouds/skalicloud/SkaliCloudMalaysiaProviderMetadata.java +++ b/providers/skalicloud-sdg-my/src/main/java/org/jclouds/skalicloud/SkaliCloudMalaysiaProviderMetadata.java @@ -21,10 +21,7 @@ package org.jclouds.skalicloud; import java.net.URI; import java.util.Properties; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.elasticstack.ElasticStackApiMetadata; -import org.jclouds.elasticstack.ElasticStackAsyncClient; -import org.jclouds.elasticstack.ElasticStackClient; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -33,9 +30,10 @@ import org.jclouds.providers.internal.BaseProviderMetadata; * * @author Adrian Cole */ -public class SkaliCloudMalaysiaProviderMetadata - extends - BaseProviderMetadata, ElasticStackApiMetadata> { +public class SkaliCloudMalaysiaProviderMetadata extends BaseProviderMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 102653451946303901L; public static Builder builder() { return new Builder(); @@ -54,14 +52,14 @@ public class SkaliCloudMalaysiaProviderMetadata super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = new Properties(); return properties; } public static class Builder extends - BaseProviderMetadata.Builder, ElasticStackApiMetadata> { + BaseProviderMetadata.Builder { protected Builder() { id("skalicloud-sdg-my") @@ -81,7 +79,7 @@ public class SkaliCloudMalaysiaProviderMetadata @Override public Builder fromProviderMetadata( - ProviderMetadata, ElasticStackApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/skalicloud-sdg-my/src/test/java/org/jclouds/skalicloud/compute/SkaliCloudMalaysiaTemplateBuilderLiveTest.java b/providers/skalicloud-sdg-my/src/test/java/org/jclouds/skalicloud/compute/SkaliCloudMalaysiaTemplateBuilderLiveTest.java index a35ea5fe04..6e47b62efd 100644 --- a/providers/skalicloud-sdg-my/src/test/java/org/jclouds/skalicloud/compute/SkaliCloudMalaysiaTemplateBuilderLiveTest.java +++ b/providers/skalicloud-sdg-my/src/test/java/org/jclouds/skalicloud/compute/SkaliCloudMalaysiaTemplateBuilderLiveTest.java @@ -24,13 +24,10 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.util.Set; -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.compute.internal.BaseTemplateBuilderLiveTest; -import org.jclouds.elasticstack.ElasticStackAsyncClient; -import org.jclouds.elasticstack.ElasticStackClient; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -44,7 +41,7 @@ import com.google.common.collect.ImmutableSet; @Test(groups = "live") public class SkaliCloudMalaysiaTemplateBuilderLiveTest extends - BaseTemplateBuilderLiveTest> { + BaseTemplateBuilderLiveTest { public SkaliCloudMalaysiaTemplateBuilderLiveTest() { provider = "skalicloud-sdg-my"; diff --git a/providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostApiMetadata.java b/providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostApiMetadata.java index 8d9edb2b04..8ca75dbdc3 100644 --- a/providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostApiMetadata.java +++ b/providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostApiMetadata.java @@ -22,21 +22,29 @@ import java.net.URI; import java.util.Properties; import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.ApiType; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; +import org.jclouds.rest.RestContext; +import org.jclouds.rest.internal.BaseRestApiMetadata; +import org.jclouds.slicehost.compute.config.SlicehostComputeServiceContextModule; +import org.jclouds.slicehost.config.SlicehostRestClientModule; +import com.google.common.collect.ImmutableSet; import com.google.common.reflect.TypeToken; +import com.google.inject.Module; /** * Implementation of {@link ApiMetadata} for Slicehost 1.0 API * * @author Adrian Cole */ -public class SlicehostApiMetadata - extends - BaseComputeServiceApiMetadata, SlicehostApiMetadata> { +public class SlicehostApiMetadata extends BaseRestApiMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = 6725672099385580694L; + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; + @Override public Builder toBuilder() { return new Builder().fromApiMetadata(this); @@ -50,27 +58,27 @@ public class SlicehostApiMetadata super(builder); } - protected static Properties defaultProperties() { - Properties properties = BaseComputeServiceApiMetadata.Builder.defaultProperties(); + public static Properties defaultProperties() { + Properties properties = BaseRestApiMetadata.defaultProperties(); properties.setProperty("jclouds.ssh.max-retries", "8"); return properties; } public static class Builder extends - BaseComputeServiceApiMetadata.Builder, SlicehostApiMetadata> { + BaseRestApiMetadata.Builder { protected Builder() { + super(SlicehostClient.class, SlicehostAsyncClient.class); id("slicehost") - .type(ApiType.COMPUTE) .name("Slicehost API") .identityName("API password") .documentation(URI.create("http://articles.slicehost.com/api")) .version("https://api.slicehost.com") .defaultEndpoint("https://api.slicehost.com") - .javaApi(SlicehostClient.class, SlicehostAsyncClient.class) .defaultProperties(SlicehostApiMetadata.defaultProperties()) - .contextBuilder(TypeToken.of(SlicehostContextBuilder.class)); + .wrapper(TypeToken.of(ComputeServiceContext.class)) + .defaultModules(ImmutableSet.>of(SlicehostRestClientModule.class, SlicehostComputeServiceContextModule.class)); } @Override @@ -79,7 +87,7 @@ public class SlicehostApiMetadata } @Override - public Builder fromApiMetadata(SlicehostApiMetadata in) { + public Builder fromApiMetadata(ApiMetadata in) { super.fromApiMetadata(in); return this; } diff --git a/providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostContextBuilder.java b/providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostContextBuilder.java deleted file mode 100644 index 57cdaf2a38..0000000000 --- a/providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostContextBuilder.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * 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.slicehost; - -import java.util.List; - -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextBuilder; -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.slicehost.compute.config.SlicehostComputeServiceContextModule; -import org.jclouds.slicehost.config.SlicehostRestClientModule; - -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class SlicehostContextBuilder - extends - ComputeServiceContextBuilder, SlicehostApiMetadata> { - - public SlicehostContextBuilder( - ProviderMetadata, SlicehostApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public SlicehostContextBuilder(SlicehostApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new SlicehostComputeServiceContextModule()); - } - - protected void addClientModule(List modules) { - modules.add(new SlicehostRestClientModule()); - } - -} \ No newline at end of file diff --git a/providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostProviderMetadata.java b/providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostProviderMetadata.java index b0aba661e7..b2f2b3e4c0 100644 --- a/providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostProviderMetadata.java +++ b/providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostProviderMetadata.java @@ -3,7 +3,6 @@ package org.jclouds.slicehost; import java.net.URI; import java.util.Properties; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -12,8 +11,11 @@ import org.jclouds.providers.internal.BaseProviderMetadata; * * @author Adrian Cole */ -public class SlicehostProviderMetadata extends BaseProviderMetadata, SlicehostApiMetadata> { +public class SlicehostProviderMetadata extends BaseProviderMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = -5260230633956988685L; + public static Builder builder() { return new Builder(); } @@ -31,12 +33,12 @@ public class SlicehostProviderMetadata extends BaseProviderMetadata, SlicehostApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder(){ id("slicehost") @@ -54,7 +56,7 @@ public class SlicehostProviderMetadata extends BaseProviderMetadata, SlicehostApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/config/SlicehostComputeServiceContextModule.java b/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/config/SlicehostComputeServiceContextModule.java index c08a56afa6..80729c2969 100644 --- a/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/config/SlicehostComputeServiceContextModule.java +++ b/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/config/SlicehostComputeServiceContextModule.java @@ -35,8 +35,6 @@ import org.jclouds.compute.domain.TemplateBuilder; import org.jclouds.compute.internal.BaseComputeService; import org.jclouds.domain.Location; import org.jclouds.functions.IdentityFunction; -import org.jclouds.slicehost.SlicehostAsyncClient; -import org.jclouds.slicehost.SlicehostClient; import org.jclouds.slicehost.compute.functions.FlavorToHardware; import org.jclouds.slicehost.compute.functions.SliceToNodeMetadata; import org.jclouds.slicehost.compute.functions.SlicehostImageToImage; @@ -57,12 +55,8 @@ import com.google.inject.TypeLiteral; * * @author Adrian Cole */ -public class SlicehostComputeServiceContextModule - extends - ComputeServiceAdapterContextModule { - public SlicehostComputeServiceContextModule() { - super(SlicehostClient.class, SlicehostAsyncClient.class); - } +public class SlicehostComputeServiceContextModule extends + ComputeServiceAdapterContextModule { @SuppressWarnings("unchecked") @Override diff --git a/providers/slicehost/src/main/java/org/jclouds/slicehost/config/SlicehostRestClientModule.java b/providers/slicehost/src/main/java/org/jclouds/slicehost/config/SlicehostRestClientModule.java index 816190b52d..b1e5ef93a5 100644 --- a/providers/slicehost/src/main/java/org/jclouds/slicehost/config/SlicehostRestClientModule.java +++ b/providers/slicehost/src/main/java/org/jclouds/slicehost/config/SlicehostRestClientModule.java @@ -19,7 +19,6 @@ package org.jclouds.slicehost.config; import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.ServerError; @@ -34,7 +33,6 @@ import org.jclouds.slicehost.handlers.ParseSlicehostErrorFromHttpResponse; * @author Adrian Cole */ @ConfiguresRestClient -@RequiresHttp public class SlicehostRestClientModule extends RestClientModule { public SlicehostRestClientModule() { diff --git a/providers/slicehost/src/test/java/org/jclouds/slicehost/SlicehostAsyncClientTest.java b/providers/slicehost/src/test/java/org/jclouds/slicehost/SlicehostAsyncClientTest.java index 692b324ca5..ac4eadd951 100644 --- a/providers/slicehost/src/test/java/org/jclouds/slicehost/SlicehostAsyncClientTest.java +++ b/providers/slicehost/src/test/java/org/jclouds/slicehost/SlicehostAsyncClientTest.java @@ -251,7 +251,7 @@ public class SlicehostAsyncClientTest extends BaseAsyncClientTest createProviderMetadata() { + public ProviderMetadata createProviderMetadata() { return new SlicehostProviderMetadata(); } diff --git a/providers/slicehost/src/test/java/org/jclouds/slicehost/SlicehostClientLiveTest.java b/providers/slicehost/src/test/java/org/jclouds/slicehost/SlicehostClientLiveTest.java index 6d0b9e3480..48cac3fca5 100644 --- a/providers/slicehost/src/test/java/org/jclouds/slicehost/SlicehostClientLiveTest.java +++ b/providers/slicehost/src/test/java/org/jclouds/slicehost/SlicehostClientLiveTest.java @@ -28,7 +28,6 @@ import java.security.SecureRandom; import java.util.Set; import java.util.concurrent.TimeUnit; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.domain.LoginCredentials; import org.jclouds.http.HttpResponseException; @@ -55,9 +54,7 @@ import com.google.inject.Injector; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "SlicehostClientLiveTest") -public class SlicehostClientLiveTest - extends - BaseComputeServiceContextLiveTest> { +public class SlicehostClientLiveTest extends BaseComputeServiceContextLiveTest { public SlicehostClientLiveTest() { provider = "slicehost"; diff --git a/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostComputeServiceLiveTest.java b/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostComputeServiceLiveTest.java index 79c960841c..ef37640c50 100644 --- a/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostComputeServiceLiveTest.java +++ b/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostComputeServiceLiveTest.java @@ -18,11 +18,8 @@ */ package org.jclouds.slicehost.compute; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.internal.BaseComputeServiceLiveTest; -import org.jclouds.slicehost.SlicehostAsyncClient; -import org.jclouds.slicehost.SlicehostClient; import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.Test; @@ -35,9 +32,7 @@ import com.google.common.collect.ImmutableMap; * @author Adrian Cole */ @Test(groups = "live", enabled = true, singleThreaded = true) -public class SlicehostComputeServiceLiveTest - extends - BaseComputeServiceLiveTest> { +public class SlicehostComputeServiceLiveTest extends BaseComputeServiceLiveTest { public SlicehostComputeServiceLiveTest() { provider = "slicehost"; diff --git a/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostTemplateBuilderLiveTest.java b/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostTemplateBuilderLiveTest.java index ff8b08c660..73db547fb9 100644 --- a/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostTemplateBuilderLiveTest.java +++ b/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostTemplateBuilderLiveTest.java @@ -24,13 +24,10 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.util.Set; -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.compute.internal.BaseTemplateBuilderLiveTest; -import org.jclouds.slicehost.SlicehostAsyncClient; -import org.jclouds.slicehost.SlicehostClient; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -42,9 +39,7 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live") -public class SlicehostTemplateBuilderLiveTest - extends - BaseTemplateBuilderLiveTest> { +public class SlicehostTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { public SlicehostTemplateBuilderLiveTest() { provider = "slicehost"; diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerApiMetadata.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerApiMetadata.java index e9347a4861..311d7b5b15 100644 --- a/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerApiMetadata.java +++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerApiMetadata.java @@ -22,21 +22,29 @@ import java.net.URI; import java.util.Properties; import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.ApiType; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; +import org.jclouds.rest.RestContext; +import org.jclouds.rest.internal.BaseRestApiMetadata; +import org.jclouds.softlayer.compute.config.SoftLayerComputeServiceContextModule; +import org.jclouds.softlayer.config.SoftLayerRestClientModule; +import com.google.common.collect.ImmutableSet; import com.google.common.reflect.TypeToken; +import com.google.inject.Module; /** - * Implementation of {@link ApiMetadata} for API + * Implementation of {@link ApiMetadata} for API * * @author Adrian Cole */ -public class SoftLayerApiMetadata - extends - BaseComputeServiceApiMetadata, SoftLayerApiMetadata> { +public class SoftLayerApiMetadata extends BaseRestApiMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = 6725672099385580694L; + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; + @Override public Builder toBuilder() { return new Builder().fromApiMetadata(this); @@ -50,8 +58,8 @@ public class SoftLayerApiMetadata super(builder); } - protected static Properties defaultProperties() { - Properties properties = BaseComputeServiceApiMetadata.Builder.defaultProperties(); + public static Properties defaultProperties() { + Properties properties = BaseRestApiMetadata.defaultProperties(); properties.setProperty("jclouds.ssh.max-retries", "5"); properties.setProperty("jclouds.ssh.retry-auth", "true"); return properties; @@ -59,11 +67,11 @@ public class SoftLayerApiMetadata public static class Builder extends - BaseComputeServiceApiMetadata.Builder, SoftLayerApiMetadata> { + BaseRestApiMetadata.Builder { protected Builder() { + super(SoftLayerClient.class, SoftLayerAsyncClient.class); id("softlayer") - .type(ApiType.COMPUTE) .name("SoftLayer API") .identityName("API Username") .credentialName("API Key") @@ -71,8 +79,8 @@ public class SoftLayerApiMetadata .version("3") .defaultEndpoint("https://api.softlayer.com/rest") .defaultProperties(SoftLayerApiMetadata.defaultProperties()) - .javaApi(SoftLayerClient.class, SoftLayerAsyncClient.class) - .contextBuilder(TypeToken.of(SoftLayerContextBuilder.class)); + .wrapper(TypeToken.of(ComputeServiceContext.class)) + .defaultModules(ImmutableSet.>of(SoftLayerRestClientModule.class, SoftLayerComputeServiceContextModule.class)); } @Override @@ -81,7 +89,7 @@ public class SoftLayerApiMetadata } @Override - public Builder fromApiMetadata(SoftLayerApiMetadata in) { + public Builder fromApiMetadata(ApiMetadata in) { super.fromApiMetadata(in); return this; } diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerContextBuilder.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerContextBuilder.java deleted file mode 100644 index 86519a9cfc..0000000000 --- a/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerContextBuilder.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * 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.softlayer; - -import java.util.List; - -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextBuilder; -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.softlayer.compute.config.SoftLayerComputeServiceContextModule; -import org.jclouds.softlayer.config.SoftLayerRestClientModule; - -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class SoftLayerContextBuilder - extends - ComputeServiceContextBuilder, SoftLayerApiMetadata> { - - public SoftLayerContextBuilder( - ProviderMetadata, SoftLayerApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public SoftLayerContextBuilder(SoftLayerApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new SoftLayerComputeServiceContextModule()); - } - - protected void addClientModule(List modules) { - modules.add(new SoftLayerRestClientModule()); - } - -} diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerProviderMetadata.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerProviderMetadata.java index 141bd163ae..97cfefc51c 100644 --- a/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerProviderMetadata.java +++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerProviderMetadata.java @@ -28,7 +28,6 @@ import static org.jclouds.softlayer.reference.SoftLayerConstants.PROPERTY_SOFTLA import java.net.URI; import java.util.Properties; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -39,9 +38,10 @@ import com.google.common.collect.ImmutableSet; * Implementation of {@link org.jclouds.types.ProviderMetadata} for SoftLayer. * @author Adrian Cole */ -public class SoftLayerProviderMetadata - extends - BaseProviderMetadata, SoftLayerApiMetadata> { +public class SoftLayerProviderMetadata extends BaseProviderMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 2196535609684739834L; public static Builder builder() { return new Builder(); @@ -60,7 +60,7 @@ public class SoftLayerProviderMetadata super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = new Properties(); properties.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_LOGIN_DETAILS_DELAY, "" + 60 * 60 * 1000); properties.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_PACKAGE_NAME, "Cloud Server"); @@ -87,9 +87,7 @@ public class SoftLayerProviderMetadata return properties; } - public static class Builder - extends - BaseProviderMetadata.Builder, SoftLayerApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder() { id("softlayer") @@ -108,8 +106,7 @@ public class SoftLayerProviderMetadata } @Override - public Builder fromProviderMetadata( - ProviderMetadata, SoftLayerApiMetadata> in) { + public Builder fromProviderMetadata(ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/config/SoftLayerComputeServiceContextModule.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/config/SoftLayerComputeServiceContextModule.java index 31edee90f4..c2f19a7845 100644 --- a/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/config/SoftLayerComputeServiceContextModule.java +++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/config/SoftLayerComputeServiceContextModule.java @@ -40,7 +40,6 @@ import org.jclouds.compute.options.TemplateOptions; import org.jclouds.domain.Location; import org.jclouds.rest.AuthorizationException; import org.jclouds.rest.suppliers.MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier; -import org.jclouds.softlayer.SoftLayerAsyncClient; import org.jclouds.softlayer.SoftLayerClient; import org.jclouds.softlayer.compute.functions.DatacenterToLocation; import org.jclouds.softlayer.compute.functions.ProductItemToImage; @@ -68,13 +67,8 @@ import com.google.inject.TypeLiteral; * * @author Adrian Cole */ -public class SoftLayerComputeServiceContextModule - extends - ComputeServiceAdapterContextModule, ProductItem, Datacenter> { - - public SoftLayerComputeServiceContextModule() { - super(SoftLayerClient.class, SoftLayerAsyncClient.class); - } +public class SoftLayerComputeServiceContextModule extends + ComputeServiceAdapterContextModule, ProductItem, Datacenter> { @Override protected void configure() { diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/config/SoftLayerRestClientModule.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/config/SoftLayerRestClientModule.java index 787c74244e..03e07d12fd 100644 --- a/providers/softlayer/src/main/java/org/jclouds/softlayer/config/SoftLayerRestClientModule.java +++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/config/SoftLayerRestClientModule.java @@ -22,7 +22,6 @@ import java.util.Map; 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; @@ -52,7 +51,6 @@ import com.google.inject.Scopes; * * @author Adrian Cole */ -@RequiresHttp @ConfiguresRestClient public class SoftLayerRestClientModule extends RestClientModule { diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceLiveTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceLiveTest.java index ffd7da5e2c..8a848c1fa1 100644 --- a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceLiveTest.java +++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceLiveTest.java @@ -18,12 +18,8 @@ */ package org.jclouds.softlayer.compute; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.internal.BaseComputeServiceLiveTest; -import org.jclouds.rest.RestContext; -import org.jclouds.softlayer.SoftLayerAsyncClient; -import org.jclouds.softlayer.SoftLayerClient; import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.Test; @@ -37,9 +33,7 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", enabled = true, sequential = true) -public class SoftLayerComputeServiceLiveTest - extends - BaseComputeServiceLiveTest> { +public class SoftLayerComputeServiceLiveTest extends BaseComputeServiceLiveTest { public SoftLayerComputeServiceLiveTest() { provider = "softlayer"; @@ -50,11 +44,6 @@ public class SoftLayerComputeServiceLiveTest protected Module getSshModule() { return new SshjSshClientModule(); } - - public void testAssignability() throws Exception { - @SuppressWarnings("unused") - RestContext tmContext = context.getProviderSpecificContext(); - } // softlayer does not support metadata @Override diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerExperimentLiveTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerExperimentLiveTest.java index 8e90948446..c98091b8a4 100644 --- a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerExperimentLiveTest.java +++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerExperimentLiveTest.java @@ -20,11 +20,9 @@ package org.jclouds.softlayer.compute; import static org.testng.Assert.assertEquals; +import org.jclouds.ContextBuilder; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextBuilder; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; -import org.jclouds.softlayer.SoftLayerAsyncClient; -import org.jclouds.softlayer.SoftLayerClient; import org.jclouds.softlayer.SoftLayerProviderMetadata; import org.testng.annotations.Test; @@ -35,9 +33,7 @@ import com.google.common.io.Closeables; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "SoftLayerExperimentLiveTest") -public class SoftLayerExperimentLiveTest - extends - BaseComputeServiceContextLiveTest> { +public class SoftLayerExperimentLiveTest extends BaseComputeServiceContextLiveTest { public SoftLayerExperimentLiveTest() { provider = "glesys"; @@ -45,13 +41,13 @@ public class SoftLayerExperimentLiveTest @Test public void testAndExperiment() { - ComputeServiceContext context = null; + ComputeServiceContext context = null; try { - context = ComputeServiceContextBuilder + context = ContextBuilder .newBuilder(new SoftLayerProviderMetadata()) .overrides(setupProperties()) - .modules(setupModules()).build(); + .modules(setupModules()).build(ComputeServiceContext.class); assertEquals(context.getComputeService().listAssignableLocations().size(), 6); diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerTemplateBuilderLiveTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerTemplateBuilderLiveTest.java index 79ab1ddf01..da61c86bc6 100644 --- a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerTemplateBuilderLiveTest.java +++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerTemplateBuilderLiveTest.java @@ -35,8 +35,6 @@ import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; import org.jclouds.compute.domain.Volume; import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; -import org.jclouds.softlayer.SoftLayerAsyncClient; -import org.jclouds.softlayer.SoftLayerClient; import org.jclouds.softlayer.compute.options.SoftLayerTemplateOptions; import org.testng.annotations.Test; @@ -49,10 +47,8 @@ import com.google.common.collect.ImmutableSet; * @author Jason King */ @Test(groups = "live") -public class SoftLayerTemplateBuilderLiveTest - extends - BaseTemplateBuilderLiveTest> { - +public class SoftLayerTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { + public SoftLayerTemplateBuilderLiveTest() { provider = "softlayer"; } @@ -102,7 +98,7 @@ public class SoftLayerTemplateBuilderLiveTest @Test public void testTemplateBuilderFindsGigabitUplink() throws IOException { - ComputeServiceContext context = null; + ComputeServiceContext context = null; try { Properties overrides = setupProperties(); overrides.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_PORT_SPEED, "1000"); @@ -120,7 +116,7 @@ public class SoftLayerTemplateBuilderLiveTest @Test public void testTemplateBuilderFindsMegabitUplink() throws IOException { - ComputeServiceContext context = null; + ComputeServiceContext context = null; try { Properties overrides = setupProperties(); overrides.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_PORT_SPEED, "100"); @@ -138,7 +134,7 @@ public class SoftLayerTemplateBuilderLiveTest @Test public void testBiggestTemplateBuilderWhenBootIsSAN() throws IOException { - ComputeServiceContext context = null; + ComputeServiceContext context = null; try { Properties overrides = setupProperties(); overrides.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_DISK0_TYPE, "SAN"); @@ -158,7 +154,7 @@ public class SoftLayerTemplateBuilderLiveTest @Test public void testDefaultTemplateBuilderWhenPrivateNetwork() throws IOException { - ComputeServiceContext context = null; + ComputeServiceContext context = null; try { Properties overrides = setupProperties(); overrides.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_CPU_REGEX, "Private [0-9]+ x ([.0-9]+) GHz Core[s]?"); @@ -178,7 +174,7 @@ public class SoftLayerTemplateBuilderLiveTest @Test public void testBiggestTemplateBuilderWhenPrivateNetwork() throws IOException { - ComputeServiceContext context = null; + ComputeServiceContext context = null; try { Properties overrides = setupProperties(); overrides.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_CPU_REGEX, "Private [0-9]+ x ([.0-9]+) GHz Core[s]?"); diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/BaseSoftLayerAsyncClientTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/BaseSoftLayerAsyncClientTest.java index 02d8dd7acf..c8420e0e65 100644 --- a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/BaseSoftLayerAsyncClientTest.java +++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/BaseSoftLayerAsyncClientTest.java @@ -38,7 +38,7 @@ public abstract class BaseSoftLayerAsyncClientTest extends BaseAsyncClientTes } @Override - public ProviderMetadata createProviderMetadata() { + public ProviderMetadata createProviderMetadata() { return new SoftLayerProviderMetadata(); } diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/BaseSoftLayerClientLiveTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/BaseSoftLayerClientLiveTest.java index 0febeb7087..43268d1d5c 100644 --- a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/BaseSoftLayerClientLiveTest.java +++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/BaseSoftLayerClientLiveTest.java @@ -18,7 +18,6 @@ */ package org.jclouds.softlayer.features; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.rest.RestContext; import org.jclouds.softlayer.SoftLayerAsyncClient; @@ -32,9 +31,7 @@ import org.testng.annotations.Test; * @author Adrian Cole */ @Test(groups = "live") -public class BaseSoftLayerClientLiveTest - extends - BaseComputeServiceContextLiveTest> { +public class BaseSoftLayerClientLiveTest extends BaseComputeServiceContextLiveTest { protected RestContext socontext; @@ -42,7 +39,7 @@ public class BaseSoftLayerClientLiveTest @Override public void setupContext() { super.setupContext(); - socontext = context.getProviderSpecificContext(); + socontext = context.unwrap(); } } diff --git a/providers/stratogen-vcloud-mycloud/src/main/java/org/jclouds/stratogen/vcloud/mycloud/StratoGenVCloudMyCloudContextBuilder.java b/providers/stratogen-vcloud-mycloud/src/main/java/org/jclouds/stratogen/vcloud/mycloud/StratoGenVCloudMyCloudContextBuilder.java deleted file mode 100644 index c4c50fb035..0000000000 --- a/providers/stratogen-vcloud-mycloud/src/main/java/org/jclouds/stratogen/vcloud/mycloud/StratoGenVCloudMyCloudContextBuilder.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * 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.stratogen.vcloud.mycloud; - -import java.util.List; - -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.stratogen.vcloud.mycloud.config.StratoGenVCloudMyCloudRestClientModule; -import org.jclouds.vcloud.VCloudApiMetadata; -import org.jclouds.vcloud.VCloudAsyncClient; -import org.jclouds.vcloud.VCloudClient; -import org.jclouds.vcloud.VCloudContextBuilder; -import org.jclouds.vcloud.compute.config.VCloudComputeServiceContextModule; - -import com.google.inject.Module; - -/** - * @author Adrian Cole - */ -public class StratoGenVCloudMyCloudContextBuilder extends VCloudContextBuilder { - public StratoGenVCloudMyCloudContextBuilder( - ProviderMetadata, VCloudApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public StratoGenVCloudMyCloudContextBuilder(VCloudApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new VCloudComputeServiceContextModule()); - } - - @Override - protected void addClientModule(List modules) { - modules.add(new StratoGenVCloudMyCloudRestClientModule()); - } - -} diff --git a/providers/stratogen-vcloud-mycloud/src/main/java/org/jclouds/stratogen/vcloud/mycloud/StratoGenVCloudMyCloudProviderMetadata.java b/providers/stratogen-vcloud-mycloud/src/main/java/org/jclouds/stratogen/vcloud/mycloud/StratoGenVCloudMyCloudProviderMetadata.java index 07a245e950..2f2e8bb15a 100644 --- a/providers/stratogen-vcloud-mycloud/src/main/java/org/jclouds/stratogen/vcloud/mycloud/StratoGenVCloudMyCloudProviderMetadata.java +++ b/providers/stratogen-vcloud-mycloud/src/main/java/org/jclouds/stratogen/vcloud/mycloud/StratoGenVCloudMyCloudProviderMetadata.java @@ -23,23 +23,24 @@ import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAU import java.net.URI; import java.util.Properties; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; +import org.jclouds.stratogen.vcloud.mycloud.config.StratoGenVCloudMyCloudComputeServiceContextModule; import org.jclouds.vcloud.VCloudApiMetadata; -import org.jclouds.vcloud.VCloudAsyncClient; -import org.jclouds.vcloud.VCloudClient; +import org.jclouds.vcloud.config.VCloudRestClientModule; -import com.google.common.reflect.TypeToken; +import com.google.common.collect.ImmutableSet; +import com.google.inject.Module; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for StratoGen VMware hosting * * @author Adrian Cole */ -public class StratoGenVCloudMyCloudProviderMetadata - extends - BaseProviderMetadata, VCloudApiMetadata> { +public class StratoGenVCloudMyCloudProviderMetadata extends BaseProviderMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = -113107768473491412L; public static Builder builder() { return new Builder(); @@ -58,13 +59,13 @@ public class StratoGenVCloudMyCloudProviderMetadata super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = new Properties(); properties.setProperty(PROPERTY_VCLOUD_DEFAULT_NETWORK, "Direct Internet"); return properties; } - public static class Builder extends BaseProviderMetadata.Builder, VCloudApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder(){ id("stratogen-vcloud-mycloud") @@ -72,7 +73,8 @@ public class StratoGenVCloudMyCloudProviderMetadata .apiMetadata( new VCloudApiMetadata().toBuilder() .buildVersion("1.5.0.464915") - .contextBuilder(TypeToken.of(StratoGenVCloudMyCloudContextBuilder.class)).build()) + .defaultModules(ImmutableSet.>of(VCloudRestClientModule.class, StratoGenVCloudMyCloudComputeServiceContextModule.class)) + .build()) .homepage(URI.create("http://www.stratogen.net")) .console(URI.create("https://mycloud.stratogen.net/cloud/org/YOUR_ORG_HERE")) .iso3166Codes("GB") @@ -87,7 +89,7 @@ public class StratoGenVCloudMyCloudProviderMetadata @Override public Builder fromProviderMetadata( - ProviderMetadata, VCloudApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/stratogen-vcloud-mycloud/src/test/java/org/jclouds/stratogen/vcloud/mycloud/compute/StratoGenVCloudMyCloudTemplateBuilderLiveTest.java b/providers/stratogen-vcloud-mycloud/src/test/java/org/jclouds/stratogen/vcloud/mycloud/compute/StratoGenVCloudMyCloudTemplateBuilderLiveTest.java index fb4590393d..d43aad1b79 100644 --- a/providers/stratogen-vcloud-mycloud/src/test/java/org/jclouds/stratogen/vcloud/mycloud/compute/StratoGenVCloudMyCloudTemplateBuilderLiveTest.java +++ b/providers/stratogen-vcloud-mycloud/src/test/java/org/jclouds/stratogen/vcloud/mycloud/compute/StratoGenVCloudMyCloudTemplateBuilderLiveTest.java @@ -24,13 +24,10 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.util.Set; -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.compute.internal.BaseTemplateBuilderLiveTest; -import org.jclouds.vcloud.VCloudAsyncClient; -import org.jclouds.vcloud.VCloudClient; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -42,9 +39,7 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live", testName = "StratoGenVCloudMyCloudTemplateBuilderLiveTest") -public class StratoGenVCloudMyCloudTemplateBuilderLiveTest - extends - BaseTemplateBuilderLiveTest> { +public class StratoGenVCloudMyCloudTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { public StratoGenVCloudMyCloudTemplateBuilderLiveTest() { provider = "stratogen-vcloud-mycloud"; diff --git a/providers/synaptic-storage/src/main/java/org/jclouds/synaptic/storage/SynapticStorageProviderMetadata.java b/providers/synaptic-storage/src/main/java/org/jclouds/synaptic/storage/SynapticStorageProviderMetadata.java index f472292fc4..fe87784fa8 100644 --- a/providers/synaptic-storage/src/main/java/org/jclouds/synaptic/storage/SynapticStorageProviderMetadata.java +++ b/providers/synaptic-storage/src/main/java/org/jclouds/synaptic/storage/SynapticStorageProviderMetadata.java @@ -4,9 +4,6 @@ import java.net.URI; import java.util.Properties; import org.jclouds.atmos.AtmosApiMetadata; -import org.jclouds.atmos.AtmosAsyncClient; -import org.jclouds.atmos.AtmosClient; -import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -16,8 +13,11 @@ import org.jclouds.providers.internal.BaseProviderMetadata; * * @author Jeremy Whitlock */ -public class SynapticStorageProviderMetadata extends BaseProviderMetadata, AtmosApiMetadata> { +public class SynapticStorageProviderMetadata extends BaseProviderMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = 1L; + public static Builder builder() { return new Builder(); } @@ -35,12 +35,12 @@ public class SynapticStorageProviderMetadata extends BaseProviderMetadata, AtmosApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder(){ id("synaptic-storage") @@ -60,7 +60,7 @@ public class SynapticStorageProviderMetadata extends BaseProviderMetadata, AtmosApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/TerremarkECloudApiMetadata.java b/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/TerremarkECloudApiMetadata.java index dfae1bf49f..944acf2257 100644 --- a/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/TerremarkECloudApiMetadata.java +++ b/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/TerremarkECloudApiMetadata.java @@ -7,18 +7,29 @@ import java.net.URI; import java.util.Properties; import org.jclouds.apis.ApiMetadata; +import org.jclouds.rest.RestContext; +import org.jclouds.trmk.ecloud.compute.config.TerremarkECloudComputeServiceContextModule; +import org.jclouds.trmk.ecloud.config.TerremarkECloudRestClientModule; import org.jclouds.trmk.vcloud_0_8.internal.TerremarkVCloudApiMetadata; +import com.google.common.collect.ImmutableSet; import com.google.common.reflect.TypeToken; +import com.google.inject.Module; /** * Implementation of {@link ApiMetadata} for Terremark eCloud v2.8 API * * @author Adrian Cole */ -public class TerremarkECloudApiMetadata extends - TerremarkVCloudApiMetadata { +public class TerremarkECloudApiMetadata extends TerremarkVCloudApiMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = -6212626084139698761L; + + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; + @Override public Builder toBuilder() { return new Builder().fromApiMetadata(this); @@ -32,26 +43,24 @@ public class TerremarkECloudApiMetadata extends super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = TerremarkVCloudApiMetadata.defaultProperties(); properties.setProperty(PROPERTY_TERREMARK_EXTENSION_NAME, "eCloudExtensions"); properties.setProperty(PROPERTY_TERREMARK_EXTENSION_VERSION, "2.8"); return properties; } - public static class Builder - extends - TerremarkVCloudApiMetadata.Builder { + public static class Builder extends TerremarkVCloudApiMetadata.Builder { protected Builder() { super(TerremarkECloudClient.class, TerremarkECloudAsyncClient.class); id("trmk-ecloud") .name("Terremark Enterprise Cloud v2.8 API") .version("0.8b-ext2.8") - .defaultProperties(TerremarkECloudApiMetadata.defaultProperties()) .defaultEndpoint("https://services.enterprisecloud.terremark.com/api") - .contextBuilder(TypeToken.of(TerremarkECloudContextBuilder.class)) - .documentation(URI.create("http://support.theenterprisecloud.com/kb/default.asp?id=533&Lang=1&SID=")); + .documentation(URI.create("http://support.theenterprisecloud.com/kb/default.asp?id=533&Lang=1&SID=")) + .defaultProperties(TerremarkECloudApiMetadata.defaultProperties()) + .defaultModules(ImmutableSet.>of(TerremarkECloudRestClientModule.class, TerremarkECloudComputeServiceContextModule.class)); } @Override @@ -60,7 +69,7 @@ public class TerremarkECloudApiMetadata extends } @Override - public Builder fromApiMetadata(TerremarkECloudApiMetadata in) { + public Builder fromApiMetadata(ApiMetadata in) { super.fromApiMetadata(in); return this; } diff --git a/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/TerremarkECloudContextBuilder.java b/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/TerremarkECloudContextBuilder.java deleted file mode 100644 index da4b9fe1bd..0000000000 --- a/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/TerremarkECloudContextBuilder.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * 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.trmk.ecloud; - -import java.util.List; - -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; -import org.jclouds.logging.jdk.config.JDKLoggingModule; -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.trmk.ecloud.compute.config.TerremarkECloudComputeServiceContextModule; -import org.jclouds.trmk.ecloud.config.TerremarkECloudRestClientModule; -import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudContextBuilder; - -import com.google.inject.Injector; -import com.google.inject.Module; - -/** - * Creates {@link TerremarkVCloudComputeServiceContext} or {@link Injector} - * instances based on the most commonly requested arguments. - *

- * Note that Threadsafe objects will be bound as singletons to the Injector or - * Context provided. - *

- *

- * If no Modules are specified, the default - * {@link JDKLoggingModule logging} and - * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be - * installed. - * - * @author Adrian Cole - * @see TerremarkVCloudComputeServiceContext - */ -public class TerremarkECloudContextBuilder - extends - TerremarkVCloudContextBuilder, TerremarkECloudApiMetadata> { - public TerremarkECloudContextBuilder() { - this(new TerremarkECloudProviderMetadata()); - } - - public TerremarkECloudContextBuilder( - ProviderMetadata, TerremarkECloudApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public TerremarkECloudContextBuilder(TerremarkECloudApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new TerremarkECloudComputeServiceContextModule()); - } - - @Override - protected void addClientModule(List modules) { - modules.add(new TerremarkECloudRestClientModule()); - } - -} diff --git a/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/TerremarkECloudProviderMetadata.java b/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/TerremarkECloudProviderMetadata.java index e1c562ea88..dd33f5852c 100644 --- a/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/TerremarkECloudProviderMetadata.java +++ b/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/TerremarkECloudProviderMetadata.java @@ -21,7 +21,6 @@ package org.jclouds.trmk.ecloud; import java.net.URI; import java.util.Properties; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -30,8 +29,11 @@ import org.jclouds.providers.internal.BaseProviderMetadata; * * @author Adrian Cole */ -public class TerremarkECloudProviderMetadata extends BaseProviderMetadata, TerremarkECloudApiMetadata> { +public class TerremarkECloudProviderMetadata extends BaseProviderMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = -759809591681141530L; + public static Builder builder() { return new Builder(); } @@ -49,12 +51,12 @@ public class TerremarkECloudProviderMetadata extends BaseProviderMetadata, TerremarkECloudApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder(){ id("trmk-ecloud") @@ -73,7 +75,7 @@ public class TerremarkECloudProviderMetadata extends BaseProviderMetadata, TerremarkECloudApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/config/TerremarkECloudRestClientModule.java b/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/config/TerremarkECloudRestClientModule.java index 73f739fcff..c777657c95 100644 --- a/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/config/TerremarkECloudRestClientModule.java +++ b/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/config/TerremarkECloudRestClientModule.java @@ -25,7 +25,6 @@ import java.util.Map; import javax.inject.Inject; import javax.inject.Singleton; -import org.jclouds.http.RequiresHttp; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.trmk.ecloud.TerremarkECloudAsyncClient; import org.jclouds.trmk.ecloud.TerremarkECloudClient; @@ -52,7 +51,6 @@ import com.google.inject.Provides; * * @author Adrian Cole */ -@RequiresHttp @ConfiguresRestClient public class TerremarkECloudRestClientModule extends TerremarkVCloudRestClientModule { diff --git a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/BaseTerremarkECloudAsyncClientTest.java b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/BaseTerremarkECloudAsyncClientTest.java index c97038565f..c4af0d6710 100644 --- a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/BaseTerremarkECloudAsyncClientTest.java +++ b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/BaseTerremarkECloudAsyncClientTest.java @@ -30,7 +30,6 @@ import javax.inject.Named; import javax.inject.Singleton; import org.jclouds.http.HttpRequest; -import org.jclouds.http.RequiresHttp; import org.jclouds.providers.ProviderMetadata; import org.jclouds.rest.AuthorizationException; import org.jclouds.rest.ConfiguresRestClient; @@ -73,7 +72,7 @@ public abstract class BaseTerremarkECloudAsyncClientTest extends BaseAsyncCli } @Override - public ProviderMetadata createProviderMetadata() { + public ProviderMetadata createProviderMetadata() { return new TerremarkECloudProviderMetadata(); } @@ -127,8 +126,7 @@ public abstract class BaseTerremarkECloudAsyncClientTest extends BaseAsyncCli .create("https://vcloud.safesecureweb.com/api/v0.8/vdcItem/2"))), ImmutableMap. of(NETWORK_REF.getName(), NETWORK_REF)); - @RequiresHttp - @ConfiguresRestClient + @ConfiguresRestClient protected static class TerremarkECloudRestClientModuleExtension extends TerremarkECloudRestClientModule { @Override diff --git a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/BaseTerremarkECloudClientLiveTest.java b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/BaseTerremarkECloudClientLiveTest.java index 57d9e41f7f..804aca0846 100644 --- a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/BaseTerremarkECloudClientLiveTest.java +++ b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/BaseTerremarkECloudClientLiveTest.java @@ -28,7 +28,8 @@ import org.testng.annotations.Test; * @author Adrian Cole */ @Test(groups = "live", enabled = true, singleThreaded = true) -public class BaseTerremarkECloudClientLiveTest extends BaseTerremarkClientLiveTest { +public class BaseTerremarkECloudClientLiveTest extends + BaseTerremarkClientLiveTest { @Override protected Properties setupProperties() { Properties props = super.setupProperties(); diff --git a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/compute/TerremarkECloudComputeServiceLiveTest.java b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/compute/TerremarkECloudComputeServiceLiveTest.java index 8ed4c60713..0476d839dc 100644 --- a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/compute/TerremarkECloudComputeServiceLiveTest.java +++ b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/compute/TerremarkECloudComputeServiceLiveTest.java @@ -22,7 +22,6 @@ import static org.testng.Assert.assertEquals; import java.util.Properties; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.ComputeMetadata; import org.jclouds.compute.domain.ComputeType; import org.jclouds.compute.domain.Image; @@ -49,9 +48,7 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", enabled = true, singleThreaded = true) -public class TerremarkECloudComputeServiceLiveTest - extends - BaseComputeServiceLiveTest> { +public class TerremarkECloudComputeServiceLiveTest extends BaseComputeServiceLiveTest { @Override protected Properties setupProperties() { @@ -107,7 +104,7 @@ public class TerremarkECloudComputeServiceLiveTest assert node.getLocation() != null; assertEquals(node.getType(), ComputeType.NODE); NodeMetadata allData = client.getNodeMetadata(node.getId()); - RestContext tmContext = context.getProviderSpecificContext(); + RestContext tmContext = context.unwrap(); VApp vApp = tmContext.getApi().findVAppInOrgVDCNamed(allData.getLocation().getParent().getDescription(), allData.getLocation().getDescription(), allData.getName()); assertEquals(vApp.getName(), allData.getName()); diff --git a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/compute/TerremarkECloudTemplateBuilderLiveTest.java b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/compute/TerremarkECloudTemplateBuilderLiveTest.java index 2426a7d444..7c7090835d 100644 --- a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/compute/TerremarkECloudTemplateBuilderLiveTest.java +++ b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/compute/TerremarkECloudTemplateBuilderLiveTest.java @@ -25,13 +25,10 @@ import java.io.IOException; import java.util.Properties; import java.util.Set; -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.compute.internal.BaseTemplateBuilderLiveTest; -import org.jclouds.trmk.ecloud.TerremarkECloudAsyncClient; -import org.jclouds.trmk.ecloud.TerremarkECloudClient; import org.jclouds.trmk.vcloud_0_8.reference.VCloudConstants; import org.testng.annotations.Test; @@ -43,9 +40,7 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live") -public class TerremarkECloudTemplateBuilderLiveTest - extends - BaseTemplateBuilderLiveTest> { +public class TerremarkECloudTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { @Override protected Properties setupProperties() { Properties props = super.setupProperties(); diff --git a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/features/DataCenterOperationsClientLiveTest.java b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/features/DataCenterOperationsClientLiveTest.java index 42bbbffc66..13b4d20cf2 100644 --- a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/features/DataCenterOperationsClientLiveTest.java +++ b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/features/DataCenterOperationsClientLiveTest.java @@ -33,12 +33,12 @@ import org.testng.annotations.Test; public class DataCenterOperationsClientLiveTest extends BaseTerremarkECloudClientLiveTest { @Test public void testListDataCentersInOrg() throws Exception { - for (ReferenceType response : getApi().listOrgs().values()) { - ECloudOrg org = getApi().getOrg(response.getHref()); + for (ReferenceType response : connection.listOrgs().values()) { + ECloudOrg org = connection.getOrg(response.getHref()); assertNotNull(response); assertNotNull(response.getName()); assertNotNull(response.getHref()); - assertEquals(getApi().getDataCenterOperationsClient().listDataCentersInOrg(org.getHref()), getApi() + assertEquals(connection.getDataCenterOperationsClient().listDataCentersInOrg(org.getHref()), connection .getDataCenterOperationsClient().listDataCenters(org.getDataCenters().getHref())); } } diff --git a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/features/TagOperationsClientLiveTest.java b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/features/TagOperationsClientLiveTest.java index dd5fe73d4a..3620c2b90c 100644 --- a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/features/TagOperationsClientLiveTest.java +++ b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/features/TagOperationsClientLiveTest.java @@ -33,12 +33,12 @@ import org.testng.annotations.Test; public class TagOperationsClientLiveTest extends BaseTerremarkECloudClientLiveTest { @Test public void testListTagsInOrg() throws Exception { - for (ReferenceType response : getApi().listOrgs().values()) { - ECloudOrg org = getApi().getOrg(response.getHref()); + for (ReferenceType response : connection.listOrgs().values()) { + ECloudOrg org = connection.getOrg(response.getHref()); assertNotNull(response); assertNotNull(response.getName()); assertNotNull(response.getHref()); - assertEquals(getApi().getTagOperationsClient().getTagNameToUsageCountInOrg(org.getHref()), getApi() + assertEquals(connection.getTagOperationsClient().getTagNameToUsageCountInOrg(org.getHref()), connection .getTagOperationsClient().getTagNameToUsageCount(org.getTags().getHref())); } } diff --git a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/xml/ECloudOrgHandlerTest.java b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/xml/ECloudOrgHandlerTest.java index b61206bd4a..1a03416cde 100644 --- a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/xml/ECloudOrgHandlerTest.java +++ b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/xml/ECloudOrgHandlerTest.java @@ -18,19 +18,17 @@ */ package org.jclouds.trmk.ecloud.xml; -import static com.google.common.base.Preconditions.checkNotNull; import static org.testng.Assert.assertEquals; import java.io.InputStream; import java.net.URI; -import java.util.Properties; import org.jclouds.http.functions.BaseHandlerTest; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.config.SaxParserModule; +import org.jclouds.trmk.ecloud.TerremarkECloudApiMetadata; import org.jclouds.trmk.ecloud.TerremarkECloudMediaType; import org.jclouds.trmk.ecloud.domain.ECloudOrg; -import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudPropertiesBuilder; import org.jclouds.trmk.vcloud_0_8.domain.internal.ReferenceTypeImpl; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; @@ -55,9 +53,7 @@ public class ECloudOrgHandlerTest extends BaseHandlerTest { @Override public void configure() { super.configure(); - Properties props = new Properties(); - Names.bindProperties(binder(), - checkNotNull(new TerremarkVCloudPropertiesBuilder(props).build(), "properties")); + Names.bindProperties(binder(),TerremarkECloudApiMetadata.defaultProperties()); } }); factory = injector.getInstance(ParseSax.Factory.class); diff --git a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/xml/TagNameToUsageCountHandlerTest.java b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/xml/TagNameToUsageCountHandlerTest.java index 3ac18c4204..17b9559408 100644 --- a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/xml/TagNameToUsageCountHandlerTest.java +++ b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/xml/TagNameToUsageCountHandlerTest.java @@ -18,17 +18,15 @@ */ package org.jclouds.trmk.ecloud.xml; -import static com.google.common.base.Preconditions.checkNotNull; import static org.testng.Assert.assertEquals; import java.io.InputStream; import java.util.Map; -import java.util.Properties; import org.jclouds.http.functions.BaseHandlerTest; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.config.SaxParserModule; -import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudPropertiesBuilder; +import org.jclouds.trmk.ecloud.TerremarkECloudApiMetadata; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; @@ -52,9 +50,7 @@ public class TagNameToUsageCountHandlerTest extends BaseHandlerTest { @Override public void configure() { super.configure(); - Properties props = new Properties(); - Names.bindProperties(binder(), - checkNotNull(new TerremarkVCloudPropertiesBuilder(props).build(), "properties")); + Names.bindProperties(binder(),TerremarkECloudApiMetadata.defaultProperties()); } }); factory = injector.getInstance(ParseSax.Factory.class); diff --git a/providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressApiMetadata.java b/providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressApiMetadata.java index 605a93fc10..cb2e234a99 100644 --- a/providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressApiMetadata.java +++ b/providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressApiMetadata.java @@ -25,18 +25,28 @@ import java.net.URI; import java.util.Properties; import org.jclouds.apis.ApiMetadata; +import org.jclouds.rest.RestContext; import org.jclouds.trmk.vcloud_0_8.internal.TerremarkVCloudApiMetadata; +import org.jclouds.trmk.vcloudexpress.compute.TerremarkVCloudExpressComputeServiceContextModule; +import org.jclouds.trmk.vcloudexpress.config.TerremarkVCloudExpressRestClientModule; +import com.google.common.collect.ImmutableSet; import com.google.common.reflect.TypeToken; +import com.google.inject.Module; /** * Implementation of {@link ApiMetadata} for the Terremark vCloud Express API * * @author Adrian Cole */ -public class TerremarkVCloudExpressApiMetadata extends - TerremarkVCloudApiMetadata { +public class TerremarkVCloudExpressApiMetadata extends TerremarkVCloudApiMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = -6212626084139698761L; + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; + @Override public Builder toBuilder() { return new Builder().fromApiMetadata(this); @@ -50,7 +60,7 @@ public class TerremarkVCloudExpressApiMetadata extends super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = TerremarkVCloudApiMetadata.defaultProperties(); properties.setProperty(PROPERTY_TERREMARK_EXTENSION_NAME, "vCloudExpressExtensions"); properties.setProperty(PROPERTY_TERREMARK_EXTENSION_VERSION, "1.6"); @@ -59,7 +69,7 @@ public class TerremarkVCloudExpressApiMetadata extends public static class Builder extends - TerremarkVCloudApiMetadata.Builder { + TerremarkVCloudApiMetadata.Builder { protected Builder() { super(TerremarkVCloudExpressClient.class, TerremarkVCloudExpressAsyncClient.class); @@ -67,11 +77,11 @@ public class TerremarkVCloudExpressApiMetadata extends .name("Terremark vCloud Express API") .identityName("Email") .credentialName("Password") - .defaultProperties(TerremarkVCloudExpressApiMetadata.defaultProperties()) + .version("0.8a-ext1.6") .defaultEndpoint("https://services.vcloudexpress.terremark.com/api") + .documentation(URI.create("https://community.vcloudexpress.terremark.com/en-us/product_docs/m/vcefiles/2342.aspx")) .defaultProperties(TerremarkVCloudExpressApiMetadata.defaultProperties()) - .contextBuilder(TypeToken.of(TerremarkVCloudExpressContextBuilder.class)) - .documentation(URI.create("https://community.vcloudexpress.terremark.com/en-us/product_docs/m/vcefiles/2342.aspx")); + .defaultModules(ImmutableSet.>of(TerremarkVCloudExpressRestClientModule.class, TerremarkVCloudExpressComputeServiceContextModule.class)); } @Override @@ -80,7 +90,7 @@ public class TerremarkVCloudExpressApiMetadata extends } @Override - public Builder fromApiMetadata(TerremarkVCloudExpressApiMetadata in) { + public Builder fromApiMetadata(ApiMetadata in) { super.fromApiMetadata(in); return this; } diff --git a/providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressContextBuilder.java b/providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressContextBuilder.java deleted file mode 100644 index 6a365fbbaa..0000000000 --- a/providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressContextBuilder.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * 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.trmk.vcloudexpress; - -import java.util.List; - -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; -import org.jclouds.logging.jdk.config.JDKLoggingModule; -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudContextBuilder; -import org.jclouds.trmk.vcloudexpress.compute.TerremarkVCloudExpressComputeServiceContextModule; -import org.jclouds.trmk.vcloudexpress.config.TerremarkVCloudExpressRestClientModule; - -import com.google.inject.Injector; -import com.google.inject.Module; - -/** - * Creates {@link TerremarkVCloudComputeServiceContext} or {@link Injector} - * instances based on the most commonly requested arguments. - *

- * Note that Threadsafe objects will be bound as singletons to the Injector or - * Context provided. - *

- *

- * If no Modules are specified, the default - * {@link JDKLoggingModule logging} and - * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be - * installed. - * - * @author Adrian Cole - * @see TerremarkVCloudComputeServiceContext - */ -public class TerremarkVCloudExpressContextBuilder - extends - TerremarkVCloudContextBuilder, TerremarkVCloudExpressApiMetadata> { - public TerremarkVCloudExpressContextBuilder() { - this(new TerremarkVCloudExpressProviderMetadata()); - } - - public TerremarkVCloudExpressContextBuilder( - ProviderMetadata, TerremarkVCloudExpressApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public TerremarkVCloudExpressContextBuilder(TerremarkVCloudExpressApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new TerremarkVCloudExpressComputeServiceContextModule()); - } - - @Override - protected void addClientModule(List modules) { - modules.add(new TerremarkVCloudExpressRestClientModule()); - } - -} diff --git a/providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressPropertiesBuilder.java b/providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressPropertiesBuilder.java deleted file mode 100644 index 5c798c9b8b..0000000000 --- a/providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressPropertiesBuilder.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * 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.trmk.vcloudexpress; - -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; -import static org.jclouds.trmk.vcloud_0_8.reference.TerremarkConstants.PROPERTY_TERREMARK_EXTENSION_NAME; -import static org.jclouds.trmk.vcloud_0_8.reference.TerremarkConstants.PROPERTY_TERREMARK_EXTENSION_VERSION; - -import java.util.Properties; - -import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudPropertiesBuilder; - -/** - * Builds properties used in Terremark VCloud Clients - * - * @author Adrian Cole - */ -public class TerremarkVCloudExpressPropertiesBuilder extends TerremarkVCloudPropertiesBuilder { - @Override - protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(PROPERTY_API_VERSION, "0.8a-ext1.6"); - properties.setProperty(PROPERTY_ISO3166_CODES, "US-FL"); - properties.setProperty(PROPERTY_TERREMARK_EXTENSION_NAME, "vCloudExpressExtensions"); - properties.setProperty(PROPERTY_TERREMARK_EXTENSION_VERSION, "1.6"); - properties.setProperty(PROPERTY_ENDPOINT, "https://services.vcloudexpress.terremark.com/api"); - return properties; - } - - public TerremarkVCloudExpressPropertiesBuilder(Properties properties) { - super(properties); - } - -} diff --git a/providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressProviderMetadata.java b/providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressProviderMetadata.java index a36e53a0d8..8b64e1b407 100644 --- a/providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressProviderMetadata.java +++ b/providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressProviderMetadata.java @@ -21,7 +21,6 @@ package org.jclouds.trmk.vcloudexpress; import java.net.URI; import java.util.Properties; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -30,8 +29,11 @@ import org.jclouds.providers.internal.BaseProviderMetadata; * * @author Adrian Cole */ -public class TerremarkVCloudExpressProviderMetadata extends BaseProviderMetadata, TerremarkVCloudExpressApiMetadata> { +public class TerremarkVCloudExpressProviderMetadata extends BaseProviderMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = -7993337019540975194L; + public static Builder builder() { return new Builder(); } @@ -49,12 +51,12 @@ public class TerremarkVCloudExpressProviderMetadata extends BaseProviderMetadata super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = new Properties(); return properties; } - public static class Builder extends BaseProviderMetadata.Builder, TerremarkVCloudExpressApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder(){ id("trmk-vcloudexpress") @@ -74,7 +76,7 @@ public class TerremarkVCloudExpressProviderMetadata extends BaseProviderMetadata @Override public Builder fromProviderMetadata( - ProviderMetadata, TerremarkVCloudExpressApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/config/TerremarkVCloudExpressRestClientModule.java b/providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/config/TerremarkVCloudExpressRestClientModule.java index e6f35b8109..6a618b5cf4 100644 --- a/providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/config/TerremarkVCloudExpressRestClientModule.java +++ b/providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/config/TerremarkVCloudExpressRestClientModule.java @@ -20,7 +20,6 @@ package org.jclouds.trmk.vcloudexpress.config; import javax.inject.Singleton; -import org.jclouds.http.RequiresHttp; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudAsyncClient; import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudClient; @@ -36,7 +35,6 @@ import com.google.inject.Provides; * * @author Adrian Cole */ -@RequiresHttp @ConfiguresRestClient public class TerremarkVCloudExpressRestClientModule extends TerremarkVCloudRestClientModule { diff --git a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/InternetServiceLiveTest.java b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/InternetServiceLiveTest.java index a25f499e91..87d95fed58 100644 --- a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/InternetServiceLiveTest.java +++ b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/InternetServiceLiveTest.java @@ -23,7 +23,6 @@ import java.util.Set; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeoutException; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.trmk.vcloud_0_8.domain.InternetService; import org.jclouds.trmk.vcloud_0_8.domain.Node; @@ -42,7 +41,7 @@ import com.google.common.collect.Sets; @Test(groups = "live", singleThreaded = true, testName = "InternetServiceLiveTest") public class InternetServiceLiveTest extends - BaseComputeServiceContextLiveTest> { + BaseComputeServiceContextLiveTest { public InternetServiceLiveTest() { provider = "trmk-vcloudexpress"; } @@ -89,7 +88,7 @@ public class InternetServiceLiveTest @BeforeClass(groups = { "integration", "live" }) public void setupContext() { super.setupContext(); - tmClient = context.getProviderSpecificContext().getApi(); + tmClient = context.unwrap(TerremarkVCloudExpressApiMetadata.CONTEXT_TOKEN).getApi(); } diff --git a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressAsyncClientTest.java b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressAsyncClientTest.java index aeccab9a00..45a8ca271a 100644 --- a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressAsyncClientTest.java +++ b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressAsyncClientTest.java @@ -38,7 +38,6 @@ import javax.inject.Named; import javax.inject.Singleton; import org.jclouds.http.HttpRequest; -import org.jclouds.http.RequiresHttp; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ReleasePayloadAndReturn; import org.jclouds.providers.ProviderMetadata; @@ -621,7 +620,7 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest createProviderMetadata() { + public ProviderMetadata createProviderMetadata() { return new TerremarkVCloudExpressProviderMetadata(); } @@ -667,8 +666,7 @@ public class TerremarkVCloudExpressAsyncClientTest extends BaseAsyncClientTest of(NETWORK_REF.getName(), NETWORK_REF)); - @RequiresHttp - @ConfiguresRestClient + @ConfiguresRestClient protected static class TerremarkVCloudRestClientModuleExtension extends TerremarkVCloudExpressRestClientModule { @Override diff --git a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/compute/TerremarkVCloudExpressComputeServiceLiveTest.java b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/compute/TerremarkVCloudExpressComputeServiceLiveTest.java index 3038f72cdd..4fe542a463 100644 --- a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/compute/TerremarkVCloudExpressComputeServiceLiveTest.java +++ b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/compute/TerremarkVCloudExpressComputeServiceLiveTest.java @@ -20,7 +20,6 @@ package org.jclouds.trmk.vcloudexpress.compute; import static org.testng.Assert.assertEquals; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.ComputeMetadata; import org.jclouds.compute.domain.ComputeType; import org.jclouds.compute.domain.Image; @@ -45,9 +44,7 @@ import com.google.common.collect.ImmutableMap; * @author Adrian Cole */ @Test(groups = "live", enabled = true, singleThreaded = true) -public class TerremarkVCloudExpressComputeServiceLiveTest - extends - BaseComputeServiceLiveTest> { +public class TerremarkVCloudExpressComputeServiceLiveTest extends BaseComputeServiceLiveTest { public TerremarkVCloudExpressComputeServiceLiveTest() { provider = "trmk-vcloudexpress"; @@ -99,7 +96,7 @@ public class TerremarkVCloudExpressComputeServiceLiveTest assertEquals(node.getType(), ComputeType.NODE); NodeMetadata allData = client.getNodeMetadata(node.getId()); System.out.println(allData.getHardware()); - RestContext tmContext = context.getProviderSpecificContext(); + RestContext tmContext = context.unwrap(); VApp vApp = tmContext.getApi().findVAppInOrgVDCNamed(null, null, allData.getName()); assertEquals(vApp.getName(), allData.getName()); } diff --git a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/compute/TerremarkVCloudExpressTemplateBuilderLiveTest.java b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/compute/TerremarkVCloudExpressTemplateBuilderLiveTest.java index f8a59be4f9..109305fd13 100644 --- a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/compute/TerremarkVCloudExpressTemplateBuilderLiveTest.java +++ b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/compute/TerremarkVCloudExpressTemplateBuilderLiveTest.java @@ -24,13 +24,10 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.util.Set; -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.compute.internal.BaseTemplateBuilderLiveTest; -import org.jclouds.trmk.vcloudexpress.TerremarkVCloudExpressAsyncClient; -import org.jclouds.trmk.vcloudexpress.TerremarkVCloudExpressClient; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -42,9 +39,7 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live") -public class TerremarkVCloudExpressTemplateBuilderLiveTest - extends - BaseTemplateBuilderLiveTest> { +public class TerremarkVCloudExpressTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { public TerremarkVCloudExpressTemplateBuilderLiveTest() { provider = "trmk-vcloudexpress"; diff --git a/providers/trystack-nova/src/main/java/org/jclouds/trystack/nova/TryStackNovaContextBuilder.java b/providers/trystack-nova/src/main/java/org/jclouds/trystack/nova/TryStackNovaContextBuilder.java deleted file mode 100644 index d015b534ba..0000000000 --- a/providers/trystack-nova/src/main/java/org/jclouds/trystack/nova/TryStackNovaContextBuilder.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * 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.trystack.nova; - -import java.util.List; - -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.openstack.nova.v1_1.NovaApiMetadata; -import org.jclouds.openstack.nova.v1_1.NovaAsyncClient; -import org.jclouds.openstack.nova.v1_1.NovaClient; -import org.jclouds.openstack.nova.v1_1.NovaContextBuilder; -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.trystack.nova.config.TryStackNovaServiceContextModule; - -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class TryStackNovaContextBuilder extends NovaContextBuilder { - - public TryStackNovaContextBuilder( - ProviderMetadata, NovaApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public TryStackNovaContextBuilder(NovaApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new TryStackNovaServiceContextModule()); - } - -} diff --git a/providers/trystack-nova/src/main/java/org/jclouds/trystack/nova/TryStackNovaProviderMetadata.java b/providers/trystack-nova/src/main/java/org/jclouds/trystack/nova/TryStackNovaProviderMetadata.java index 1a974e1dee..b67eecf5be 100644 --- a/providers/trystack-nova/src/main/java/org/jclouds/trystack/nova/TryStackNovaProviderMetadata.java +++ b/providers/trystack-nova/src/main/java/org/jclouds/trystack/nova/TryStackNovaProviderMetadata.java @@ -25,23 +25,24 @@ import static org.jclouds.openstack.nova.v1_1.config.NovaProperties.AUTO_GENERAT import java.net.URI; import java.util.Properties; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.openstack.nova.v1_1.NovaApiMetadata; -import org.jclouds.openstack.nova.v1_1.NovaAsyncClient; -import org.jclouds.openstack.nova.v1_1.NovaClient; +import org.jclouds.openstack.nova.v1_1.config.NovaRestClientModule; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; +import org.jclouds.trystack.nova.config.TryStackNovaServiceContextModule; -import com.google.common.reflect.TypeToken; +import com.google.common.collect.ImmutableSet; +import com.google.inject.Module; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for TryStack Nova * * @author Adrian Cole */ -public class TryStackNovaProviderMetadata - extends - BaseProviderMetadata, NovaApiMetadata> { +public class TryStackNovaProviderMetadata extends BaseProviderMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = -8567407993297259224L; public static Builder builder() { return new Builder(); @@ -60,7 +61,7 @@ public class TryStackNovaProviderMetadata super(builder); } - protected static Properties defaultProperties() { + public static Properties defaultProperties() { Properties properties = new Properties(); properties.setProperty(PROPERTY_TRUST_ALL_CERTS, "true"); properties.setProperty(CREDENTIAL_TYPE, "passwordCredentials"); @@ -68,14 +69,15 @@ public class TryStackNovaProviderMetadata return properties; } - public static class Builder extends BaseProviderMetadata.Builder, NovaApiMetadata> { + public static class Builder extends BaseProviderMetadata.Builder { protected Builder(){ id("trystack-nova") .name("TryStack.org (Nova)") .apiMetadata( - new NovaApiMetadata().toBuilder().contextBuilder(TypeToken.of(TryStackNovaContextBuilder.class)) - .build()) + new NovaApiMetadata().toBuilder() + .defaultModules(ImmutableSet.>of(NovaRestClientModule.class, TryStackNovaServiceContextModule.class)) + .build()) .homepage(URI.create("https://trystack.org")) .console(URI.create("https://trystack.org/dash")) .iso3166Codes("US-CA") @@ -90,7 +92,7 @@ public class TryStackNovaProviderMetadata @Override public Builder fromProviderMetadata( - ProviderMetadata, NovaApiMetadata> in) { + ProviderMetadata in) { super.fromProviderMetadata(in); return this; } diff --git a/providers/trystack-nova/src/test/java/org/jclouds/trystack/nova/compute/TryStackNovaTemplateBuilderLiveTest.java b/providers/trystack-nova/src/test/java/org/jclouds/trystack/nova/compute/TryStackNovaTemplateBuilderLiveTest.java index ed4ae1e715..a23f3e92ff 100644 --- a/providers/trystack-nova/src/test/java/org/jclouds/trystack/nova/compute/TryStackNovaTemplateBuilderLiveTest.java +++ b/providers/trystack-nova/src/test/java/org/jclouds/trystack/nova/compute/TryStackNovaTemplateBuilderLiveTest.java @@ -23,13 +23,10 @@ import static org.testng.Assert.assertEquals; import java.util.Set; -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.compute.internal.BaseTemplateBuilderLiveTest; -import org.jclouds.openstack.nova.v1_1.NovaAsyncClient; -import org.jclouds.openstack.nova.v1_1.NovaClient; import org.jclouds.openstack.nova.v1_1.compute.options.NovaTemplateOptions; import org.testng.annotations.Test; @@ -42,8 +39,7 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "TryStackNovaTemplateBuilderLiveTest") -public class TryStackNovaTemplateBuilderLiveTest extends - BaseTemplateBuilderLiveTest> { +public class TryStackNovaTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { public TryStackNovaTemplateBuilderLiveTest() { provider = "trystack-nova"; diff --git a/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/DunkelVCloudDirectorContextBuilder.java b/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/DunkelVCloudDirectorContextBuilder.java index 350cb0fcf9..496f679901 100644 --- a/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/DunkelVCloudDirectorContextBuilder.java +++ b/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/DunkelVCloudDirectorContextBuilder.java @@ -18,14 +18,8 @@ */ package org.jclouds.dunkel.vcd; -import java.util.List; -import java.util.Properties; - -import org.jclouds.vcloud.VCloudContextBuilder; -import org.jclouds.dunkel.vcd.config.DunkelVCloudDirectorComputeServiceContextModule; -import org.jclouds.dunkel.vcd.config.DunkelVCloudDirectorRestClientModule; - -import com.google.inject.Module; +import src.main.java.org.jclouds.dunkel.vcd.config.DunkelVCloudDirectorComputeServiceContextModule; +import src.main.java.org.jclouds.dunkel.vcd.config.DunkelVCloudDirectorRestClientModule; /** * diff --git a/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/DunkelVCloudDirectorPropertiesBuilder.java b/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/DunkelVCloudDirectorPropertiesBuilder.java index 29521af599..e246599839 100644 --- a/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/DunkelVCloudDirectorPropertiesBuilder.java +++ b/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/DunkelVCloudDirectorPropertiesBuilder.java @@ -18,14 +18,6 @@ */ package org.jclouds.dunkel.vcd; -import static org.jclouds.Constants.PROPERTY_BUILD_VERSION; -import static org.jclouds.Constants.PROPERTY_ENDPOINT; -import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; -import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_NETWORK; - -import java.util.Properties; - -import org.jclouds.vcloud.VCloudPropertiesBuilder; /** * diff --git a/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/DunkelVCloudDirectorProviderMetadata.java b/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/DunkelVCloudDirectorProviderMetadata.java index 3fa940cfeb..f657fe5d55 100644 --- a/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/DunkelVCloudDirectorProviderMetadata.java +++ b/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/DunkelVCloudDirectorProviderMetadata.java @@ -18,13 +18,6 @@ */ package org.jclouds.dunkel.vcd; -import com.google.common.collect.ImmutableSet; - -import java.net.URI; -import java.util.Set; - -import org.jclouds.providers.BaseProviderMetadata; -import org.jclouds.providers.ProviderMetadata; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for Dunkel vCloud Director diff --git a/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/config/DunkelVCloudDirectorComputeServiceContextModule.java b/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/config/DunkelVCloudDirectorComputeServiceContextModule.java index f73cd4c0a4..210e5a1f23 100644 --- a/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/config/DunkelVCloudDirectorComputeServiceContextModule.java +++ b/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/config/DunkelVCloudDirectorComputeServiceContextModule.java @@ -18,15 +18,6 @@ */ package org.jclouds.dunkel.vcd.config; -import static org.jclouds.compute.domain.OsFamily.RHEL; - -import org.jclouds.compute.domain.TemplateBuilder; -import org.jclouds.compute.options.TemplateOptions; -import org.jclouds.vcloud.compute.config.VCloudComputeServiceContextModule; -import org.jclouds.vcloud.compute.options.VCloudTemplateOptions; -import org.jclouds.vcloud.domain.network.IpAddressAllocationMode; - -import com.google.inject.Injector; /** * diff --git a/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/config/DunkelVCloudDirectorRestClientModule.java b/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/config/DunkelVCloudDirectorRestClientModule.java index 1c6aba2d37..9bb92e1c1f 100644 --- a/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/config/DunkelVCloudDirectorRestClientModule.java +++ b/sandbox-providers/dunkel-vcd/src/main/java/org/jclouds/dunkel/vcd/config/DunkelVCloudDirectorRestClientModule.java @@ -18,15 +18,11 @@ */ package org.jclouds.dunkel.vcd.config; -import org.jclouds.http.RequiresHttp; -import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.vcloud.config.VCloudRestClientModule; /** * * @author Adrian Cole */ -@RequiresHttp @ConfiguresRestClient public class DunkelVCloudDirectorRestClientModule extends VCloudRestClientModule { diff --git a/sandbox-providers/dunkel-vcd/src/test/java/org/jclouds/dunkel/vcd/DunkelVCloudDirectorProviderTest.java b/sandbox-providers/dunkel-vcd/src/test/java/org/jclouds/dunkel/vcd/DunkelVCloudDirectorProviderTest.java index ad1043bff2..5589905127 100644 --- a/sandbox-providers/dunkel-vcd/src/test/java/org/jclouds/dunkel/vcd/DunkelVCloudDirectorProviderTest.java +++ b/sandbox-providers/dunkel-vcd/src/test/java/org/jclouds/dunkel/vcd/DunkelVCloudDirectorProviderTest.java @@ -18,10 +18,7 @@ */ package org.jclouds.dunkel.vcd; -import org.jclouds.providers.BaseProviderMetadataTest; -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.dunkel.vcd.DunkelVCloudDirectorProviderMetadata; -import org.testng.annotations.Test; +import src.main.java.org.jclouds.dunkel.vcd.DunkelVCloudDirectorProviderMetadata; /** * diff --git a/sandbox-providers/dunkel-vcd/src/test/java/org/jclouds/dunkel/vcd/compute/DunkelVCloudDirectorComputeServiceLiveTest.java b/sandbox-providers/dunkel-vcd/src/test/java/org/jclouds/dunkel/vcd/compute/DunkelVCloudDirectorComputeServiceLiveTest.java index d5e46c831b..9f43601cd5 100644 --- a/sandbox-providers/dunkel-vcd/src/test/java/org/jclouds/dunkel/vcd/compute/DunkelVCloudDirectorComputeServiceLiveTest.java +++ b/sandbox-providers/dunkel-vcd/src/test/java/org/jclouds/dunkel/vcd/compute/DunkelVCloudDirectorComputeServiceLiveTest.java @@ -18,8 +18,6 @@ */ package org.jclouds.dunkel.vcd.compute; -import org.jclouds.vcloud.compute.VCloudComputeServiceLiveTest; -import org.testng.annotations.Test; /** * diff --git a/sandbox-providers/dunkel-vcd/src/test/java/org/jclouds/dunkel/vcd/compute/DunkelVCloudDirectorTemplateBuilderLiveTest.java b/sandbox-providers/dunkel-vcd/src/test/java/org/jclouds/dunkel/vcd/compute/DunkelVCloudDirectorTemplateBuilderLiveTest.java index fc67f05871..0025def75d 100644 --- a/sandbox-providers/dunkel-vcd/src/test/java/org/jclouds/dunkel/vcd/compute/DunkelVCloudDirectorTemplateBuilderLiveTest.java +++ b/sandbox-providers/dunkel-vcd/src/test/java/org/jclouds/dunkel/vcd/compute/DunkelVCloudDirectorTemplateBuilderLiveTest.java @@ -18,20 +18,6 @@ */ package org.jclouds.dunkel.vcd.compute; -import static org.jclouds.compute.util.ComputeServiceUtils.getCores; -import static org.testng.Assert.assertEquals; - -import java.io.IOException; -import java.util.Set; - -import org.jclouds.compute.BaseTemplateBuilderLiveTest; -import org.jclouds.compute.domain.OsFamily; -import org.jclouds.compute.domain.OsFamilyVersion64Bit; -import org.jclouds.compute.domain.Template; -import org.testng.annotations.Test; - -import com.google.common.base.Predicate; -import com.google.common.collect.ImmutableSet; /** * diff --git a/skeletons/standalone-compute/src/main/java/org/jclouds/servermanager/ServerManagerApiMetadata.java b/skeletons/standalone-compute/src/main/java/org/jclouds/servermanager/ServerManagerApiMetadata.java index b858a0fe7a..a8fa9e5f35 100644 --- a/skeletons/standalone-compute/src/main/java/org/jclouds/servermanager/ServerManagerApiMetadata.java +++ b/skeletons/standalone-compute/src/main/java/org/jclouds/servermanager/ServerManagerApiMetadata.java @@ -3,18 +3,20 @@ package org.jclouds.servermanager; import java.net.URI; import org.jclouds.apis.ApiMetadata; +import org.jclouds.apis.internal.BaseApiMetadata; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.internal.BaseComputeServiceApiMetadata; -import org.jclouds.servermanager.compute.ServerManagerComputeServiceContextBuilder; - -import com.google.common.reflect.TypeToken; +import org.jclouds.servermanager.compute.config.ServerManagerComputeServiceContextModule; /** * Implementation of {@link ApiMetadata} for an example of library integration (ServerManager) * * @author Adrian Cole */ -public class ServerManagerApiMetadata extends BaseComputeServiceApiMetadata, ServerManagerApiMetadata> { +public class ServerManagerApiMetadata extends BaseApiMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 3606170564482119304L; + public static Builder builder() { return new Builder(); } @@ -32,7 +34,7 @@ public class ServerManagerApiMetadata extends BaseComputeServiceApiMetadata, ServerManagerApiMetadata> { + public static class Builder extends BaseApiMetadata.Builder { protected Builder(){ id("servermanager") @@ -41,12 +43,9 @@ public class ServerManagerApiMetadata extends BaseComputeServiceApiMetadata>(getClass()){ - private static final long serialVersionUID = 1L; - }) - .javaApi(ServerManager.class, ServerManager.class) .documentation(URI.create("http://www.jclouds.org/documentation/userguide/compute")) - .contextBuilder(TypeToken.of(ServerManagerComputeServiceContextBuilder.class)); + .wrapper(ComputeServiceContext.class) + .defaultModule(ServerManagerComputeServiceContextModule.class); } @Override diff --git a/skeletons/standalone-compute/src/main/java/org/jclouds/servermanager/compute/ServerManagerComputeServiceContextBuilder.java b/skeletons/standalone-compute/src/main/java/org/jclouds/servermanager/compute/ServerManagerComputeServiceContextBuilder.java deleted file mode 100644 index f10174a8f0..0000000000 --- a/skeletons/standalone-compute/src/main/java/org/jclouds/servermanager/compute/ServerManagerComputeServiceContextBuilder.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * 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.servermanager.compute; - -import java.util.List; - -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.StandaloneComputeServiceContextBuilder; -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.servermanager.ServerManager; -import org.jclouds.servermanager.ServerManagerApiMetadata; -import org.jclouds.servermanager.compute.config.ServerManagerComputeServiceContextModule; - -import com.google.inject.Module; - -/** - * - * @author Adrian Cole - */ -public class ServerManagerComputeServiceContextBuilder - extends - StandaloneComputeServiceContextBuilder, ServerManagerApiMetadata> { - - public ServerManagerComputeServiceContextBuilder() { - super(new ServerManagerApiMetadata()); - } - - public ServerManagerComputeServiceContextBuilder( - ProviderMetadata, ServerManagerApiMetadata> providerMetadata) { - super(providerMetadata); - } - - public ServerManagerComputeServiceContextBuilder(ServerManagerApiMetadata apiMetadata) { - super(apiMetadata); - } - - @Override - protected void addContextModule(List modules) { - modules.add(new ServerManagerComputeServiceContextModule()); - } -} diff --git a/skeletons/standalone-compute/src/main/java/org/jclouds/servermanager/compute/config/ServerManagerComputeServiceContextModule.java b/skeletons/standalone-compute/src/main/java/org/jclouds/servermanager/compute/config/ServerManagerComputeServiceContextModule.java index 778a5446f7..efcce8aa61 100644 --- a/skeletons/standalone-compute/src/main/java/org/jclouds/servermanager/compute/config/ServerManagerComputeServiceContextModule.java +++ b/skeletons/standalone-compute/src/main/java/org/jclouds/servermanager/compute/config/ServerManagerComputeServiceContextModule.java @@ -26,7 +26,6 @@ import org.jclouds.servermanager.Datacenter; import org.jclouds.servermanager.Hardware; import org.jclouds.servermanager.Image; import org.jclouds.servermanager.Server; -import org.jclouds.servermanager.ServerManager; import org.jclouds.servermanager.compute.functions.DatacenterToLocation; import org.jclouds.servermanager.compute.functions.ServerManagerHardwareToHardware; import org.jclouds.servermanager.compute.functions.ServerManagerImageToImage; @@ -41,11 +40,7 @@ import com.google.inject.TypeLiteral; * @author Adrian Cole */ public class ServerManagerComputeServiceContextModule extends - ComputeServiceAdapterContextModule { - - public ServerManagerComputeServiceContextModule() { - super(ServerManager.class, ServerManager.class); - } + ComputeServiceAdapterContextModule { @Override protected void configure() { diff --git a/skeletons/standalone-compute/src/test/java/org/jclouds/servermanager/compute/ServerManagerComputeServiceContextBuilderTest.java b/skeletons/standalone-compute/src/test/java/org/jclouds/servermanager/compute/ServerManagerComputeServiceContextBuilderTest.java index ba0eeb06ff..87b85a2f84 100644 --- a/skeletons/standalone-compute/src/test/java/org/jclouds/servermanager/compute/ServerManagerComputeServiceContextBuilderTest.java +++ b/skeletons/standalone-compute/src/test/java/org/jclouds/servermanager/compute/ServerManagerComputeServiceContextBuilderTest.java @@ -22,10 +22,9 @@ import static org.testng.Assert.assertEquals; import java.util.Properties; +import org.jclouds.ContextBuilder; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextBuilder; -import org.jclouds.rest.RestContext; -import org.jclouds.servermanager.ServerManager; +import org.jclouds.lifecycle.Closer; import org.jclouds.servermanager.ServerManagerApiMetadata; import org.testng.annotations.Test; @@ -34,26 +33,20 @@ import org.testng.annotations.Test; * @author Adrian Cole * */ -@Test(groups = "unit", testName = "ServerManagerComputeServiceContextBuilderTest") +@Test(groups = "unit", testName = "ServerManagerContextBuilderTest") public class ServerManagerComputeServiceContextBuilderTest { - @Test - public void testCanBuildDirectly() { - ComputeServiceContext context = new ServerManagerComputeServiceContextBuilder() - .build(); - context.close(); - } @Test public void testCanBuildWithApiMetadata() { - ComputeServiceContext context = ComputeServiceContextBuilder.newBuilder( - new ServerManagerApiMetadata()).build(); + ComputeServiceContext context = ContextBuilder.newBuilder( + new ServerManagerApiMetadata()).build(ComputeServiceContext.class); context.close(); } @Test public void testCanBuildById() { - ComputeServiceContext context = ComputeServiceContextBuilder.newBuilder("servermanager").build(); + ComputeServiceContext context = ContextBuilder.newBuilder("servermanager").build(ComputeServiceContext.class); context.close(); } @@ -63,20 +56,17 @@ public class ServerManagerComputeServiceContextBuilderTest { overrides.setProperty("servermanager.endpoint", "http://host"); overrides.setProperty("servermanager.api-version", "1"); - ComputeServiceContext context = new ServerManagerComputeServiceContextBuilder() - .overrides(overrides).build(); + ComputeServiceContext context = ContextBuilder.newBuilder("servermanager") + .overrides(overrides).build(ComputeServiceContext.class); context.close(); } @Test - public void testProviderSpecificContextIsCorrectType() { - ComputeServiceContext context = new ServerManagerComputeServiceContextBuilder() - .build(); + public void testUnwrapIsCorrectType() { + ComputeServiceContext context = ContextBuilder.newBuilder("servermanager").build(ComputeServiceContext.class); - RestContext providerContext = context.getProviderSpecificContext(); - - assertEquals(providerContext.getApi().getClass(), ServerManager.class); + assertEquals(context.unwrap().getClass(), Closer.class); context.close(); } diff --git a/skeletons/standalone-compute/src/test/java/org/jclouds/servermanager/compute/ServerManagerComputeServiceLiveTest.java b/skeletons/standalone-compute/src/test/java/org/jclouds/servermanager/compute/ServerManagerComputeServiceLiveTest.java index e194d09a23..1d1fc7c376 100644 --- a/skeletons/standalone-compute/src/test/java/org/jclouds/servermanager/compute/ServerManagerComputeServiceLiveTest.java +++ b/skeletons/standalone-compute/src/test/java/org/jclouds/servermanager/compute/ServerManagerComputeServiceLiveTest.java @@ -21,12 +21,10 @@ package org.jclouds.servermanager.compute; import static org.jclouds.compute.util.ComputeServiceUtils.getCores; import static org.testng.Assert.assertEquals; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.Template; import org.jclouds.compute.internal.BaseComputeServiceLiveTest; -import org.jclouds.servermanager.ServerManager; import org.jclouds.ssh.jsch.config.JschSshClientModule; import org.testng.annotations.Test; @@ -36,8 +34,7 @@ import com.google.common.collect.ImmutableMap; * @author Adrian Cole */ @Test(groups = "live", enabled = true, singleThreaded = true) -public class ServerManagerComputeServiceLiveTest extends - BaseComputeServiceLiveTest> { +public class ServerManagerComputeServiceLiveTest extends BaseComputeServiceLiveTest { public ServerManagerComputeServiceLiveTest() { provider = "servermanager"; diff --git a/skeletons/standalone-compute/src/test/java/org/jclouds/servermanager/compute/ServerManagerExperimentLiveTest.java b/skeletons/standalone-compute/src/test/java/org/jclouds/servermanager/compute/ServerManagerExperimentLiveTest.java index fefa7e3879..38c5a503f9 100644 --- a/skeletons/standalone-compute/src/test/java/org/jclouds/servermanager/compute/ServerManagerExperimentLiveTest.java +++ b/skeletons/standalone-compute/src/test/java/org/jclouds/servermanager/compute/ServerManagerExperimentLiveTest.java @@ -18,10 +18,9 @@ */ package org.jclouds.servermanager.compute; +import org.jclouds.ContextBuilder; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextBuilder; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; -import org.jclouds.servermanager.ServerManager; import org.jclouds.servermanager.ServerManagerApiMetadata; import org.testng.annotations.Test; @@ -30,9 +29,7 @@ import org.testng.annotations.Test; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "ServerManagerExperimentLiveTest") -public class ServerManagerExperimentLiveTest - extends - BaseComputeServiceContextLiveTest> { +public class ServerManagerExperimentLiveTest extends BaseComputeServiceContextLiveTest { public ServerManagerExperimentLiveTest() { provider = "servermanager"; @@ -40,9 +37,9 @@ public class ServerManagerExperimentLiveTest @Test public void testAndExperiment() { - ComputeServiceContext context = null; + ComputeServiceContext context = null; try { - context = ComputeServiceContextBuilder.newBuilder(new ServerManagerApiMetadata()).build(); + context = ContextBuilder.newBuilder(new ServerManagerApiMetadata()).build(ComputeServiceContext.class); context.getComputeService().listNodes();