Flexible and secure run-time configuration based on user home directory

It can be very useful to provide a configuration mechanism that uses files that are located outside of the source and resources directories. The advantages are:
  • Passwords cannot (by accident) be commited to an online repo.
  • A clear distinction between default properties and the ones specific to a deployment or installation.
  • Configuration is independent of the build procedure.
In the following links to source code of implementations of loading properties files are provided. Please feel free to extend this page.

ALERT! For compile time configuration using Maven see also BestPracticeDifferentPropertySetsInMaven.

Example 1: Supervisor

Feature of this example: Storing properties in a local folder, including saving them there if they are not available yet.


Example 2: OpenSensorSearch

Feature of this example: Overriding the default properties with the ones provided in a fixed named file in the user home dir. Has the advantage that only the required settings have to be made.

Abstract class providing the loading functions: https://github.com/52North/OpenSensorSearch/blob/master/common/src/main/java/org/n52/oss/common/AbstractConfigModule.java

Implementation of the class (which defines the file name to look for): https://github.com/52North/OpenSensorSearch/blob/master/service/src/main/java/org/n52/sir/ConfigModule.java

Example 3: WPS

Feature of this example: Very good Java code style and use of Guava.


Topic revision: r3 - 23 Jun 2014, DanielNuest
Legal Notice | Privacy Statement

This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Wiki? Send feedback