Application Configuration
Purpose¶
A utility to manage application configuration.
Methods¶
Binding name: p6.appconfig
Method: void save(String appKey, Map<String, Object> config)
Save the configuration defined in a key/value map.
The configuration is stored into a table AppConfig attached to the application appKey.
The table will automatically be created if it does not exist.
Each value is converted to its string representation before being saved. The following types are supported :
- String (default)
- Double
- Long
- Integer
- Float
- Boolean
- Byte
- UUID
- Date
- ZonedDateTime
- Character
If the type of the value does not match one of the previous types, the fallback conversion used will be
the String.
Method: Object get(String appKey, String key)
Returns the configuration value
A P6Exception exception will be throw if:
- the
AppConfigtable does not exist - there is no configuration entry for the specified key
Examples¶
Example 1
Save the initial configuration
p6.appconfig.save("p6_demo", [ "description": "free text", "initialized": true, "version": 1 ])
Example 2
Read configuration
def description = p6.appconfig.get("p6_demo", "description") boolean initialized = p6.appconfig.get("p6_demo", "initialized")