2017-02-09

Tamaya Metamodel: Staged PropertySources (Extension Module)

Tamaya Staged is an extension module. Refer to the extensions documentation for further details.

Overview

Tamaya Staged PropertySources extension provides a base class and default implementation for loading multistaged configuration easily from a common configuration location.

Compatibility

The module is based on Java 7, so it will run on Java 7 and beyond.

Installation

To benefit from Tamaya CDI integration you only must add the corresponding dependency to your module:

<dependency>
  <groupId>org.apache.tamaya.ext.metamodels</groupId>
  <artifactId>tamaya-metamodel.staged</artifactId>
  <version>{tamaya_version}</version>
</dependency>

The component will not register any components. The component basically provides the following options:

  • Use it as default configuration extension. Hereby you should define your stages in use by setting the env.STAGE system property with the stages to be loaded in order of precedence (most significant last), e.g. sys-env,DEFAULTS,TEST,DEVELOPMENT. _Additionally_ you must register +org.apache.tamaya.staged.StagedConfigPropertiesProvider as in

META-INF
|_service
  |_org.apache.tamaya.spi.PropertySourceProvider

Tamaya will then load .properties files from System.getenv(), classpath:DEFAULTS.properties, classpath:TEST.properties and classpath:DEVELOPMENT.properties

  • For more advanced requirements, such as alternate locations, patterns or formats, you can also extend one of the provided classes (org.apache.tamaya.staged.StagedConfigPropertiesProvider,

    • BaseStagedPropertySourceProvider). Extending provides features such as:

    • Defining a prefix for all entries provided/loaded.

    • Using alternate locations or formats.

    • Defining the ordinals used.