org.apache.commons.configuration2.SystemConfiguration Java Examples

The following examples show how to use org.apache.commons.configuration2.SystemConfiguration. 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: CombinedConfigurationBuilder.java    From commons-configuration with Apache License 2.0 6 votes vote down vote up
/**
 * Handles a file with system properties that may be defined in the
 * definition configuration. If such property file is configured, all of its
 * properties are added to the system properties.
 *
 * @param config the definition configuration
 * @param basePath the base path defined for this builder (may be
 *        <b>null</b>)
 * @throws ConfigurationException if an error occurs.
 */
protected void initSystemProperties(final HierarchicalConfiguration<?> config,
        final String basePath) throws ConfigurationException
{
    final String fileName = config.getString(KEY_SYSTEM_PROPS);
    if (fileName != null)
    {
        try
        {
            SystemConfiguration.setSystemProperties(basePath, fileName);
        }
        catch (final Exception ex)
        {
            throw new ConfigurationException(
                    "Error setting system properties from " + fileName, ex);
        }
    }
}
 
Example #2
Source File: AliceRecognition.java    From carina with Apache License 2.0 6 votes vote down vote up
private AliceRecognition() {
    try {
        CombinedConfiguration config = new CombinedConfiguration(new MergeCombiner());
        config.addConfiguration(new SystemConfiguration());
        config.addConfiguration(new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class)
                .configure(new Parameters().properties().setFileName(ALICE_PROPERTIES)).getConfiguration());

        this.enabled = config.getBoolean(ALICE_ENABLED, false);
        String url = config.getString(ALICE_SERVICE_URL, null);
        String accessToken = config.getString(ALICE_ACCESS_TOKEN, null);
        String command = config.getString(ALICE_COMMAND, null);

        if (enabled && !StringUtils.isEmpty(url) && !StringUtils.isEmpty(accessToken)) {
            this.client = new AliceClient(url, command);
            this.client.setAuthToken(accessToken);
            this.enabled = this.client.isAvailable();
        }
    } catch (Exception e) {
        LOGGER.error("Unable to initialize Alice: " + e.getMessage(), e);
    }
}
 
Example #3
Source File: Schema2MarkupConfigBuilder.java    From swagger2markup with Apache License 2.0 5 votes vote down vote up
protected static CompositeConfiguration getCompositeConfiguration(Configuration configuration) {
    CompositeConfiguration compositeConfiguration = new CompositeConfiguration();
    compositeConfiguration.addConfiguration(new SystemConfiguration());
    compositeConfiguration.addConfiguration(configuration);
    compositeConfiguration.addConfiguration(getDefaultConfiguration());
    return compositeConfiguration;
}
 
Example #4
Source File: ConfigurationProviderImpl.java    From cryptotrader with GNU Affero General Public License v3.0 4 votes vote down vote up
private Optional<Configuration> createSystem() {
    return Optional.of(new SystemConfiguration());
}