I am using cfg4j library for reflecting the changes in the beans on changes in the config files (auto-reload/refresh)
public ConfigurationProvider getConfigurationProvider()
{
ConfigFilesProvider configFilesProvider = () -> Arrays.asList(Paths.get("session.properties"));
ConfigurationSource source = new FilesConfigurationSource(configFilesProvider);
Environment environment = new ImmutableEnvironment("/home/boss/");
ReloadStrategy reloadStrategy = new PeriodicalReloadStrategy(5, TimeUnit.SECONDS);
return new ConfigurationProviderBuilder()
.withConfigurationSource(source)
.withEnvironment(environment)
.withReloadStrategy(reloadStrategy)
.build();
}
...
//Binding on the class with Provider
getConfigurationProvider().bind("session-config",SessionConfig.class);
Now the existing application also has existing guice binding
import static io.airlift.configuration.ConfigBinder.configBinder;
...
Bootstrap app = new Bootstrap(
new ClientModule(),
binder -> {
configBinder(binder).bindConfig(SessionConfig.class);
});
My question is : if we add additional binding
getConfigurationProvider().bind("sample-config",SessionConfig.class);
How can I use the same instance of the class SessionConfig or will the same instance of the class be used in both the bindings?
PS: I am using airlift framework for guice bindings used in presto.