5.3 Runtime Configuration - Reference Documentation
Authors: Andres Almiray
Version: 1.2.0
5.3 Runtime Configuration
The application's runtime configuration is available through theconfig property of the application instance. This is a ConfigObject whose contents are obtained by merging Application.groovy and Config.groovy. Builder configuration is available through the builderConfig property and reflects the contents of Builder.groovy. Configuration files may also be provided as properties files; settings on the matching script will be overridden by those set in the properties file.
5.3.1 Internationalization Support
Configuration files are i18n aware which means you can append locale specific strings to a configuration file, for exampleConfig_de_CH.groovy. Locale suffixes are resolved from least to most specific; for a locale with language = 'de', country = 'CH' and variant = 'Basel' the following files are loaded in order
Config.groovyConfig.propertiesConfig_de.groovyConfig_de.propertiesConfig_de_CH.groovyConfig_de_CH.propertiesConfig_de_CH_Basel.groovyConfig_de_CH_Basel.properties
5.3.2 External Configuration Support
Some deployments require that configuration be sourced from more than one place and be changeable without requiring a rebuild of the application. In order to support deployment scenarios such as these the configuration can be externalized. To do so, point Griffon at the locations of the configuration files that should be used by adding agriffon.config.locations setting in Config.groovy, for example:griffon.config.locations = [
"classpath:${appName}-config.properties",
"classpath:${appName}-config.groovy",
"file:${userHome}/.griffon/${appName}-config.properties",
"file:${userHome}/.griffon/${appName}-config.groovy"]USER_HOME.It is also possible to load config by specifying a class that is a config script.griffon.config.locations = [com.my.app.MyConfig]
config property of the GriffonApplication object and are hence obtainable from there.Values that have the same name as previously defined values will overwrite the existing values, and the pointed to configuration sources are loaded in the order in which they are defined.