users@jersey.java.net

Re: [Jersey] Putting the RESTful "connectedness" around my existing Domain objects

From: Martin Probst <mail_at_martin-probst.com>
Date: Fri, 10 Jul 2009 09:59:09 +0200

> I think I am asking for a templating language with Java EL
> in addition to the existing JAXB approach.
>
> Thoughts?

I think I would also need some sort of a view language for XML
serialization. JAXB is in my opinion lacking a lot - it cannot
serialize Lists or Maps, it refuses to serialize objects that it
cannot deserialize, it doesn't support interfaces, and so on. Also
using the annotation configuration conflates two orthogonal things -
your model on the one hand, and it's serialization to XML on the other
hand. This bites you if you have a model that makes sense and should
be used outside of the REST application, thus limits reuse. This also
makes it difficult (impossible?) to represent your object differently
in different places.

JAXB really is only a choice if you have very trivial Java Beans (not
POJOs!) in your model. In my opinion, the whole Java -> XML|JSON
mapping thing is far from being solved.

That being said, beyond that I would suggest to "just" use XSLT on the
resulting XML if you need a template language. It's a well thought out
language and very powerful while being a really good match for the
template use case. Things like Java EL make me shudder. Coming up with
something that is actually significantly better than the existing
template languages will be hard.

Martin