/** * 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; }); }
/** * 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; }); }
/** * 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; }); }
/** * 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); }
/** * 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); }
/** * 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); }
@SuppressWarnings({ "unchecked", "rawtypes" }) static void addClientModule(ApiMetadata apiMetadata, List<Module> modules) { // TODO: move this up if (apiMetadata instanceof HttpApiMetadata) { HttpApiMetadata api = HttpApiMetadata.class.cast(apiMetadata); modules.add(new HttpApiModule(api.getApi())); } else if (apiMetadata instanceof RestApiMetadata) { RestApiMetadata rest = RestApiMetadata.class.cast(apiMetadata); modules.add(new RestClientModule(typeToken(rest.getApi()), typeToken(rest.getAsyncApi()))); } else { modules.add(new RestModule()); modules.add(new SyncToAsyncHttpInvocationModule()); } }
@SuppressWarnings({ "unchecked", "rawtypes" }) static void addClientModule(ApiMetadata apiMetadata, List<Module> modules) { // TODO: move this up if (apiMetadata instanceof HttpApiMetadata) { HttpApiMetadata api = HttpApiMetadata.class.cast(apiMetadata); modules.add(new HttpApiModule(api.getApi())); } else if (apiMetadata instanceof RestApiMetadata) { RestApiMetadata rest = RestApiMetadata.class.cast(apiMetadata); modules.add(new RestClientModule(typeToken(rest.getApi()), typeToken(rest.getAsyncApi()))); } else { modules.add(new RestModule()); modules.add(new SyncToAsyncHttpInvocationModule()); } }
@SuppressWarnings({ "unchecked", "rawtypes" }) static void addClientModule(ApiMetadata apiMetadata, List<Module> modules) { // TODO: move this up if (apiMetadata instanceof HttpApiMetadata) { HttpApiMetadata api = HttpApiMetadata.class.cast(apiMetadata); modules.add(new HttpApiModule(api.getApi())); } else if (apiMetadata instanceof RestApiMetadata) { RestApiMetadata rest = RestApiMetadata.class.cast(apiMetadata); modules.add(new RestClientModule(typeToken(rest.getApi()), typeToken(rest.getAsyncApi()))); } else { modules.add(new RestModule()); modules.add(new SyncToAsyncHttpInvocationModule()); } }
@Override protected void configure() { install(new RestModule()); install(new SyncToAsyncHttpInvocationModule()); bind(ChefApi.class).to(TransientChefApi.class); bind(LocalBlobStore.class).annotatedWith(Names.named("databags")) .toInstance( ContextBuilder .newBuilder(new TransientApiMetadata()) .modules( ImmutableSet.<Module> of(new ExecutorServiceModule(sameThreadExecutor(), sameThreadExecutor()))).buildInjector().getInstance(LocalBlobStore.class)); }