In an OSGi runtime ecosystem, you must consider how your apps can rely on OSGi services in other modules for functionality. It’s possible for service implementations to be swapped out or removed entirely, and your app must not just survive but thrive in this environment.
If you want to call OSGi services from an OSGi Declarative Services
classes, it’s easy: you just use a Declarative Services
to inject the service. The component activates when the referenced service is
If you want to call an OSGi service from a bean, use OSGi CDI integration.
@Components and OSGi CDI integration with beans manage
much of the complexity of service dynamism for you transparently. If you can use
either of them, you should. Otherwise, read implement a Service
look up services in the service registry.