@Override public void configure(Binder binder) { binder.disableCircularProxies(); bindConfig(binder).to(LifeCycleConfig.class); binder.bindListener( any(), new TypeListener() { @Override public <T> void hear(TypeLiteral<T> type, TypeEncounter<T> encounter) { encounter.register( (InjectionListener<T>) obj -> { if (isLifeCycleClass(obj.getClass())) { LifeCycleManager lifeCycleManager = lifeCycleManagerRef.get(); if (lifeCycleManager != null) { try { lifeCycleManager.addInstance(obj); } catch (Exception e) { throw new RuntimeException(e); } } else { injectedInstances.add(obj); } } }); } }); }
@Override public void configure(Binder binder) { binder.requireExplicitBindings(); binder.disableCircularProxies(); binder.bind(NodeInfo.class).in(Scopes.SINGLETON); ConfigurationModule.bindConfig(binder).to(NodeConfig.class); MBeanModule.newExporter(binder).export(NodeInfo.class).withGeneratedName(); }
public void configure(Binder binder) { binder.requireExplicitBindings(); binder.disableCircularProxies(); binder.bind(PersonStore.class).in(Scopes.SINGLETON); newExporter(binder).export(PersonStore.class).withGeneratedName(); binder.bind(PersonsResource.class).in(Scopes.SINGLETON); binder.bind(PersonResource.class).in(Scopes.SINGLETON); bindConfig(binder).to(StoreConfig.class); eventBinder(binder).bindEventClient(PersonEvent.class); discoveryBinder(binder).bindHttpAnnouncement("person"); }
@Override public void configure(Binder binder) { binder.disableCircularProxies(); binder.bind(GuiceContainer.class).in(Scopes.SINGLETON); binder.bind(Servlet.class).annotatedWith(TheServlet.class).to(Key.get(GuiceContainer.class)); binder.bind(JsonMapper.class).in(Scopes.SINGLETON); binder.bind(ParsingExceptionMapper.class).in(Scopes.SINGLETON); binder.bind(TimingResourceFilterFactory.class).in(Scopes.SINGLETON); binder .bind(new TypeLiteral<Map<String, String>>() {}) .annotatedWith(TheServlet.class) .toProvider(TheServletParametersProvider.class) .in(Scopes.SINGLETON); }
@Override public void configure(Binder binder) { binder.disableCircularProxies(); binder.bind(HttpServer.class).toProvider(HttpServerProvider.class).in(Scopes.SINGLETON); binder.bind(HttpServerInfo.class).in(Scopes.SINGLETON); binder.bind(RequestStats.class).in(Scopes.SINGLETON); Multibinder.newSetBinder(binder, Filter.class, TheServlet.class); Multibinder.newSetBinder(binder, Filter.class, TheAdminServlet.class); Multibinder.newSetBinder(binder, HttpResourceBinding.class, TheServlet.class); newExporter(binder).export(RequestStats.class).withGeneratedName(); ConfigurationModule.bindConfig(binder).to(HttpServerConfig.class); eventBinder(binder).bindEventClient(HttpRequestEvent.class); binder .bind(AnnouncementHttpServerInfo.class) .to(LocalAnnouncementHttpServerInfo.class) .in(Scopes.SINGLETON); }
@Override public void configure(Binder binder) { binder.requireExplicitBindings(); binder.disableCircularProxies(); // global binder.bind(StoreResource.class).in(Scopes.SINGLETON); binder.bind(DateTime.class).toProvider(RealTimeProvider.class).in(Scopes.NO_SCOPE); ; binder.bind(SmileMapper.class).in(Scopes.SINGLETON); binder.bind(ConflictResolver.class).in(Scopes.SINGLETON); // per store Key<HttpClient> httpClientKey = Key.get(HttpClient.class, annotation); Key<LocalStore> localStoreKey = Key.get(LocalStore.class, annotation); Key<StoreConfig> storeConfigKey = Key.get(StoreConfig.class, annotation); Key<RemoteStore> remoteStoreKey = Key.get(RemoteStore.class, annotation); bindConfig(binder).annotatedWith(annotation).prefixedWith(name).to(StoreConfig.class); binder.install(new HttpClientModule(name, annotation)); binder .bind(DistributedStore.class) .annotatedWith(annotation) .toProvider( new DistributedStoreProvider(name, localStoreKey, storeConfigKey, remoteStoreKey)) .in(Scopes.SINGLETON); binder .bind(Replicator.class) .annotatedWith(annotation) .toProvider(new ReplicatorProvider(name, localStoreKey, httpClientKey, storeConfigKey)) .in(Scopes.SINGLETON); binder .bind(HttpRemoteStore.class) .annotatedWith(annotation) .toProvider(new RemoteHttpStoreProvider(name, httpClientKey, storeConfigKey)) .in(Scopes.SINGLETON); binder .bind(LocalStore.class) .annotatedWith(annotation) .to(localStoreClass) .in(Scopes.SINGLETON); binder .bind(RemoteStore.class) .annotatedWith(annotation) .to(Key.get(HttpRemoteStore.class, annotation)); newExporter(binder) .export(DistributedStore.class) .annotatedWith(annotation) .as(generatedNameOf(DistributedStore.class, named(name))); newExporter(binder) .export(HttpRemoteStore.class) .annotatedWith(annotation) .as(generatedNameOf(HttpRemoteStore.class, named(name))); newExporter(binder) .export(Replicator.class) .annotatedWith(annotation) .as(generatedNameOf(Replicator.class, named(name))); newMapBinder(binder, String.class, LocalStore.class).addBinding(name).to(localStoreKey); newMapBinder(binder, String.class, StoreConfig.class).addBinding(name).to(storeConfigKey); }
@Override public void disableCircularProxies() { binder.disableCircularProxies(); }