Larry,

You will need to implement your own ResourceConfig and ClassScanner that are
OSGi-aware.  The DefaultResourceConfig with Jersey will not work out of the
box and the ClassScanner they provide does not work either.

The way I'd recommend going is:
  - Implement your ResourceConfig and ClassScanner
  - Implement a service and activator
  - In the service activator register the Jersey servlet with the
HttpService provided by Jetty

The other issue you'll encounter is that Jersey creates a new instance of
your JSR311 annotated classes for each request.  If you are using DS you'll
need some sort of ServiceLocator that can get a ServiceReference and resolve
a service.  I use FrameworkUtil.getBundle() to get my bundle, from which I
get a BundleContext, from which I can resolve services.

I have my Jersey wired up this way and it works pretty nicely.  I can
refresh/update my services and my thin JSR311 layer takes advantage of the
new services when they come online.  Very handy...


Good luck,

-c

On Tue, Apr 6, 2010 at 12:55 PM, Larry Touve <[email protected]>wrote:

> I'm using Jersey to develop some RESTful Web Services.  I'd like to create
> these as OSGI bundles that I can deploy.  Is there any (relatively easy) way
> to do this?  I'm currently running Glassfish V3, and am deploying bundles to
> the underlying Felix, but  I'd like to run just Felix (without GF) and have
> the Web Services exposed (through the Felix http bundle?).
>
> I looked at the example from the Apache Felix HTTP Service page (
> http://felix.apache.org/site/apache-felix-http-service.html)  where the
> ServiceReference from the HttpService class is used to register a pojo that
> extends HttpServlet.  Would It be similar for a Jersey POJO?
>
>
> Thanks,
>  Larry
>
>

Reply via email to