@Override public void setup(Binder binder) { bindConfig(binder).to(DiscoveryConfig.class); jaxrsBinder(binder).bind(ServiceResource.class).withApplicationPrefix(); binder.bind(InitializationTracker.class).in(Scopes.SINGLETON); discoveryBinder(binder).bindHttpAnnouncement("discovery"); // dynamic announcements jaxrsBinder(binder).bind(DynamicAnnouncementResource.class).withApplicationPrefix(); binder.bind(DynamicStore.class).to(ReplicatedDynamicStore.class).in(Scopes.SINGLETON); binder.install( new ReplicatedStoreModule("dynamic", ForDynamicStore.class, InMemoryStore.class)); // static announcements jaxrsBinder(binder).bind(StaticAnnouncementResource.class).withApplicationPrefix(); binder.bind(StaticStore.class).to(ReplicatedStaticStore.class).in(Scopes.SINGLETON); binder.install( new ReplicatedStoreModule("static", ForStaticStore.class, PersistentStore.class)); bindConfig(binder).prefixedWith("static").to(PersistentStoreConfig.class); // config-based static announcements binder.bind(ConfigStore.class).in(Scopes.SINGLETON); bindConfig(binder).to(ConfigStoreConfig.class); // proxy announcements DiscoveryConfig discoveryConfig = buildConfigObject(DiscoveryConfig.class); if (!discoveryConfig.getProxyUris().isEmpty()) { httpClientBinder(binder) .bindBalancingHttpClient( "discovery.proxy", ForProxyStore.class, discoveryConfig.getProxyUris()); } binder.bind(ProxyStore.class).in(Scopes.SINGLETON); }
/** * Returns the choice values from configured environment params. * * @param envParams map for configured parameters * @return the choice values from configured environment params. */ public Map getChoiceValues(Map envParams) { List discoveryConfigList = ProviderUtils.getAllDiscoveryConfig(); Map answer = new HashMap(); if (discoveryConfigList != null && !discoveryConfigList.isEmpty()) { for (Iterator it = discoveryConfigList.iterator(); it.hasNext(); ) { DiscoveryConfig discoConfig = (DiscoveryConfig) it.next(); answer.put(discoConfig.getName(), discoConfig.getName()); } } answer.put("[Empty]", "label.Empty"); // return the choice values map return (answer); }