users@glassfish.java.net

Re: documentation for osgi extensions?

From: Erik Brakkee <erik.brakkee_at_gmail.com>
Date: Thu, 8 Apr 2010 22:03:47 +0200

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.