dev@jax-ws.java.net

Re: Thread safety of the JAX-WS API

From: Doug Kohlert <Doug.Kohlert_at_Sun.COM>
Date: Tue, 03 Oct 2006 19:14:52 -0700

I thought Roberto's comment was that he didn't think the the thread
safety thing should be in the spec. I thought he was talking about some
text stating that the Service objects should not be created in a tight
loop and that is what I didn't think should go in the spec.

Kohsuke Kawaguchi wrote:

> Doug Kohlert wrote:
>
>> I am not sure this should be addressed in the spec as another
>> implementation might be much faster at creating a Service instance.
>
>
> You shouldn't think in terms of whether something can be fast or not.
> You should think in terms of striking the right balance between the
> usability and the implementation freedom.
>
> If requiring a thread safety is going to restrict the implementation
> choice significantly enough that it outweighs the user benefit, then
> you don't want to say anything. If it does overall help users, you
> should.
>
> Take a look at Template in JAXP. It does require that a Template
> object be immutable and thread-safe, so that it allows multiple
> threads to create Transformer from a single Template object. If this
> is not required, then the user would have to have parse a XSLT
> stylesheet in every thread, which is a usability problem (as well as
> performance problem.) In comparison, implementing a Template in a
> thread-safe way is very easy. Hence that requirement.
>
>
> Similar thing applies to JAX-WS Service object. I don't think
> requiring a service to be thread-safe is going to restrict the
> implementation choice at all --- at most you have to put synchronized
> keywords everywhere, but that's it.
>
> So in terms of striking the right balance, I think there's a
> significant gain in usability/performance if we can require Service to
> be thread-safe, and very little to lose.
>