users@jersey.java.net

Re: [Jersey] JSONObjectProvider doesn't check media type

From: Tatu Saloranta <tsaloranta_at_gmail.com>
Date: Thu, 11 Jun 2009 11:32:54 -0700

On Thu, Jun 11, 2009 at 11:25 AM, Martin Probst<mail_at_martin-probst.com> wrote:
>> But why not use POJOs themselves? Or can you not add annotations
>> if/when needed? Maybe you start with non-object data?
>
> I do have objects, however they are not beans, and they come from
> another API which I don't want to clutter with annotations for JSON
> serialization, as that should be orthogonal to the original API. I'll
> need to try out what Jackson offers here.

Ok. Btw -- intention of Jackson is not to require annotations, so
basic stuff won't need it. And for future (alas, not 1.1, but 1.2),
there will be a way to do "mix-in" annotations: which is just a fancy
way of saying that one can bind annotations at runtime to classes when
things must be configured.

So maybe it could work, maybe not.

>> It shouldn't, if classes you use are beans.
>
> That's the problem - I don't have beans. E.g. some method returns an
> XhiveDriverIf, which is the actual object representing my resource.
> It's a typical Java API with some 50 methods, of which I want to
> expose ~5 things: one thing is a Map<String,Number> (statistics), one
> thing is a List of sub-objects which in turn have three fields I'm
> interested in. Some of the fields have to be mangled, e.g. turned into
> proper URIs through UriInfo to be a nice HATEOAS citizen.

Ok. That's also related to some future plans ("views"). I know it
won't help you here and now, but it helps me to know what is needed.
And it has been requested by many users already: ability to subset
information; either for scope like here, or for some form of simple
versioning.

Configuration of mapping of types to custom (de)serializers exists,
both as mapper configuration and annotations. They are the last
resorts, but for real type conversions are needed.

...
> Thanks for your insights!

Likewise: it is useful and necessary to learn from use cases others have!

I have learnt a lot by just "eating my own dog food", but there are limits.

-+ Tatu +-