users@jersey.java.net

[Jersey] make resources from osgi bundles available to jersey

From: Eike Kettner <news_at_eknet.org>
Date: Sun, 17 Jul 2011 01:02:27 +0200

Hello

I'm new to jersey and I'm successful so far with using jersey
from my osgi application (using version 1.9-ea01). I'm using the
ServletContainer with a WAB and a javax.ws.rs.Application class as init
parameter. Adding resources from within "getSingletons()" works nice.

Now I like to have other bundles contribute resources to the
application. I couldn't find good information on how to add resources
dynamically. For example, I like other bundles to implement this
interface and expose it to the OSGi registry:

  interface ResourceProvider {
    Object[] getResourceSingletons();
  }

If such a ResourceProvider service from some bundle enters the OSGi
registry, I like to make all the resource objects from this provider
available to jersey. If the ResourceProvider leaves, the resource
objects must be unregistered, because they are not available anymore. If
this makes any sense, is there somewhere documentation on how to
accomplish this with jersey? I found the "reload" method in
ServletContainer, is this the way to go?

Then Googleing led me to http://www.dynamicjava.org/projects/dynamic-rs
which looks like what I like to do. But this project had its last (and
only) release in 2009, so I was wondering if it might be obsolete by
now... Does anyone know more about this?

Thanks and regards
Eike

-- 
email: eike@eknet.org   https://www.eknet.org  pgp: 481161A0