users@jersey.java.net

[Jersey] Re: Live registration of resources

From: Pavel Bucek <pavel.bucek_at_oracle.com>
Date: Wed, 06 Apr 2011 18:25:18 +0200

Hello,

Jersey creates optimized resource model at startup, but you can force
"re-creating" almost everything - see ScaningResourceConfig.onReload().

So, what you probably want to do is extend ScanningResourceConfig and
implement your own scanner (which you already have, you just need to
implement that interface and report found resources to ScannerListener,
see FileScanner class). When you have this in place, just call onReload
whenever change is detected and jersey will take care of
reloading/rebuilding inner resource model.

Le me know whether you need some additional info (I can create sample or
something which could help you).

Regards,
Pavel

On 04/06/2011 04:35 PM, Alexandre Borgoltz wrote:
> Hi,
>
> I am trying to use jersey as embedded in an OSGi engine (in an Eclipse
> RCP application with jetty embedded actually).
> I have developped a nice way to contribute REST resources to an
> application via eclipse's extension mecanism.
> Everything works fine except for one thing: resources registration.
>
> The default behaviour is an automatic scan of WEB-INF/lib and classes.
> I have written my own "Application" that replaces the scan of the
> classpath by a scan of eclipse registry : works fine.
> BUT it is a good practise in an OSGi environment to track registry
> changes, instead of reading it once. I could do that cleanly, being
> notified everytime a new REST resource is contributing - but I haven't
> found the way to register these resources programmatically once the
> jersey engine launched.
>
> Can Jersey add resources /live/ ? Or is it a limitation that you must
> know the list of classes or singletons before it starts up?
>
> I thank you in advance for your help!
>
> --
> Alexandre
>