Search code examples
osgiapache-felixosgi-bundle

Environment specific configurations in Felix Configurator


Felix Configurator allows to apply service configurations using JSON files. I provided a bunch of json files under OSGI-INF/configurations and those were picked by the configurator bundle which applied the configs correctly. This is great but I am thinking of applying the configurations on environment basis like Sling run mode configs or Spring profiles for that matter.

I have looked into the Felix Configurator code and specs but could not find any reference to such a capability.

OSGi experts, please suggest how this could be achieved.


Solution

  • If you only need to replace values in a config but have no structural changes then felix interpolation is the best solution.

    A good practice for docker is to use environment variables:

    com.my.userinfo:
    "greeting": "Hello $[env:USER]!"

    Just make sure you use the newest version of felix configadmin as interpolation uses a new configadmin feature from OSGi R7.