commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Lyall, Keith" <>
Subject [configuration] Comparison of Commons Configuration With JFig and JConfig
Date Fri, 12 Mar 2004 10:38:01 GMT

I have recently been looking at config tools and looked at Commons
Configuration, JFig and JConfig.

While JFig and JConfig appear to be quite similar, the Commons Configuration
project seems a lot more flexible. Specifically I am keen on the ability to
have my configuration details in different stores (property files, XML
files, database or JNDI) at different stages of the development lifecycle
i.e. I may start of with the config in a properties file for initial
development but when moving across to testing and production I might start
to use a database or LDAP server. This is a feature that neither of the
other two packages has and is excellent.

One feature that JFig has and Commons Configuration and JConfig appear to be
missing (I am no expert in any of these packages so please correct me if I
am wrong) is the ability to dynamically specify the configuration to use at
runtime for example by setting a system parameter i.e. by using
-Dconfig=test .

This would allow different config files to be loaded dependent on the
environment they are in i.e. development, test, uat or production.

I have an updated version of the ConfigurationFactory class that has this
feature if it is of interest to the project.

The updated version allows the configuration to be retrieved using the code:

Configuration config = ConfigurationFactory.getDynamicConfiguration();

I created a static method to minimise the number of lines of code to get the
configuration and make it as simplistic as possible. This is similar to
getting a Logger using Commons Logging.

Then when I run my application or server I can optionally specify the
"config" system property.

If no "config" system property is set then the default config.xml file is
loaded from the root of the classpath.

Example config.xml

<?xml version="1.0" encoding="ISO-8859-1" ?>

  <properties fileName=""/>

If the "config" property is set e.g. -Dconfig=test, then the test-config.xml
file is loaded from the root of the classpath.

Example test-config.xml

<?xml version="1.0" encoding="ISO-8859-1" ?>

  <properties fileName=""/>
  <properties fileName=""/>

Finally if the "config" property is set e.g. -Dconfig=production, then the
production-config.xml file is loaded from the root of the classpath.

Example production-config.xml 

<?xml version="1.0" encoding="ISO-8859-1" ?>

  <properties fileName=""/>
  <properties fileName=""/>

As I said, I am no expert in any of these packages so I may have missed if
this sort of functionality is already in Commons Configuration but if is not
and it is of interest to the project let me know and I will submit the code
with tests.

Keith Lyall.

  This electronic mail system is used for information purposes and is
  not intended to form any legal contract or binding agreement.
  The content is confidentia

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message