From fd3a5a3b9aa860f050645fcec1589e6951f18cba Mon Sep 17 00:00:00 2001 From: adriancole Date: Wed, 30 Jan 2013 12:51:17 -0800 Subject: [PATCH] decoupled InvokeHttpMethod, which allows circular dependencies in cloudstack to resolve --- .../java/org/jclouds/rest/config/AsyncHttpApiProvider.java | 7 ++++--- .../main/java/org/jclouds/rest/config/HttpApiProvider.java | 7 ++++--- core/src/main/java/org/jclouds/rest/config/RestModule.java | 3 +++ 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/org/jclouds/rest/config/AsyncHttpApiProvider.java b/core/src/main/java/org/jclouds/rest/config/AsyncHttpApiProvider.java index 84fc4d94cb..2765f27349 100644 --- a/core/src/main/java/org/jclouds/rest/config/AsyncHttpApiProvider.java +++ b/core/src/main/java/org/jclouds/rest/config/AsyncHttpApiProvider.java @@ -23,9 +23,10 @@ import java.lang.reflect.Proxy; import javax.inject.Inject; import javax.inject.Singleton; +import org.jclouds.reflect.Invocation; import org.jclouds.rest.internal.DelegatesToInvocationFunction; -import org.jclouds.rest.internal.InvokeHttpMethod; +import com.google.common.base.Function; import com.google.inject.Provider; import com.google.inject.TypeLiteral; @@ -36,10 +37,10 @@ import com.google.inject.TypeLiteral; @Singleton public class AsyncHttpApiProvider implements Provider { private final Class asyncApiType; - private final DelegatesToInvocationFunction httpInvoker; + private final DelegatesToInvocationFunction> httpInvoker; @Inject - private AsyncHttpApiProvider(DelegatesToInvocationFunction httpInvoker, + private AsyncHttpApiProvider(DelegatesToInvocationFunction> httpInvoker, TypeLiteral asyncApiType) { this.httpInvoker = httpInvoker; this.asyncApiType = asyncApiType.getRawType(); diff --git a/core/src/main/java/org/jclouds/rest/config/HttpApiProvider.java b/core/src/main/java/org/jclouds/rest/config/HttpApiProvider.java index 820ebe1f39..4df9f77e63 100644 --- a/core/src/main/java/org/jclouds/rest/config/HttpApiProvider.java +++ b/core/src/main/java/org/jclouds/rest/config/HttpApiProvider.java @@ -24,9 +24,10 @@ import java.lang.reflect.Proxy; import javax.inject.Inject; import javax.inject.Singleton; +import org.jclouds.reflect.Invocation; import org.jclouds.rest.internal.DelegatesToInvocationFunction; -import org.jclouds.rest.internal.InvokeHttpMethod; +import com.google.common.base.Function; import com.google.common.cache.Cache; import com.google.common.reflect.Invokable; import com.google.inject.Provider; @@ -38,11 +39,11 @@ import com.google.inject.Provider; @Singleton public class HttpApiProvider implements Provider { private final Class apiType; - private final DelegatesToInvocationFunction httpInvoker; + private final DelegatesToInvocationFunction> httpInvoker; @Inject private HttpApiProvider(Cache, Invokable> invokables, - DelegatesToInvocationFunction httpInvoker, Class apiType, Class asyncApiType) { + DelegatesToInvocationFunction> httpInvoker, Class apiType, Class asyncApiType) { this.httpInvoker = httpInvoker; this.apiType = apiType; RestModule.putInvokables(apiType, asyncApiType, invokables); 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 661adc37f9..e4819c8b44 100644 --- a/core/src/main/java/org/jclouds/rest/config/RestModule.java +++ b/core/src/main/java/org/jclouds/rest/config/RestModule.java @@ -48,6 +48,7 @@ import org.jclouds.rest.AuthorizationException; import org.jclouds.rest.HttpAsyncClient; import org.jclouds.rest.HttpClient; import org.jclouds.rest.binders.BindToJsonPayloadWrappedWith; +import org.jclouds.rest.internal.InvokeHttpMethod; import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.rest.internal.TransformerForRequest; @@ -150,6 +151,8 @@ public class RestModule extends AbstractModule { install(new FactoryModuleBuilder().build(BindToJsonPayloadWrappedWith.Factory.class)); bind(new TypeLiteral>>() { }).to(TransformerForRequest.class); + bind(new TypeLiteral>() { + }).to(InvokeHttpMethod.class); bind(new TypeLiteral>() { }).to(MapHttp4xxCodesToExceptions.class); bind(new TypeLiteral>() {