I prefer to have subclasses and different methods.. it is faster and cleaner..
yes, I was talking about jpa. because in my project the JPA entities
are serializable by JAXB.. so it is the same at the end......
if you rely on Adapters the performance will decay.. and the
maintenance will become more complex (IMHO)
here it is my serializable Entities folder:
http://kenai.com/projects/puj/sources/arena/show/arena-model/src/main/java/com/kenai/puj/arena/model/entity?rev=411
On Thu, Jan 14, 2010 at 4:38 PM, Comerford, Sean
<Sean.Comerford_at_espn3.com> wrote:
> I don't see MappedSuperclass in the jaxb API docs.... are you referring to
> the JPA annotation of that name?
>
> I am actually using that in some places as my resources are mostly JPA
> entities but not quite sure how helps here. I'm looking to avoid messing
> with my class hierarchy (or adding new classes) solely for the purpose of
> having different XML/JSON representations of them though going that route
> would certainly work.
>
> I'm guessing the answer probably lies in having multiple custom JAXB binding
> definitions but I'm wondering if there is a best practice around this.
>
> And my second question is basically related to how I would implement the
> multiple custom bindings if do in fact have to go that route.
>
> On 1/14/10 10:23 AM, "Felipe Gaścho" <fgaucho_at_gmail.com> wrote:
>
>> check @MappedSuperclass in jaxb.. it solves your problems :)
>>
>> On Thu, Jan 14, 2010 at 4:16 PM, Comerford, Sean
>> <Sean.Comerford_at_espn3.com> wrote:
>>> 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
>>>
>>
>>
>
> --
> Sean Comerford, Software Engineer
> ESPN.com Site Architecture Group
> Office: 860.766.6454 Cell: 860.329.5842
>
>
> ---------------------------------------------------------------------
> 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