Java Reference
In-Depth Information
commonly used libraries that don't offer an OSG i bundle distribution. The bundles
provided by the EBR are available under a variety of different licenses, the same ones
with which the original projects were made available.
Maven Central
Many popular libraries are available on Maven Central as OSG i bundles, even when
the library authors haven't made a bundle packaging available. The JAR and bundle
packaging can co-exist on Maven Central because they have different group ID s; usu-
ally, the group ID of the bundle is the ID of the project that repackaged it. This makes
it harder to find individual bundles, but easier to browse the whole collection.
The Apache ServiceMix and Apache Geronimo projects have both pushed a large
number of useful bundles to Maven Central. Therefore, the most common group ID s
for repackaged bundles on Maven Central are org/apache/servicemix/bundles/ ,
org/apache/geronimo/bundles , and org/apache/geronimo/specs .
If you're unlucky enough to find that the library you want to use isn't available from
SpringSource, Apache, or anywhere you've managed to search on Google, then it's time
to start thinking about taking matters into your own hands. A couple of options are open
to you here, options broadly similar to those used by Apache and SpringSource.
Building your own bundles
When you've reached the point where you need to convert your library JAR into a bun-
dle yourself, we're afraid that things get more difficult for you. Unfortunately, there's
no magic wand to wave, but there's a little pixie dust we can introduce you to later.
We'll start by looking at how to build your library bundle by hand. This isn't particu-
larly easy, but it's important to know how it's done, even though later we'll show you
some of the automated tools.
Although it may seem like a lot of effort, as long as you don't have more than a couple
of simple libraries to convert, building OSG i manifests by hand isn't always a bad idea.
You learn a lot about the library in the process. The first step for building an OSG i
bundle from a JAR is simple: you need to extract the JAR 's manifest file. This can be
done using a zip utility, or by using the jar command, as follows:
jar xf jarfile.jar META-INF/MANIFEST.MF
Having extracted your manifest file, the first and most important things you need to add
are Bundle-ManifestVersion: 2 and a Bundle-SymbolicName for your bundle. While
you're at it, you should also provide a version for your bundle using the Bundle-Version
header. At this point you have, theoretically, added enough information to the manifest
to turn your library into a valid OSG i bundle. If you remember back to the start of the
topic, you didn't even need to specify the bundle version for that, though hopefully you
now know why you always should supply a version.
Although there's now enough metadata to install this bundle into an OSG i frame-
work, it wouldn't be useful in its current state. To be able to use this library, you'll have
to export some packages from it. Assuming the library is well documented (and at
Search WWH ::

Custom Search