dev@jsr311.java.net

Re: JSR311: Response isn't adequate

From: Bill Burke <bburke_at_redhat.com>
Date: Thu, 28 Feb 2008 12:10:12 -0500

Marc Hadley wrote:
> A few points on OutputStream access:
>
> - We had such a capability in the initial API proposal but it was
> removed as being too low level and covering much of the API space
> already covered by the servlet API. See:
>

We can pretty much do any low level thing with the JAX-RS API for input
that we can do with HttpServletRequest. We can get access to the raw
InputStream, all the headers, etc...

But for responses, access to the OutputStream is considered too low
level? We can inject a InputStream, but not an OutputStream? Doesn't
make any sense.


> https://jsr311.dev.java.net/source/browse/jsr311/trunk/src/jsr311-api/src/javax/ws/rs/core/WebResource.java?rev=7&view=markup
>
> https://jsr311.dev.java.net/source/browse/jsr311/trunk/src/jsr311-api/src/javax/ws/rs/core/HttpResponseContext.java?rev=7&view=markup
>
>
> - As already mentioned you can get at an OutputStream in a
> MessageBodyWriter provided you are able to wrap the necessary resources
> in a type that the MessageBodyWriter can operate on.
>

And I've already told you that this just not cut it for specific use
cases (Blobs). It is going to make EJB integration(really anybody that
uses JTA) unusable in those cases. I don't think Lobs are an
unreasonable use case to support.

> - In a servlet container you can inject HttpServletResponse and use the
> OutputStream from that but you'll have to set any headers yourself
> before you commence writing.
>

So, anything that doesn't fit the @Provider model, we'll have to escape
to Servlet API or worse, have our own vendor specific extension for?
Hmmmm...All because we can't inject an OutputStream.


BTW, You've pretty much duplicated the Servlet API in most ways already.
  This isn't a bad thing. I'm finding JAX-RS very elegant in the
applications I'm prototyping and hope to use it as a replacement for a
servlet as much as possible.

Bill

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