dev@jsr311.java.net

Re: JSR311: Response isn't adequate

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Fri, 07 Mar 2008 11:35:05 -0500

On Mar 7, 2008, at 10:53 AM, Bill Burke wrote:
>
>>> I don't think getting access to Input/OutputStreams creates a
>>> suboptimal design. Since a JAX-RS endpoint uses annotations
>>> rather than a static interface contract to process requests, its
>>> easy to plug in new models as they become available through the
>>> specification or as vendor plugins. The key is to get the
>>> extension SPIs correct.
>> Again, returning an InputStream is fine and optimal. My issue is
>> with giving
>> a direct access to Response's OutputStream is that it forces
>> thread-per-request model and prevents optimization in the HTTP/IO
>> layers.
>
> The StreamOutput injected interface that Marc proposed is an option
> and is not forcing anything. On the other hand, not allowing
> OutputSTream access to the Resource class *is* enforcing a
> particular model.
>
A compromise: include the StreamOutput interface but put a strong
warning in the javadoc that use of it will prevent a container from
optimizing IO and thread usage.

Marc.

---
Marc Hadley <marc.hadley at sun.com>
CTO Office, Sun Microsystems.