users@jersey.java.net

Re: Dynamic reconfiguration?

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Tue, 08 Apr 2008 12:13:46 +0200

Hi Tom,

Tom Davies wrote:
> I want to be able to add and remove resources from a WebApplication at
> runtime.
>
> I understand how to write a ResourceConfig implementation which keeps
> track of which resources should be available.
>
> Can I simply extend ServletContainer and add a method:
>
> void reload() {
> this.application = create();
>
> configure(servletConfig, resourceConfig, this.application);
>
> initiate(resourceConfig, this.application);
> }
>
> which I would call when the state of my resourceConfig instance changes?
>

That will work (IIRC another developer has done a similar tricks). It is
not the most efficient way. (Infact i want to use a similar mechanism
for reloading with JavaRebel.)

I would recommend doing it like this:

    WebApplication _application = create();
    configure(servletConfig, resourceConfig, _application);
    initiate(resourceConfig, _application);
    this.application = _application; // IIUC this operation is atomic

That way you will avoid indeterminate state if requests arrive when
reloading.


> Or is there a better way?
>

Not currently. Ideally we need methods on WebApplication to add/remove
resource classes dynamically (and manage the synchronization issues).

Paul.

> Thanks,
> Tom
> --
> ATLASSIAN - http://www.atlassian.com
> Our products help over 8,500 customers in more than 95 countries to
> collaborate
>
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>

-- 
| ? + ? = To question
----------------\
    Paul Sandoz
         x38109
+33-4-76188109