0

I would like to use the Config Admin service to manage configuration for my services. Since I'm just starting to use OSGi, I would like to introduce it step by step. So, I would like to keep some of my applications as they are now, without executing them inside an OSGi framework. But, I would also like to be able to use the Config Admin service from these legacy applications, so they can also get configuration information as other OSGi services.

Is it possible to do with OSGi? By looking at the specs, I've found a specification for Foreign Applications Access. I don't know if it's related to my problem. If it is possible, where I can find resources about how to make my legacy applications interact with the Config Admin service.

I precise that I'm using Apache Felix in the case it's implementation specific.

Thanks

manash
  • 6,985
  • 12
  • 65
  • 125

1 Answers1

0

Basically what you want to have is code the can run inside as well as outside OSGi. When in OSGi you want to leverage the config admin service. Is that correct?

So a good solution for this is following the principle of dependency injection. You code should not load configs, instead it should expect the config to be injected. For example use a setter where you need a config attribute. Outside of OSGi you can use spring or hand code injections to set the configs. Inside OSGi you could use an Activator or a blueprint context. Both will be inactive when you do not run in OSGi so it does not hurt to always have them.

See my first Apache Karaf Tutorial for how this works. The tutorial only shows the setup for OSGi but it is easy to see what you would need to do outside OSGi to configure the example. Karaf Tutorial Part 1 - Installation and First application

Christian Schneider
  • 19,420
  • 2
  • 39
  • 64