1

I have a class that implements java.util Collection interface and I want to have a custom XML marshalling using jax-b.

When I try to use an XmlAdapter, it's ignored and jax-b uses the default behavior for collection.

If I remove implements Collection, jax-b uses my adapter.

Following code doesn't work:

@XmlJavaTypeAdapter(value = MyAdapter.class)
public class MyClassCollection implements Collection<MyClass> {
    ...
}

Following code works (but doesn't implement Collection):

@XmlJavaTypeAdapter(value = MyAdapter.class)
public class MyClassCollection {
    ...
}

Does someone have an idea on how to use MyAdapter.class with a class that implements Collection?

Thanks in advance!

greg
  • 11
  • 1
  • Below is a link to an answer I gave to a similar question if you are interested in using EclipseLink JAXB (MOXy): http://stackoverflow.com/questions/10075634/npe-when-using-moxys-meta-data-with-a-class-that-implements-java-util-map/10091556#10091556. What type of representation are you trying to achieve? – bdoughan Sep 25 '12 at 15:12

0 Answers0