You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Guy Pardon <gu...@atomikos.com> on 2012/01/30 11:24:20 UTC

JAX-RS resource classes and thread-safety

Hi,

The JAXRS spec says that a new Resource object should be created for each request - is this the case in CXF?

From what I understood, this is not what happens? 

Guy

Re: JAX-RS resource classes and thread-safety

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi

On 30/01/12 10:24, Guy Pardon wrote:
> Hi,
>
> The JAXRS spec says that a new Resource object should be created for each request - is this the case in CXF?
>
>  From what I understood, this is not what happens?

If you use singleton resource classes then indeed a single instance is 
shared. The injected JAX-RS context instances are thread-safe though, 
but the custom state would need to be protected assuming it;s modified 
after the initialization.

If you need a per-request resource creation then check this section please:

http://cxf.apache.org/docs/jaxrs-services-configuration.html#JAXRSServicesConfiguration-Lifecyclemanagement

HTH, Sergey


>
> Guy