users@jersey.java.net

Re: [Jersey] using jaxb to stream a large data set

From: Felipe Gaścho <fgaucho_at_gmail.com>
Date: Tue, 9 Feb 2010 18:54:17 +0100

can you use Stax? http://jcp.org/en/jsr/detail?id=173

On Tue, Feb 9, 2010 at 6:52 PM, Paul Sandoz <Paul.Sandoz_at_sun.com> wrote:
>
> On Feb 9, 2010, at 6:44 PM, Moiz Dohadwala wrote:
>
>> Paul,
>>
>> Thanks. I was leading that way myself. My concern regarding using jaxb
>> fragments for streaming was the ability to marshal to json seamlessly. I
>> guess I will find out.
>>
>
> You should be able to do that if you return a collection with a lazy
> iterator implementation.
>
> The StreamingOutput can work for XML or JSON but you need to do that work
> using JSONJAXBContext when JSON is used. Or say using Jackson instead.
>
> Paul.
>
>> -Moiz
>>
>> -----Original Message-----
>> From: Paul.Sandoz_at_Sun.COM [mailto:Paul.Sandoz_at_Sun.COM]
>> Sent: Tuesday, February 09, 2010 9:06 AM
>> To: users_at_jersey.dev.java.net
>> Subject: Re: [Jersey] using jaxb to stream a large data set
>>
>>
>> On Feb 9, 2010, at 1:15 AM, Moiz Dohadwala wrote:
>>
>>> Hello,
>>>
>>> We am currently using jersey to build a set of reports. The reports
>>> on the UI are paginated, since the data set can potentially be very
>>> large. However, we need to provide a download option to allow the
>>> user to download the entire set. Currently we have been using jaxb
>>> to provide support for xml as well as json. What options to we have
>>> to support streaming streaming using jaxb in jersey?
>>>
>>
>> JAXB is not a streaming-based API so i guess any approach would be to
>> utilize "fragments" of JAXB.
>>
>> The only current support for fragments of JAXB is returning a List<T>
>> or Collection<T> (and it would be really easy to extend to support
>> Iterator<T>).
>>
>> You could implement a Collection that supports a lazy iterator.
>>
>> Alternatively you could implement the JAXB fragment marshaling
>> yourself using StreamingOutput [1].
>>
>> Paul.
>>
>> [1]
>> https://jsr311.dev.java.net/nonav/javadoc/javax/ws/rs/core/StreamingOutput.html
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>



-- 
------------------------------------------
   Felipe Gaścho
   10+ Java Programmer
   CEJUG Senior Advisor