2017-01-15

Tamaya Builder (Extension Module)

Overview

The Tamaya builder module provides a generic (one time) builder for creating Configuration instances, e.g. as follows:

ConfigurationBuilder builder = new ConfigurationBuilder();
// do something
Configuration config = builder.build();

Basically the builder allows to create configuration instances completely independent of the current configuration setup. This gives you full control on the Configuration setup.

Compatibility

The module is based on Java 7, so it will run on Java 7 and does not require Java 8. The ConfigurationProvider as defined by the API, provides a builder instance for ConfigurationContext in a similar way. A Configuration can also be created by passing an instance of a ConfigurationContext:

Installation

To benefit from configuration builder support you only must add the corresponding dependency to your module:

<dependency>
  <groupId>org.apache.tamaya.ext</groupId>
  <artifactId>tamaya-builder</artifactId>
  <version>0.3-incubating-SNAPSHOT</version>
</dependency>

Supported Functionality

The builder allows you to add PropertySource instances:

ConfigurationBuilder builder = new ConfigurationBuilder();
builder.addPropertySources(sourceOne).addPropertySources(sourceTwo);
Configuration config = builder.build();

Similarly you can add filters:

builder.addPropertyFilters(new MyConfigFilter());

…​or PropertySourceProvider instances:

builder.addPropertySourceProvider(new MyPropertySourceProvider());

Also the builder module allows to include/exclude any filters and property source already known to the current ConfigurationContext:

builder.disableProvidedPropertyConverters();
builder.enableProvidedPropertyConverters();

builder.disableProvidedPropertyFilters();
builder.enableProvidedPropertyFilters();

builder.disableProvidedPropertySources();
builder.enableProvidedPropertySources();