I'm new on diving in the OSGi world. I'm trying to develop an application with the following modules(bundles):
Suppose the default-service bundle contains internal data access services.Therefore, it needs some configuration for the database access. It doesn't feel right to me to place the DB configuration within the default-services bundle. Also, the web bundle should not know how the default-service is internally wired.
My question is: Does OSGi have a concept of configuration bundle? My idea was to deploy a bundle responsible for the default-service configuration. Is there a similar solution for that?
Have you looked at ConfigurationAdmin service? Your bundles should use ConfigurationAdmin to receive their configuration. If you use Declarative Services in your bundles, DS will automate the use of ConfigurationAdmin for you.
Depending on how you expect to do configuration, fragments may suit your needs. They allow you to add extra information to the existing bundles classpath. We use this to provide different configurations for different runtime environments (dev, test, ...). You simply deploy the appropriate fragment bundle to have the correct configuration.
I actually developed a little bundle that can detect configuration data in other bundles with the extender pattern. In my case this is a Jason file. Got some special tricks to handle passwords and binary files like ssl certificates.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With