use of org.apache.commons.configuration2.sync.ReadWriteSynchronizer in project vcell by virtualcell.
the class VCellConfiguration method getConfiguration.
private static synchronized Configuration getConfiguration() throws ConfigurationException {
if (configurationBuilder == null) {
Parameters params = new Parameters();
File propertiesFile = new File(ResourceUtil.getVcellHome(), "vcellconfig.properties");
if (!propertiesFile.exists()) {
try {
propertiesFile.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
FileBasedBuilderParameters thing = params.fileBased().setFile(propertiesFile);
configurationBuilder = new FileBasedConfigurationBuilder<PropertiesConfiguration>(PropertiesConfiguration.class).configure(thing);
configurationBuilder.setAutoSave(true);
try {
propertiesConfiguration = configurationBuilder.getConfiguration();
propertiesConfiguration.setSynchronizer(new ReadWriteSynchronizer());
} catch (org.apache.commons.configuration2.ex.ConfigurationException e) {
e.printStackTrace();
throw new ConfigurationException("failed to create configuration from file " + propertiesFile + ": " + e.getMessage());
}
}
return propertiesConfiguration;
}
Aggregations