Last active
October 8, 2018 08:45
-
-
Save paulwellnerbou/3e309535a8a516477dc2bede478f79f2 to your computer and use it in GitHub Desktop.
Code Examples Apache Commons Configuration2 Documentation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
usersettings.properties file
isHighlightInteractedObject=false