/** * Attempts to load a message file and sets the file changed reloading * strategy on the configuration if the runtime mode is Dev. */ private PropertiesConfiguration loadLanguageConfiguration(String fileOrUrl) { PropertiesConfiguration configuration = SwissKnife .loadConfigurationInUtf8(fileOrUrl); if (configuration != null && ninjaProperties.isDev()) { // enable runtime reloading of translations in dev mode FileChangedReloadingStrategy strategy = new FileChangedReloadingStrategy(); configuration.setReloadingStrategy(strategy); } return configuration; }
.setReloadingStrategy(new FileChangedReloadingStrategy()); if (shouldReload) { externalConfiguration .setReloadingStrategy(new FileChangedReloadingStrategy());
PropertiesConfiguration configurationProperties; try { configurationProperties = new PropertiesConfiguration(propertyFileName); configurationProperties.setReloadingStrategy(new FileChangedReloadingStrategy()); } catch (ConfigurationException e) { JNotify.addWatch(propertyFileDirectory, JNotify.FILE_CREATED, false, new FileCreatedListener()); }
PropertiesConfiguration config = new PropertiesConfiguration("usergui.properties"); config.setReloadingStrategy(new FileChangedReloadingStrategy());
PropertiesConfiguration propertiesConfig = new PropertiesConfiguration("yourProps.properties"); propertiesConfig.setReloadingStrategy(new FileChangedReloadingStrategy());
PropertiesConfiguration config = new PropertiesConfiguration("usergui.properties"); config.setReloadingStrategy(new FileChangedReloadingStrategy());
private static PropertiesConfiguration getExternalConfiguration(Path config) throws ConfigurationException { PropertiesConfiguration propertiesConfiguration = initConfiguration(); LOGGER.trace("Loading configuration from file {}", config); propertiesConfiguration.load(config.toFile()); RodaPropertiesReloadStrategy rodaPropertiesReloadStrategy = new RodaPropertiesReloadStrategy(); rodaPropertiesReloadStrategy.setRefreshDelay(5000); propertiesConfiguration.setReloadingStrategy(rodaPropertiesReloadStrategy); return propertiesConfiguration; }
private static PropertiesConfiguration initPropertiesConfiguration( FileObject fileObject ) throws FileSystemException, ConfigurationException { PropertiesConfiguration propertiesConfiguration = new PropertiesConfiguration( fileObject.getURL() ); propertiesConfiguration.setAutoSave( true ); FileChangedReloadingStrategy fileChangedReloadingStrategy = new FileChangedReloadingStrategy(); fileChangedReloadingStrategy.setRefreshDelay( 1000L ); propertiesConfiguration.setReloadingStrategy( fileChangedReloadingStrategy ); return propertiesConfiguration; }
/** * Get properties from configuration file. * * @return PropertiesConfiguration object */ private static PropertiesConfiguration getConfig() { if (config == null) { synchronized (ConfigMain.class) { PropertiesConfiguration initialized = config; if (initialized == null) { PropertiesConfiguration.setDefaultListDelimiter('&'); try { initialized = new PropertiesConfiguration(CONFIG_FILE); } catch (ConfigurationException e) { logger.warn("Loading of {} failed. Trying to start with empty configuration. Exception: {}", CONFIG_FILE, e); initialized = new PropertiesConfiguration(); } initialized.setListDelimiter('&'); initialized.setReloadingStrategy(new FileChangedReloadingStrategy()); config = initialized; } } } return config; }
/** * Returns the configuration. * * @param configFile * file with configuration * @return the configuration */ static PropertiesConfiguration getConfig(String configFile) { if (Objects.isNull(config)) { synchronized (Config.class) { PropertiesConfiguration initialized = config; if (Objects.isNull(initialized)) { AbstractConfiguration.setDefaultListDelimiter('&'); try { initialized = new PropertiesConfiguration(configFile); } catch (ConfigurationException e) { logger.warn("Loading of " + configFile + " failed. Trying to start with empty configuration.", e); initialized = new PropertiesConfiguration(); } initialized.setListDelimiter('&'); initialized.setReloadingStrategy(new FileChangedReloadingStrategy()); initialized.setThrowExceptionOnMissing(true); config = initialized; } } } return config; }
propertiesConfiguration.setReloadingStrategy(new ReloadingStrategy()
PropertiesConfiguration configuration = new PropertiesConfiguration("example.properties"); configuration .setReloadingStrategy(new FileChangedReloadingStrategy()); return configuration; } catch (ConfigurationException e) {
configuration.setReloadingStrategy(configReloadingStrategy);
public class PropStandaloneConfigurationTest { public static void main(String[] args) throws ConfigurationException, InterruptedException { final PropertiesConfiguration config = new PropertiesConfiguration("app-project.properties"); config.setListDelimiter(','); config.setAutoSave(true); FileChangedReloadingStrategy reload = new FileChangedReloadingStrategy(); reload.setRefreshDelay(2000L); config.setReloadingStrategy(reload); Provider<Integer> cacheRetriesProvider = new Provider<Integer>() { @Override public Integer get() { return config.getInt("cache.retries"); } }; while (true) { System.out.println(cacheRetriesProvider.get()); Thread.sleep(3000L); } } }
conf.setReloadingStrategy(reloadingStrategy); configuration.addConfiguration(conf);
conf.setReloadingStrategy(reloadingStrategy); configuration.addConfiguration(conf);
public TajoSystemMetrics(TajoConf tajoConf, Class clazz, String hostAndPort) { super(MetricsUtil.getGroupName(clazz)); this.hostAndPort = hostAndPort; try { this.metricsPropertyFileName = tajoConf.getVar(TajoConf.ConfVars.METRICS_PROPERTY_FILENAME); this.metricsProps = new PropertiesConfiguration(metricsPropertyFileName); this.metricsProps.addConfigurationListener(new MetricsReloadListener()); FileChangedReloadingStrategy reloadingStrategy = new FileChangedReloadingStrategy(); reloadingStrategy.setRefreshDelay(5 * 1000); this.metricsProps.setReloadingStrategy(reloadingStrategy); } catch (ConfigurationException e) { LOG.warn(e.getMessage(), e); } // PropertiesConfiguration fire configurationChanged after getXXX() // So neeaded calling getXXX periodically propertyChangeChecker = new Thread() { public void run() { while(!stop.get()) { String value = metricsProps.getString("reporter.file"); try { Thread.sleep(10 * 1000); } catch (InterruptedException e) { } } } }; propertyChangeChecker.start(); }
public TajoSystemMetrics(TajoConf tajoConf, Class clazz, String hostAndPort) { super(MetricsUtil.getGroupName(clazz)); this.hostAndPort = hostAndPort; try { this.metricsPropertyFileName = tajoConf.getVar(TajoConf.ConfVars.METRICS_PROPERTY_FILENAME); this.metricsProps = new PropertiesConfiguration(metricsPropertyFileName); this.metricsProps.addConfigurationListener(new MetricsReloadListener()); FileChangedReloadingStrategy reloadingStrategy = new FileChangedReloadingStrategy(); reloadingStrategy.setRefreshDelay(5 * 1000); this.metricsProps.setReloadingStrategy(reloadingStrategy); } catch (ConfigurationException e) { LOG.warn(e.getMessage(), e); } // PropertiesConfiguration fire configurationChanged after getXXX() // So neeaded calling getXXX periodically propertyChangeChecker = new Thread() { public void run() { while(!stop.get()) { String value = metricsProps.getString("reporter.file"); try { Thread.sleep(10 * 1000); } catch (InterruptedException e) { } } } }; propertyChangeChecker.start(); }
conf.setReloadingStrategy(strategy); conf.setAutoSave(true);
/** * Does the actual work of reading the configuration from System * Properties and/or juddiv3.properties file. When the juddiv3.properties * file is updated the file will be reloaded. By default the reloadDelay is * set to 1 second to prevent excessive date stamp checking. */ private void loadConfiguration() throws ConfigurationException { //Properties from system properties CompositeConfiguration compositeConfig = new CompositeConfiguration(); compositeConfig.addConfiguration(new SystemConfiguration()); //Properties from file PropertiesConfiguration propConfig = new PropertiesConfiguration(UDDI_PROPERTIES); long refreshDelay = propConfig.getLong(Property.UDDI_CONFIGURATION_RELOAD_DELAY, 1000l); log.debug("Setting refreshDelay to " + refreshDelay); FileChangedReloadingStrategy fileChangedReloadingStrategy = new FileChangedReloadingStrategy(); fileChangedReloadingStrategy.setRefreshDelay(refreshDelay); propConfig.setReloadingStrategy(fileChangedReloadingStrategy); compositeConfig.addConfiguration(propConfig); //Making the new configuration globally accessible. config = compositeConfig; }