I need to use a global data value between a couple of OSGi modules. What's the best way to use a singleton data property holder in OSGi modules?
Should I design a "common" module, which exports a package and store global singleton in this common module package?
Thanks in advance
It depends a bit how complex the initialisation of the data is. If you simply want to share some kind of constant then a singleton in a shared module is a good choice.
In other cases the loading is more involved. For example if you load the data from a database and loading might have other dependencies like a DataSource. In these cases it is better to just share an interface and a service. This then allows to hide the dependencies and initialisation effort from users of the service.