I was thinking of integration OSGI in a different way using CDI.
What this involves is creating a WAB with a bundle activator. In the start
method of the BundleActivator, the BundleContext can be made available
(static variable) so it can be accessed later. Then I can create a managed
bean with a producer method
class MyOsgiServiceFactory {
@Produces @ApplicationScoped
MyServiceFromOsgi createMyServiceFromOsgi() {
BundleContext context = ... retrieve it...
MyServiceFromOsgi service = .... get osgi service from
context ....
return service
}
}
After that, I can use @Inject to inject the service.
Also, I don't want to make EJBs available as OSGI services (yet) so that's
not a problem for me.