Java: what configuration structure to use?

I need to decide which configuration structure to use. At the moment, I am thinking about using property files and XML files. My configuration should have some primitive grouping, for example. in XML format there will be something like:

<configuration> <group name="abc"> <param1>value1</param1> <param2>value2</param2> </group> <group name="def"> <param3>value3</param3> <param4>value4</param4> </group> </configuration> 

or properties file (something similar to log4j.properties):

 group.abc.param1 = value1 group.abc.param2 = value2 group.def.param3 = value3 group.def.param4 = value4 

I need a bi-directional (read and write) library / configuration structure. A good feature would be that I could read somehow different configuration groups as different objects, so I could later transfer them to different places, for example. - read everything that belongs to the group "abc", as one object, and "def" as another. If this is not possible, I can always split one configuration object into smaller ones in terms of application initialization.

Which structure is best for me?

+6
java xml properties frameworks configuration
source share
3 answers

Since you say that you can also store objects in the config, I would suggest the following:

http://commons.apache.org/configuration/

+12
source share

The easiest way to do this is to use Simple XML. It can bind XML to Java POJOs in a very simple way. In addition, it is much faster than other similar XML binding frameworks.

http://simple.sourceforge.net

Only 270K without dependencies.

+4
source share

Please take a look at this URL: http://issues.apache.org/jira/browse/CONFIGURATION-394

The configuration structure we are looking for is something on top of the Apache Commons configuration and should support Concurrency problems, JMX problems, and most stores (for example, the .properties file, .xml files, or PreferencesAPI).

What the weblogic team offers in the Administration Console, through which you can receive transactional (atomic) updates in configurations so that registered registered listeners are notified.

The Apache guys insist that this project is beyond the scope of the Commons Configuration, perhaps!

I attached a simple configuration structure, please see

+1
source share

All Articles