naming convention and warning feedback from issue #1511

This commit is contained in:
adriancole 2013-04-10 08:13:13 -07:00
parent 32c0acdb23
commit 5bc0678a1c
27 changed files with 92 additions and 97 deletions

View File

@ -18,7 +18,7 @@
*/
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.concurrent.TimeUnit;
@ -207,9 +207,9 @@ public class CloudStackRestClientModule extends RestClientModule<CloudStackClien
});
bind(CredentialType.class).toProvider(CredentialTypeFromPropertyOrDefault.class);
// session client is used directly for filters and retry handlers, so let's bind it explicitly
bindMappedHttpApi(binder(), SessionClient.class, SessionAsyncClient.class);
bindMappedHttpApi(binder(), CloudStackDomainClient.class, CloudStackDomainAsyncClient.class);
bindMappedHttpApi(binder(), CloudStackGlobalClient.class, CloudStackGlobalAsyncClient.class);
bindSyncToAsyncHttpApi(binder(), SessionClient.class, SessionAsyncClient.class);
bindSyncToAsyncHttpApi(binder(), CloudStackDomainClient.class, CloudStackDomainAsyncClient.class);
bindSyncToAsyncHttpApi(binder(), CloudStackGlobalClient.class, CloudStackGlobalAsyncClient.class);
bind(HttpRetryHandler.class).annotatedWith(ClientError.class).to(InvalidateSessionAndRetryOn401AndLogoutOnClose.class);
super.configure();

View File

@ -18,7 +18,7 @@
*/
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.AuthenticationAsyncApi;
@ -37,7 +37,7 @@ public class MappedAuthenticationApiModule extends AbstractModule {
@Override
protected void configure() {
// 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);
}
}

View File

@ -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.rackspace.cloudidentity.v2_0.config.CloudIdentityAuthenticationModule;
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.reflect.TypeToken;
@ -89,7 +89,7 @@ public class CloudIdentityApiMetadata extends KeystoneApiMetadata {
.context(CONTEXT_TOKEN)
.documentation(URI.create("http://docs.rackspace.com/auth/api/v2.0/auth-api-devguide/"))
.defaultModules(ImmutableSet.<Class<? extends Module>>builder()
.add(MappedCloudIdentityAuthenticationApiModule.class)
.add(SyncToAsyncCloudIdentityAuthenticationApiModule.class)
.add(CloudIdentityAuthenticationModule.class)
.add(KeystoneAdminURLModule.class)
.add(KeystoneParserModule.class)

View File

@ -18,7 +18,7 @@
*/
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.AuthenticationAsyncApi;
@ -36,13 +36,13 @@ import com.google.inject.Provides;
* {@link CloudIdentityAuthenticationApiModule}
*/
@Deprecated
public class MappedCloudIdentityAuthenticationApiModule extends AbstractModule {
public class SyncToAsyncCloudIdentityAuthenticationApiModule extends AbstractModule {
@Override
protected void configure() {
// AuthenticationApi is used directly for filters and retry handlers, so
// let's bind it explicitly
bindMappedHttpApi(binder(), CloudIdentityAuthenticationApi.class, CloudIdentityAuthenticationAsyncApi.class);
bindSyncToAsyncHttpApi(binder(), CloudIdentityAuthenticationApi.class, CloudIdentityAuthenticationAsyncApi.class);
}
@Provides

View File

@ -18,7 +18,7 @@
*/
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 java.util.concurrent.TimeUnit;
@ -70,7 +70,7 @@ public abstract class TemporaryUrlExtensionModule<A extends CommonSwiftAsyncClie
TemporaryUrlExtensionModule<SwiftKeystoneAsyncClient> {
protected void bindTemporaryUrlKeyApi() {
bindMappedHttpApi(binder(), TemporaryUrlKeyApi.class, KeystoneTemporaryUrlKeyAsyncApi.class);
bindSyncToAsyncHttpApi(binder(), TemporaryUrlKeyApi.class, KeystoneTemporaryUrlKeyAsyncApi.class);
}
@Override
@ -115,7 +115,7 @@ public abstract class TemporaryUrlExtensionModule<A extends CommonSwiftAsyncClie
protected abstract void bindRequestSigner();
protected void bindTemporaryUrlKeyApi() {
bindMappedHttpApi(binder(), TemporaryUrlKeyApi.class, TemporaryUrlKeyAsyncApi.class);
bindSyncToAsyncHttpApi(binder(), TemporaryUrlKeyApi.class, TemporaryUrlKeyAsyncApi.class);
}
}

View File

@ -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.uniqueIndex;
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.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_FENCEMODE;
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>>() {
}).to(new TypeLiteral<ValidateVAppTemplateAndReturnEnvelopeOrThrowIllegalArgumentException>() {
});
bindMappedHttpApi(binder(), VCloudVersionsClient.class, VCloudVersionsAsyncClient.class);
bindMappedHttpApi(binder(), VCloudLoginClient.class, VCloudLoginAsyncClient.class);
bindSyncToAsyncHttpApi(binder(), VCloudVersionsClient.class, VCloudVersionsAsyncClient.class);
bindSyncToAsyncHttpApi(binder(), VCloudLoginClient.class, VCloudLoginAsyncClient.class);
}
protected void bindCacheLoaders() {

View File

@ -19,7 +19,7 @@
package org.jclouds.openstack.config;
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.concurrent.ExecutionException;
@ -59,7 +59,7 @@ public class OpenStackAuthenticationModule extends AbstractModule {
@Override
protected void configure() {
// 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));
bind(HttpRetryHandler.class).annotatedWith(ClientError.class).to(RetryOnRenew.class);
}

View File

@ -18,7 +18,7 @@
*/
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 java.util.concurrent.ExecutionException;
@ -60,7 +60,7 @@ public class AuthenticationServiceModule extends AbstractModule {
@Override
protected void configure() {
// 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,
RegionIdToURIFromAuthForServiceSupplier.class).build(RegionIdToURISupplier.Factory.class));
install(new FactoryModuleBuilder().implement(ImplicitRegionIdSupplier.class, V1DefaultRegionIdSupplier.class)

View File

@ -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.uniqueIndex;
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.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>>>() {
}).to(new TypeLiteral<AllCatalogItemsInOrg>() {
});
bindMappedHttpApi(binder(), TerremarkVCloudVersionsClient.class, TerremarkVCloudVersionsAsyncClient.class);
bindMappedHttpApi(binder(), TerremarkVCloudLoginClient.class, TerremarkVCloudLoginAsyncClient.class);
bindSyncToAsyncHttpApi(binder(), TerremarkVCloudVersionsClient.class, TerremarkVCloudVersionsAsyncClient.class);
bindSyncToAsyncHttpApi(binder(), TerremarkVCloudLoginClient.class, TerremarkVCloudLoginAsyncClient.class);
}
@Provides

View File

@ -85,7 +85,7 @@ import org.jclouds.rest.RestApiMetadata;
import org.jclouds.rest.RestContext;
import org.jclouds.rest.config.CredentialStoreModule;
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.RestModule;
@ -524,7 +524,7 @@ public class ContextBuilder {
modules.add(new RestClientModule(typeToken(rest.getApi()), typeToken(rest.getAsyncApi())));
} else {
modules.add(new RestModule());
modules.add(new MappedHttpInvocationModule());
modules.add(new SyncToAsyncHttpInvocationModule());
}
}

View File

@ -36,12 +36,12 @@ public interface HttpApiMetadata<A> extends ApiMetadata {
/**
* @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();
}

View File

@ -25,7 +25,7 @@ import javax.inject.Singleton;
import org.jclouds.reflect.Invocation;
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.inject.Provider;
@ -39,13 +39,13 @@ import com.google.inject.TypeLiteral;
*/
@Deprecated
@Singleton
public class AnnotatedMappedHttpApiProvider<A> implements Provider<A> {
public class AnnotatedSyncToAsyncHttpApiProvider<A> implements Provider<A> {
private final Class<? super A> annotatedApiType;
private final DelegatesToPotentiallyMappedInvocationFunction<A, Function<Invocation, Object>> httpInvoker;
private final DelegatesToPotentiallySyncToAsyncInvocationFunction<A, Function<Invocation, Object>> httpInvoker;
@Inject
private AnnotatedMappedHttpApiProvider(
DelegatesToPotentiallyMappedInvocationFunction<A, Function<Invocation, Object>> httpInvoker,
private AnnotatedSyncToAsyncHttpApiProvider(
DelegatesToPotentiallySyncToAsyncInvocationFunction<A, Function<Invocation, Object>> httpInvoker,
TypeLiteral<A> annotatedApiType) {
this.httpInvoker = httpInvoker;
this.annotatedApiType = annotatedApiType.getRawType();

View File

@ -47,10 +47,9 @@ public class BinderUtils {
bindAnnotatedHttpApiProvider(binder, api);
}
@SuppressWarnings("unchecked")
@SuppressWarnings({ "unchecked", "serial" })
private static <T> void bindAnnotatedHttpApiProvider(Binder binder, Class<T> annotated) {
TypeToken<AnnotatedHttpApiProvider<T>> token = new TypeToken<AnnotatedHttpApiProvider<T>>() {
private static final long serialVersionUID = 1L;
}.where(new TypeParameter<T>() {
}, annotated);
binder.bind(annotated).toProvider(TypeLiteral.class.cast(TypeLiteral.get(token.getType())));
@ -75,10 +74,10 @@ public class BinderUtils {
* longer supported.
*/
@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, async);
bindAnnotatedMappedHttpApiProvider(binder, async);
bindAnnotatedSyncToAsyncHttpApiProvider(binder, async);
bindHttpApiProvider(binder, sync, async);
}
@ -87,10 +86,9 @@ public class BinderUtils {
* longer supported.
*/
@Deprecated
@SuppressWarnings("unchecked")
private static <T> void bindAnnotatedMappedHttpApiProvider(Binder binder, Class<T> annotated) {
TypeToken<AnnotatedMappedHttpApiProvider<T>> token = new TypeToken<AnnotatedMappedHttpApiProvider<T>>() {
private static final long serialVersionUID = 1L;
@SuppressWarnings({ "unchecked", "serial" })
private static <T> void bindAnnotatedSyncToAsyncHttpApiProvider(Binder binder, Class<T> annotated) {
TypeToken<AnnotatedSyncToAsyncHttpApiProvider<T>> token = new TypeToken<AnnotatedSyncToAsyncHttpApiProvider<T>>() {
}.where(new TypeParameter<T>() {
}, annotated);
binder.bind(annotated).toProvider(TypeLiteral.class.cast(TypeLiteral.get(token.getType())));
@ -102,10 +100,9 @@ public class BinderUtils {
* longer supported.
*/
@Deprecated
@SuppressWarnings("unchecked")
@SuppressWarnings({ "unchecked", "serial" })
private static <S, A> void bindHttpApiProvider(Binder binder, Class<S> sync, Class<A> async) {
TypeToken<MappedHttpApiProvider<S, A>> token = new TypeToken<MappedHttpApiProvider<S, A>>() {
private static final long serialVersionUID = 1L;
TypeToken<SyncToAsyncHttpApiProvider<S, A>> token = new TypeToken<SyncToAsyncHttpApiProvider<S, A>>() {
}.where(new TypeParameter<S>() {
}, sync).where(new TypeParameter<A>() {
}, async);
@ -143,20 +140,18 @@ public class BinderUtils {
* longer supported.
*/
@Deprecated
@SuppressWarnings("unchecked")
@SuppressWarnings({ "unchecked", "serial" })
private static <S, A> void bindCallGetOnFutures(Binder binder, Class<S> sync, Class<A> async) {
TypeToken<CallGetOnFuturesProvider<S, A>> token = new TypeToken<CallGetOnFuturesProvider<S, A>>() {
private static final long serialVersionUID = 1L;
}.where(new TypeParameter<S>() {
}, sync).where(new TypeParameter<A>() {
}, async);
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) {
binder.bind(TypeLiteral.class.cast(TypeLiteral.get(new TypeToken<Class<K>>() {
private static final long serialVersionUID = 1L;
}.where(new TypeParameter<K>() {
}, sync).getType()))).toInstance(sync);
}

View File

@ -24,7 +24,7 @@ import java.lang.reflect.Proxy;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.rest.internal.DelegatesToPotentiallyMappedInvocationFunction;
import org.jclouds.rest.internal.DelegatesToPotentiallySyncToAsyncInvocationFunction;
import org.jclouds.rest.internal.InvokeAndCallGetOnFutures;
import com.google.common.cache.Cache;
@ -40,15 +40,15 @@ import com.google.inject.Provider;
public class CallGetOnFuturesProvider<S, A> implements Provider<S> {
private final Class<? super S> apiType;
private final DelegatesToPotentiallyMappedInvocationFunction<S, InvokeAndCallGetOnFutures<A>> syncInvoker;
private final DelegatesToPotentiallySyncToAsyncInvocationFunction<S, InvokeAndCallGetOnFutures<A>> syncInvoker;
@Inject
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) {
this.syncInvoker = syncInvoker;
this.apiType = apiType;
MappedHttpInvocationModule.putInvokables(apiType, asyncApiType, invokables);
SyncToAsyncHttpInvocationModule.putInvokables(apiType, asyncApiType, invokables);
}
@SuppressWarnings("unchecked")

View File

@ -19,7 +19,7 @@
package org.jclouds.rest.config;
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;
@ -40,14 +40,14 @@ public class RestClientModule<S, A> extends RestModule {
protected final TypeToken<S> syncClientType;
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
* a subclass of a bound type, or natural instantiation w/resolved type params.
*/
protected RestClientModule(Map<Class<?>, Class<?>> sync2Async) {
this.invocationModule = new MappedHttpInvocationModule(sync2Async);
this.invocationModule = new SyncToAsyncHttpInvocationModule(sync2Async);
this.syncClientType = checkBound(new TypeToken<S>(getClass()) {
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.
*/
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.asyncClientType = checkBound(asyncClientType);
}
@ -83,7 +83,7 @@ public class RestClientModule<S, A> extends RestModule {
protected void configure() {
super.configure();
install(invocationModule);
bindMappedHttpApi(binder(), syncClientType.getRawType(), asyncClientType.getRawType());
bindSyncToAsyncHttpApi(binder(), syncClientType.getRawType(), asyncClientType.getRawType());
bindErrorHandlers();
bindRetryHandlers();
}

View File

@ -25,7 +25,7 @@ import javax.inject.Inject;
import javax.inject.Singleton;
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.cache.Cache;
@ -39,16 +39,16 @@ import com.google.inject.Provider;
*/
@Deprecated
@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 DelegatesToPotentiallyMappedInvocationFunction<S, Function<Invocation, Object>> httpInvoker;
private final DelegatesToPotentiallySyncToAsyncInvocationFunction<S, Function<Invocation, Object>> httpInvoker;
@Inject
private MappedHttpApiProvider(Cache<Invokable<?, ?>, Invokable<?, ?>> invokables,
DelegatesToPotentiallyMappedInvocationFunction<S, Function<Invocation, Object>> httpInvoker, Class<S> apiType, Class<A> asyncApiType) {
private SyncToAsyncHttpApiProvider(Cache<Invokable<?, ?>, Invokable<?, ?>> invokables,
DelegatesToPotentiallySyncToAsyncInvocationFunction<S, Function<Invocation, Object>> httpInvoker, Class<S> apiType, Class<A> asyncApiType) {
this.httpInvoker = httpInvoker;
this.apiType = apiType;
MappedHttpInvocationModule.putInvokables(apiType, asyncApiType, invokables);
SyncToAsyncHttpInvocationModule.putInvokables(apiType, asyncApiType, invokables);
}
@SuppressWarnings("unchecked")

View File

@ -34,9 +34,9 @@ import org.jclouds.reflect.Invocation;
import org.jclouds.rest.HttpAsyncClient;
import org.jclouds.rest.HttpClient;
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.InvokeMappedHttpMethod;
import org.jclouds.rest.internal.InvokeSyncToAsyncHttpMethod;
import com.google.common.annotations.VisibleForTesting;
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
public class MappedHttpInvocationModule extends AbstractModule {
public class SyncToAsyncHttpInvocationModule extends AbstractModule {
protected final Map<Class<?>, Class<?>> sync2Async;
public MappedHttpInvocationModule() {
public SyncToAsyncHttpInvocationModule() {
this(ImmutableMap.<Class<?>, Class<?>> of());
}
public MappedHttpInvocationModule(Map<Class<?>, Class<?>> sync2Async) {
public SyncToAsyncHttpInvocationModule(Map<Class<?>, Class<?>> sync2Async) {
this.sync2Async = sync2Async;
}
@ -71,8 +71,8 @@ public class MappedHttpInvocationModule extends AbstractModule {
bind(new TypeLiteral<Map<Class<?>, Class<?>>>() {
}).toInstance(sync2Async);
bind(new TypeLiteral<Function<Invocation, Object>>() {
}).to(InvokeMappedHttpMethod.class);
org.jclouds.rest.config.BinderUtils.bindMappedHttpApi(binder(), HttpClient.class, HttpAsyncClient.class);
}).to(InvokeSyncToAsyncHttpMethod.class);
BinderUtils.bindSyncToAsyncHttpApi(binder(), HttpClient.class, HttpAsyncClient.class);
}
/**
@ -88,7 +88,7 @@ public class MappedHttpInvocationModule extends AbstractModule {
* function view of above
*
* @see InvokeAndCallGetOnFutures
* @see InvokeMappedHttpMethod
* @see InvokeSyncToAsyncHttpMethod
*/
@Provides
@Singleton

View File

@ -84,14 +84,14 @@ public abstract class BaseHttpApiMetadata<A> extends BaseApiMetadata implements
}
private void init() {
javaApi(api)
api(api)
.name(api.getSimpleName())
.context(contextToken(typeToken(api)))
.defaultProperties(BaseHttpApiMetadata.defaultProperties());
}
@Override
public T javaApi(Class<A> api) {
public T api(Class<A> api) {
this.api = checkNotNull(api, "api");
return self();
}
@ -101,7 +101,7 @@ public abstract class BaseHttpApiMetadata<A> extends BaseApiMetadata implements
public T fromApiMetadata(ApiMetadata in) {
if (in instanceof HttpApiMetadata) {
HttpApiMetadata<?> http = HttpApiMetadata.class.cast(in);
javaApi(Class.class.cast(http.getApi()));
api(Class.class.cast(http.getApi()));
}
super.fromApiMetadata(in);
return self();

View File

@ -47,12 +47,12 @@ import com.google.inject.util.Types;
*/
@Deprecated
@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> {
private final Map<Class<?>, Class<?>> syncToAsync;
@Inject
DelegatesToPotentiallyMappedInvocationFunction(Injector injector, SetCaller setCaller, Class<S> ownerType,
DelegatesToPotentiallySyncToAsyncInvocationFunction(Injector injector, SetCaller setCaller, Class<S> ownerType,
Function<InvocationSuccess, Optional<Object>> optionalConverter, F methodInvoker,
Map<Class<?>, Class<?>> syncToAsync) {
super(injector, setCaller, ownerType, optionalConverter, methodInvoker);

View File

@ -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
public class InvokeMappedHttpMethod implements Function<Invocation, Object> {
public class InvokeSyncToAsyncHttpMethod implements Function<Invocation, Object> {
@Resource
private Logger logger = Logger.NULL;
@ -73,7 +73,7 @@ public class InvokeMappedHttpMethod implements Function<Invocation, Object> {
@Inject
@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,
TimeLimiter timeLimiter, InvocationConfig config,
@Named(PROPERTY_USER_THREADS) ListeningExecutorService userExecutor) {
@ -261,7 +261,7 @@ public class InvokeMappedHttpMethod implements Function<Invocation, Object> {
return true;
if (o == null || getClass() != o.getClass())
return false;
InvokeMappedHttpMethod that = InvokeMappedHttpMethod.class.cast(o);
InvokeSyncToAsyncHttpMethod that = InvokeSyncToAsyncHttpMethod.class.cast(o);
return equal(this.annotationProcessor, that.annotationProcessor);
}

View File

@ -54,7 +54,7 @@ public class MappedHttpInvocationModuleTest {
public void testPutInvokablesWhenInterfacesMatch() {
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);
@ -78,7 +78,7 @@ public class MappedHttpInvocationModuleTest {
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = ".* has different typed exceptions than target .*")
public void testPutInvokablesWhenInterfacesMatchExceptExceptions() {
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 {
@ -88,7 +88,7 @@ public class MappedHttpInvocationModuleTest {
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "no such method .*")
public void testPutInvokablesWhenTargetMethodNotFound() {
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<?, ?>>>() {
@ -99,7 +99,7 @@ public class MappedHttpInvocationModuleTest {
};
public void testSeedKnownSync2AsyncIncludesHttpClientByDefault() {
Map<Invokable<?, ?>, Invokable<?, ?>> cache = MappedHttpInvocationModule.seedKnownSync2AsyncInvokables(
Map<Invokable<?, ?>, Invokable<?, ?>> cache = SyncToAsyncHttpInvocationModule.seedKnownSync2AsyncInvokables(
ImmutableMap.<Class<?>, Class<?>> of()).asMap();
assertEquals(cache.size(), 6);
@ -107,7 +107,7 @@ public class MappedHttpInvocationModuleTest {
}
public void testSeedKnownSync2AsyncInvokablesInterfacesMatch() {
Map<Invokable<?, ?>, Invokable<?, ?>> cache = MappedHttpInvocationModule.seedKnownSync2AsyncInvokables(
Map<Invokable<?, ?>, Invokable<?, ?>> cache = SyncToAsyncHttpInvocationModule.seedKnownSync2AsyncInvokables(
ImmutableMap.<Class<?>, Class<?>> of(Sync.class, Async.class)).asMap();
assertEquals(cache.size(), 7);

View File

@ -37,7 +37,7 @@ import org.jclouds.http.HttpRequest;
import org.jclouds.http.HttpResponse;
import org.jclouds.reflect.Invocation;
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.BeforeClass;
import org.testng.annotations.BeforeMethod;
@ -96,7 +96,7 @@ public class InvokeMappedHttpMethodTest {
@SuppressWarnings("rawtypes")
private org.jclouds.Fallback fallback;
private InvocationConfig config;
private InvokeMappedHttpMethod invokeHttpMethod;
private InvokeSyncToAsyncHttpMethod invokeHttpMethod;
private ListenableFuture<HttpResponse> future;
@ -108,7 +108,7 @@ public class InvokeMappedHttpMethodTest {
fallback = createMock(org.jclouds.Fallback.class);
config = createMock(InvocationConfig.class);
future = createMock(ListenableFuture.class);
invokeHttpMethod = new InvokeMappedHttpMethod(sync2async, toRequest, http, transformerForRequest, timeLimiter, config,
invokeHttpMethod = new InvokeSyncToAsyncHttpMethod(sync2async, toRequest, http, transformerForRequest, timeLimiter, config,
userThreads);
expect(config.getCommandName(asyncGet)).andReturn("ns:get");
expect(config.getFallback(asyncGet)).andReturn(fallback);

View File

@ -18,7 +18,7 @@
*/
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.util.Properties;
@ -114,7 +114,7 @@ public class HPCloudObjectStorageApiMetadata extends SwiftKeystoneApiMetadata {
}
@Override
protected void bindTemporaryUrlKeyApi() {
bindMappedHttpApi(binder(), TemporaryUrlKeyApi.class, KeystoneTemporaryUrlKeyAsyncApi.class);
bindSyncToAsyncHttpApi(binder(), TemporaryUrlKeyApi.class, KeystoneTemporaryUrlKeyAsyncApi.class);
}
}
}

View File

@ -34,7 +34,7 @@ import org.jclouds.providers.ProviderMetadata;
import org.jclouds.providers.internal.BaseProviderMetadata;
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.MappedCloudIdentityAuthenticationApiModule;
import org.jclouds.rackspace.cloudidentity.v2_0.config.SyncToAsyncCloudIdentityAuthenticationApiModule;
import com.google.common.collect.ImmutableSet;
import com.google.inject.Module;
@ -83,7 +83,7 @@ public class CloudBlockStorageUKProviderMetadata extends BaseProviderMetadata {
.endpointName("identity service url ending in /v2.0/")
.documentation(URI.create("http://docs.rackspace.com/cbs/api/v1.0/cbs-devguide/content/overview.html"))
.defaultModules(ImmutableSet.<Class<? extends Module>>builder()
.add(MappedCloudIdentityAuthenticationApiModule.class)
.add(SyncToAsyncCloudIdentityAuthenticationApiModule.class)
.add(CloudIdentityAuthenticationModule.class)
.add(ZoneModule.class)
.add(CinderParserModule.class)

View File

@ -34,7 +34,7 @@ import org.jclouds.providers.ProviderMetadata;
import org.jclouds.providers.internal.BaseProviderMetadata;
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.MappedCloudIdentityAuthenticationApiModule;
import org.jclouds.rackspace.cloudidentity.v2_0.config.SyncToAsyncCloudIdentityAuthenticationApiModule;
import com.google.common.collect.ImmutableSet;
import com.google.inject.Module;
@ -84,7 +84,7 @@ public class CloudBlockStorageUSProviderMetadata extends BaseProviderMetadata {
.endpointName("identity service url ending in /v2.0/")
.documentation(URI.create("http://docs.rackspace.com/cbs/api/v1.0/cbs-devguide/content/overview.html"))
.defaultModules(ImmutableSet.<Class<? extends Module>>builder()
.add(MappedCloudIdentityAuthenticationApiModule.class)
.add(SyncToAsyncCloudIdentityAuthenticationApiModule.class)
.add(CloudIdentityAuthenticationModule.class)
.add(ZoneModule.class)
.add(CinderParserModule.class)

View File

@ -34,7 +34,7 @@ import org.jclouds.providers.ProviderMetadata;
import org.jclouds.providers.internal.BaseProviderMetadata;
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.MappedCloudIdentityAuthenticationApiModule;
import org.jclouds.rackspace.cloudidentity.v2_0.config.SyncToAsyncCloudIdentityAuthenticationApiModule;
import org.jclouds.rackspace.cloudservers.uk.config.CloudServersUKComputeServiceContextModule;
import com.google.common.collect.ImmutableSet;
@ -85,7 +85,7 @@ public class CloudServersUKProviderMetadata extends BaseProviderMetadata {
.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"))
.defaultModules(ImmutableSet.<Class<? extends Module>>builder()
.add(MappedCloudIdentityAuthenticationApiModule.class)
.add(SyncToAsyncCloudIdentityAuthenticationApiModule.class)
.add(CloudIdentityAuthenticationModule.class)
.add(ZoneModule.class)
.add(NovaParserModule.class)

View File

@ -34,7 +34,7 @@ import org.jclouds.providers.ProviderMetadata;
import org.jclouds.providers.internal.BaseProviderMetadata;
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.MappedCloudIdentityAuthenticationApiModule;
import org.jclouds.rackspace.cloudidentity.v2_0.config.SyncToAsyncCloudIdentityAuthenticationApiModule;
import org.jclouds.rackspace.cloudservers.us.config.CloudServersUSComputeServiceContextModule;
import com.google.common.collect.ImmutableSet;
@ -86,7 +86,7 @@ public class CloudServersUSProviderMetadata extends BaseProviderMetadata {
.endpointName("identity service url ending in /v2.0/")
.documentation(URI.create("http://docs.rackspace.com/loadbalancers/api/v1.0/clb-devguide/content/index.html"))
.defaultModules(ImmutableSet.<Class<? extends Module>>builder()
.add(MappedCloudIdentityAuthenticationApiModule.class)
.add(SyncToAsyncCloudIdentityAuthenticationApiModule.class)
.add(CloudIdentityAuthenticationModule.class)
.add(ZoneModule.class)
.add(NovaParserModule.class)