Tech Challenges for a Young Craftsman

Main menu

Post navigation

Auto-Provisioning OSGi Features: The Basics

Welcome to the first blog post of my new tech blog. Unfortunately, the topic I chose was far larger than I anticipated, so this will actually consist of several blog-posts.

With each post, I will include a zip which shows how the example has evolved. If you want to skip straight to the zip, please scroll to the end of the post

In this series I will cover:

The Basics

(Turning your “features.xml” into a feature template)

Deployment and Installation

(Getting XML to your Nexus easily)

Automatic Versioning

(The magic glue that makes this all automatic)

I will be assuming an understanding of Maven, and can include a later blog-post on the topic if viewers seem to want this.

Auto-Provisioning? What do you mean?

Recently, during a software project, we decided to deliver an application via OSGi inside a ServiceMix container. In order to do that, we chose to provision a “feature”, allowing the customer to install the entire application through a simple URL.

Doing so raised some interesting problems. How do you deploy a versioned “feature” file to a Nexus repository? And how do you automate the versioning of the bundles contained within it?

Our solution to that problem is the topic for this blog series. Feedback would be very appreciated.

The process of creating a template features file is actually the most basic, and provides the least gain. However, it also lays the groundwork upon which the next two posts will build, so I will start there.

The first step is to simply create a “features” template. Place this in an appropriate templates directory, and format it to properly describe your feature. Use maven-style variables where relevant. For example:

Now that we’ve set things up like this, maven can associate the variable with the appropriate dependency. Since all we’re doing is creating a template right now, this might seem pointless, but it will become very important later.