Skip to content

Instantly share code, notes, and snippets.

@paulwellnerbou
Last active October 8, 2018 08:45
Show Gist options
  • Save paulwellnerbou/3e309535a8a516477dc2bede478f79f2 to your computer and use it in GitHub Desktop.
Save paulwellnerbou/3e309535a8a516477dc2bede478f79f2 to your computer and use it in GitHub Desktop.
Code Examples Apache Commons Configuration2 Documentation
/*
* First example from https://commons.apache.org/proper/commons-configuration/userguide/howto_reloading.html#Reloading_File-based_Configurations
*/
Parameters params = new Parameters();
// Read data from this file
File propertiesFile = new File("config.properties");
ReloadingFileBasedConfigurationBuilder<FileBasedConfiguration> builder =
new ReloadingFileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class)
.configure(params.fileBased()
.setFile(propertiesFile));
PeriodicReloadingTrigger trigger = new PeriodicReloadingTrigger(builder.getReloadingController(),
null, 1, TimeUnit.MINUTES);
trigger.start();
/*
* Second example from https://commons.apache.org/proper/commons-configuration/userguide/howto_reloading.html#Reloading_File-based_Configurations
*/
// Create and initialize the builder
final ReloadingFileBasedConfigurationBuilder<FileBasedConfiguration> builder =
new ReloadingFileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class)
.configure(...);
// Register an event listener for triggering reloading checks
builder.addEventListener(ConfigurationBuilderEvent.CONFIGURATION_REQUEST,
new EventListener()
{
@Override
public void onEvent(Event event)
{
builder.getReloadingController().checkForReloading(null);
}
});
}
@sameer1sharma
Copy link

usersettings.properties file
isHighlightInteractedObject=false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment