users@jersey.java.net

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

From: Casper Bang <casper.bang_at_gmail.com>
Date: Tue, 22 Mar 2011 15:46:19 +0100

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