@Inject private CallGetOnFuturesProvider(Cache<Invokable<?, ?>, Invokable<?, ?>> invokables, DelegatesToPotentiallySyncToAsyncInvocationFunction<S, InvokeAndCallGetOnFutures<A>> syncInvoker, Class<S> apiType, Class<A> asyncApiType) { this.syncInvoker = syncInvoker; this.apiType = apiType; SyncToAsyncHttpInvocationModule.putInvokables(apiType, asyncApiType, invokables); }
/** * seeds well-known invokables. */ @Provides @Singleton protected Cache<Invokable<?, ?>, Invokable<?, ?>> seedKnownSync2AsyncInvokables() { return seedKnownSync2AsyncInvokables(sync2Async); }
@Override protected void configure() { bind(new TypeLiteral<Map<Class<?>, Class<?>>>() { }).toInstance(sync2Async); bind(new TypeLiteral<Function<Invocation, Object>>() { }).to(InvokeSyncToAsyncHttpMethod.class); BinderUtils.bindSyncToAsyncHttpApi(binder(), HttpClient.class, HttpAsyncClient.class); }
/** * 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 SyncToAsyncHttpInvocationModule(sync2Async); this.syncClientType = checkBound(new TypeToken<S>(getClass()) { private static final long serialVersionUID = 1L; }); this.asyncClientType = checkBound(new TypeToken<A>(getClass()) { private static final long serialVersionUID = 1L; }); }
public static void putInvokables(Class<?> sync, Class<?> async, Cache<Invokable<?, ?>, Invokable<?, ?>> cache) { for (Invokable<?, ?> invoked : methods(sync)) { Invokable<?, ?> delegatedMethod = method(async, invoked.getName(), getParameterTypes(invoked)); checkArgument(delegatedMethod.getExceptionTypes().equals(invoked.getExceptionTypes()) || isCloseable(delegatedMethod), "invoked %s has different typed exceptions than target %s", invoked, delegatedMethod); cache.put(invoked, delegatedMethod); } }
/** * 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 SyncToAsyncHttpInvocationModule(sync2Async); this.syncClientType = checkBound(new TypeToken<S>(getClass()) { private static final long serialVersionUID = 1L; }); this.asyncClientType = checkBound(new TypeToken<A>(getClass()) { private static final long serialVersionUID = 1L; }); }
public static void putInvokables(Class<?> sync, Class<?> async, Cache<Invokable<?, ?>, Invokable<?, ?>> cache) { for (Invokable<?, ?> invoked : methods(sync)) { Invokable<?, ?> delegatedMethod = method(async, invoked.getName(), getParameterTypes(invoked)); checkArgument(delegatedMethod.getExceptionTypes().equals(invoked.getExceptionTypes()) || isCloseable(delegatedMethod), "invoked %s has different typed exceptions than target %s", invoked, delegatedMethod); cache.put(invoked, delegatedMethod); } }
@Inject private SyncToAsyncHttpApiProvider(Cache<Invokable<?, ?>, Invokable<?, ?>> invokables, DelegatesToPotentiallySyncToAsyncInvocationFunction<S, Function<Invocation, Object>> httpInvoker, Class<S> apiType, Class<A> asyncApiType) { this.httpInvoker = httpInvoker; this.apiType = apiType; SyncToAsyncHttpInvocationModule.putInvokables(apiType, asyncApiType, invokables); }
/** * 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 SyncToAsyncHttpInvocationModule(sync2Async); this.syncClientType = checkBound(new TypeToken<S>(getClass()) { private static final long serialVersionUID = 1L; }); this.asyncClientType = checkBound(new TypeToken<A>(getClass()) { private static final long serialVersionUID = 1L; }); }
@Override protected void configure() { bind(new TypeLiteral<Map<Class<?>, Class<?>>>() { }).toInstance(sync2Async); bind(new TypeLiteral<Function<Invocation, Object>>() { }).to(InvokeSyncToAsyncHttpMethod.class); BinderUtils.bindSyncToAsyncHttpApi(binder(), HttpClient.class, HttpAsyncClient.class); }
public static void putInvokables(Class<?> sync, Class<?> async, Cache<Invokable<?, ?>, Invokable<?, ?>> cache) { for (Invokable<?, ?> invoked : methods(sync)) { Invokable<?, ?> delegatedMethod = method(async, invoked.getName(), getParameterTypes(invoked)); checkArgument(delegatedMethod.getExceptionTypes().equals(invoked.getExceptionTypes()) || isCloseable(delegatedMethod), "invoked %s has different typed exceptions than target %s", invoked, delegatedMethod); cache.put(invoked, delegatedMethod); } }
/** * seeds well-known invokables. */ @Provides @Singleton protected Cache<Invokable<?, ?>, Invokable<?, ?>> seedKnownSync2AsyncInvokables() { return seedKnownSync2AsyncInvokables(sync2Async); }
@Inject private CallGetOnFuturesProvider(Cache<Invokable<?, ?>, Invokable<?, ?>> invokables, DelegatesToPotentiallySyncToAsyncInvocationFunction<S, InvokeAndCallGetOnFutures<A>> syncInvoker, Class<S> apiType, Class<A> asyncApiType) { this.syncInvoker = syncInvoker; this.apiType = apiType; SyncToAsyncHttpInvocationModule.putInvokables(apiType, asyncApiType, invokables); }
/** * 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 SyncToAsyncHttpInvocationModule(sync2Async); this.syncClientType = checkBound(syncClientType); this.asyncClientType = checkBound(asyncClientType); }
@Override protected void configure() { bind(new TypeLiteral<Map<Class<?>, Class<?>>>() { }).toInstance(sync2Async); bind(new TypeLiteral<Function<Invocation, Object>>() { }).to(InvokeSyncToAsyncHttpMethod.class); BinderUtils.bindSyncToAsyncHttpApi(binder(), HttpClient.class, HttpAsyncClient.class); }
/** * seeds well-known invokables. */ @Provides @Singleton protected Cache<Invokable<?, ?>, Invokable<?, ?>> seedKnownSync2AsyncInvokables() { return seedKnownSync2AsyncInvokables(sync2Async); }
@Inject private SyncToAsyncHttpApiProvider(Cache<Invokable<?, ?>, Invokable<?, ?>> invokables, DelegatesToPotentiallySyncToAsyncInvocationFunction<S, Function<Invocation, Object>> httpInvoker, Class<S> apiType, Class<A> asyncApiType) { this.httpInvoker = httpInvoker; this.apiType = apiType; SyncToAsyncHttpInvocationModule.putInvokables(apiType, asyncApiType, invokables); }
/** * 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 SyncToAsyncHttpInvocationModule(sync2Async); this.syncClientType = checkBound(syncClientType); this.asyncClientType = checkBound(asyncClientType); }
public void testSeedKnownSync2AsyncIncludesHttpClientByDefault() { Map<Invokable<?, ?>, Invokable<?, ?>> cache = SyncToAsyncHttpInvocationModule.seedKnownSync2AsyncInvokables( ImmutableMap.<Class<?>, Class<?>> of()).asMap(); assertEquals(cache.size(), 6); assertEquals(filterEntries(cache, isHttpInvokable), cache); }
@Inject private SyncToAsyncHttpApiProvider(Cache<Invokable<?, ?>, Invokable<?, ?>> invokables, DelegatesToPotentiallySyncToAsyncInvocationFunction<S, Function<Invocation, Object>> httpInvoker, Class<S> apiType, Class<A> asyncApiType) { this.httpInvoker = httpInvoker; this.apiType = apiType; SyncToAsyncHttpInvocationModule.putInvokables(apiType, asyncApiType, invokables); }