@Version(value="3.0.0")

# Package org.eclipse.microprofile.config

Configuration for Java MicroProfile

See: Description

Interface Summary
Config: Resolves the property value by searching through all configured `ConfigSources`.
ConfigValue: The ConfigValue holds additional information after the lookup of a configuration property and is itself immutable.

Class Summary
ConfigProvider: This is the central class to access a `Config`.

## Package org.eclipse.microprofile.config Description

Configuration for Java MicroProfile

## Rationale

For many project artifacts (e.g. WAR, EAR) it should be possible to build them only once and then install them at different customers, stages, etc. They need to target those different execution environments without the necessity of any repackaging. In other words: depending on the situation they need different configuration.

This is easily achievable by having a set of default configuration values inside the project artifact. But be able to overwrite those default values from external.

## How it works

A Configuration consists of the information collected from the registered `ConfigSources`. These `ConfigSources` get sorted according to their ordinal. That way it is possible to overwrite configuration with lower importance from outside.

By default there are 3 ConfigSources:

- `System.getProperties()` (ordinal=400)
- `System.getenv()` (ordinal=300)
- all `META-INF/microprofile-config.properties` files on the ClassPath. (ordinal=100, separately configurable via a config_ordinal property inside each file)

That means that one can put the default configuration in a `META-INF/microprofile-config.properties` anywhere on the classpath and the Operations team can later simply e.g set a system property to change this default configuration.

It is of course also possible to register own `ConfigSources`. A `ConfigSource` could e.g. read configuration values from a database table, a remote server, etc

## Accessing and Using the Configuration

The configuration of an application is represented by an instance of `Config`. The `Config` can be accessed via the `ConfigProvider`.

     Config config = ConfigProvider.getConfig();
     String restUrl = config.getValue("myproject.some.endpoint.url", String.class);

Injection via a JSR-330 DI container is also supported:

     @Inject
     @ConfigProperty(name="myproject.some.endpoint.url");
     private String restUrl;

Author:
  Emily Jiang, Mark Struberg