TOML Config Source

The TOML Config Source takes configuration properties from a TOML configuration file.

Configuration in Payara Server

You can configure TOML Config Source either via the admin console or the asadmin utility.

You’ll need the path of the TOML configuration file and the maximum recursion depth.

From the Admin Console

To configure the config source from the admin console, go to Configsyour-configMicroProfileConfigTOML.

Payara Server Administration Console configuration route

From here you can enter the path to the TOML configuration file and set the maximum recursion depth.

You can also decide whether to apply these changes dynamically or on the next server restart. If the config source is enabled or disabled dynamically it will take effect across the server immediately.

From the Command Line

To configure the TOML Config Source from the command line, use these commands:

Usage

Provided that all of the above sections are configured correctly, the properties can be injected into any applicable MicroProfile Config injection point as with any other Config Source. They can also be fetched using the asadmin utility.

To prevent StackOverFlowException issues, the depth parameter limits the recursion depth when reading properties from the TOML file. If the maximum recursion depth is reached, further properties will not be read.

Examples

Example TOML file
title = "TOML Example"

[owner]
name = "Tom Preston-Werner"
dob = 1979-05-27T07:32:00-08:00

[database]
enabled = true
ports = [ 8000, 8001, 8002 ]
Retrieving properties programmatically
Config config = ConfigProvider.getConfig();
String ownerName = config.getValue("owner.name", String.class);
Inject configuration properties
@Inject
@ConfigProperty(name="database.ports[0]")
private Optional<Integer> databasePort;