Look Inside Your OSGi Bundles and Build them Block by Block
OSGi provides the infrastructure to build applications from components and services, provided as bundles. But how can we work equally structured also within bundles? We show how to build OSGi bundles with Reactive Blocks, by plugging together building blocks. This makes it easy to handle concurrency, reuse behavior and find intricate concurrency errors automatically.
Let’s have a look at a typical OSGi application, for instance one that runs on a residential gateway. It needs to coordinate behavior of several other bundles, listen to incoming messages, respond in time, handle remote configuration changes and react on its own bundle life cycle. Also, the bundle should react properly when the network goes down or when required services get unavailable.
When so much happens in parallel, it get’s complicated. Concurrent programming is still a delicate art form. Code with lots of concurrency is hard to write and debug (race conditions, anyone?). The code is also hard to understand for any other developer that inherits it.
Reactive Blocks is a tool integrated with the Java tools in Eclipse. With it, Java code is organized in the form of building blocks, which can be plugged together using graphical data flows. The data flows make it easy to handle concurrency and synchronize behavior. But Reactive Blocks does not try to replace Java programming. Graphics and code work together. The data flows simply describe when Java operations are called.
Libraries of building blocks provide functions that are often used. As an example, libraries for OSGi provide building blocks to listen to other services and OSGi events. It's also possible to make new building blocks.
Applications are constructed by connecting building blocks. An automatic analysis checks the behavior of the application. You can detect, for instance, that a bundle contains logic that drives it into a deadlock instead of nicely shutting down.
The structure with building blocks makes it easier to keep the overview of an application, even if it is highly concurrent and complicated. Suddenly you can look inside your OSGi application bundle!
Frank Alexander Kraemer [Bitreactive AS]