Search code examples
osgiblueprint-osgideclarative-services

OSGi activation method fallback


I was wondering if it is somehow possible to create a fallback from one activation method to another? Let's say i have a bundle that is activated via Declarative Services, but SCR is not installed on the application server in question. Is it possible to have a bundle with both Declarative Services and Blueprint activators, and decide the load order? For example: Can i make a bundle and specify that it should be loaded by SCR if available, and Blueprints if SCR is not installed?


Solution

  • If you want to use SCR functionality and your bundle is installed in an app server that doesn't have SCR then the easiest answer is to install SCR. It's a single, small bundle, and it is a dependency of your bundle just as much as the packages etc that you depend on.

    If you really cannot install SCR or rely on SCR already being available, then you need to write a BundleActivator. This is normally only necessary for very low-level "plumbing"-type bundles, or when running on extremely resource-constrained devices.