I'm working on a Spring App where I need to access all the property files kept inside a folder. I tried the ReloadingCombinedConfigurationBuilder approach but the configuration is updated only once and then further file changes don't appear. Here is the code I am using:
ReloadingCombinedConfigurationBuilder combinedBuilder = new ReloadingCombinedConfigurationBuilder()
.configure(params.fileBased().setFile(new File("configuration.xml")));
Here is my configuration.xml:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<configuration>
<properties fileName="{absolute-path}/a.properties" config-reload="true" reloadingRefreshDelay="10000"/>
<properties fileName="{absolute-path}/b.properties" config-reload="true"/>
</configuration>
Then I add few properties Configuration programmatically. If I do not add a Configuration programmatically combinedBuilder.getReloadingController() returns null while setting trigger.
Configuration config = builder.getConfiguration();
combinedBuilder.getConfiguration().addConfiguration(myFileBasedConfigurationBuilderconfig.getConfiguration());
And start the trigger:
PeriodicReloadingTrigger trigger = new PeriodicReloadingTrigger(
combinedBuilder.getReloadingController(), null, 5, TimeUnit.SECONDS);
trigger.start();
When I execute it and change the properties file the change is reflected once & then it stops providing changed values.
Suggestions are welcome.