users@jersey.java.net

Re: [Jersey] JAX-RS Specification and threading guarantees

From: Marc Hadley <marc.hadley_at_oracle.com>
Date: Fri, 23 Apr 2010 15:06:35 -0400

On Apr 23, 2010, at 12:46 PM, Laird Nelson wrote:

> What guarantees regarding threads can be made about the interaction of
> a MessageBodyWriter and a ContextResolver?
>
> Specifically, is it (intended to be) guaranteed by the specification
> that during writeTo() as handled by provider-supplied MBWs any
> ContextResolvers that get invoked will be invoked on the same thread?
>
> I would think this would have to be a guarantee, but I wanted to make sure.
>
This isn't guaranteed by the specification.

> Additionally, I have an MBW that is itself also a ContextResolver. I
> note in the logs--happily--that only one instance of this class is
> created. Is that something I can rely on, or are JAX-RS
> implementations free to create one instance of my class for its
> MessageBodyWriter role and one instance for its ContextResolver role?
>
Unless overridden somehow, the default is to create one instance of each @Provider class.

Marc.