List of usage examples for org.apache.commons.configuration FileConfiguration reload
void reload();
From source file:gda.data.metadata.PersistantMetadataEntry.java
synchronized private FileConfiguration openConfig() throws ConfigurationException, IOException { // if (config == null) { FileConfiguration config = LocalParameters.getXMLConfiguration("persistantMetadata"); config.reload(); if (config.getString(getName()) == null) { logger.warn("No saved entry found for PersistantMetadataEntry named: '" + getName() + "'. Setting it to: '" + getDefaultValue() + "'"); // setValue(getDefaultValue()); config.setProperty(getName(), getDefaultValue()); config.save();/* w w w . j a va 2 s. c o m*/ notifyIObservers(this, getDefaultValue()); } // } return config; }
From source file:gda.util.persistence.LocalParametersTest.java
/** * Test adding properties to a configuration. * /*from ww w .j a va2 s .c om*/ * @throws Exception */ public void testAddingParameters() throws Exception { FileConfiguration lp = LocalParameters.getXMLConfiguration("newone"); lp.setProperty("gda.a.x", "value gda.a.x"); lp.setProperty("gda.a._11_", "blarghh"); lp.save(); lp.reload(); List<Object> keys = getKeysFromXMLConfiguration(lp); assertTrue(keys.size() == 2 || keys.size() == 3); assertTrue(keys.contains("gda.a.x")); assertTrue(keys.contains("gda.a._11_")); if (keys.size() == 3) { assertTrue(keys.contains("")); } }
From source file:com.twitter.distributedlog.config.ConfigurationSubscription.java
@VisibleForTesting void reload() {/* www . j a v a2 s . com*/ // No-op if already loaded. if (!initConfig()) { return; } // Reload if config exists. Set<String> confKeys = Sets.newHashSet(); for (FileConfiguration fileConfig : fileConfigs) { LOG.debug("Check and reload config, file={}, lastModified={}", fileConfig.getFile(), fileConfig.getFile().lastModified()); fileConfig.reload(); // load keys Iterator keyIter = fileConfig.getKeys(); while (keyIter.hasNext()) { String key = (String) keyIter.next(); confKeys.add(key); } } // clear unexisted keys Iterator viewIter = viewConfig.getKeys(); while (viewIter.hasNext()) { String key = (String) viewIter.next(); if (!confKeys.contains(key)) { clearViewProperty(key); } } LOG.info("Reload features : {}", confKeys); // load keys from files for (FileConfiguration fileConfig : fileConfigs) { try { loadView(fileConfig); } catch (Exception ex) { if (!fileNotFound(ex)) { LOG.error("Config reload failed for file {}", fileConfig.getFileName(), ex); } } } for (ConfigurationListener listener : confListeners) { listener.onReload(viewConfig); } }
From source file:org.betaconceptframework.astroboa.engine.definition.ContentDefinitionConfiguration.java
private void feedParserWithUserDefinedSchemas(XSOMParser xsomParser, List<FileConfiguration> repositoryDefinitionFileConfigurations) { List<String> absolutePathsOfFilesToExclude = new ArrayList<String>(); boolean feedParser = true; while (feedParser) { feedParser = false;/* ww w . j av a2 s . c o m*/ //Create XSOM Parser if (xsomParser == null) { xsomParser = createXsomParser(); } for (FileConfiguration fileConf : repositoryDefinitionFileConfigurations) { if (fileConf.getFile() == null) { logger.warn( "Found empty file configuration. This means that one of the XSD provided is not a valid xml. Parsing will continue for the rest of the xsds"); } else { String absolutePath = fileConf.getFile().getAbsolutePath(); if (!absolutePathsOfFilesToExclude.contains(absolutePath)) { logger.debug("Reloadding and parsing file {}", absolutePath); try { fileConf.reload(); xsomParser.parse(fileConf.getFile()); definitionVisitor.addXMLSchemaDefinitionForFileName( FileUtils.readFileToByteArray(fileConf.getFile()), StringUtils.substringAfterLast(absolutePath, File.separator)); } catch (Exception e) { //Just issue a warning logger.warn("Parse error for definition file " + absolutePath + " This file is excluded from building Astroboa Definitions", e); //we need to feed parser again since it sets an error flag to true //and does not produce any schemas at all. feedParser = true; absolutePathsOfFilesToExclude.add(absolutePath); xsomParser = null; definitionVisitor.clear(); break; } } } } } }