felix-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bengt Rodehav <be...@rodehav.com>
Subject Fileinstall, problems with variable substitution and write back
Date Tue, 26 Nov 2013 10:52:29 GMT
I'm using Apache Karaf 2.3.3 which comes with FileInstall 3.2.6. I have set
the felix.fileinstall.enableConfigSave property to true in order to have
FileInstall write back configuration changes to the file. Normally all
configuration changes are done by editing the configuration file but there
is one property that I change programmatically using ConfigAdmin (an
"enable" property to start/stop my service). I am dependent on that
property being persisted in the configuration file which is why I set the
enableConfigSave property to true.

When configuring FileInstall to write back configuration changes to the
configuration file, it is important that variables are not substituted for
the evaluated value. This normally works since FileInstall evalutates the
property in the configuration file and compares it with the configuration
admin's value. If they are the same, the value in the configuration file is
kept unchanged.

However, when using the escape character this is broken. In my case I'm
using Apache Camel underneath. When configuring routes via the config
admin, I sometimes need to set a value to
"${expression-to-be-evaluated-by-camel}". I therefore escape the "{" and
"}" to stop FileInstall from trying to evaluate the expression. Like this:


This also normally works but not when I have an indirection. E g when
specifying the following:


FileInstall will change the configuration file to:

ab = ${var}b

Note that the variable "ab" has now been expanded and written back to the
configuration file even if neither of the variables "a" and "ab" have been

I think this is because FileInstall does the following:

1. Calculates the value of "a" to "$\{var}
2. Calculates the value of "b" to "${var}b

Note that every evaluation will perform "unescaping". This means that an
extra "unescaping" will be done for every indirection which fools
FileInstall into thinking that the property has been changed.

I'm not exactly sure how this should be fixed in FileInstall. One idea is
to never "unescape" already evaluated variables. Actually I think this is
probably what would fix this...

Does anybody have any ideas about this? Should I create a JIRA?


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message