Topic
3 replies Latest Post - ‏2012-11-28T17:16:21Z by Jacek_Laskowski
Jacek_Laskowski
Jacek_Laskowski
133 Posts
ACCEPTED ANSWER

Pinned topic Web app that uses OSGi services updated at runtime

‏2012-11-23T06:57:59Z |
Hi,

Here goes my highly imaginary use case I'm going to use to demo Liberty Profile with Enterprise OSGi (OSGi Blueprint) and Java EE.

$ ./bin/server version WebSphere Application Server wlp-1.0.1.cl0120121004-1949(websphere-kernel_1.0.1) on OpenJDK 64-Bit Server VM, version 1.7.0-u10-b09-20121009

I'd like to base my web application (WAB) on services that come and go at any time while the app's running. Since a part of the web app is a servlet I use

context = 

new InitialContext(); Hello hello = (Hello) context.lookup(
"blueprint:comp/HelloBeanBeanService"); hello.hello();

The web app uses blueprint.xml to register a reference to a service.

How should I structure the web app and the other bundles so refreshing a browser will pick up the changes in the service without restarting/redeploying the web app with the servlet?

I thought about developing an EBA with interfaces and dropping it to a shared repository. Another EBA (OSGi app?) to expose/register the service and the WAB in another EBA to use the service. Is this the way to leverage the potential of LP with Enterprise OSGi? Could you perhaps enhance the example to better suit my needs of developing a highly dynamic web app based upon OSGi services? Any help appreciated.

Jacek
Japila :: verba docent, exempla trahunt
  • MarkN
    MarkN
    10 Posts
    ACCEPTED ANSWER

    Re: Web app that uses OSGi services updated at runtime

    ‏2012-11-26T16:42:36Z  in response to Jacek_Laskowski
    Hi Jacek,
    OSGi applications are deliberately isolated from each other. You can use SCA to communicate between them on the Full WAS profile. On Liberty, you'll need to make the bundles all part of a single application, or consider other means of achieving inter-application communication.

    Regards,
    Mark
    • Jacek_Laskowski
      Jacek_Laskowski
      133 Posts
      ACCEPTED ANSWER

      Re: Web app that uses OSGi services updated at runtime

      ‏2012-11-26T17:30:23Z  in response to MarkN
      Hi Mark,

      Thanks for the response, but it's contradicted a bit my weekend's findings about Application-ExportService, which I did like as it widens my knowledge about OSGi in LP. Is this supported in OSGi applications in Liberty Profile? I'm leaning towards saying no as my initial labs showed, but hope I'm mistaken.

      Let's assume for a moment Application-ExportService is not supported.

      What I'm aiming at is to find out how to demo the service dynamicity in Liberty Profile. Where should I place common (interface) bundles? Should they be in shared repository? I think so.

      Where should be service bundles with services registered with Blueprint? Should they again be in shared repository? I don't think so.

      If a service bundle should be a part of OSGi application (EBA), how can I update it so the next time a servlet looks it up it receives another implementation?

      What I could find out so far is that the only way to update a service bundle is to update (= redeploy) the EBA it belongs to. If so, how does this differ from not using services, but static libraries as it is in Java EE? I understand the merits of OSGi services, but I can't demo them in Liberty Profile.

      I'd like to bounce/update a service bundle and have the servlet used the newest one over the one it used before. I could use rank to level up the importance of a given service implementation, but I'm still unable to find a way to let the servlet use another service once it's installed to LP.

      Is EBA redeployment the only way to change service bundles within?

      I don't mind staying within the realm of a single OSGi application, if that's the way to do it right. I'd however like to be able to update a service bundle without redeploying WAB with the servlet and have the update visible to the WAB. How?

      In OSGi runtimes I used before, mostly Felix and Equinox, I used to update a service bundle to have the update been visible and the next time another bundle (perhaps WAB with a servlet) looked it up the update has been picked up. I can't even seem to list OSGi services registered via OSGi Blueprint on the LP OSGi console. I think it's because they're hidden within a Blueprint container for every Blueprint-based OSGi Application and there's no way to use the console to list their content. Is there a way to achieve it?

      Please help as I'm stuck mental-wise. It's so depressing that when I'm demo'ing LP with OSGi services the last question I'm willing to hear is how to update services without the other components touched (which should be the primary question I should answer with ease, right?)

      Jacek
      Japila :: verba docent, exempla trahunt