users@jersey.java.net

Looking for "best practices"

From: Comerford, Sean <Sean.Comerford_at_espn3.com>
Date: Thu, 14 Jan 2010 15:16:17 +0000

So Iım slowly working through a prototype application and have a couple of
high level newbie questions.

Q1) How to best provide a ³light² XML/JSON feed?
 
Initial testing has shown that (due to performance considerations) I need to
slim down the markup Iım outputting. Un/marshalling costs are just too high
if I output all the fields we have in our POJOs.

I can easily accomplish that by marking a lot of stuff @XmlTransient so itıs
omitted.

But the problem with that is there are SOME cases where I really do need
want those fields in the markup.

So what Iım looking to do is develop a ³light² and ³full² version of my
output. Short of basic coding conventions (i.e. gving multiple classes
representing the same underlying data but with differing JAXB annotations),
does jersey or JAXB provide anything in this respect?

Creating resource ³views² is one possible solution I guess but Iım not sure
that feels right and it certainly loses some of the ³automagic² benefit of
the Jersey+JAXB framework but perhaps Iım missing something.

Q2) Controlling the Jersey life cycle... I could have sworn I saw an example
of this but canıt seem to find now. Letıs say for the sake of argument I
want to marshal my Java objects to XML myself (maybe to cache the JAXB
generated markup) and have my @GET method return that instead of a JAXB
annotated POJO instance.... How do I do that / can someone point me to an
example?

-- 
Sean Comerford, Software Engineer
ESPN.com Site Architecture Group
Office: 860.766.6454    Cell: 860.329.5842