-
Notifications
You must be signed in to change notification settings - Fork 3
4. Property Resolvers
PACIFy's main goal is to configure a package. It knows where a configuration exist's and how to replace it but PACIFy doesn't have the knowledge about the values. For that PACIFy is asking the resolvers.
PACIFy ships with two build-in resolvers:
but you can implement your own resolver. It's really easy :-). There is a third implementation of a resolver but this one isn't included by default:
At runtime PACIFy isn't restricted to one resolver, you can chain them! PACIFy will then ask for a property value in the given resolver chain order.
Due to the fact that PACIFy doesn't have any knowledge about the resolver implementation and their needs, the commandline api to them is really simple. If your resolver need's some runtime parameter you have to specify them like:
-R<resolverId>.<parameter>=<value>
e.G.
-RFileResolver.file=prod.properties
PACIFy will then forward that Parameter to the particular resolver. In this example the FileResolver will get the parameter file with the value prod.properties.
This is the Command Line Resolver. The main purpose of this resolver is to chain him with other resolvers and to overwrite a value.
java -jar pacify.jar
replace \
--packagePath=/share/app/deployment-package-app-v1.0 \
--resolvers=CmdResolver,FileResolver \
-RCmdResolver.log.level=DEBUG \
-RFileResolver.file=prod.properties
In this example the properties will be resolved via CmdResolver and FileResolver. But the CmdResolver is prioritised. So all values will be resolved by the FileResolver except the log.level.
| Parameter | Mandatary | Default | Description |
|---|---|---|---|
| beginToken | no | %{ | What is the begin token of a placeholder if you reference a property in a value. |
| endToken | no | } | The end token of a placeholder. |
| encoding | no | UTF-8 | The Encoding. |
| <property> | no | Your property which you want to resolve via commandline. |
Here you find a really simple solution to manage your properties. The FileResolver is reading the configuration from a file, which looks like a property file. But there is more, he supports inheritance and references! Here a small example:
===== base.properties =====
jdbc.host=example.org
jdbc.port=1521
jdbc.sid=xe
jdbc.url=jdbc:oracle:thin:@%{jdbc.host}:%{jdbc.port}/%{jdbc.sid}
============================
===== test1.properties =====
#!import base.properties
jdbc.host=another.host.org
============================
If you call now PACIFy using the FileResolver and as parameter -RFileResolver.file=test1.properties the result will be:
===== result ==============
jdbc.host=another.host.org
jdbc.port=1521
jdbc.sid=xe
jdbc.url=jdbc:oracle:thin:@another.host.org:1521/xe
============================
This is really powerful and brings your configuration to a minimum. Have a look at the examples for more usages.
| Parameter | Mandatary | Default | Description |
|---|---|---|---|
| file | yes | Path to the file where to load the properties from. | |
| beginToken | no | %{ | What is the begin token of a placeholder if you reference a property in a value. |
| endToken | no | } | The end token of a placeholder. |
| encoding | no | UTF-8 | The Encoding of the property file. |