public void configure(Binder binder) { binder.disableCircularProxies(); binder.requireExplicitBindings(); binder.bind(Agent.class).in(Scopes.SINGLETON); MBeanModule.newExporter(binder).export(Agent.class).withGeneratedName(); binder.bind(AgentResource.class).in(Scopes.SINGLETON); binder.bind(SlotResource.class).in(Scopes.SINGLETON); binder.bind(AssignmentResource.class).in(Scopes.SINGLETON); binder.bind(LifecycleResource.class).in(Scopes.SINGLETON); binder.bind(VersionConflictExceptionMapper.class).in(Scopes.SINGLETON); binder.bind(DeploymentManagerFactory.class).to(DirectoryDeploymentManagerFactory.class).in(Scopes.SINGLETON); binder.bind(LifecycleManager.class).to(LauncherLifecycleManager.class).in(Scopes.SINGLETON); binder.bind(ServiceInventoryResource.class).in(Scopes.SINGLETON); ConfigurationModule.bindConfig(binder).to(AgentConfig.class); } }
@Override protected void installJMX() { super.installJMX(); final ExportBuilder builder = MBeanModule.newExporter(binder()); for (final Class beanClass : beans) { builder.export(beanClass).withGeneratedName(); } if (log4jEnabled) { builder.export(Log4JMBean.class).withGeneratedName(); } }
@Override public void configure(Binder binder) { // bind service inventory binder.bind(ServiceInventory.class).in(Scopes.SINGLETON); bindConfig(binder).to(ServiceInventoryConfig.class); // for legacy configurations bindConfig(binder).to(DiscoveryClientConfig.class); // bind discovery client and dependencies binder.bind(DiscoveryLookupClient.class).to(HttpDiscoveryLookupClient.class).in(Scopes.SINGLETON); binder.bind(DiscoveryAnnouncementClient.class).to(HttpDiscoveryAnnouncementClient.class).in(Scopes.SINGLETON); jsonCodecBinder(binder).bindJsonCodec(ServiceDescriptorsRepresentation.class); jsonCodecBinder(binder).bindJsonCodec(Announcement.class); // bind the http client httpClientBinder(binder).bindAsyncHttpClient("discovery", ForDiscoveryClient.class); // bind announcer binder.bind(Announcer.class).in(Scopes.SINGLETON); // Must create a multibinder for service announcements or construction will fail if no // service announcements are bound, which is legal for processes that don't have public services Multibinder.newSetBinder(binder, ServiceAnnouncement.class); binder.bind(ServiceSelectorFactory.class).to(CachingServiceSelectorFactory.class).in(Scopes.SINGLETON); MBeanModule.newExporter(binder).export(ServiceInventory.class).withGeneratedName(); }