Changes between Initial Version and Version 1 of JaxB


Ignore:
Timestamp:
01/30/17 21:37:13 (8 years ago)
Author:
wouter
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • JaxB

    v1 v1  
     1JaxB is very troublesome when it comes to template classes and abstract classes.
     2The main problems are serializations containing xsi and xmlns annotations. Such annotations make the xml unreadable and rigid (resisting future changes).
     3
     4List (java.util) combined with abstract classes can be made to work, with a number of annotations. Assume class X is an abstract class with X1 and X2 as implementations.
     5
     6Then
     7 * annotate all occurences List<X> with @XmlElementRef
     8 * add @XmlSeeAlso({X1.class, X2.class}) to the X class
     9 * annotate X1 and X2 with @XmlRootElement (and maybe give it a nicer name there too)
     10
     11General templates like  Myclass<T extends Object> do not serialize nicely. This is because erasure causes the class to serialize 'Object' and deserializing 'Object' will probably result in xsi stuff.
     12What you can do is to do
     13
     14* Myclass<T extends X>
     15* handle all serialization in class X (not in the T classes)
     16
     17This means that you can't have class-specific deserializations.
     18Maybe you can combine this with the tricks used with List (see above), I never figured this out