Back when I did OSGI, I used to deal with this using DS and configuration, I expect it’s easier to set up the necessary configurations now.
The core would have a service with a reference to the product service. The configuration installed with the product sets the cardinality of the reference as minimum 1 (or however many are expected), so it’s mandatory. If a product doesn’t include the service, it sets the cardinality 0, so it’s optional. David Jencks > On Nov 4, 2021, at 3:40 AM, JB Onofré <[email protected]> wrote: > > Hi > > Why not using a whiteboard pattern. You can have kind of controller service > acting as whiteboard on « business » services. > When a service pop up, the controller can deal with it. > > Regards > JB > >> Le 4 nov. 2021 à 10:13, Serge Démoulin <[email protected]> a écrit : >> >> >> Hi >> >> We are developing a platform based on bundles >> Our products are based on this platform. >> product = platform bundles + product specific bundles >> >> A product can change the behaviour of the platform by implementing singleton >> OSGi services >> >> >> We would like make these service optional but it's not easy >> Therefore if the platform doesn't find such a service there too possibilities >> - the product doesn't implement this service. The platform behaviour stay >> unchanged, alright >> - the product intends to implement the service in a bundle but the bundle >> that implement this service is broken. In this case the product has not the >> right behaviour >> >> The complex solution that we implement is >> Such service is seen as mandatory by the platform and the platform has a >> default implementation of the service in a bundle . >> The build of the product removes this bundle and bring its own bundle >> >> This build is error-prone and expensive to realize. >> >> Do have an idea how we should have optional service but detect if the >> product intends to implement the service (without integration tests in the >> product that test the correct behaviour) ? >> >> An idea for instance >> If the service are declare with @Component >> Scan every MANIFEST.MF to find pretty exactly which services are intended to >> be implemented >> >> Best regards >> >> Serge >
