IntroThe Commons Configuration software library provides a generic configuration interface which enables a Java application to read configuration data from a variety of sources. Commons Configuration provides typed access to single, and multi-valued configuration parameters as demonstrated by the following code: Double double = config.getDouble("number"); Integer integer = config.getInteger("number"); Configuration parameters may be loaded from the following sources:
CombinedConfigurationBuilder and
a CombinedConfiguration . Additional sources of configuration parameters can
be created by using custom configuration objects. This customization can be achieved by
extending AbstractConfiguration or AbstractHierarchicalConfiguration .
The full Javadoc API documentation is available here. Commons Configuration 1.x and 2.xAfter its initial release in 2004, Apache Commons Configuration has been steadily improved, and a series of feature releases has been published over the years. All of these releases were binary backwards-compatible. The latest release of this series is version 1.10. This code base is now pretty mature and does what it is expected to do. Nevertheless, there have been some design decisions made in the past which are problematic in retrospect. For instance, access to configuration objects is always synchronized which might be a performance issue in some use cases, or support for reloading of configuration data is very limited - just to mention a few pain points. These problems could not be fixed without breaking backwards compatibility in the affected areas. Therefore, work has been spent on a major redesign of the library addressing some of the weaknesses of the 1.x versions. The results have been made available over a longer period as a series of alpha and beta releases. Now the final version 2.0 is available incorporating feedback from the community. Note that this is not a drop-in replacement for Commons Configuration 1.x! Changes on client code are required to make use of the new version. There is a Migration guide that can be used as guideline when upgrading from version 1.x to 2.0. It describes the most important changes. A good source of information is also the Changes Report that explains all of the changes and bug fixes that have been applied. Both Commons Configuration 1.10 and the most recent 2.x release can be downloaded from the Apache download area. The artifacts have also been deployed to Maven central (with different coordinates for both versions to avoid conflicts). Which version should you use? Well, if you are a long-term user of Commons Configuration 1.x and happy with its functionality, there is no urgent pressure to upgrade to the newest version. New projects, however, should start with the new API as it offers more functionality and makes some tasks easier and cleaner. Also note that development currently focuses exclusively on the 2.x branch, so that the probability for bug-fix releases for version 1.x is pretty low. History
Commons Configuration started as code in Apache JServ. The JServ code was subsequently
added to Jakarta Turbine. After Jakarta
Turbine, this configuration interface moved to Jakarta Velocity
and underwent various improvements. After Velocity, this code was introduced to the
Apache Commons as BugsBugs may be reported via the ASF JIRA system. Detailed information can be found on the issue tracking page. |