ConfigLoader

public class ConfigLoader

A class which loads the RSB configuration from different sources and stores it in a Properties object.

Author

jwienke, jmoringe

Constructors

ConfigLoader

public ConfigLoader(String prefix, String environmentPrefix)

Creates a new instance with specific parameters.

Parameters
  • prefix – installation prefix to search for the config files in prefix/etc/rsb.conf.

  • environmentPrefix – prefix for environment variables

ConfigLoader

public ConfigLoader()

Uses “/” as the config file prefix and “RSB_” as the environment variable prefix.

Methods

load

public Properties load(Properties results)

Loads properties from the default sources. These are several config files and environment variables. The passed in instance is not cleared from existing properties before. If you need this, use Properties.reset().

Parameters

results – the instance to fill with new properties

Returns

the result instance, now loaded

loadEnv

public Properties loadEnv(Properties results)

Loads properties from the environment variable. The passed in instance is not cleared before loading.

Parameters

results – the instance to fill with new properties

Returns

the passed in instance

loadFile

public Properties loadFile(File file, Properties results)

Reads options from a config file. Assumes that the file exists. The passed in instance is not cleared before loading from the file.

Parameters
  • file – the file to read

  • results – the instance to fill with new properties

Throws
Returns

the instance with properties

loadFileIfAvailable

public Properties loadFileIfAvailable(int index, File file, String description, Properties results)

Loads a config file if the file exists. Reading errors are ignored. The passed in instance is not cleared before loading the file.

Parameters
  • index – the index of the file in the configuration file cascade

  • file – the file to read, might not exist

  • description – a description of the file being loaded

  • results – the instance to fill with new properties

Returns

the result instance with loaded properties