You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Benson Margulies <bi...@gmail.com> on 2009/10/22 00:02:19 UTC

Thread safety and injected items in implementations

So, say that my container is helpfully running multiple threads and thus
calling into my service on multiple threads. What happens when there is
request-specific stuff to inject?

In particular, for JAX-RS:


    @Context
    private org.apache.cxf.jaxrs.ext.MessageContext messageContext;

Re: Thread safety and injected items in implementations

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

> So, say that my container is helpfully running multiple threads and thus
> calling into my service on multiple threads. What happens when there is
> request-specific stuff to inject?
>
> In particular, for JAX-RS:
>
>
>    @Context
>    private org.apache.cxf.jaxrs.ext.MessageContext messageContext;
>

If you service bean is a singleton then a thread-safe proxy will be injected early on, during the service initialization. If it is a 
prototype then a new MessageContext instance will be created during every request

cheers, Sergey