0 Replies Latest reply on Dec 4, 2013 5:43 AM by Dinabandhu Mitra

    Weld + OSGI + PAX-CDI in jboss?

    Dinabandhu Mitra Newbie



      I am fairly new to osgi, have done some projects using CDI (injection & interceptors). I am exploring the possibility of using OSGI and CDI together to get plugin type facility for extending a web application. I have gone through weld, pax-cdi and jboss as 7 osgi subsystem documentation and tried the quickstart osgi. However I am not really sure how to go about using CDI & OSGI together. Doubts are primarily from packaging and deployment (what goes where) point of view. I am giving below summary of my understanding and questions. If anyone can comment/answer I would be very grateful.


      1. From documentation, to use PAX CDI (0.5.0)I need weld 2.1.0. We are using jboss 7.x.x. Is it possible to replace the bundled weld (1.x.x) with weld 2.1.0? Or it requires subsystem level changes and I need to wait for wildfly to come out? From some JIRA cases I saw, it looks like there is subsystem level change but I wanted to confirm if that indeed is the case and there is no work around.


      2. On deployment, packaging and function following is my understanding, is this correct.

           a) To use CDI & OSGI together I need to do the following -

                Step 1 : - Configure following pax-cdi bundles in bundles folder of jboss and activate them using osgi subsystem configuration -

          • pax-cdi-api
          • pax-cdi-spi
          • pax-cdi-extender
          • pax-cdi-extension
          • pax-cdi-weld
          • pax-cdi-web
          • pax-cdi-web-weld

                Step 2: Create bean bundle. The bean bundle must have -

          • beans.xml to enable cdi scanning
          • Osgi bundle activator
          • all osgi meta information
          • must require pax-cdi extender capability as given in pax-cdi doc.
          • must include one @OSGIServiceProvider bean.

                Step 3: deploy bean bundle to jboss using any of standard jboss deployment method.

                Step 4. Create web application. The web application -

          • Contains a servlet.
          • the servlet must use @OSGIService & @Inject to inject an instance of the bean (proxy).
          • At this point servlet can use the injected bean as if it was a CDI bean declared in the web application itself.

                Step 3. Deploy the web application in jboss using any of standard deployment method.


      Is this understanding correct? If not I would appreciate any pointers on where I am going wrong. Also, I would like to get the setup working in Tomcat as well. Any pointers on that would be great.


      Thanks & regards,