RE: Dynamic JAX-RS application

2010-04-19 Thread Jerome Louvel
Hi Fabio,

Your approach looks just fine to me. Restlet routers, such as virtual hosts,
have been designed for concurrent changes.

Just make sure to call stop() on the detached application (after it has been
detached) to give a chance for eventual cleanup actions.

Best regards,
Jerome Louvel
--
Restlet ~ Founder and Technical Lead ~ http://www.restlet.org
Noelios Technologies ~ http://www.noelios.com


-Message d'origine-
De : Fabio Mancinelli [mailto:fabio.mancine...@gmail.com] 
Envoyé : mardi 9 mars 2010 18:30
À : discuss@restlet.tigris.org
Cc : stephan.ko...@web.de
Objet : Dynamic JAX-RS application

Hi everybody,

I have the following use case: I would like to setup a dynamic JAX-RS
application where you can dynamically add and remove resources at
runtime.

Now I have successfully managed to add/remove resources in the following way
:

1) I create a new javax.ws.rs.core.Application whose getClasses method
returns the new set of classes (at time T)
2) I detach the current org.restlet.ext.jaxrs.JaxRsApplication from
the component defaultHost.
3) I create a new org.restlet.ext.jaxrs.JaxRsApplication
4) I add to the JaxRsApplication created in 3) the configuration created in
1)
5) I attach the new application instance to the component.

Things seems to work without problems.

I posted the code on http://pastebin.com/9F4BBJYL

The behavior is the correct one

1) /another doesn't exist
2) /hello is accessed
3) The /another resource starts to respond
4) The /hello resource is gone

So my question is : has this code something wrong (e.g., a possible
memory leak or whatever) ? Are there other more elegant ways to
realize my use case?

Thanks.

Regards,
Fabio

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=24571
43

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2588979


Dynamic JAX-RS application

2010-03-09 Thread Fabio Mancinelli
Hi everybody,

I have the following use case: I would like to setup a dynamic JAX-RS
application where you can dynamically add and remove resources at
runtime.

Now I have successfully managed to add/remove resources in the following way :

1) I create a new javax.ws.rs.core.Application whose getClasses method
returns the new set of classes (at time T)
2) I detach the current org.restlet.ext.jaxrs.JaxRsApplication from
the component defaultHost.
3) I create a new org.restlet.ext.jaxrs.JaxRsApplication
4) I add to the JaxRsApplication created in 3) the configuration created in 1)
5) I attach the new application instance to the component.

Things seems to work without problems.

I posted the code on http://pastebin.com/9F4BBJYL

The behavior is the correct one

1) /another doesn't exist
2) /hello is accessed
3) The /another resource starts to respond
4) The /hello resource is gone

So my question is : has this code something wrong (e.g., a possible
memory leak or whatever) ? Are there other more elegant ways to
realize my use case?

Thanks.

Regards,
Fabio

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2457143


Dynamic JAX-RS application

2010-03-09 Thread Fabio Mancinelli
Hi everybody,

I have the following use case: I would like to setup a dynamic JAX-RS
application where you can dynamically add and remove resources at
runtime.

Now I have successfully managed to add/remove resources in the following way :

1) I create a new javax.ws.rs.core.Application whose getClasses method
returns the new set of classes (at time T)
2) I detach the current org.restlet.ext.jaxrs.JaxRsApplication from
the component defaultHost.
3) I create a new org.restlet.ext.jaxrs.JaxRsApplication
4) I add to the JaxRsApplication created in 3) the configuration created in 1)
5) I attach the new application instance to the component.

Things seems to work without problems.

I posted the code on http://pastebin.com/9F4BBJYL

The behavior is the correct one

1) /another doesn't exist
2) /hello is accessed
3) The /another resource starts to respond
4) The /hello resource is gone

So my question is : has this code something wrong (e.g., a possible
memory leak or whatever) ? Are there other more elegant ways to
realize my use case?

Thanks.

Regards,
Fabio

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2457248