You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Ralph Goers (JIRA)" <ji...@apache.org> on 2008/12/18 23:03:44 UTC

[jira] Created: (CONFIGURATION-353) Allow Commons Configuration to set system properties

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.


[jira] Closed: (CONFIGURATION-353) Allow Commons Configuration to set system properties

Posted by "Ralph Goers (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CONFIGURATION-353?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ralph Goers closed CONFIGURATION-353.
-------------------------------------

    Resolution: Fixed

SystemConfiguration was modified to add a static method to set the system properties from a configuration. DefaultConfigurationBuilder was enhanced to allow the system properties to be set before creating the combined 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.


[jira] Commented: (CONFIGURATION-353) Allow Commons Configuration to set system properties

Posted by "Emmanuel Bourg (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CONFIGURATION-353?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12723962#action_12723962 ] 

Emmanuel Bourg commented on CONFIGURATION-353:
----------------------------------------------

Commons Configuration is a generic API, not a framework. We cannot make restrictive assumptions on how the API must be used. In particular we cannot judge that system properties are not worth being initialized from something else than a properties file. What if someone wants to use a INI or a plist file?

I understand the intent of the change, but I don't think SystemConfiguration should have been changed. The configuration builder is the only "framework-ish" part of Commons Configuration, this is where such changes can take place. The rest of the API should remain as generic as possible.

> 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.


[jira] Commented: (CONFIGURATION-353) Allow Commons Configuration to set system properties

Posted by "Emmanuel Bourg (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CONFIGURATION-353?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12723726#action_12723726 ] 

Emmanuel Bourg commented on CONFIGURATION-353:
----------------------------------------------

That change is weird. Why does it work only with PropertiesConfiguration? I would have preferred adding a single method taking any configuration, and let the DefaultConfigurationBuilder deal with the source configuration. That looks cleaner to me. Initializing the system properties would look like this:

SystemConfiguration.setSystemProperties(new PropertiesConfiguration("system.properties"));

Alternatively, this could have been solved without modifying SystemConfiguration by using a simple copy:

ConfigurationUtils.copy(new PropertiesConfiguration("system.properties"), new SystemConfiguration());


> 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.


[jira] Commented: (CONFIGURATION-353) Allow Commons Configuration to set system properties

Posted by "Ralph Goers (JIRA)" <ji...@apache.org>.
    [ 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.


[jira] Commented: (CONFIGURATION-353) Allow Commons Configuration to set system properties

Posted by "Ralph Goers (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CONFIGURATION-353?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12724326#action_12724326 ] 

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

I thought of that initially. It doesn't work because it doesn't happen soon enough. For example, notice that the entity resolver references a system property. Putting the attribution on the configuration element insures that system properties get set before anything else happens.

> 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.


[jira] Commented: (CONFIGURATION-353) Allow Commons Configuration to set system properties

Posted by "Ralph Goers (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CONFIGURATION-353?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12724071#action_12724071 ] 

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

So you are saying you would prefer that the static methods be moved into DefaultConfigurationBuilder? That is easy enough to do. I can certainly try to make it more generic to support more types of configurations, but I don't think putting some restrictions on this is necessarily bad.

> 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.


[jira] Commented: (CONFIGURATION-353) Allow Commons Configuration to set system properties

Posted by "Emmanuel Bourg (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CONFIGURATION-353?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12724120#action_12724120 ] 

Emmanuel Bourg commented on CONFIGURATION-353:
----------------------------------------------

Actually I would remove completely the static methods (or keep a generic setSystemProperties(Configuration) method in SystemConfiguration for the convenience).

In DefaultConfigurationBuilder, instead of declaring a 'systemProperties' attribute on the root configuration element, I would probably implement an "init" attribute on the system element. So initializing the system properties would look like this :

{code:xml}
<configuration>
  <system init="system.properties"/>
</configuration>
{code}


> 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.


[jira] Commented: (CONFIGURATION-353) Allow Commons Configuration to set system properties

Posted by "Emmanuel Bourg (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CONFIGURATION-353?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12724458#action_12724458 ] 

Emmanuel Bourg commented on CONFIGURATION-353:
----------------------------------------------

Ok, that's fine for the configuration descriptor then.

> 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.