[ 
https://issues.apache.org/jira/browse/CONFIGURATION-353?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12723858#action_12723858
 ] 

Ralph Goers commented on CONFIGURATION-353:
-------------------------------------------

bq.That change is weird. Why does it work only with PropertiesConfiguration?
Because a) it is wierd to populate system properties from anything other than 
properties and b) this is meant to be a simple way of getting system properties 
set for an application instead of putting lots of -Ds in a startup script. More 
complicated XML is unnecessary.

bq. SystemConfiguration.setSystemProperties(new 
PropertiesConfiguration("system.properties"));
DefaultConfigurationBuilder allows the property file name to be variable, which 
is required for my use case. If you are really inquiring about why not do 
SystemConfiguration.setSystemProperties(new PropertiesConfiguration(filename)) 
then I must have missed where that constructor could accept an XML properties 
file. Also, DefaultConfigurationBuilder's base path needs to be passed in along 
with the file name.

bq.ConfigurationUtils.copy(new PropertiesConfiguration("system.properties"), 
new SystemConfiguration());
The intent was not to create a new SystemConfiguration. The intent was to get 
the system properties set as my first comment indicates.

Here is an example usage. repoURL is defined in app-config.properties along 
with other system properties used by the application.

<?xml version="1.0" encoding="UTF-8"?>
                <!--
                                Test configuration definition file that 
demonstrates complex initialization
                -->
<configuration systemProperties="app-config.properties">
                <header>
                                <result delimiterParsingDisabled="true" 
forceReloadCheck="true"
                                                
config-class="org.apache.commons.configuration.DynamicCombinedConfiguration" 
keyPattern="$${mdc:bcId}">
                                                <expressionEngine 
config-class="org.apache.commons.configuration.tree.xpath.XPathExpressionEngine"
 />
                                                <nodeCombiner 
config-class="org.apache.commons.configuration.tree.MergeCombiner" />
                                </result>
                                <entity-resolver 
catalogFiles="${sys:repoURL}/repositoryResolver.xml" debug="true" />
                                <fileSystem 
config-class="org.apache.commons.configuration.VFSFileSystem" />
                                <lookups>
                                                <lookup config-prefix="mdc" 
config-class="org.slf4j.ext.MDCStrLookup" />
                                                <lookup config-prefix="expr" 
config-class="org.apache.commons.configuration.interpol.ExprLookup">
                                                                <variables>
                                                                                
<variable name="String" value="Class:org.apache.commons.lang.StringUtils" />
                                                                </variables>
                                                </lookup>
                                </lookups>
                                <providers>
                                                <provider config-tag="multifile"
                                                                
config-class="org.apache.commons.configuration.DefaultConfigurationBuilder$FileConfigurationProvider"
                                                                
configurationClass="org.apache.commons.configuration.MultiFileHierarchicalConfiguration"
 />
                                </providers>
                </header>
 
                <override>
                                <multifile
                                                
filePattern="${sys:repoURL}/fi/$$${mdc:bcIndex}/$$${mdc:canonicalId}/$$${mdc:canonicalId}-env.xml"
                                                delimiterParsingDisabled="true" 
attributeSplittingDisabled="true"
                                                config-name="fiConfig" 
schemaValidation="${sys:schemaValidation}">
                                                <reloadingStrategy delay="60000"
                                                                
config-class="org.apache.commons.configuration.reloading.VFSFileMonitorReloadingStrategy"
 />
                                </multifile>
                                <xml 
fileName="${sys:repoURL}/defaults/env-defaults.xml" config-name="defaultConfig" 
optional="true"
                                                delimiterParsingDisabled="true" 
attributeSplittingDisabled="true"
                                                
schemaValidation="${sys:schemaValidation}">
                                                <reloadingStrategy 
config-class="org.apache.commons.configuration.reloading.VFSFileMonitorReloadingStrategy"
 />
                                </xml>
                </override>
 
</configuration>

> Allow Commons Configuration to set system properties
> ----------------------------------------------------
>
>                 Key: CONFIGURATION-353
>                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-353
>             Project: Commons Configuration
>          Issue Type: New Feature
>    Affects Versions: 1.6
>         Environment: All
>            Reporter: Ralph Goers
>             Fix For: 1.6
>
>
> SystemConfiguration allows the system properties to be accessed as a 
> configuration and used in a combined configuration. However, no mechanism is 
> available to set system properties from an external file. Such a facility 
> would alleviate having to place a bunch of -D options on the command line.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to