OSGi tooling

There’s a really interesting conversation going on at TSS about OSGi and future directions for Enterprise Java.

I’ve posted a reply which I thought it was worth reposting here:

I think there are two issues with [the approach of repackaging existing modules as OSGi bundles and simply importing/exporting all packages] which really cause headaches going forward; Module vs API dependencies and complex “Uses” graphs.

Firstly module vs api; in most dependency tools such as Maven and Ivy the developer specifies dependencies at the module layer – i.e.

<dependency org=”org.apache.log4j” name=”org.apache.log4j” rev=”1.2.15″ />

But then spring have added an OSGi version of the module which has a different module id.

<dependency org=”org.apache.log4j” name=”com.springsource.org.apache.log4j” rev=”1.2.15″ />

How does the tooling know that these two modules are actually compatible? It can’t and this tends to lead to false dependency failures. This is the same problem as using module dependencies in OSGi at runtime. Actually the code is not dependent on the module but on the API that the module supplies.

Having been working with OSGi as part of our [1] distributed OSGi platform for almost 4 years now, I came to the conclusion that the tooling should use the notion of package import at build time – just as OSGi does at runtime. This is the approach I’ve taken in Sigil [2] which we’re now using to build our next product release.

Having taken the jump to use API dependencies our build system is now much simpler to manage. Instead of having to manually lookup which module supplies a package, I just type the package into the IDE and our tooling goes off and trawls the OSGi manifest information in various repositories to find a module that supports it (seemless). We’ve also used this on a number of third party applications (the record being a project with over 600 modules – which we managed to convert to use sigil in less than a couple of hours based on pretty much a simple grep of the java code for java import statements).

Secondly the major thorn in the approach of naively exporting all packages in a module is the complex “uses” information it generates. “Uses” is a flag provided by OSGi on exports to assert that the class space is coherent across multiple bundle import/export hops.

It is currently believed that the “uses” information makes the problem of resolving bundle dependencies NP-complete. As the number of bundles and import/exports increases the number of calculations the OSGi runtime has to do to check that all bundles can sit together goes up at a terrifying rate.

I’ve referred to this as placing barbed wire around sand castles (in most cases). If the modules were more sensibly designed i.e. only exporting the “really” public code then this problem is much reduced.

I’m also attending the summit Jason refers to and I’ve called a BOF “OSGi Development Tooling” with Peter Kriens and Chris Aniszczyk at the OSGiDevCon conference just prior to the summit to discuss tooling efforts w.r.t. OSGi. The BOF is open to the general public and it would be great to hear opinions before we sit down at the summit to figure out a path forwards.

[1] http://www.paremus.com
[2] http://sigil.codecauldron.org

Share This:

Leave a comment

Your email address will not be published. Required fields are marked *