-2

I have to evaluate, how to use Apache Commons Configuration for our configuration structure.

I only find how to handle hierarchical structuring for configurations that comes from within 1 file. But how can I handle hierarchical structures like shown in the two screen.

I have numerous configuration files stored in an increasing number of subdirectories. You can see a minimized example in the folder structure screen folder structure

folder structure

Each subdirectory contains files of the same configuration type and each file contains hierarchical organized information.

The number of configuration types will increase in the near future and may increase on the long hall even more

The directory will contain at the moment round about 100 files. Each file represents information for one customer.

To have the configuration provided in files structured by the file system is chosen for a good number of reasons, and to explain them here would go far off topic.

Screen of the hierarchical structure of the configuration

  • root means root directory
  • provider, and customer are subdirectories of the root dir
  • elkconfiguration is a configuration stored in the root dir
  • the next level are files like e.g. swiss or customerB
  • the next levels is configured within files

To have the configuration in files and use the file system to structure them as a tree is set for a good number of reason. To explain these reasons would go off-topic. What is not set yet, is Apache Common Configuration. If there is open source, that suites our needs better, than I am happy to hear your advise.

fancyJaneDo
  • 67
  • 10

1 Answers1

1

What you are asking for is a custom way to combine the configurations.

Have a look at combined configuration and CombinedConfigurationBuilder

You should be able to :

XMLConfiguration rootFolder = new XMLConfiguration();
XMLConfiguration providerFolder = new XMLConfiguration();
CombinedConfiguration config = new CombinedConfiguration(new OverrideCombiner());
config.addConfiguration(providerFolder); // provider overrides the root
config.addConfiguration(rootFolder);

This order can be configuration driven and a definition that you will provide to your configuration manager.

linkcrux
  • 328
  • 4
  • 13