users@jersey.java.net

[Jersey] Re: Pluggable StAX message body writers as streaming alternative to JAXB POJO's?

From: Casper Bang <casper.bang_at_gmail.com>
Date: Thu, 24 Mar 2011 09:08:21 +0100

Hi Jacub,

I am not familiar with XMLStreamWriter, but if this would allow for
streaming XML/JSON etc. then I guess that's what I mean. :)

/Casper


On Thu, Mar 24, 2011 at 1:10 AM, Jakub Podlesak
<jakub.podlesak_at_oracle.com>wrote:

> Hi Casper,
>
> you mean something like:
>
> public interface XMLStreamOutput {
> void write(XMLStreamWriter writer) throws XMLStreamException;
> }
>
> where Jersey would figure out the right writer to use,
> based on the actual resource method @Produces types
> and HTTP request headers?
>
> ~Jakub
>
>
> On 03/22/2011 03:46 PM, Casper Bang wrote:
>
> Jersey's custom message body writers for JAXB beans is cool, but it
> suffers from two issues:
>
> 1) It requires a static model/projection to be typed, often making for
> these resource-dependent "shadow" hierarchies.
> 2) In case of large responses and/or responses with rolling latency (i.e. a
> database recordset), it can take long to start returning data.
>
> So I was wondering, would it be possible to generate StAX events and tie
> into Jersey's existing JAXB message body writers? Currently I am
> returning StreamingOutput from resources but it doesn't really let me reuse
> as much as Jersey as I want. To output both XML and JSON for instance, I
> need to implement two different resource methods with (slightly) different
> code emitting to the Stream.
>
> Seems like pluggable message body writers for StAX events would provide
> for some nice steaming support where the JAXB/POJO approach is too static or
> too slow/latent.
>
> /Casper
>
>
>