dev@jsr311.java.net

Re: JSR311: Response isn't adequate

From: Bill Burke <bburke_at_redhat.com>
Date: Tue, 04 Mar 2008 17:13:32 -0500

Marc Hadley wrote:
> On Mar 4, 2008, at 1:26 PM, Bill Burke wrote:
>>
>> Marc Hadley wrote:
>>> How does the following sound:
>>> public interface StreamingOutput {
>>> OutputStream getOutputStream(int status, MultivaluedMap<String,
>>> Object> metadata);
>>> }
>>
>> I'm wondering if MessageBodyWriters should follow the same sort of
>> contract as they have the same "commit" ordering problem, don't they?
>>
> You mean split the writeTo into two methods, e.g. writeMetadata +
> writeBody ?
>

No. I mean

writeTo(T t, MediaType type, StreamingOutput output);



> I don't know if that is really necessary, I tried to capture the need to
> update headers first in the existing javadoc, IMO that should be
> sufficient.
>

If Javadoc is sufficient for MessageBodyWriter, then why not have a
OutputStream getOutputStream() method on Response? Sure, you'd have to
tunnel the OutputStream and header processing through a ThreadLocal, but
the API would be simpler and consistent.

Just some thoughts...

Bill



-- 
Bill Burke
JBoss, a division of Red Hat
http://bill.burkecentral.com