mirror of https://github.com/apache/jclouds.git
naming convention and warning feedback from issue #1511
This commit is contained in:
parent
32c0acdb23
commit
5bc0678a1c
|
@ -18,7 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.cloudstack.config;
|
package org.jclouds.cloudstack.config;
|
||||||
|
|
||||||
import static org.jclouds.rest.config.BinderUtils.bindMappedHttpApi;
|
import static org.jclouds.rest.config.BinderUtils.bindSyncToAsyncHttpApi;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
@ -207,9 +207,9 @@ public class CloudStackRestClientModule extends RestClientModule<CloudStackClien
|
||||||
});
|
});
|
||||||
bind(CredentialType.class).toProvider(CredentialTypeFromPropertyOrDefault.class);
|
bind(CredentialType.class).toProvider(CredentialTypeFromPropertyOrDefault.class);
|
||||||
// session client is used directly for filters and retry handlers, so let's bind it explicitly
|
// session client is used directly for filters and retry handlers, so let's bind it explicitly
|
||||||
bindMappedHttpApi(binder(), SessionClient.class, SessionAsyncClient.class);
|
bindSyncToAsyncHttpApi(binder(), SessionClient.class, SessionAsyncClient.class);
|
||||||
bindMappedHttpApi(binder(), CloudStackDomainClient.class, CloudStackDomainAsyncClient.class);
|
bindSyncToAsyncHttpApi(binder(), CloudStackDomainClient.class, CloudStackDomainAsyncClient.class);
|
||||||
bindMappedHttpApi(binder(), CloudStackGlobalClient.class, CloudStackGlobalAsyncClient.class);
|
bindSyncToAsyncHttpApi(binder(), CloudStackGlobalClient.class, CloudStackGlobalAsyncClient.class);
|
||||||
bind(HttpRetryHandler.class).annotatedWith(ClientError.class).to(InvalidateSessionAndRetryOn401AndLogoutOnClose.class);
|
bind(HttpRetryHandler.class).annotatedWith(ClientError.class).to(InvalidateSessionAndRetryOn401AndLogoutOnClose.class);
|
||||||
|
|
||||||
super.configure();
|
super.configure();
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.openstack.keystone.v2_0.config;
|
package org.jclouds.openstack.keystone.v2_0.config;
|
||||||
|
|
||||||
import static org.jclouds.rest.config.BinderUtils.bindMappedHttpApi;
|
import static org.jclouds.rest.config.BinderUtils.bindSyncToAsyncHttpApi;
|
||||||
|
|
||||||
import org.jclouds.openstack.keystone.v2_0.AuthenticationApi;
|
import org.jclouds.openstack.keystone.v2_0.AuthenticationApi;
|
||||||
import org.jclouds.openstack.keystone.v2_0.AuthenticationAsyncApi;
|
import org.jclouds.openstack.keystone.v2_0.AuthenticationAsyncApi;
|
||||||
|
@ -37,7 +37,7 @@ public class MappedAuthenticationApiModule extends AbstractModule {
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
// AuthenticationApi is used directly for filters and retry handlers, so let's bind it explicitly
|
// AuthenticationApi is used directly for filters and retry handlers, so let's bind it explicitly
|
||||||
bindMappedHttpApi(binder(), AuthenticationApi.class, AuthenticationAsyncApi.class);
|
bindSyncToAsyncHttpApi(binder(), AuthenticationApi.class, AuthenticationAsyncApi.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ import org.jclouds.openstack.keystone.v2_0.config.KeystoneRestClientModule;
|
||||||
import org.jclouds.openstack.keystone.v2_0.config.KeystoneRestClientModule.KeystoneAdminURLModule;
|
import org.jclouds.openstack.keystone.v2_0.config.KeystoneRestClientModule.KeystoneAdminURLModule;
|
||||||
import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityAuthenticationModule;
|
import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityAuthenticationModule;
|
||||||
import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityCredentialTypes;
|
import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityCredentialTypes;
|
||||||
import org.jclouds.rackspace.cloudidentity.v2_0.config.MappedCloudIdentityAuthenticationApiModule;
|
import org.jclouds.rackspace.cloudidentity.v2_0.config.SyncToAsyncCloudIdentityAuthenticationApiModule;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.reflect.TypeToken;
|
import com.google.common.reflect.TypeToken;
|
||||||
|
@ -89,7 +89,7 @@ public class CloudIdentityApiMetadata extends KeystoneApiMetadata {
|
||||||
.context(CONTEXT_TOKEN)
|
.context(CONTEXT_TOKEN)
|
||||||
.documentation(URI.create("http://docs.rackspace.com/auth/api/v2.0/auth-api-devguide/"))
|
.documentation(URI.create("http://docs.rackspace.com/auth/api/v2.0/auth-api-devguide/"))
|
||||||
.defaultModules(ImmutableSet.<Class<? extends Module>>builder()
|
.defaultModules(ImmutableSet.<Class<? extends Module>>builder()
|
||||||
.add(MappedCloudIdentityAuthenticationApiModule.class)
|
.add(SyncToAsyncCloudIdentityAuthenticationApiModule.class)
|
||||||
.add(CloudIdentityAuthenticationModule.class)
|
.add(CloudIdentityAuthenticationModule.class)
|
||||||
.add(KeystoneAdminURLModule.class)
|
.add(KeystoneAdminURLModule.class)
|
||||||
.add(KeystoneParserModule.class)
|
.add(KeystoneParserModule.class)
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.rackspace.cloudidentity.v2_0.config;
|
package org.jclouds.rackspace.cloudidentity.v2_0.config;
|
||||||
|
|
||||||
import static org.jclouds.rest.config.BinderUtils.bindMappedHttpApi;
|
import static org.jclouds.rest.config.BinderUtils.bindSyncToAsyncHttpApi;
|
||||||
|
|
||||||
import org.jclouds.openstack.keystone.v2_0.AuthenticationApi;
|
import org.jclouds.openstack.keystone.v2_0.AuthenticationApi;
|
||||||
import org.jclouds.openstack.keystone.v2_0.AuthenticationAsyncApi;
|
import org.jclouds.openstack.keystone.v2_0.AuthenticationAsyncApi;
|
||||||
|
@ -36,13 +36,13 @@ import com.google.inject.Provides;
|
||||||
* {@link CloudIdentityAuthenticationApiModule}
|
* {@link CloudIdentityAuthenticationApiModule}
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public class MappedCloudIdentityAuthenticationApiModule extends AbstractModule {
|
public class SyncToAsyncCloudIdentityAuthenticationApiModule extends AbstractModule {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
// AuthenticationApi is used directly for filters and retry handlers, so
|
// AuthenticationApi is used directly for filters and retry handlers, so
|
||||||
// let's bind it explicitly
|
// let's bind it explicitly
|
||||||
bindMappedHttpApi(binder(), CloudIdentityAuthenticationApi.class, CloudIdentityAuthenticationAsyncApi.class);
|
bindSyncToAsyncHttpApi(binder(), CloudIdentityAuthenticationApi.class, CloudIdentityAuthenticationAsyncApi.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
|
@ -18,7 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.openstack.swift.blobstore.config;
|
package org.jclouds.openstack.swift.blobstore.config;
|
||||||
|
|
||||||
import static org.jclouds.rest.config.BinderUtils.bindMappedHttpApi;
|
import static org.jclouds.rest.config.BinderUtils.bindSyncToAsyncHttpApi;
|
||||||
import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
|
import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
|
||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
@ -70,7 +70,7 @@ public abstract class TemporaryUrlExtensionModule<A extends CommonSwiftAsyncClie
|
||||||
TemporaryUrlExtensionModule<SwiftKeystoneAsyncClient> {
|
TemporaryUrlExtensionModule<SwiftKeystoneAsyncClient> {
|
||||||
|
|
||||||
protected void bindTemporaryUrlKeyApi() {
|
protected void bindTemporaryUrlKeyApi() {
|
||||||
bindMappedHttpApi(binder(), TemporaryUrlKeyApi.class, KeystoneTemporaryUrlKeyAsyncApi.class);
|
bindSyncToAsyncHttpApi(binder(), TemporaryUrlKeyApi.class, KeystoneTemporaryUrlKeyAsyncApi.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -115,7 +115,7 @@ public abstract class TemporaryUrlExtensionModule<A extends CommonSwiftAsyncClie
|
||||||
protected abstract void bindRequestSigner();
|
protected abstract void bindRequestSigner();
|
||||||
|
|
||||||
protected void bindTemporaryUrlKeyApi() {
|
protected void bindTemporaryUrlKeyApi() {
|
||||||
bindMappedHttpApi(binder(), TemporaryUrlKeyApi.class, TemporaryUrlKeyAsyncApi.class);
|
bindSyncToAsyncHttpApi(binder(), TemporaryUrlKeyApi.class, TemporaryUrlKeyAsyncApi.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ import static com.google.common.collect.Iterables.transform;
|
||||||
import static com.google.common.collect.Maps.transformValues;
|
import static com.google.common.collect.Maps.transformValues;
|
||||||
import static com.google.common.collect.Maps.uniqueIndex;
|
import static com.google.common.collect.Maps.uniqueIndex;
|
||||||
import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
|
import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
|
||||||
import static org.jclouds.rest.config.BinderUtils.bindMappedHttpApi;
|
import static org.jclouds.rest.config.BinderUtils.bindSyncToAsyncHttpApi;
|
||||||
import static org.jclouds.util.Predicates2.retry;
|
import static org.jclouds.util.Predicates2.retry;
|
||||||
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_FENCEMODE;
|
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_FENCEMODE;
|
||||||
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED;
|
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED;
|
||||||
|
@ -206,8 +206,8 @@ public class VCloudRestClientModule extends RestClientModule<VCloudClient, VClou
|
||||||
bind(new TypeLiteral<Function<VAppTemplate, Envelope>>() {
|
bind(new TypeLiteral<Function<VAppTemplate, Envelope>>() {
|
||||||
}).to(new TypeLiteral<ValidateVAppTemplateAndReturnEnvelopeOrThrowIllegalArgumentException>() {
|
}).to(new TypeLiteral<ValidateVAppTemplateAndReturnEnvelopeOrThrowIllegalArgumentException>() {
|
||||||
});
|
});
|
||||||
bindMappedHttpApi(binder(), VCloudVersionsClient.class, VCloudVersionsAsyncClient.class);
|
bindSyncToAsyncHttpApi(binder(), VCloudVersionsClient.class, VCloudVersionsAsyncClient.class);
|
||||||
bindMappedHttpApi(binder(), VCloudLoginClient.class, VCloudLoginAsyncClient.class);
|
bindSyncToAsyncHttpApi(binder(), VCloudLoginClient.class, VCloudLoginAsyncClient.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void bindCacheLoaders() {
|
protected void bindCacheLoaders() {
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
package org.jclouds.openstack.config;
|
package org.jclouds.openstack.config;
|
||||||
|
|
||||||
import static com.google.common.base.Suppliers.memoizeWithExpiration;
|
import static com.google.common.base.Suppliers.memoizeWithExpiration;
|
||||||
import static org.jclouds.rest.config.BinderUtils.bindMappedHttpApi;
|
import static org.jclouds.rest.config.BinderUtils.bindSyncToAsyncHttpApi;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
@ -59,7 +59,7 @@ public class OpenStackAuthenticationModule extends AbstractModule {
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
// OpenStackAuthClient is used directly for filters and retry handlers, so let's bind it explicitly
|
// OpenStackAuthClient is used directly for filters and retry handlers, so let's bind it explicitly
|
||||||
bindMappedHttpApi(binder(), OpenStackAuthClient.class, OpenStackAuthAsyncClient.class);
|
bindSyncToAsyncHttpApi(binder(), OpenStackAuthClient.class, OpenStackAuthAsyncClient.class);
|
||||||
install(new FactoryModuleBuilder().build(URIFromAuthenticationResponseForService.Factory.class));
|
install(new FactoryModuleBuilder().build(URIFromAuthenticationResponseForService.Factory.class));
|
||||||
bind(HttpRetryHandler.class).annotatedWith(ClientError.class).to(RetryOnRenew.class);
|
bind(HttpRetryHandler.class).annotatedWith(ClientError.class).to(RetryOnRenew.class);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.openstack.keystone.v1_1.config;
|
package org.jclouds.openstack.keystone.v1_1.config;
|
||||||
|
|
||||||
import static org.jclouds.rest.config.BinderUtils.bindMappedHttpApi;
|
import static org.jclouds.rest.config.BinderUtils.bindSyncToAsyncHttpApi;
|
||||||
import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
|
import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
|
||||||
|
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
@ -60,7 +60,7 @@ public class AuthenticationServiceModule extends AbstractModule {
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
// ServiceClient is used directly for filters and retry handlers, so let's bind it explicitly
|
// ServiceClient is used directly for filters and retry handlers, so let's bind it explicitly
|
||||||
bindMappedHttpApi(binder(), AuthenticationClient.class, AuthenticationAsyncClient.class);
|
bindSyncToAsyncHttpApi(binder(), AuthenticationClient.class, AuthenticationAsyncClient.class);
|
||||||
install(new FactoryModuleBuilder().implement(RegionIdToURISupplier.class,
|
install(new FactoryModuleBuilder().implement(RegionIdToURISupplier.class,
|
||||||
RegionIdToURIFromAuthForServiceSupplier.class).build(RegionIdToURISupplier.Factory.class));
|
RegionIdToURIFromAuthForServiceSupplier.class).build(RegionIdToURISupplier.Factory.class));
|
||||||
install(new FactoryModuleBuilder().implement(ImplicitRegionIdSupplier.class, V1DefaultRegionIdSupplier.class)
|
install(new FactoryModuleBuilder().implement(ImplicitRegionIdSupplier.class, V1DefaultRegionIdSupplier.class)
|
||||||
|
|
|
@ -26,7 +26,7 @@ import static com.google.common.collect.Iterables.transform;
|
||||||
import static com.google.common.collect.Maps.transformValues;
|
import static com.google.common.collect.Maps.transformValues;
|
||||||
import static com.google.common.collect.Maps.uniqueIndex;
|
import static com.google.common.collect.Maps.uniqueIndex;
|
||||||
import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
|
import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
|
||||||
import static org.jclouds.rest.config.BinderUtils.bindMappedHttpApi;
|
import static org.jclouds.rest.config.BinderUtils.bindSyncToAsyncHttpApi;
|
||||||
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_TIMEOUT_TASK_COMPLETED;
|
||||||
import static org.jclouds.util.Predicates2.retry;
|
import static org.jclouds.util.Predicates2.retry;
|
||||||
|
|
||||||
|
@ -134,8 +134,8 @@ public class TerremarkVCloudRestClientModule<S, A> extends RestClientModule<S, A
|
||||||
bind(new TypeLiteral<Function<org.jclouds.trmk.vcloud_0_8.domain.Org, Iterable<? extends CatalogItem>>>() {
|
bind(new TypeLiteral<Function<org.jclouds.trmk.vcloud_0_8.domain.Org, Iterable<? extends CatalogItem>>>() {
|
||||||
}).to(new TypeLiteral<AllCatalogItemsInOrg>() {
|
}).to(new TypeLiteral<AllCatalogItemsInOrg>() {
|
||||||
});
|
});
|
||||||
bindMappedHttpApi(binder(), TerremarkVCloudVersionsClient.class, TerremarkVCloudVersionsAsyncClient.class);
|
bindSyncToAsyncHttpApi(binder(), TerremarkVCloudVersionsClient.class, TerremarkVCloudVersionsAsyncClient.class);
|
||||||
bindMappedHttpApi(binder(), TerremarkVCloudLoginClient.class, TerremarkVCloudLoginAsyncClient.class);
|
bindSyncToAsyncHttpApi(binder(), TerremarkVCloudLoginClient.class, TerremarkVCloudLoginAsyncClient.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
|
|
|
@ -85,7 +85,7 @@ import org.jclouds.rest.RestApiMetadata;
|
||||||
import org.jclouds.rest.RestContext;
|
import org.jclouds.rest.RestContext;
|
||||||
import org.jclouds.rest.config.CredentialStoreModule;
|
import org.jclouds.rest.config.CredentialStoreModule;
|
||||||
import org.jclouds.rest.config.HttpApiModule;
|
import org.jclouds.rest.config.HttpApiModule;
|
||||||
import org.jclouds.rest.config.MappedHttpInvocationModule;
|
import org.jclouds.rest.config.SyncToAsyncHttpInvocationModule;
|
||||||
import org.jclouds.rest.config.RestClientModule;
|
import org.jclouds.rest.config.RestClientModule;
|
||||||
import org.jclouds.rest.config.RestModule;
|
import org.jclouds.rest.config.RestModule;
|
||||||
|
|
||||||
|
@ -524,7 +524,7 @@ public class ContextBuilder {
|
||||||
modules.add(new RestClientModule(typeToken(rest.getApi()), typeToken(rest.getAsyncApi())));
|
modules.add(new RestClientModule(typeToken(rest.getApi()), typeToken(rest.getAsyncApi())));
|
||||||
} else {
|
} else {
|
||||||
modules.add(new RestModule());
|
modules.add(new RestModule());
|
||||||
modules.add(new MappedHttpInvocationModule());
|
modules.add(new SyncToAsyncHttpInvocationModule());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,12 +36,12 @@ public interface HttpApiMetadata<A> extends ApiMetadata {
|
||||||
/**
|
/**
|
||||||
* @see ApiMetadata#getApi()
|
* @see ApiMetadata#getApi()
|
||||||
*/
|
*/
|
||||||
T javaApi(Class<A> api);
|
T api(Class<A> api);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return the type of the api which has http annotations on its methods.
|
* @return the type of the java api which has http annotations on its methods.
|
||||||
*/
|
*/
|
||||||
Class<A> getApi();
|
Class<A> getApi();
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.reflect.Invocation;
|
import org.jclouds.reflect.Invocation;
|
||||||
import org.jclouds.rest.internal.DelegatesToInvocationFunction;
|
import org.jclouds.rest.internal.DelegatesToInvocationFunction;
|
||||||
import org.jclouds.rest.internal.DelegatesToPotentiallyMappedInvocationFunction;
|
import org.jclouds.rest.internal.DelegatesToPotentiallySyncToAsyncInvocationFunction;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.inject.Provider;
|
import com.google.inject.Provider;
|
||||||
|
@ -39,13 +39,13 @@ import com.google.inject.TypeLiteral;
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@Singleton
|
@Singleton
|
||||||
public class AnnotatedMappedHttpApiProvider<A> implements Provider<A> {
|
public class AnnotatedSyncToAsyncHttpApiProvider<A> implements Provider<A> {
|
||||||
private final Class<? super A> annotatedApiType;
|
private final Class<? super A> annotatedApiType;
|
||||||
private final DelegatesToPotentiallyMappedInvocationFunction<A, Function<Invocation, Object>> httpInvoker;
|
private final DelegatesToPotentiallySyncToAsyncInvocationFunction<A, Function<Invocation, Object>> httpInvoker;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private AnnotatedMappedHttpApiProvider(
|
private AnnotatedSyncToAsyncHttpApiProvider(
|
||||||
DelegatesToPotentiallyMappedInvocationFunction<A, Function<Invocation, Object>> httpInvoker,
|
DelegatesToPotentiallySyncToAsyncInvocationFunction<A, Function<Invocation, Object>> httpInvoker,
|
||||||
TypeLiteral<A> annotatedApiType) {
|
TypeLiteral<A> annotatedApiType) {
|
||||||
this.httpInvoker = httpInvoker;
|
this.httpInvoker = httpInvoker;
|
||||||
this.annotatedApiType = annotatedApiType.getRawType();
|
this.annotatedApiType = annotatedApiType.getRawType();
|
|
@ -47,10 +47,9 @@ public class BinderUtils {
|
||||||
bindAnnotatedHttpApiProvider(binder, api);
|
bindAnnotatedHttpApiProvider(binder, api);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings({ "unchecked", "serial" })
|
||||||
private static <T> void bindAnnotatedHttpApiProvider(Binder binder, Class<T> annotated) {
|
private static <T> void bindAnnotatedHttpApiProvider(Binder binder, Class<T> annotated) {
|
||||||
TypeToken<AnnotatedHttpApiProvider<T>> token = new TypeToken<AnnotatedHttpApiProvider<T>>() {
|
TypeToken<AnnotatedHttpApiProvider<T>> token = new TypeToken<AnnotatedHttpApiProvider<T>>() {
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
}.where(new TypeParameter<T>() {
|
}.where(new TypeParameter<T>() {
|
||||||
}, annotated);
|
}, annotated);
|
||||||
binder.bind(annotated).toProvider(TypeLiteral.class.cast(TypeLiteral.get(token.getType())));
|
binder.bind(annotated).toProvider(TypeLiteral.class.cast(TypeLiteral.get(token.getType())));
|
||||||
|
@ -75,10 +74,10 @@ public class BinderUtils {
|
||||||
* longer supported.
|
* longer supported.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static <S, A> void bindMappedHttpApi(Binder binder, Class<S> sync, Class<A> async) {
|
public static <S, A> void bindSyncToAsyncHttpApi(Binder binder, Class<S> sync, Class<A> async) {
|
||||||
bindClass(binder, sync);
|
bindClass(binder, sync);
|
||||||
bindClass(binder, async);
|
bindClass(binder, async);
|
||||||
bindAnnotatedMappedHttpApiProvider(binder, async);
|
bindAnnotatedSyncToAsyncHttpApiProvider(binder, async);
|
||||||
bindHttpApiProvider(binder, sync, async);
|
bindHttpApiProvider(binder, sync, async);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,10 +86,9 @@ public class BinderUtils {
|
||||||
* longer supported.
|
* longer supported.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings({ "unchecked", "serial" })
|
||||||
private static <T> void bindAnnotatedMappedHttpApiProvider(Binder binder, Class<T> annotated) {
|
private static <T> void bindAnnotatedSyncToAsyncHttpApiProvider(Binder binder, Class<T> annotated) {
|
||||||
TypeToken<AnnotatedMappedHttpApiProvider<T>> token = new TypeToken<AnnotatedMappedHttpApiProvider<T>>() {
|
TypeToken<AnnotatedSyncToAsyncHttpApiProvider<T>> token = new TypeToken<AnnotatedSyncToAsyncHttpApiProvider<T>>() {
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
}.where(new TypeParameter<T>() {
|
}.where(new TypeParameter<T>() {
|
||||||
}, annotated);
|
}, annotated);
|
||||||
binder.bind(annotated).toProvider(TypeLiteral.class.cast(TypeLiteral.get(token.getType())));
|
binder.bind(annotated).toProvider(TypeLiteral.class.cast(TypeLiteral.get(token.getType())));
|
||||||
|
@ -102,10 +100,9 @@ public class BinderUtils {
|
||||||
* longer supported.
|
* longer supported.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings({ "unchecked", "serial" })
|
||||||
private static <S, A> void bindHttpApiProvider(Binder binder, Class<S> sync, Class<A> async) {
|
private static <S, A> void bindHttpApiProvider(Binder binder, Class<S> sync, Class<A> async) {
|
||||||
TypeToken<MappedHttpApiProvider<S, A>> token = new TypeToken<MappedHttpApiProvider<S, A>>() {
|
TypeToken<SyncToAsyncHttpApiProvider<S, A>> token = new TypeToken<SyncToAsyncHttpApiProvider<S, A>>() {
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
}.where(new TypeParameter<S>() {
|
}.where(new TypeParameter<S>() {
|
||||||
}, sync).where(new TypeParameter<A>() {
|
}, sync).where(new TypeParameter<A>() {
|
||||||
}, async);
|
}, async);
|
||||||
|
@ -143,20 +140,18 @@ public class BinderUtils {
|
||||||
* longer supported.
|
* longer supported.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings({ "unchecked", "serial" })
|
||||||
private static <S, A> void bindCallGetOnFutures(Binder binder, Class<S> sync, Class<A> async) {
|
private static <S, A> void bindCallGetOnFutures(Binder binder, Class<S> sync, Class<A> async) {
|
||||||
TypeToken<CallGetOnFuturesProvider<S, A>> token = new TypeToken<CallGetOnFuturesProvider<S, A>>() {
|
TypeToken<CallGetOnFuturesProvider<S, A>> token = new TypeToken<CallGetOnFuturesProvider<S, A>>() {
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
}.where(new TypeParameter<S>() {
|
}.where(new TypeParameter<S>() {
|
||||||
}, sync).where(new TypeParameter<A>() {
|
}, sync).where(new TypeParameter<A>() {
|
||||||
}, async);
|
}, async);
|
||||||
binder.bind(sync).toProvider(TypeLiteral.class.cast(TypeLiteral.get(token.getType())));
|
binder.bind(sync).toProvider(TypeLiteral.class.cast(TypeLiteral.get(token.getType())));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings({ "unchecked", "serial" })
|
||||||
private static <K> void bindClass(Binder binder, Class<K> sync) {
|
private static <K> void bindClass(Binder binder, Class<K> sync) {
|
||||||
binder.bind(TypeLiteral.class.cast(TypeLiteral.get(new TypeToken<Class<K>>() {
|
binder.bind(TypeLiteral.class.cast(TypeLiteral.get(new TypeToken<Class<K>>() {
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
}.where(new TypeParameter<K>() {
|
}.where(new TypeParameter<K>() {
|
||||||
}, sync).getType()))).toInstance(sync);
|
}, sync).getType()))).toInstance(sync);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ import java.lang.reflect.Proxy;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.rest.internal.DelegatesToPotentiallyMappedInvocationFunction;
|
import org.jclouds.rest.internal.DelegatesToPotentiallySyncToAsyncInvocationFunction;
|
||||||
import org.jclouds.rest.internal.InvokeAndCallGetOnFutures;
|
import org.jclouds.rest.internal.InvokeAndCallGetOnFutures;
|
||||||
|
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.Cache;
|
||||||
|
@ -40,15 +40,15 @@ import com.google.inject.Provider;
|
||||||
public class CallGetOnFuturesProvider<S, A> implements Provider<S> {
|
public class CallGetOnFuturesProvider<S, A> implements Provider<S> {
|
||||||
|
|
||||||
private final Class<? super S> apiType;
|
private final Class<? super S> apiType;
|
||||||
private final DelegatesToPotentiallyMappedInvocationFunction<S, InvokeAndCallGetOnFutures<A>> syncInvoker;
|
private final DelegatesToPotentiallySyncToAsyncInvocationFunction<S, InvokeAndCallGetOnFutures<A>> syncInvoker;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private CallGetOnFuturesProvider(Cache<Invokable<?, ?>, Invokable<?, ?>> invokables,
|
private CallGetOnFuturesProvider(Cache<Invokable<?, ?>, Invokable<?, ?>> invokables,
|
||||||
DelegatesToPotentiallyMappedInvocationFunction<S, InvokeAndCallGetOnFutures<A>> syncInvoker, Class<S> apiType,
|
DelegatesToPotentiallySyncToAsyncInvocationFunction<S, InvokeAndCallGetOnFutures<A>> syncInvoker, Class<S> apiType,
|
||||||
Class<A> asyncApiType) {
|
Class<A> asyncApiType) {
|
||||||
this.syncInvoker = syncInvoker;
|
this.syncInvoker = syncInvoker;
|
||||||
this.apiType = apiType;
|
this.apiType = apiType;
|
||||||
MappedHttpInvocationModule.putInvokables(apiType, asyncApiType, invokables);
|
SyncToAsyncHttpInvocationModule.putInvokables(apiType, asyncApiType, invokables);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
package org.jclouds.rest.config;
|
package org.jclouds.rest.config;
|
||||||
|
|
||||||
import static org.jclouds.reflect.Types2.checkBound;
|
import static org.jclouds.reflect.Types2.checkBound;
|
||||||
import static org.jclouds.rest.config.BinderUtils.bindMappedHttpApi;
|
import static org.jclouds.rest.config.BinderUtils.bindSyncToAsyncHttpApi;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -40,14 +40,14 @@ public class RestClientModule<S, A> extends RestModule {
|
||||||
protected final TypeToken<S> syncClientType;
|
protected final TypeToken<S> syncClientType;
|
||||||
protected final TypeToken<A> asyncClientType;
|
protected final TypeToken<A> asyncClientType;
|
||||||
|
|
||||||
private final MappedHttpInvocationModule invocationModule;
|
private final SyncToAsyncHttpInvocationModule invocationModule;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Note that this ctor requires that you instantiate w/resolved generic params. For example, via
|
* Note that this ctor requires that you instantiate w/resolved generic params. For example, via
|
||||||
* a subclass of a bound type, or natural instantiation w/resolved type params.
|
* a subclass of a bound type, or natural instantiation w/resolved type params.
|
||||||
*/
|
*/
|
||||||
protected RestClientModule(Map<Class<?>, Class<?>> sync2Async) {
|
protected RestClientModule(Map<Class<?>, Class<?>> sync2Async) {
|
||||||
this.invocationModule = new MappedHttpInvocationModule(sync2Async);
|
this.invocationModule = new SyncToAsyncHttpInvocationModule(sync2Async);
|
||||||
this.syncClientType = checkBound(new TypeToken<S>(getClass()) {
|
this.syncClientType = checkBound(new TypeToken<S>(getClass()) {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
});
|
});
|
||||||
|
@ -74,7 +74,7 @@ public class RestClientModule<S, A> extends RestModule {
|
||||||
* only necessary when type params are not resolvable at runtime.
|
* only necessary when type params are not resolvable at runtime.
|
||||||
*/
|
*/
|
||||||
public RestClientModule(TypeToken<S> syncClientType, TypeToken<A> asyncClientType, Map<Class<?>, Class<?>> sync2Async) {
|
public RestClientModule(TypeToken<S> syncClientType, TypeToken<A> asyncClientType, Map<Class<?>, Class<?>> sync2Async) {
|
||||||
this.invocationModule = new MappedHttpInvocationModule(sync2Async);
|
this.invocationModule = new SyncToAsyncHttpInvocationModule(sync2Async);
|
||||||
this.syncClientType = checkBound(syncClientType);
|
this.syncClientType = checkBound(syncClientType);
|
||||||
this.asyncClientType = checkBound(asyncClientType);
|
this.asyncClientType = checkBound(asyncClientType);
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ public class RestClientModule<S, A> extends RestModule {
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
super.configure();
|
super.configure();
|
||||||
install(invocationModule);
|
install(invocationModule);
|
||||||
bindMappedHttpApi(binder(), syncClientType.getRawType(), asyncClientType.getRawType());
|
bindSyncToAsyncHttpApi(binder(), syncClientType.getRawType(), asyncClientType.getRawType());
|
||||||
bindErrorHandlers();
|
bindErrorHandlers();
|
||||||
bindRetryHandlers();
|
bindRetryHandlers();
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.reflect.Invocation;
|
import org.jclouds.reflect.Invocation;
|
||||||
import org.jclouds.rest.internal.DelegatesToPotentiallyMappedInvocationFunction;
|
import org.jclouds.rest.internal.DelegatesToPotentiallySyncToAsyncInvocationFunction;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.Cache;
|
||||||
|
@ -39,16 +39,16 @@ import com.google.inject.Provider;
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@Singleton
|
@Singleton
|
||||||
public class MappedHttpApiProvider<S, A> implements Provider<S> {
|
public class SyncToAsyncHttpApiProvider<S, A> implements Provider<S> {
|
||||||
private final Class<? super S> apiType;
|
private final Class<? super S> apiType;
|
||||||
private final DelegatesToPotentiallyMappedInvocationFunction<S, Function<Invocation, Object>> httpInvoker;
|
private final DelegatesToPotentiallySyncToAsyncInvocationFunction<S, Function<Invocation, Object>> httpInvoker;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private MappedHttpApiProvider(Cache<Invokable<?, ?>, Invokable<?, ?>> invokables,
|
private SyncToAsyncHttpApiProvider(Cache<Invokable<?, ?>, Invokable<?, ?>> invokables,
|
||||||
DelegatesToPotentiallyMappedInvocationFunction<S, Function<Invocation, Object>> httpInvoker, Class<S> apiType, Class<A> asyncApiType) {
|
DelegatesToPotentiallySyncToAsyncInvocationFunction<S, Function<Invocation, Object>> httpInvoker, Class<S> apiType, Class<A> asyncApiType) {
|
||||||
this.httpInvoker = httpInvoker;
|
this.httpInvoker = httpInvoker;
|
||||||
this.apiType = apiType;
|
this.apiType = apiType;
|
||||||
MappedHttpInvocationModule.putInvokables(apiType, asyncApiType, invokables);
|
SyncToAsyncHttpInvocationModule.putInvokables(apiType, asyncApiType, invokables);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
|
@ -34,9 +34,9 @@ import org.jclouds.reflect.Invocation;
|
||||||
import org.jclouds.rest.HttpAsyncClient;
|
import org.jclouds.rest.HttpAsyncClient;
|
||||||
import org.jclouds.rest.HttpClient;
|
import org.jclouds.rest.HttpClient;
|
||||||
import org.jclouds.rest.internal.DelegatesToInvocationFunction;
|
import org.jclouds.rest.internal.DelegatesToInvocationFunction;
|
||||||
import org.jclouds.rest.internal.DelegatesToPotentiallyMappedInvocationFunction;
|
import org.jclouds.rest.internal.DelegatesToPotentiallySyncToAsyncInvocationFunction;
|
||||||
import org.jclouds.rest.internal.InvokeAndCallGetOnFutures;
|
import org.jclouds.rest.internal.InvokeAndCallGetOnFutures;
|
||||||
import org.jclouds.rest.internal.InvokeMappedHttpMethod;
|
import org.jclouds.rest.internal.InvokeSyncToAsyncHttpMethod;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
@ -55,14 +55,14 @@ import com.google.inject.TypeLiteral;
|
||||||
* @deprecated will be removed in jclouds 1.7; use {@link HttpApiModule}
|
* @deprecated will be removed in jclouds 1.7; use {@link HttpApiModule}
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public class MappedHttpInvocationModule extends AbstractModule {
|
public class SyncToAsyncHttpInvocationModule extends AbstractModule {
|
||||||
protected final Map<Class<?>, Class<?>> sync2Async;
|
protected final Map<Class<?>, Class<?>> sync2Async;
|
||||||
|
|
||||||
public MappedHttpInvocationModule() {
|
public SyncToAsyncHttpInvocationModule() {
|
||||||
this(ImmutableMap.<Class<?>, Class<?>> of());
|
this(ImmutableMap.<Class<?>, Class<?>> of());
|
||||||
}
|
}
|
||||||
|
|
||||||
public MappedHttpInvocationModule(Map<Class<?>, Class<?>> sync2Async) {
|
public SyncToAsyncHttpInvocationModule(Map<Class<?>, Class<?>> sync2Async) {
|
||||||
this.sync2Async = sync2Async;
|
this.sync2Async = sync2Async;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,8 +71,8 @@ public class MappedHttpInvocationModule extends AbstractModule {
|
||||||
bind(new TypeLiteral<Map<Class<?>, Class<?>>>() {
|
bind(new TypeLiteral<Map<Class<?>, Class<?>>>() {
|
||||||
}).toInstance(sync2Async);
|
}).toInstance(sync2Async);
|
||||||
bind(new TypeLiteral<Function<Invocation, Object>>() {
|
bind(new TypeLiteral<Function<Invocation, Object>>() {
|
||||||
}).to(InvokeMappedHttpMethod.class);
|
}).to(InvokeSyncToAsyncHttpMethod.class);
|
||||||
org.jclouds.rest.config.BinderUtils.bindMappedHttpApi(binder(), HttpClient.class, HttpAsyncClient.class);
|
BinderUtils.bindSyncToAsyncHttpApi(binder(), HttpClient.class, HttpAsyncClient.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -88,7 +88,7 @@ public class MappedHttpInvocationModule extends AbstractModule {
|
||||||
* function view of above
|
* function view of above
|
||||||
*
|
*
|
||||||
* @see InvokeAndCallGetOnFutures
|
* @see InvokeAndCallGetOnFutures
|
||||||
* @see InvokeMappedHttpMethod
|
* @see InvokeSyncToAsyncHttpMethod
|
||||||
*/
|
*/
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
|
@ -84,14 +84,14 @@ public abstract class BaseHttpApiMetadata<A> extends BaseApiMetadata implements
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init() {
|
private void init() {
|
||||||
javaApi(api)
|
api(api)
|
||||||
.name(api.getSimpleName())
|
.name(api.getSimpleName())
|
||||||
.context(contextToken(typeToken(api)))
|
.context(contextToken(typeToken(api)))
|
||||||
.defaultProperties(BaseHttpApiMetadata.defaultProperties());
|
.defaultProperties(BaseHttpApiMetadata.defaultProperties());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T javaApi(Class<A> api) {
|
public T api(Class<A> api) {
|
||||||
this.api = checkNotNull(api, "api");
|
this.api = checkNotNull(api, "api");
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,7 @@ public abstract class BaseHttpApiMetadata<A> extends BaseApiMetadata implements
|
||||||
public T fromApiMetadata(ApiMetadata in) {
|
public T fromApiMetadata(ApiMetadata in) {
|
||||||
if (in instanceof HttpApiMetadata) {
|
if (in instanceof HttpApiMetadata) {
|
||||||
HttpApiMetadata<?> http = HttpApiMetadata.class.cast(in);
|
HttpApiMetadata<?> http = HttpApiMetadata.class.cast(in);
|
||||||
javaApi(Class.class.cast(http.getApi()));
|
api(Class.class.cast(http.getApi()));
|
||||||
}
|
}
|
||||||
super.fromApiMetadata(in);
|
super.fromApiMetadata(in);
|
||||||
return self();
|
return self();
|
||||||
|
|
|
@ -47,12 +47,12 @@ import com.google.inject.util.Types;
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@Beta
|
@Beta
|
||||||
public final class DelegatesToPotentiallyMappedInvocationFunction<S, F extends Function<Invocation, Object>> extends
|
public final class DelegatesToPotentiallySyncToAsyncInvocationFunction<S, F extends Function<Invocation, Object>> extends
|
||||||
DelegatesToInvocationFunction<S, F> {
|
DelegatesToInvocationFunction<S, F> {
|
||||||
private final Map<Class<?>, Class<?>> syncToAsync;
|
private final Map<Class<?>, Class<?>> syncToAsync;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
DelegatesToPotentiallyMappedInvocationFunction(Injector injector, SetCaller setCaller, Class<S> ownerType,
|
DelegatesToPotentiallySyncToAsyncInvocationFunction(Injector injector, SetCaller setCaller, Class<S> ownerType,
|
||||||
Function<InvocationSuccess, Optional<Object>> optionalConverter, F methodInvoker,
|
Function<InvocationSuccess, Optional<Object>> optionalConverter, F methodInvoker,
|
||||||
Map<Class<?>, Class<?>> syncToAsync) {
|
Map<Class<?>, Class<?>> syncToAsync) {
|
||||||
super(injector, setCaller, ownerType, optionalConverter, methodInvoker);
|
super(injector, setCaller, ownerType, optionalConverter, methodInvoker);
|
|
@ -58,7 +58,7 @@ import com.google.common.util.concurrent.UncheckedTimeoutException;
|
||||||
* @deprecated will be replaced in jclouds 1.7 with {@link InvokeHttpMethod}, as async interfaces are no longer supported.
|
* @deprecated will be replaced in jclouds 1.7 with {@link InvokeHttpMethod}, as async interfaces are no longer supported.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public class InvokeMappedHttpMethod implements Function<Invocation, Object> {
|
public class InvokeSyncToAsyncHttpMethod implements Function<Invocation, Object> {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private Logger logger = Logger.NULL;
|
private Logger logger = Logger.NULL;
|
||||||
|
@ -73,7 +73,7 @@ public class InvokeMappedHttpMethod implements Function<Invocation, Object> {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
InvokeMappedHttpMethod(Function<Invocation, Invocation> sync2async, Function<Invocation, HttpRequest> annotationProcessor,
|
InvokeSyncToAsyncHttpMethod(Function<Invocation, Invocation> sync2async, Function<Invocation, HttpRequest> annotationProcessor,
|
||||||
HttpCommandExecutorService http, Function<HttpRequest, Function<HttpResponse, ?>> transformerForRequest,
|
HttpCommandExecutorService http, Function<HttpRequest, Function<HttpResponse, ?>> transformerForRequest,
|
||||||
TimeLimiter timeLimiter, InvocationConfig config,
|
TimeLimiter timeLimiter, InvocationConfig config,
|
||||||
@Named(PROPERTY_USER_THREADS) ListeningExecutorService userExecutor) {
|
@Named(PROPERTY_USER_THREADS) ListeningExecutorService userExecutor) {
|
||||||
|
@ -261,7 +261,7 @@ public class InvokeMappedHttpMethod implements Function<Invocation, Object> {
|
||||||
return true;
|
return true;
|
||||||
if (o == null || getClass() != o.getClass())
|
if (o == null || getClass() != o.getClass())
|
||||||
return false;
|
return false;
|
||||||
InvokeMappedHttpMethod that = InvokeMappedHttpMethod.class.cast(o);
|
InvokeSyncToAsyncHttpMethod that = InvokeSyncToAsyncHttpMethod.class.cast(o);
|
||||||
return equal(this.annotationProcessor, that.annotationProcessor);
|
return equal(this.annotationProcessor, that.annotationProcessor);
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class MappedHttpInvocationModuleTest {
|
||||||
|
|
||||||
public void testPutInvokablesWhenInterfacesMatch() {
|
public void testPutInvokablesWhenInterfacesMatch() {
|
||||||
Cache<Invokable<?, ?>, Invokable<?, ?>> cache = CacheBuilder.newBuilder().build();
|
Cache<Invokable<?, ?>, Invokable<?, ?>> cache = CacheBuilder.newBuilder().build();
|
||||||
MappedHttpInvocationModule.putInvokables(Sync.class, Async.class, cache);
|
SyncToAsyncHttpInvocationModule.putInvokables(Sync.class, Async.class, cache);
|
||||||
|
|
||||||
assertEquals(cache.size(), 1);
|
assertEquals(cache.size(), 1);
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ public class MappedHttpInvocationModuleTest {
|
||||||
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = ".* has different typed exceptions than target .*")
|
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = ".* has different typed exceptions than target .*")
|
||||||
public void testPutInvokablesWhenInterfacesMatchExceptExceptions() {
|
public void testPutInvokablesWhenInterfacesMatchExceptExceptions() {
|
||||||
Cache<Invokable<?, ?>, Invokable<?, ?>> cache = CacheBuilder.newBuilder().build();
|
Cache<Invokable<?, ?>, Invokable<?, ?>> cache = CacheBuilder.newBuilder().build();
|
||||||
MappedHttpInvocationModule.putInvokables(Sync.class, AsyncWithException.class, cache);
|
SyncToAsyncHttpInvocationModule.putInvokables(Sync.class, AsyncWithException.class, cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static interface AsyncWithMisnamedMethod {
|
private static interface AsyncWithMisnamedMethod {
|
||||||
|
@ -88,7 +88,7 @@ public class MappedHttpInvocationModuleTest {
|
||||||
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "no such method .*")
|
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "no such method .*")
|
||||||
public void testPutInvokablesWhenTargetMethodNotFound() {
|
public void testPutInvokablesWhenTargetMethodNotFound() {
|
||||||
Cache<Invokable<?, ?>, Invokable<?, ?>> cache = CacheBuilder.newBuilder().build();
|
Cache<Invokable<?, ?>, Invokable<?, ?>> cache = CacheBuilder.newBuilder().build();
|
||||||
MappedHttpInvocationModule.putInvokables(Sync.class, AsyncWithMisnamedMethod.class, cache);
|
SyncToAsyncHttpInvocationModule.putInvokables(Sync.class, AsyncWithMisnamedMethod.class, cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
static final Predicate<Entry<Invokable<?, ?>, Invokable<?, ?>>> isHttpInvokable = new Predicate<Map.Entry<Invokable<?, ?>, Invokable<?, ?>>>() {
|
static final Predicate<Entry<Invokable<?, ?>, Invokable<?, ?>>> isHttpInvokable = new Predicate<Map.Entry<Invokable<?, ?>, Invokable<?, ?>>>() {
|
||||||
|
@ -99,7 +99,7 @@ public class MappedHttpInvocationModuleTest {
|
||||||
};
|
};
|
||||||
|
|
||||||
public void testSeedKnownSync2AsyncIncludesHttpClientByDefault() {
|
public void testSeedKnownSync2AsyncIncludesHttpClientByDefault() {
|
||||||
Map<Invokable<?, ?>, Invokable<?, ?>> cache = MappedHttpInvocationModule.seedKnownSync2AsyncInvokables(
|
Map<Invokable<?, ?>, Invokable<?, ?>> cache = SyncToAsyncHttpInvocationModule.seedKnownSync2AsyncInvokables(
|
||||||
ImmutableMap.<Class<?>, Class<?>> of()).asMap();
|
ImmutableMap.<Class<?>, Class<?>> of()).asMap();
|
||||||
|
|
||||||
assertEquals(cache.size(), 6);
|
assertEquals(cache.size(), 6);
|
||||||
|
@ -107,7 +107,7 @@ public class MappedHttpInvocationModuleTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSeedKnownSync2AsyncInvokablesInterfacesMatch() {
|
public void testSeedKnownSync2AsyncInvokablesInterfacesMatch() {
|
||||||
Map<Invokable<?, ?>, Invokable<?, ?>> cache = MappedHttpInvocationModule.seedKnownSync2AsyncInvokables(
|
Map<Invokable<?, ?>, Invokable<?, ?>> cache = SyncToAsyncHttpInvocationModule.seedKnownSync2AsyncInvokables(
|
||||||
ImmutableMap.<Class<?>, Class<?>> of(Sync.class, Async.class)).asMap();
|
ImmutableMap.<Class<?>, Class<?>> of(Sync.class, Async.class)).asMap();
|
||||||
|
|
||||||
assertEquals(cache.size(), 7);
|
assertEquals(cache.size(), 7);
|
||||||
|
|
|
@ -37,7 +37,7 @@ import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.jclouds.reflect.Invocation;
|
import org.jclouds.reflect.Invocation;
|
||||||
import org.jclouds.rest.config.InvocationConfig;
|
import org.jclouds.rest.config.InvocationConfig;
|
||||||
import org.jclouds.rest.internal.InvokeMappedHttpMethod.InvokeAndTransform;
|
import org.jclouds.rest.internal.InvokeSyncToAsyncHttpMethod.InvokeAndTransform;
|
||||||
import org.testng.annotations.AfterMethod;
|
import org.testng.annotations.AfterMethod;
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.BeforeMethod;
|
import org.testng.annotations.BeforeMethod;
|
||||||
|
@ -96,7 +96,7 @@ public class InvokeMappedHttpMethodTest {
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
private org.jclouds.Fallback fallback;
|
private org.jclouds.Fallback fallback;
|
||||||
private InvocationConfig config;
|
private InvocationConfig config;
|
||||||
private InvokeMappedHttpMethod invokeHttpMethod;
|
private InvokeSyncToAsyncHttpMethod invokeHttpMethod;
|
||||||
|
|
||||||
private ListenableFuture<HttpResponse> future;
|
private ListenableFuture<HttpResponse> future;
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ public class InvokeMappedHttpMethodTest {
|
||||||
fallback = createMock(org.jclouds.Fallback.class);
|
fallback = createMock(org.jclouds.Fallback.class);
|
||||||
config = createMock(InvocationConfig.class);
|
config = createMock(InvocationConfig.class);
|
||||||
future = createMock(ListenableFuture.class);
|
future = createMock(ListenableFuture.class);
|
||||||
invokeHttpMethod = new InvokeMappedHttpMethod(sync2async, toRequest, http, transformerForRequest, timeLimiter, config,
|
invokeHttpMethod = new InvokeSyncToAsyncHttpMethod(sync2async, toRequest, http, transformerForRequest, timeLimiter, config,
|
||||||
userThreads);
|
userThreads);
|
||||||
expect(config.getCommandName(asyncGet)).andReturn("ns:get");
|
expect(config.getCommandName(asyncGet)).andReturn("ns:get");
|
||||||
expect(config.getFallback(asyncGet)).andReturn(fallback);
|
expect(config.getFallback(asyncGet)).andReturn(fallback);
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.hpcloud.objectstorage;
|
package org.jclouds.hpcloud.objectstorage;
|
||||||
|
|
||||||
import static org.jclouds.rest.config.BinderUtils.bindMappedHttpApi;
|
import static org.jclouds.rest.config.BinderUtils.bindSyncToAsyncHttpApi;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
@ -114,7 +114,7 @@ public class HPCloudObjectStorageApiMetadata extends SwiftKeystoneApiMetadata {
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
protected void bindTemporaryUrlKeyApi() {
|
protected void bindTemporaryUrlKeyApi() {
|
||||||
bindMappedHttpApi(binder(), TemporaryUrlKeyApi.class, KeystoneTemporaryUrlKeyAsyncApi.class);
|
bindSyncToAsyncHttpApi(binder(), TemporaryUrlKeyApi.class, KeystoneTemporaryUrlKeyAsyncApi.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ import org.jclouds.providers.ProviderMetadata;
|
||||||
import org.jclouds.providers.internal.BaseProviderMetadata;
|
import org.jclouds.providers.internal.BaseProviderMetadata;
|
||||||
import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityAuthenticationModule;
|
import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityAuthenticationModule;
|
||||||
import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityCredentialTypes;
|
import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityCredentialTypes;
|
||||||
import org.jclouds.rackspace.cloudidentity.v2_0.config.MappedCloudIdentityAuthenticationApiModule;
|
import org.jclouds.rackspace.cloudidentity.v2_0.config.SyncToAsyncCloudIdentityAuthenticationApiModule;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
|
@ -83,7 +83,7 @@ public class CloudBlockStorageUKProviderMetadata extends BaseProviderMetadata {
|
||||||
.endpointName("identity service url ending in /v2.0/")
|
.endpointName("identity service url ending in /v2.0/")
|
||||||
.documentation(URI.create("http://docs.rackspace.com/cbs/api/v1.0/cbs-devguide/content/overview.html"))
|
.documentation(URI.create("http://docs.rackspace.com/cbs/api/v1.0/cbs-devguide/content/overview.html"))
|
||||||
.defaultModules(ImmutableSet.<Class<? extends Module>>builder()
|
.defaultModules(ImmutableSet.<Class<? extends Module>>builder()
|
||||||
.add(MappedCloudIdentityAuthenticationApiModule.class)
|
.add(SyncToAsyncCloudIdentityAuthenticationApiModule.class)
|
||||||
.add(CloudIdentityAuthenticationModule.class)
|
.add(CloudIdentityAuthenticationModule.class)
|
||||||
.add(ZoneModule.class)
|
.add(ZoneModule.class)
|
||||||
.add(CinderParserModule.class)
|
.add(CinderParserModule.class)
|
||||||
|
|
|
@ -34,7 +34,7 @@ import org.jclouds.providers.ProviderMetadata;
|
||||||
import org.jclouds.providers.internal.BaseProviderMetadata;
|
import org.jclouds.providers.internal.BaseProviderMetadata;
|
||||||
import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityAuthenticationModule;
|
import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityAuthenticationModule;
|
||||||
import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityCredentialTypes;
|
import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityCredentialTypes;
|
||||||
import org.jclouds.rackspace.cloudidentity.v2_0.config.MappedCloudIdentityAuthenticationApiModule;
|
import org.jclouds.rackspace.cloudidentity.v2_0.config.SyncToAsyncCloudIdentityAuthenticationApiModule;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
|
@ -84,7 +84,7 @@ public class CloudBlockStorageUSProviderMetadata extends BaseProviderMetadata {
|
||||||
.endpointName("identity service url ending in /v2.0/")
|
.endpointName("identity service url ending in /v2.0/")
|
||||||
.documentation(URI.create("http://docs.rackspace.com/cbs/api/v1.0/cbs-devguide/content/overview.html"))
|
.documentation(URI.create("http://docs.rackspace.com/cbs/api/v1.0/cbs-devguide/content/overview.html"))
|
||||||
.defaultModules(ImmutableSet.<Class<? extends Module>>builder()
|
.defaultModules(ImmutableSet.<Class<? extends Module>>builder()
|
||||||
.add(MappedCloudIdentityAuthenticationApiModule.class)
|
.add(SyncToAsyncCloudIdentityAuthenticationApiModule.class)
|
||||||
.add(CloudIdentityAuthenticationModule.class)
|
.add(CloudIdentityAuthenticationModule.class)
|
||||||
.add(ZoneModule.class)
|
.add(ZoneModule.class)
|
||||||
.add(CinderParserModule.class)
|
.add(CinderParserModule.class)
|
||||||
|
|
|
@ -34,7 +34,7 @@ import org.jclouds.providers.ProviderMetadata;
|
||||||
import org.jclouds.providers.internal.BaseProviderMetadata;
|
import org.jclouds.providers.internal.BaseProviderMetadata;
|
||||||
import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityAuthenticationModule;
|
import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityAuthenticationModule;
|
||||||
import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityCredentialTypes;
|
import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityCredentialTypes;
|
||||||
import org.jclouds.rackspace.cloudidentity.v2_0.config.MappedCloudIdentityAuthenticationApiModule;
|
import org.jclouds.rackspace.cloudidentity.v2_0.config.SyncToAsyncCloudIdentityAuthenticationApiModule;
|
||||||
import org.jclouds.rackspace.cloudservers.uk.config.CloudServersUKComputeServiceContextModule;
|
import org.jclouds.rackspace.cloudservers.uk.config.CloudServersUKComputeServiceContextModule;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
@ -85,7 +85,7 @@ public class CloudServersUKProviderMetadata extends BaseProviderMetadata {
|
||||||
.endpointName("identity service url ending in /v2.0/")
|
.endpointName("identity service url ending in /v2.0/")
|
||||||
.documentation(URI.create("http://docs.rackspace.com/servers/api/v2/cs-devguide/content/ch_preface.html#webhelp-currentid"))
|
.documentation(URI.create("http://docs.rackspace.com/servers/api/v2/cs-devguide/content/ch_preface.html#webhelp-currentid"))
|
||||||
.defaultModules(ImmutableSet.<Class<? extends Module>>builder()
|
.defaultModules(ImmutableSet.<Class<? extends Module>>builder()
|
||||||
.add(MappedCloudIdentityAuthenticationApiModule.class)
|
.add(SyncToAsyncCloudIdentityAuthenticationApiModule.class)
|
||||||
.add(CloudIdentityAuthenticationModule.class)
|
.add(CloudIdentityAuthenticationModule.class)
|
||||||
.add(ZoneModule.class)
|
.add(ZoneModule.class)
|
||||||
.add(NovaParserModule.class)
|
.add(NovaParserModule.class)
|
||||||
|
|
|
@ -34,7 +34,7 @@ import org.jclouds.providers.ProviderMetadata;
|
||||||
import org.jclouds.providers.internal.BaseProviderMetadata;
|
import org.jclouds.providers.internal.BaseProviderMetadata;
|
||||||
import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityAuthenticationModule;
|
import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityAuthenticationModule;
|
||||||
import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityCredentialTypes;
|
import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityCredentialTypes;
|
||||||
import org.jclouds.rackspace.cloudidentity.v2_0.config.MappedCloudIdentityAuthenticationApiModule;
|
import org.jclouds.rackspace.cloudidentity.v2_0.config.SyncToAsyncCloudIdentityAuthenticationApiModule;
|
||||||
import org.jclouds.rackspace.cloudservers.us.config.CloudServersUSComputeServiceContextModule;
|
import org.jclouds.rackspace.cloudservers.us.config.CloudServersUSComputeServiceContextModule;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
@ -86,7 +86,7 @@ public class CloudServersUSProviderMetadata extends BaseProviderMetadata {
|
||||||
.endpointName("identity service url ending in /v2.0/")
|
.endpointName("identity service url ending in /v2.0/")
|
||||||
.documentation(URI.create("http://docs.rackspace.com/loadbalancers/api/v1.0/clb-devguide/content/index.html"))
|
.documentation(URI.create("http://docs.rackspace.com/loadbalancers/api/v1.0/clb-devguide/content/index.html"))
|
||||||
.defaultModules(ImmutableSet.<Class<? extends Module>>builder()
|
.defaultModules(ImmutableSet.<Class<? extends Module>>builder()
|
||||||
.add(MappedCloudIdentityAuthenticationApiModule.class)
|
.add(SyncToAsyncCloudIdentityAuthenticationApiModule.class)
|
||||||
.add(CloudIdentityAuthenticationModule.class)
|
.add(CloudIdentityAuthenticationModule.class)
|
||||||
.add(ZoneModule.class)
|
.add(ZoneModule.class)
|
||||||
.add(NovaParserModule.class)
|
.add(NovaParserModule.class)
|
||||||
|
|
Loading…
Reference in New Issue