Is your OSGi toolset Pax'd out? - No Fluff Just Stuff

Is your OSGi toolset Pax'd out?

Posted by: Craig Walls on August 1, 2008

If you're wanting to wade in the waters of OSGi (or even if you're ready to do a deep dive), you owe it to yourself to take a look at what the folks at OPS4J are doing, specifically with their Pax collection of projects.

Let me give you the nickel tour of what Pax has to offer...

Coin

Coin is a relatively new entry to the Pax family (at this time there's not even a release available). Pax Coin is advertised as a highly configurable implementation of the OSGi Configuration Admin Service Specification that supports configuration from a variety of sources. Those sources could include the file system, a bundle, or the service registry. I don't know much about Coin yet, but it looks very promising.

ConfMan

ConfMan is an implementation of the OSGi Configuration Admin agent that loads configuration details from a properties file. It does require that a Configuration Admin service be installed in the OSGi framework. It's unclear to me what the future of ConfMan is with regard to Coin, but I think that ConfMan could end up being an agent to feed Coin.

Construct

Pax Construct is, in my opinion, the crown jewel of the Pax family. In a nutshell, Construct is a Maven plugin, plus a dozen or so scripts that make short work of developing OSGi-based projects. I like to describe Construct as "OSGi on Rails" (DHH probably won't care for me using that name...oh well). Keeping the comparisons in the Java space, you might compare Construct to Matt Raible's AppFuse. But Construct is less about "let's build a web site" and more about how to quickly develop OSGi bundle projects. Pax Construct can generate project folders, wrap non-bundle JARs, embed JARs in bundle projects, manage your MANIFEST, provision your bundles, and much more. If you're just starting out on a new OSGi project, I'd definitely consider using Construct to kick start the effort.

Cursor

Pax Cursor is an Eclipse plugin that uses Pax Runner (see below) to provide all supported OSGi platforms in Eclipse. In contrast to Eclipse PDE which is limited to deploying to a single version of Equinox, Cursor makes it possible to work with Felix, Knopflerfish, Concierge, and even multiple versions of Equinox within Eclipse.

Drone

Pax Drone is an bundle testing framework for OSGi, based on JUnit. A Drone test case sets up an OSGi framework (using Pax Runner under the covers), installs a selection of bundles, then makes the BundleContext available to the test methods to make assertions against the framework and the bundles contained therein.

Logging

Pax Logging is an implementation of the OSGi Logging Service that provides the API of several popular logging packages (such as Log4J and Commons Logging). The problem with the conventional logging packages is that due to they way they deal with the class space, they are incompatible with OSGi. The problem with the OSGi logging service is that it doesn't implement any of the de facto logging APIs. Pax Logging satisfies both issues.

Reflector

Reflector provides the ability to inspect a running application without any special debugger. It comes in the form of a handful of bundles that can be installed/uninstalled at will (while the application is still running) to help pinpoint problems.

RadMan

Pax RadMan is still in drawing board and prototyping stages, so there's not much to see yet. But it aims to be a remote and distributed management solution for OSGi, enabling remote administration of an OSGi installation, including installation/update/uninstallation of bundles (among other things). Sounds interesting.

Runner

Starting an OSGi framework, then installing and starting all of the bundles in an application can be a tedious endeavor. Pax Runner simplifies all of that by starting an OSGi framework of your choosing (Equinox, Felix, Concierge, or Knopflerfish) and installing/starting a selection of bundles that you specify. What's especially cool about Pax Runner is that it can provision the bundles from several sources, including the file system, an HTTP URL, and from a Maven repository.

Swissbox

As the various Pax projects were being created, several common utilities were discovered. Those utilities found a home in Swissbox. But, since the utilities are generic, they can be used outside of Pax...perhaps in your OSGi application. Included are utilities for dealing with the core OSGi framework, writing implementations of the extender pattern, dealing with the service lifecycle, and tracking services.

URL

Most OSGi frameworks (Equinox, anyway) can resolve and install bundles from file and http URLs. Pax URL extends the framework to support other URLs, including...

  • classpath: - Access resources in the classpath or within other bundles
  • mvn: - Access bundles in a Maven repository
  • obr: - Access bundles in an OBR repository
  • war: - Automatically wraps WAR files with an OSGi manifest
  • wrap: - Uses Peter Kriens' BND to wrap non-bundle JARs as OSGi bundles

Web

Pax Web is an implementation of the OSGi R4 Http Service. Under the covers it uses Jetty 6. What sets Pax Web apart from other implementations of the Http Service is that it supports the full Java web portfolio, including servlets, filters, listeners, error pages, and JSPs (most Http Service implementations only support servlets).

Personal note: I think Pax Web is great, but have stopped using it in favor of Spring-DM's Jetty and/or Tomcat bundles, which work much better with Spring-DM's web extender.

Web Extender

Pax Web Extender is an implementation of the extender pattern that watches for WAR bundles to be installed, then parses their WEB-INF/web.xml file to deploy them to the Http Service (such as Pax Web).

Personal note: Again, I like Web Extender, but find that Spring-DM's web extender is a much better choice for my Spring-oriented needs.

Wicket

Pax Wicket is an OSGi extension to Apache Wicket that makes it possible to add, remove, and move around parts of a Wicket application at runtime (without restarting the application) by loading and unloading OSGi bundles.

As I said in the beginning, Pax is a must-see collection of tools for OSGi developers. If you're working in OSGi or even interested in looking into OSGi, you should have a look at Pax. I'd start with Construct, Runner, and URL, as I have found them to be the most valuable parts. (Note that Contruct uses Runner in its pax-provision script, so if you're using Construct, you're already using Runner).

Today I've kept my blog entry peaceful, by giving you an overview of the goodness that Pax provides. But in my next entry I'll express a little frustration...a topic perfectly suitable for a Monday. In the meantime, have a Pax-ful weekend!

Craig Walls

About Craig Walls

Craig Walls is a Principal Engineer, Java Champion, Alexa Champion, and the author of Spring AI in Action, Spring in Action, and Build Talking Apps. He's a zealous promoter of the Spring Framework, speaking frequently at local user groups and conferences and writing about Spring. When he's not slinging code, Craig is planning his next trip to Disney World or Disneyland and spending as much time as he can with his wife, two daughters, 1 bird and 2 dogs.

Why Attend the NFJS Tour?

  • » Cutting-Edge Technologies
  • » Agile Practices
  • » Peer Exchange

Current Topics:

  • Languages on the JVM: Scala, Groovy, Clojure
  • Enterprise Java
  • Core Java, Java 8
  • Agility
  • Testing: Geb, Spock, Easyb
  • REST
  • NoSQL: MongoDB, Cassandra
  • Hadoop
  • Spring 4
  • Cloud
  • Automation Tools: Gradle, Git, Jenkins, Sonar
  • HTML5, CSS3, AngularJS, jQuery, Usability
  • Mobile Apps - iPhone and Android
  • More...
Learn More »