org.apache.commons.configuration.FileConfiguration Java Examples

The following examples show how to use org.apache.commons.configuration.FileConfiguration. 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 File: ConfigurationSubscription.java    From distributedlog with 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 File: ConfigComponent.java    From otroslogviewer with 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 #3
Source File: OptionsParamWebSocket.java    From zap-extensions with 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 #4
Source File: ReloadablePropertySourceTest.java    From herd with 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 #5
Source File: ConfigurationSubscription.java    From distributedlog with 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 #6
Source File: ConfigurationSubscription.java    From distributedlog with 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 #7
Source File: ConfigurationSubscription.java    From distributedlog with Apache License 2.0 5 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 #8
Source File: ConfigurationSubscription.java    From distributedlog with 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 #9
Source File: ConfigurationSubscription.java    From distributedlog with 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 #10
Source File: HttpPanelJsonView.java    From zap-extensions with Apache License 2.0 4 votes vote down vote up
@Override
public void saveConfiguration(FileConfiguration fileConfiguration) {}
 
Example #11
Source File: HttpPanelJsonView.java    From zap-extensions with Apache License 2.0 4 votes vote down vote up
@Override
public void loadConfiguration(FileConfiguration fileConfiguration) {}
 
Example #12
Source File: SyntaxHighlightTextArea.java    From zap-extensions with Apache License 2.0 4 votes vote down vote up
public void loadConfiguration(String key, FileConfiguration fileConfiguration) {
    setAntiAliasingEnabled(
            fileConfiguration.getBoolean(key + ANTI_ALIASING, this.getAntiAliasingEnabled()));

    Component c = getParent();
    if (c instanceof JViewport) {
        c = c.getParent();
        if (c instanceof RTextScrollPane) {
            final RTextScrollPane scrollPane = (RTextScrollPane) c;
            scrollPane.setLineNumbersEnabled(
                    fileConfiguration.getBoolean(
                            key + SHOW_LINE_NUMBERS, scrollPane.getLineNumbersEnabled()));

            setCodeFoldingEnabled(
                    fileConfiguration.getBoolean(
                            key + CODE_FOLDING, this.isCodeFoldingEnabled()));
            scrollPane.setFoldIndicatorEnabled(this.isCodeFoldingEnabled());
        }
    }

    setLineWrap(fileConfiguration.getBoolean(key + WORD_WRAP, this.getLineWrap()));

    setHighlightCurrentLine(
            fileConfiguration.getBoolean(
                    key + HIGHLIGHT_CURRENT_LINE, this.getHighlightCurrentLine()));
    setFadeCurrentLineHighlight(
            fileConfiguration.getBoolean(
                    key + FADE_CURRENT_HIGHLIGHT_LINE, this.getFadeCurrentLineHighlight()));

    setWhitespaceVisible(
            fileConfiguration.getBoolean(
                    key + SHOW_WHITESPACE_CHARACTERS, this.isWhitespaceVisible()));
    setEOLMarkersVisible(
            fileConfiguration.getBoolean(
                    key + SHOW_NEWLINE_CHARACTERS, this.getEOLMarkersVisible()));

    setMarkOccurrences(
            fileConfiguration.getBoolean(key + MARK_OCCURRENCES, this.getMarkOccurrences()));

    setRoundedSelectionEdges(
            fileConfiguration.getBoolean(
                    key + ROUNDED_SELECTION_EDGES, this.getRoundedSelectionEdges()));

    setBracketMatchingEnabled(
            fileConfiguration.getBoolean(
                    key + BRACKET_MATCHING, this.isBracketMatchingEnabled()));
    setAnimateBracketMatching(
            fileConfiguration.getBoolean(
                    key + ANIMATED_BRACKET_MATCHING, this.getAnimateBracketMatching()));
}
 
Example #13
Source File: SyntaxHighlightTextArea.java    From zap-extensions with Apache License 2.0 4 votes vote down vote up
public void saveConfiguration(String key, FileConfiguration fileConfiguration) {
    fileConfiguration.setProperty(
            key + ANTI_ALIASING, Boolean.valueOf(this.getAntiAliasingEnabled()));

    Component c = getParent();
    if (c instanceof JViewport) {
        c = c.getParent();
        if (c instanceof RTextScrollPane) {
            final RTextScrollPane scrollPane = (RTextScrollPane) c;
            fileConfiguration.setProperty(
                    key + SHOW_LINE_NUMBERS,
                    Boolean.valueOf(scrollPane.getLineNumbersEnabled()));
            fileConfiguration.setProperty(
                    key + CODE_FOLDING, Boolean.valueOf(this.isCodeFoldingEnabled()));
        }
    }

    fileConfiguration.setProperty(key + WORD_WRAP, Boolean.valueOf(this.getLineWrap()));

    fileConfiguration.setProperty(
            key + HIGHLIGHT_CURRENT_LINE, Boolean.valueOf(this.getHighlightCurrentLine()));
    fileConfiguration.setProperty(
            key + FADE_CURRENT_HIGHLIGHT_LINE,
            Boolean.valueOf(this.getFadeCurrentLineHighlight()));

    fileConfiguration.setProperty(
            key + SHOW_WHITESPACE_CHARACTERS, Boolean.valueOf(this.isWhitespaceVisible()));
    fileConfiguration.setProperty(
            key + SHOW_NEWLINE_CHARACTERS, Boolean.valueOf(this.getEOLMarkersVisible()));

    fileConfiguration.setProperty(
            key + MARK_OCCURRENCES, Boolean.valueOf(this.getMarkOccurrences()));

    fileConfiguration.setProperty(
            key + ROUNDED_SELECTION_EDGES, Boolean.valueOf(this.getRoundedSelectionEdges()));

    fileConfiguration.setProperty(
            key + BRACKET_MATCHING, Boolean.valueOf(this.isBracketMatchingEnabled()));
    fileConfiguration.setProperty(
            key + ANIMATED_BRACKET_MATCHING, Boolean.valueOf(this.getAnimateBracketMatching()));
}
 
Example #14
Source File: AbstractAMFTextView.java    From zap-extensions with Apache License 2.0 4 votes vote down vote up
@Override
public void saveConfiguration(FileConfiguration fileConfiguration) {}
 
Example #15
Source File: AbstractAMFTextView.java    From zap-extensions with Apache License 2.0 4 votes vote down vote up
@Override
public void loadConfiguration(FileConfiguration fileConfiguration) {}
 
Example #16
Source File: EventStreamComponent.java    From zap-extensions with Apache License 2.0 4 votes vote down vote up
@Override
public void saveConfig(FileConfiguration fileConfiguration) {
    views.saveConfig(fileConfiguration);
}
 
Example #17
Source File: EventStreamComponent.java    From zap-extensions with Apache License 2.0 4 votes vote down vote up
@Override
public void loadConfig(FileConfiguration fileConfiguration) {
    views.loadConfig(fileConfiguration);
}
 
Example #18
Source File: EventStreamComponent.java    From zap-extensions with 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 #19
Source File: ClientComponent.java    From zap-extensions with Apache License 2.0 4 votes vote down vote up
@Override
public void saveConfig(FileConfiguration fileConfiguration) {
    views.saveConfig(fileConfiguration);
}
 
Example #20
Source File: ResponseBrowserView.java    From zap-extensions with Apache License 2.0 4 votes vote down vote up
@Override
public void saveConfiguration(FileConfiguration fileConfiguration) {}
 
Example #21
Source File: ResponseBrowserView.java    From zap-extensions with Apache License 2.0 4 votes vote down vote up
@Override
public void loadConfiguration(FileConfiguration fileConfiguration) {}
 
Example #22
Source File: WebSocketComponent.java    From zap-extensions with Apache License 2.0 4 votes vote down vote up
@Override
public void saveConfig(FileConfiguration fileConfiguration) {
    views.saveConfig(fileConfiguration);
}
 
Example #23
Source File: WebSocketComponent.java    From zap-extensions with Apache License 2.0 4 votes vote down vote up
@Override
public void loadConfig(FileConfiguration fileConfiguration) {
    views.loadConfig(fileConfiguration);
}
 
Example #24
Source File: WebSocketComponent.java    From zap-extensions with 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 File: ConfigManagerUtil.java    From xnx3 with Apache License 2.0 4 votes vote down vote up
public FileConfiguration getFileConfiguration(){
	return this.config;
}
 
Example #26
Source File: ClientComponent.java    From zap-extensions with Apache License 2.0 4 votes vote down vote up
@Override
public void loadConfig(FileConfiguration fileConfiguration) {
    views.loadConfig(fileConfiguration);
}
 
Example #27
Source File: ClientComponent.java    From zap-extensions with 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 #28
Source File: HttpPanelViewStateView.java    From zap-extensions with Apache License 2.0 4 votes vote down vote up
@Override
public void saveConfiguration(FileConfiguration fileConfiguration) {}
 
Example #29
Source File: HttpPanelViewStateView.java    From zap-extensions with Apache License 2.0 4 votes vote down vote up
@Override
public void loadConfiguration(FileConfiguration fileConfiguration) {}
 
Example #30
Source File: PropertiesConfigurationBuilder.java    From distributedlog with Apache License 2.0 4 votes vote down vote up
@Override
public FileConfiguration getConfiguration() throws ConfigurationException {
    return new PropertiesConfiguration(url);
}