|
[
Permlink
| « Hide
]
Ralph Goers added a comment - 18/Dec/08 10:32 PM
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.
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());
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.
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.
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"?> <override> </configuration> 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. 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.
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 : <configuration> <system init="system.properties"/> </configuration> 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.
Ok, that's fine for the configuration descriptor then.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||