Java Code Examples for org.apache.commons.configuration.FileConfiguration

The following examples show how to use org.apache.commons.configuration.FileConfiguration. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: distributedlog   Source File: ConfigurationSubscription.java    License: Apache License 2.0 6 votes vote down vote up
private boolean initConfig() {
    if (fileConfigs.isEmpty()) {
        try {
            for (FileConfigurationBuilder fileConfigBuilder : fileConfigBuilders) {
                FileConfiguration fileConfig = fileConfigBuilder.getConfiguration();
                FileChangedReloadingStrategy reloadingStrategy = new FileChangedReloadingStrategy();
                reloadingStrategy.setRefreshDelay(0);
                fileConfig.setReloadingStrategy(reloadingStrategy);
                fileConfigs.add(fileConfig);
            }
        } catch (ConfigurationException ex) {
            if (!fileNotFound(ex)) {
                LOG.error("Config init failed {}", ex);
            }
        }
    }
    return !fileConfigs.isEmpty();
}
 
Example 2
Source Project: distributedlog   Source File: ConfigurationSubscription.java    License: Apache License 2.0 6 votes vote down vote up
private boolean initConfig() {
    if (fileConfigs.isEmpty()) {
        try {
            for (FileConfigurationBuilder fileConfigBuilder : fileConfigBuilders) {
                FileConfiguration fileConfig = fileConfigBuilder.getConfiguration();
                FileChangedReloadingStrategy reloadingStrategy = new FileChangedReloadingStrategy();
                reloadingStrategy.setRefreshDelay(0);
                fileConfig.setReloadingStrategy(reloadingStrategy);
                fileConfigs.add(fileConfig);
            }
        } catch (ConfigurationException ex) {
            if (!fileNotFound(ex)) {
                LOG.error("Config init failed {}", ex);
            }
        }
    }
    return !fileConfigs.isEmpty();
}
 
Example 3
Source Project: distributedlog   Source File: ConfigurationSubscription.java    License: Apache License 2.0 5 votes vote down vote up
private void loadView(FileConfiguration fileConfig) {
    Iterator fileIter = fileConfig.getKeys();
    while (fileIter.hasNext()) {
        String key = (String) fileIter.next();
        setViewProperty(fileConfig, key, fileConfig.getProperty(key));
    }
}
 
Example 4
Source Project: distributedlog   Source File: ConfigurationSubscription.java    License: Apache License 2.0 5 votes vote down vote up
private void setViewProperty(FileConfiguration fileConfig,
                             String key,
                             Object value) {
    if (!viewConfig.containsKey(key) || !viewConfig.getProperty(key).equals(value)) {
        LOG.debug("Setting property, key={} value={}", key, fileConfig.getProperty(key));
        viewConfig.setProperty(key, fileConfig.getProperty(key));
    }
}
 
Example 5
Source Project: distributedlog   Source File: ConfigurationSubscription.java    License: Apache License 2.0 5 votes vote down vote up
private void loadView(FileConfiguration fileConfig) {
    Iterator fileIter = fileConfig.getKeys();
    while (fileIter.hasNext()) {
        String key = (String) fileIter.next();
        setViewProperty(fileConfig, key, fileConfig.getProperty(key));
    }
}
 
Example 6
Source Project: distributedlog   Source File: ConfigurationSubscription.java    License: Apache License 2.0 5 votes vote down vote up
private void setViewProperty(FileConfiguration fileConfig,
                             String key,
                             Object value) {
    if (!viewConfig.containsKey(key) || !viewConfig.getProperty(key).equals(value)) {
        LOG.debug("Setting property, key={} value={}", key, fileConfig.getProperty(key));
        viewConfig.setProperty(key, fileConfig.getProperty(key));
    }
}
 
Example 7
Source Project: herd   Source File: ReloadablePropertySourceTest.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Gets a new properties configuration that will re-load the properties from a file every time it is called.
 *
 * @return the properties configuration.
 * @throws ConfigurationException if the properties configuration couldn't be created.
 */
private PropertiesConfiguration getNewPropertiesConfiguration() throws ConfigurationException
{
    // Create a new properties configuration.
    // We are using this instead of a database configuration for easier testing.
    PropertiesConfiguration propertiesConfiguration = new PropertiesConfiguration(propertiesFile);

    // Create a reloading strategy that will always reload when asked.
    // There were some problems using the FileChangedReloadingStrategy where it wasn't detecting changed files and causing some methods in this
    // JUnit to fail.
    propertiesConfiguration.setReloadingStrategy(new ReloadingStrategy()
    {
        @Override
        public void setConfiguration(FileConfiguration configuration)
        {
        }

        @Override
        public void init()
        {
        }

        @Override
        public boolean reloadingRequired()
        {
            // Tell the caller that the properties should always be reloaded.
            return true;
        }

        @Override
        public void reloadingPerformed()
        {
        }
    });

    return propertiesConfiguration;
}
 
Example 8
Source Project: zap-extensions   Source File: OptionsParamWebSocket.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void parse() {
    FileConfiguration cfg = getConfig();
    isForwardAll = cfg.getBoolean(FORWARD_ALL, false);
    isBreakOnPingPong = cfg.getBoolean(BREAK_ON_PING_PONG, false);
    isBreakOnAll = cfg.getBoolean(BREAK_ON_ALL, false);
    confirmRemoveProxyExcludeRegex =
            cfg.getBoolean(CONFIRM_REMOVE_PROXY_EXCLUDE_REGEX_KEY, false);
    removeExtensionsHeader = cfg.getBoolean(REMOVE_EXTENSIONS_HEADER_KEY, true);
}
 
Example 9
Source Project: otroslogviewer   Source File: ConfigComponent.java    License: Apache License 2.0 5 votes vote down vote up
public void reload() {
  boolean mainConfigLoaded = false;
  for (ConfigView configView : configViews) {
    Configuration configurationForView;

    try {
      configurationForView = configurationProvider.getConfigurationForView(configView);
      if (configurationForView instanceof DataConfiguration) {
        DataConfiguration dc = (DataConfiguration) configurationForView;
        configurationForView = dc.getConfiguration();
      }
      if (configurationForView instanceof FileConfiguration) {
        FileConfiguration fc = (FileConfiguration) configurationForView;
        if (configView instanceof InMainConfig) {
          if (!mainConfigLoaded) {
            fc.reload();
            mainConfigLoaded = true;
          }
        } else {
          fc.reload();
        }
        configView.loadConfiguration(fc);
      }
    } catch (ConfigurationException e1) {
      //TODO ??
      e1.printStackTrace();
    }
  }
}
 
Example 10
Source Project: xnx3   Source File: ConfigManagerUtil.java    License: Apache License 2.0 4 votes vote down vote up
public FileConfiguration getFileConfiguration(){
	return this.config;
}
 
Example 11
public static void main(String[] args) throws Exception {
    FileConfiguration configuration = new PropertiesConfiguration(args[0]);
    new GraknSparkComputer(HadoopGraph.open(configuration))
            .program(VertexProgram.createVertexProgram(HadoopGraph.open(configuration), configuration))
            .submit().get();
}
 
Example 12
@Override
public FileConfiguration getConfiguration() throws ConfigurationException {
    return new PropertiesConfiguration(url);
}
 
Example 13
@Override
public FileConfiguration getConfiguration() throws ConfigurationException {
    return new PropertiesConfiguration(url);
}
 
Example 14
Source Project: zap-extensions   Source File: HttpPanelViewStateView.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void loadConfiguration(FileConfiguration fileConfiguration) {}
 
Example 15
Source Project: zap-extensions   Source File: HttpPanelViewStateView.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void saveConfiguration(FileConfiguration fileConfiguration) {}
 
Example 16
Source Project: zap-extensions   Source File: ClientComponent.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void addView(HttpPanelView view, Object options, FileConfiguration fileConfiguration) {
    views.addView(view, fileConfiguration);
}
 
Example 17
Source Project: zap-extensions   Source File: ClientComponent.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void loadConfig(FileConfiguration fileConfiguration) {
    views.loadConfig(fileConfiguration);
}
 
Example 18
Source Project: zap-extensions   Source File: ClientComponent.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void saveConfig(FileConfiguration fileConfiguration) {
    views.saveConfig(fileConfiguration);
}
 
Example 19
Source Project: zap-extensions   Source File: WebSocketComponent.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void addView(HttpPanelView view, Object options, FileConfiguration fileConfiguration) {
    views.addView(view, fileConfiguration);
}
 
Example 20
Source Project: zap-extensions   Source File: WebSocketComponent.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void loadConfig(FileConfiguration fileConfiguration) {
    views.loadConfig(fileConfiguration);
}
 
Example 21
Source Project: zap-extensions   Source File: WebSocketComponent.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void saveConfig(FileConfiguration fileConfiguration) {
    views.saveConfig(fileConfiguration);
}
 
Example 22
Source Project: zap-extensions   Source File: ResponseBrowserView.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void loadConfiguration(FileConfiguration fileConfiguration) {}
 
Example 23
Source Project: zap-extensions   Source File: ResponseBrowserView.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void saveConfiguration(FileConfiguration fileConfiguration) {}
 
Example 24
Source Project: zap-extensions   Source File: EventStreamComponent.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void addView(HttpPanelView view, Object options, FileConfiguration fileConfiguration) {
    views.addView(view, fileConfiguration);
}
 
Example 25
Source Project: zap-extensions   Source File: EventStreamComponent.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void loadConfig(FileConfiguration fileConfiguration) {
    views.loadConfig(fileConfiguration);
}
 
Example 26
Source Project: zap-extensions   Source File: EventStreamComponent.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void saveConfig(FileConfiguration fileConfiguration) {
    views.saveConfig(fileConfiguration);
}
 
Example 27
Source Project: zap-extensions   Source File: AbstractAMFTextView.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void loadConfiguration(FileConfiguration fileConfiguration) {}
 
Example 28
Source Project: zap-extensions   Source File: AbstractAMFTextView.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void saveConfiguration(FileConfiguration fileConfiguration) {}
 
Example 29
Source Project: zap-extensions   Source File: HttpPanelJsonView.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void loadConfiguration(FileConfiguration fileConfiguration) {}
 
Example 30
Source Project: zap-extensions   Source File: HttpPanelJsonView.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void saveConfiguration(FileConfiguration fileConfiguration) {}