mirror of https://github.com/apache/jclouds.git
Merge pull request #1268 from jclouds/decouple-InvokeHttpMethod
decoupled InvokeHttpMethod, which allows circular dependencies in cloudstack to resolve
This commit is contained in:
commit
d1299c9311
|
@ -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<A> implements Provider<A> {
|
||||
private final Class<? super A> asyncApiType;
|
||||
private final DelegatesToInvocationFunction<A, InvokeHttpMethod> httpInvoker;
|
||||
private final DelegatesToInvocationFunction<A, Function<Invocation, Object>> httpInvoker;
|
||||
|
||||
@Inject
|
||||
private AsyncHttpApiProvider(DelegatesToInvocationFunction<A, InvokeHttpMethod> httpInvoker,
|
||||
private AsyncHttpApiProvider(DelegatesToInvocationFunction<A, Function<Invocation, Object>> httpInvoker,
|
||||
TypeLiteral<A> asyncApiType) {
|
||||
this.httpInvoker = httpInvoker;
|
||||
this.asyncApiType = asyncApiType.getRawType();
|
||||
|
|
|
@ -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<S, A> implements Provider<S> {
|
||||
private final Class<? super S> apiType;
|
||||
private final DelegatesToInvocationFunction<S, InvokeHttpMethod> httpInvoker;
|
||||
private final DelegatesToInvocationFunction<S, Function<Invocation, Object>> httpInvoker;
|
||||
|
||||
@Inject
|
||||
private HttpApiProvider(Cache<Invokable<?, ?>, Invokable<?, ?>> invokables,
|
||||
DelegatesToInvocationFunction<S, InvokeHttpMethod> httpInvoker, Class<S> apiType, Class<A> asyncApiType) {
|
||||
DelegatesToInvocationFunction<S, Function<Invocation, Object>> httpInvoker, Class<S> apiType, Class<A> asyncApiType) {
|
||||
this.httpInvoker = httpInvoker;
|
||||
this.apiType = apiType;
|
||||
RestModule.putInvokables(apiType, asyncApiType, invokables);
|
||||
|
|
|
@ -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<Function<HttpRequest, Function<HttpResponse, ?>>>() {
|
||||
}).to(TransformerForRequest.class);
|
||||
bind(new TypeLiteral<Function<Invocation, Object>>() {
|
||||
}).to(InvokeHttpMethod.class);
|
||||
bind(new TypeLiteral<org.jclouds.Fallback<Object>>() {
|
||||
}).to(MapHttp4xxCodesToExceptions.class);
|
||||
bind(new TypeLiteral<Function<Invocation, HttpRequest>>() {
|
||||
|
|
Loading…
Reference in New Issue