Eclipse MicroProfile Config API

Since 4.1.2.173 

Provided version of the API: MicroProfile Config 1.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.

A full overview for the reasoning behind the API can be found in the README for the source code repository.

The complete specification is maintained in the same repository

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:

Source Ordinal Description

directory

90

Reads configuration properties from files in a specified directory. Each file name is the confguration property name and the contents of the file are the config property value. This config source can be used to read Kubernetes secrets files. See below on how to specify the directory to be used for secrets files using asadmin.

domain

110

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

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 appllication. 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.

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.

password

105

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

Converters

In addition to the standard converters specified by the API, Payara’s implementation includes out-of-the-box converters for URL and InetAddress. These have @Priority of 1, the same as the default converters.

Payara Specific 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 Payara 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

Asadmin Commands

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

set-config-ordinal

Usage

asadmin> set-config-ordinal --ordinal=<integer.value> --source=domain|config| server|application|module|cluster

Aim

Provides a way to set the ordinal for a given config source. Where multiple configuration properties exist, the property from a source with a higher ordinal number is preferred.

Command Options
Option Description Default Mandatory

ordinal

The value of the ordinal to set. This must be a number greater than 1. A lower number ordinal means lower order of precedence.

-

yes

source

The value of the source to change. Must be one of: domain, config, server, application, module, cluster

-

yes

target

The target Payara config to apply the change to

server (the DAS)

no

Example
asadmin> set-config-ordinal --ordinal=600 --source=application

get-config-ordinal

Usage

asadmin> get-config-ordinal --source=domain|config|server|application|module|cluster

Aim

Returns the ordinal value for the given ConfigSource type.

Command Options
Option Description Default Mandatory

source

The ConfigSource to get the ordinal for. Must be one of: domain, config, server, application, module, cluster

-

yes

Example
asadmin> get-config-ordinal --source=cluster

set-config-property

Usage

asadmin> set-config-property --propertyName=<property.name> --propertyValue= <property.val> --source=domain|config|server|application|module|cluster --sourceName=<source.name> --moduleName=<module.name> --target=<target[default:server]>

Aim

Sets the given property name and value in one of the built-in config sources. The source is specified with --source and, where there is ambiguity, the --sourceName and --moduleName options can be used. For example, where the source is server, the --sourceName can be used to specify the name of the server where the config property is to be stored.

Command Options
Option Description Default Mandatory

propertyName

The name of the configuration property to set

-

yes

propertyValue

The value of the configuration property to set

-

yes

source

The ConfigSource where the property is to be stored

-

yes

sourceName

The name of the ConfigSource when there may be ambiguity, for example a ConfigSource of type application must specify the name of the application. This property is required for sources of type: config, server, application or module

-

no

moduleName

The name of the module when the ConfigSource is of type module. When this is specified, the sourceName parameter must be provided and must have the name of the application where the module is deployed.

-

no

target

The target configuration where the command should be run

server (the DAS)

no

Example
asadmin> set-config-property
    --propertyName=JMSBrokerURL
    --propertyValue=my.jms.hostname
    --source=module
    --sourceName=myApplication
    --moduleName=myModule
    --target=myAppCluster

delete-config-property

Usage

asadmin> delete-config-property --propertyName=<property.name> --source=domain| config|server|application|module|cluster --sourceName=<source.name> --moduleName=<module.name> --target=<target[default:server]>

Aim

Deletes the given property name in one of the built-in config sources so that the property no longer exists. The source is specified with --source and, where there is ambiguity, the --sourceName and --moduleName options can be used. For example, where the source is server, the --sourceName can be used to specify the name of the server where the config property is to be stored. moduleName should only be used when the --source=module.

Command Options
Option Description Default Mandatory

propertyName

The name of the configuration property to delete

-

yes

source

The ConfigSource where the property is stored

-

yes

sourceName

The name of the ConfigSource when there may be ambiguity, for example a ConfigSource of type application must specify the name of the application. This property is required for sources of type: config, server, application or module

-

no

moduleName

The name of the module when the ConfigSource is of type module. When this is specified, the sourceName parameter must be provided and must have the name of the application where the module is deployed.

-

no

target

The target configuration where the command should be run

server (the DAS)

no

Example
asadmin> delete-config-property
    --propertyName=JMSBrokerURL
    --source=module
    --sourceName=myApplication
    --moduleName=myModule
    --target=myAppCluster

get-config-property

Usage

asadmin> get-config-property --propertyName=<property.name> --source=domain| config|server|application|module|cluster --sourceName=<source.name> --moduleName=<module.name> --target=<target[default:server]>

Aim

Gets the value for the given property name in one of the built-in config sources. The source is specified with --source and, where there is ambiguity, the --sourceName and --moduleName options can be used. For example, where the source is server, the --sourceName can be used to specify the name of the server where the config property is to be stored.

Command Options
Option Description Default Mandatory

propertyName

The name of the configuration property to get

-

yes

source

The ConfigSource where the property is stored

-

yes

sourceName

The name of the ConfigSource when there may be ambiguity, for example a ConfigSource of type application must specify the name of the application. This property is required for sources of type: config, server, application or module

-

no

moduleName

The name of the module when the ConfigSource is of type module. When this is specified, the sourceName parameter must be provided and must have the name of the application where the module is deployed.

-

no

target

The target configuration where the command should be run

server (the DAS)

no

Example
asadmin> get-config-property
    --propertyName=JMSBrokerURL
    --source=module
    --sourceName=myApplication
    --moduleName=myModule
    --target=myAppCluster

set-config-secrets-dir

Usage

asadmin> set-config-secrets-dir --directory=<full.path.to.dir> --target=<target[default:server]>

Aim

Sets the directory to be used for the directory config source.

Command Options
Option Description Default Mandatory

directory

Full path to the directory containing configuration files

-

yes

target

The target configuration where the command should be run

server (the DAS)

no

Example
asadmin> set-config-secrets-dir
    --directory=/home/payara/.secrets
    --target=myAppCluster

get-config-secrets-dir

Usage

asadmin> get-config-secrets-dir --target=<target[default:server]>

Aim

Gets the value of the directory to be used for the directory config source.

Command Options
Option Description Default Mandatory

target

The target configuration where the command should be run

server (the DAS)

no

Example
asadmin> get-config-secrets-dir
    --target=myAppCluster