Eclipse MicroProfile Config API

The Payara Platform 6.0.0 provides MicroProfile Configuration 3.0.2

Background

The Config API was created to allow for the modification of application configuration from outside the application without needing the application to be repackaged.

The complete specification can be found on the Eclipse MicroProfile website.

Breaking changes introduced in MicroProfile Config 3.0.2 are listed in the official specification under Incompatible Changes

Config Sources

A ConfigSource is a definition of a source of configuration values that can be used by an application. In addition to the default ConfigSources outlined by the specification, the following are also supported ConfigSources:

Where multiple configuration properties exist, the property from a source with a higher ordinal number is preferred.
Source Ordinal Description

directory

90

Reads configuration properties from files in a specified directory. Each file name is the configuration property name and the contents of the file are the config property value. This config source can be used to read Kubernetes secrets files. + You can find out more about directory config sources here: Directory Config Sources

password

105

Retrieves and stores config values in the password alias store. These will be available to all server instances in a domain.

domain

110

Retrieves and stores config values in the domain.xml as key values. These will then apply to all instances within a domain

jndi

115

Retrieves and stores config values within the JNDI tree. The property name being the dotted name path in the JNDI tree and the value being stored in the JNDI tree. These are modifiable by current admin console functionality.

config

120

Retrieves and stores config values at the level of the named configuration in the domain.xml; server-config, for example. MicroProfile Configuration property values will apply to all instances that use the Payara configuration specified.

server

130

Retrieves and stores config values at the level of the server in the domain.xml. Property values will only apply on the named server instance

application

140

Retrieves and stores config values at the level of the application. Property values will only be available for the specified application on all server instances it is deployed

module

150

Retrieves and stores config values at the level of an individual module within an application. Property values will only be available for the specified module on all server instances it is deployed

cluster

160

Retrieves and stores config values in the Hazelcast cluster as name value pairs. These will be available for all server instances that are members of the cluster.

payara-expression

170

Reads configuration properties from a payara-expression-config.properties file. This should be stored in the same location as your microprofile-config.properties file This file can be used to reference properties containing variables which will be translated to their actual values upon retrieval. + The property values should be in the format referenced here: Types of Variables

cloud

180

Reads configuration properties from various Cloud provider secret stores. + You can find out more about our supported cloud config sources here: Cloud Config Sources

jdbc

190

Reads configuration properties from a specified database table. + You can find out more about JDBC config sources here: JDBC Config Sources

ldap

200

Reads configuration properties from a specified LDAP directory. + You can find out more about LDAP config sources here: LDAP Config Sources

Converters

In addition to the standard converters specified by the API, Payara Platform’s implementation includes out-of-the-box converters for URL and InetAddress.

These have @Priority of 1, the same as the default converters.

Payara Platform Configuration Properties

In addition to the standard configuration properties, Payara Server and Micro provide a number of out-of-the-box config properties you can use in your application to find information about the runtime environment.

Property Description

payara.instance.type

The type of the runtime from DAS, INSTANCE, EMBEDDED, MICRO

payara.instance.name

The name of the instance e.g. server

payara.instance.root

The directory which is the root of the instance installation

payara.domain.name

The name of the Payara domain

payara.domain.installroot

The directory which is the root of the Payara software installation

payara.config.dir

The directory in which the server’s configuration files reside

payara.instance.starttime

The start time of the server in System.currentTimeMillis

payara.instance.config.name

The name of the configuration this server is using

payara.instance.admin.port

The administration port number of this instance

payara.instance.admin.host

The host IP address which the admin listener is listening on

payara.instance.http.port

The HTTP port for http-listener

payara.instance.http.address

The IP address the http listener is listening on

payara.instance.http.enabled

Whether the http listener is enabled

payara.instance.https.port

The HTTP port for https-listener

payara.instance.https.address

The IP address the https listener is listening on

payara.instance.https.enabled

Whether the https listener is enabled

Payara Server offers additional facilities to configure specific settings of the MicroProfile Configuration API, described next.

Config Ordinal Configuration

Configuration variables ordinal values can be configured by using Admin Console or via the Asadmin CLI.

Using the Admin Console

To configure the ordinal value in the Admin Console, go to Configuration → [instance-configuration (like server-config)] → MicroProfile → Config → Ordinal:

Set Config Ordinal

Using Asadmin Commands

A --source value of jndi is not supported for these asadmin commands yet. The JNDI ConfigSource does exist and is usable from the Config API, though.

The following Asadmin commands can be used to manipulate configuration sources ordinal values:

Configuration Property Manipulation

Configuration properties can be configured by using Admin Console or Asadmin commands.

Using the Admin Console

To configure the property in the Admin Console, go to Configuration → [instance-configuration (like server-config)] → MicroProfile → Config → Property:

Set Config Property

Using Asadmin Commands

The following Asadmin commands can be used to directly configure MicroProfile configuration properties:

Cache Duration Configuration

The cache duration of the values of a configuration property can be configured by using Asadmin commands. By default, the cached value of properties have a TTL (time to live) of 60 seconds.

That means each individual property does not change for 60 seconds since it has been resolved before. Therefore, it can take up to 60 seconds for changes made visible by a source to become effective.

If properties were not resolved recently, the change can become visible faster than the cache duration or even immediately because some time already passed since they had been last resolved and cached.

Use the set-config-cache to modify this setting.