Open
Description
Loaders / ConfigLoader2
- Each loader has a unique "prefix"
- There are builtin core loaders such as
classpath file cmd stdin
- There are additional loaders like
aws
andvault
etc that are registered via service loading
Flags
The known flags we want to support are:
NOT_REQUIRED
NO_INTERPOLATION
Note: maybe:
prefix has been used as a synonym for NOT_REQUIRED
.
Raw source expressions
Examples of <raw source expression>
s
classpath:foo.properties
classpath:some/other.yaml
maybe:classpath:application-test.properties
file:${user.home}/config/myapp.properties
file:/app/config/myapp.yaml
file:./relative/myapp.yaml
cmd:-P
cmd
stdin
aws:aws.appconfig
aws
vault:myvault.prefix
Bootstrap
- classpath:avaje-config.properties [or avaje-config.yaml?]
- This is loaded as raw Key Values
- Process the
avaje.load.sources
Process the avaje.load.sources
- Remove
avaje.load.sources
value. Delimited list of "load source keys" or "known source plugins". Delimited by space or comma. - Remove
avaje.load.prefix
value. Defaults to_load_
. - Remove
avaje.flags.prefix
value. Defaults to_flags_
. - Split the
avaje.load.sources
into an ordered list of "load source key"s - For each "load source key"
5.1. Remove the_load_<source key> value
[with default of<source key>
] produces a<raw source expression>
5.2. Remove the_flags_<source key> value
produces a<set of flags>
5.3. At this point we have an order list of<raw source expression>
+set of flags
- Run interpolation of the remaining key values
- Add these interpolated key values to the context
- For each
<raw source expression>
+set of flags
8.1. "perform a load for a source"
8.2. Note that this can be recursive depth first traversal
Perform a load for a source
- Translate a
maybe:
prefix into aNOT_REQUIRED
flag - Determine the prefix which identifies the
ConfigLoader2
to use - Determine the optional path [remainder after the prefix is removed]
- Perform interpolation on the optional path
ConfigLoader2.load()
returning theKeyValues2
for this source. If "required" and source was not found throw exception- Process the
avaje.load.sources
on the returnedKeyValues2
- If "interpolation" flag then execute interpolation on the
KeyValues2
Example avaje-config.properties
## specify load order including test
avaje.load.sources=foo bar cmd test aws vault
avaje.load.prefix=_load_
avaje.flags.prefix=_flags_
_load_test=maybe:classpath:application-test.properties
_load_foo=classpath:foo-repository-layer.properties classpath:foo-service-layer.properties.
_load_bar=classpath:bar-repository-layer.properties classpath:bar-service-layer.properties.
_load_cmd=cmd
_load_aws=aws ## or aws:aws.appconfig
_load_vault=maybe:vault:myvault.prefix
aws.appconfig.region=${AWS_REGION}
aws.appconfig.appName=myapp
aws.appconfig.env=${ENV:local}
Metadata
Metadata
Assignees
Labels
No labels