List of usage examples for org.apache.commons.configuration2.builder FileBasedConfigurationBuilder setAutoSave
public synchronized void setAutoSave(final boolean enabled)
From source file:com.heliosdecompiler.helios.Helios.java
private static Configuration loadConfiguration() throws IOException, ConfigurationException { Configurations configurations = new Configurations(); File file = Constants.SETTINGS_FILE_XML; if (!file.exists()) { XMLConfiguration tempConfiguration = new XMLConfiguration(); new FileHandler(tempConfiguration).save(file); }//from w w w . j av a 2 s .co m FileBasedConfigurationBuilder<XMLConfiguration> builder = configurations.xmlBuilder(file); builder.setAutoSave(true); return builder.getConfiguration(); }
From source file:com.pnf.jebauto.AutoUtil.java
/** * Create an Apache properties object out of a JEB2 configuration file. * /*from ww w.j a va 2s. co m*/ * @param path path to a JEB2 configuration file, such as jeb-client.cfg or jeb-engines.cfg * @return */ public static PropertiesConfiguration createPropertiesConfiguration(String path) { File configfile = new File(path); if (!configfile.isFile()) { try { configfile.createNewFile(); } catch (IOException e) { throw new RuntimeException(e); } } Parameters params = new Parameters(); FileBasedConfigurationBuilder<PropertiesConfiguration> builder = new FileBasedConfigurationBuilder<>( PropertiesConfiguration.class).configure(params.properties().setFileName(path)); builder.setAutoSave(true); try { return builder.getConfiguration(); } catch (ConfigurationException e) { throw new RuntimeException(e); } }
From source file:de.perdoctus.ebikeconnect.gui.cdi.ConfigurationProducer.java
@Produces public Configuration createConfiguration() throws Exception { if (!settingsPath.exists() && !settingsPath.mkdirs()) { final IOException exception = new IOException( "Could not create settings file in " + settingsPath.getAbsolutePath()); logger.error(exception.getMessage(), exception); throw exception; }//from w w w . ja va 2s . c o m final File configFile = new File(settingsPath.getAbsolutePath() + File.separatorChar + "settings"); if (!configFile.exists() && !configFile.createNewFile()) { final IOException exception = new IOException( "Could not create settings file in " + configFile.getAbsolutePath()); logger.error(exception.getMessage(), exception); throw exception; } final Configurations configurations = new Configurations(); final FileBasedConfigurationBuilder<PropertiesConfiguration> builder = configurations .propertiesBuilder(configFile); builder.setAutoSave(true); return builder.getConfiguration(); }
From source file:org.jbb.lib.properties.encrypt.PropertiesEncryptionIT.java
private void readPropertiesFile() throws ConfigurationException { String propertiesFilePath = jbbMetaData.jbbHomePath() + File.separator + "jbb-testbed.properties"; FileBasedConfigurationBuilder<PropertiesConfiguration> builder = new FileBasedConfigurationBuilder<>( PropertiesConfiguration.class).configure( new Parameters().properties().setPath(propertiesFilePath).setIncludesAllowed(false)); builder.setAutoSave(true); propFile = builder.getConfiguration(); }
From source file:org.jbb.lib.properties.FreshInstallPropertiesCreator.java
private static PropertiesConfiguration getTargetPropertiesFromJbbPath(File propertyFile) { try {/* w w w .j ava 2 s. com*/ FileBasedConfigurationBuilder<PropertiesConfiguration> builder = new FileBasedConfigurationBuilder<>( PropertiesConfiguration.class).configure( new Parameters().properties().setFile(propertyFile).setIncludesAllowed(false)); builder.setAutoSave(true); return builder.getConfiguration(); } catch (ConfigurationException e) { throw new IllegalStateException(e); } }
From source file:org.jbb.lib.properties.UpdateFilePropertyChangeListener.java
@Override public void propertyChange(PropertyChangeEvent evt) { for (String propertyFile : propFiles) { try {/*from w w w.j av a 2 s . c om*/ FileBasedConfigurationBuilder<PropertiesConfiguration> builder = new FileBasedConfigurationBuilder<>( PropertiesConfiguration.class).configure( new Parameters().properties().setFileName(propertyFile).setIncludesAllowed(false)); builder.setAutoSave(true); PropertiesConfiguration conf = builder.getConfiguration(); evt.setPropagationId(propertyFile); conf.setProperty(evt.getPropertyName(), evt.getNewValue()); } catch (ConfigurationException e) { throw new IllegalArgumentException(e); } } }
From source file:org.jbb.system.impl.install.InstallationFileManager.java
public void createInstallationFile(InstallationData installationData) { Parameters params = new Parameters(); File installFile = getInstallFile(); try {// w w w. jav a 2 s .co m FileUtils.touch(installFile); } catch (IOException e) { throw new IllegalStateException(e); } FileBasedConfigurationBuilder<FileBasedConfiguration> builder = new FileBasedConfigurationBuilder<FileBasedConfiguration>( PropertiesConfiguration.class).configure(params.fileBased().setFile(installFile)); builder.setAutoSave(true); try { FileBasedConfiguration configuration = builder.getConfiguration(); configuration.addProperty("installationId", UUID.randomUUID().toString()); configuration.addProperty("installationVersion", jbbMetaData.jbbVersion()); configuration.addProperty("installationDate", LocalDateTime.now().toString()); configuration.addProperty("boardFounderUsername", installationData.getAdminUsername()); builder.save(); } catch (ConfigurationException e) { throw new IllegalStateException(e); } }