JPz'log Coin Coin and Plop da Plop

27Oct/091

OSGi development made easier

Lego

I must confess that I happen to write OSGi bundles, and somehow happen to actually enjoy that, despite all the care you need to have with respect to:

  • dynamicity-handling boilerplate code
  • having to maintain a MANIFEST
  • forced mutable class design
  • concurrency issues (you often have to spin a thread when your bundle starts).

Creating an OSGi bundle is not very complicated per-se, but tooling has historically been quite limited. Fortunately, we now have a good Maven-based toolchain.

Indeed, wouldn't it be nice to focus on just writing your own bundles and forget about the rest?

First of all I suggest that you use the Apache Felix Maven Bundle. With minimal definitions, it takes the pain of maintaining the MANIFEST entries away from you with minimal informations:

  • it makes a bundle by using most of the informations available from your POM
  • by default, it maintains the imported / exported packages much like you would expect
  • it leverages each of your POM depency nicely: if it's a bundle then fine, otherwise it will either wrap it as a bundle or simply embed the classes (dealing with non-bundles is a huge pain point in OSGi).

The second Maven plugin that I wanted to tell you about is the Pax Plugin by the OPS4J crew. This plugin is another time-saver, as it is able to automatically provision an OSGi runtime (Apache Felix by default, but you can ask for Eclipse Equinox, Knoplerfish, etc).

Without this plugin, you either have to manually install your bundles into an OSGi runtime, or write configuration files to get the provisionned environment that you need for your tests. All of that is handled by the Pax plugin, and you get the extra benefit of beeing able to try your bundles on several OSGi runtimes.

Indeed, to try your bundles on Apache Felix, simply type:

mvn pax:provision

and if you want to play with Eclipse Equinox:

mvn pax:provision -Dframework=equinox

Those two complementary plugins should definitly make OSGi development simpler, at least from the toolchain point of view :-)

Share this post:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • Live
  • Netvibes
  • StumbleUpon
  • Technorati
  • FriendFeed
  • Wikio
  • Twitter
  • Identi.ca
  • Reddit
  • RSS
  • Slashdot

Related posts:

  1. The Java jungle: integrated development environments
  2. ScalaTest in Maven
  3. Building Glassfish v3 from SVN
  4. Apache Geronimo 2.1 is out
  5. Random bullet points that are related to Java stuff

Comments (1) Trackbacks (0)
  1. Interesting things, thx jpz.


Leave a comment


No trackbacks yet.

JPz'log is Digg proof thanks to caching by WP Super Cache