Back to top

PropLoad

A java library for loading properties depending on the environment.

What is it

Web applications (and other software) often needs to be configured depending on the environment it is deployed in. PropLoad reads in properties files depending on what machine it is run.

The standard behaviour is to look in the class path for a file module.properties (where module is a given module name), and then continues with:

  • module.hostname.properties
  • module.username.properties
  • module.hostname.username.properties

After that it continues in a similar scheme at the typical file system folders (e.g., user’s home directory).

Properties defined in files that are read in later override earlier defined properties. The standard behaviour can easily be changed by implementing PropLoad.

This library has been inspired by Gerhard Müller’s properties loader.

Features

Beside the just described search for properties files, PropLoad’s other main feature is key references. You can reference the value of other keys with ${...}. In the following, baz will resolve to boombar.

foo = bar
baz = boom${foo}

You can also use key references in key references:

env = dev
a.prod = 42
a.dev  = 23
a      = ${a.${env}}

Download