Hi,I'm developing application and expose it to a client front-end using web
application running in Jersey and using JAXB for serialization.
I have several entities in my application, for example NetworkObject and
Relation. NetworkObject has id and name and Relation has fromObject and
toObject which, as you might guessed, point to reference of NetworkObject.
I'm considering Relation to be sub-resource of NetworkObject.
Since I want changes to single NetworkObject to be atomic I'm using a
UnitOfWork approach as follows:
I have base class UowCommand and derive from it several sub-classes like
ChangeName, AddRelation, UpdateRelation, RemoveRelation. Each sub-class
contain enough information to perform the action on the server side.
The problem :)
I don't know how to explain JAXB to de-serialize list of UowCommand which
actually have sub-class instances in it.
Meaning, it is very important to preserve the order in which the actions
occur so I have a class which has list of UowCommand. On the client side I
serialize the list and get something like this:
<unitOfWork>
<commands>
<addRelation toObject="123" />
<addRelation toObject="456" />
<removeRelation toObject="789" />
</commands>
<unitOfWork>
How should I annotate the JAXB classes on the server so I'll be able to
de-serialize this kind of xml.
Another question: is it possible to do the same (sub-class) with JSON? Maybe
with jettison notation?
The reason I'm straying from RESTful way, a little, is because my object
graph (and their representation) can become very large. I think that sending
whole resource representation for every tiny update might be overkill. For
example, if I only wish to change the name of an object I have to create
full representation include all it relations.
Also I need a way to change multiple properties (as the example above) and
make sure it is atomic change.
Thank you very much,
Ido.