Re: JSR311: Response isn't adequate

From: Stephan Koops <>
Date: Mon, 03 Mar 2008 19:20:55 +0100

Hello Marc,

I think, it's good, to use getOutputStream(Result), because this make it
clearer, what is meant with the method. It could throw an
IllegalArgumentException, if an entity is set.
When using read only interfaces, very often we accpet a
UnsupportedOperationException, why no here an IllegalArgumentException?


Marc Hadley schrieb:
> How does the following sound:
> public interface StreamingOutput {
> OutputStream getOutputStream(int status, MultivaluedMap<String,
> Object> metadata);
> }
> A resource method can have a parameter of the above type but, if so,
> it MUST have a void return type. You get an output stream by passing
> in the desired status code and metadata which you can get from a
> Response instance (or create yourself). I don't want
> getOutputStream(Response) since that brings up questions about what to
> do if the response contains an entity and I don't really like any of
> the answers to that question. Calling getOutputStream more than once
> isn't allowed.
> An example of usage:
> @GET
> public void getData(StreamingOutput so) {
> Response r = Response.created("someuri").type("sometype").build();
> OuptutStream os = so.getOutputStream(r.getStatus(), r.getMetadata());
> os.write(...)
> }
> We'd still use @ProduceMime to choose a method to call and to default
> the content type if not explicitly set.
> I had a failure of imagination when coming up with the interface and
> method names, if you have better ideas I'd like to hear them.
> Marc