Class ChainedPropertiesLoader

java.lang.Object
com.saperion.common.config.loader.AbstractPropertiesLoader
com.saperion.common.config.loader.ChainedPropertiesLoader
All Implemented Interfaces:
PropertiesLoader

public class ChainedPropertiesLoader extends AbstractPropertiesLoader

The ChainedPropertiesLoader can be used to define a chain of PropertiesLoaders that should be used to load properties. The chain is defined by adding mandatory or optional PropertiesLoaders using the methods addMandatoryPropertiesLoader(PropertiesLoader) and addOptionalPropertiesLoader(PropertiesLoader).

Each PropertiesResource will then be loaded by the registered PropertiesLoaders-chain. The PropertiesLoaders registration order is also being used for loading.

A single Properties object is filled by the returned Properties of each PropertiesLoader in the chain. As a result, properties values by the same key will be overwritten in the returned Properties instance.

Example: The PropertiesLoaders A & B are registered in the stated order. Then load(PropertiesResource) is called on the ChainedPropertiesLoader. Now ChainedPropertiesLoader loops through it's chain: PropertiesLoader A is used to load the PropertiesResource. The returned Properties are temporarily stored in P. PropertiesLoader B is used to load the PropertiesResource. The returned Properties are also stored in P. This possibly overwrites property values with the same key. P is returned by the load(PropertiesResource) method. This is also true for the method loadList(List).

This implementation is not synchronized. If used by different threads concurrently, external synchronization is necessary.

Author:
sts
See Also: