Hi Frank,
Frank Martínez wrote:
> I think this is a good work based on a good specification.
> I was working on a propietary rest framework by the last 3 weeks, and
> then i found jsr311 and this project. I want to use this framework
> instead of develop the propietary ones, but there is one thing i wish
> in a rest framework, and is the ability to access the
> HttpServletResponse's OutputStream directly in some circumstances.
>
> For example:
> I have developed a tool that takes a hierarchical sql query (String)
> and an OutputStream and then executes the query and produces an xml
> output directly to the passed OutputStream. So I dont want to
> transform the SQL results in a graph of java objects and then
> serialize this again into xml using an EntityProvider .... and I dont
> want to get this result in a String and then return this string
> because it is not as good as the direct OutputStream writing (With
> large xml results)
>
One approach is to write an entity provider for processing a Java type
that represents the SQL query. The entity provider is responsible for
executing the query, producing the XML and writing directly to the
output stream.
Jersey can support a method signature:
public void getParts(HttpRequestContext request,
HttpResponseContext response)
but this is non-standard and has not been properly tested since the
focus has been on getting the standard method signatures implemented. It
is very likely to fail because the runtime does not know if a response
has been written or not.
> What do you think about that?
> Maybe if were possible to pass the output stream as an annotated
> method parameter like:
>
> @HttpMethod("GET")
> public void getParts(@Output OutputStream out, ...) {
> .....
> }
>
> Or something like that.
>
That could work, although we also need to additionally support the
setting of HTTP response headers by the application.
Having an output parameter that you pass a Response to (with a null
entity) and returns the OutputStream could be one way of doing this.
BTW Jersey does support pluggable HTTP method signatures using the
ResourceMethodDispatchProvider, it is experimental and not in the API
but it is still possible (for someone feeling brave enough) to implement
the method signature you have proposed as an experiment.
Paul.
--
| ? + ? = To question
----------------\
Paul Sandoz
x38109
+33-4-76188109