users@jersey.java.net

Jersey as pure OSGi bundles

From: Richard Wallace <rwallace_at_thewallacepack.net>
Date: Sun, 14 Jun 2009 17:05:22 -0700

Hey all,

I've done some work on making the Jersey modules real OSGi bundles.
I've been doing this work on a branch I created on GitHub
<http://github.com/rwallace/jersey-osgi-ified/tree/master>. I now
have the jersey-core, jersey-server and jersey-json loading and
working in an OSGi framework (tested on Felix 1.8.0), without having
to do any hacks or classloading tricks in application code. Just
create the ServletContainer and go!

To do this I used the ServiceMix OSGi Locator code from
<https://svn.apache.org/repos/asf/servicemix/smx4/specs/trunk/locator/src/main/java/org/apache/servicemix/specs/locator/>.
 I was trying to use it out of the box, but they made the assumption
in the BundleFactoryLoader implementation that only a single
implementation would appear in the META-INF/services files. This
doesn't work for Jersey, so I had to make some minor modifications to
get everything happy. Other than that, I just added the
maven-bundle-plugin to the build of the submodules and cleaned up the
Import-Package declarations.

Another bit of work I had to do was to make the jsr311-api use the
ServiceMix OSGiLocator code as well. I don't have that published at
the moment, but if you want me to put it up on GitHub that's easy
enough.

You can see I didn't do all the modules. I left the jersey-client,
jersey-atom, and the jersey-fastinfoset alone. I didn't try these yet
because I don't use them so don't really have a good way to test them.
 But they should be just as simple as the jersey-json one was, and
someone with a way to test that they're really working should be able
to get it done quickly enough. I left the jersey-bundle one alone for
similar reasons, thinking that once the smaller modules are done it
should be pretty easy to put it all together in the jersey-bundle. It
should really only require pom changes and merging the Import-Package
settings of each of the submodules that are included in it.

Let me know if you have any questions about what I did and how it
works! I'd love to see this included in the 1.1.1 release so I can
upgrade from 1.0.2.

Rich