users@jaxb.java.net

Re: _at_XmlJavaTypeAdapter ignored on method level, class level and package level

From: Wolfgang Laun <wolfgang.laun_at_gmail.com>
Date: Tue, 7 Sep 2010 15:49:58 +0200

The problem is that JAXB must be able to provide the XmlAdapter
with a POJO *class* object representing the XML data. If this is defined by
an
interface in manually written Java code, then there's no way JAXB
can instantiate this intermediary representation.

For marshalling, your XmlAdapter produces an object implementing
the interface, but here JAXB merely has to use the getters to
create a DOM element.

Preferably, such services should define the XML interface by an
XML schema, which would let you generate XML on the client
and/or server side via Java code derived from the XML schema,
and then such problems do not arise.

-W


On 7 September 2010 14:40, cfind <hong-linh_at_gmx.de> wrote:

>
> Hi Wolfgang!
>
> Thank you very much for your reply.
>
> I am wondering why this method worked:
>
> @XmlJavaTypeAdapter(DicomAdapter.class)
> public DicomObject getDicomObject(String name);
>
> Here I have DicomObject as a return value and the adapter is able to handle
> DicomObject instances. If I have DicomObject as a parameter value, like in
> the example listed above, I receive the IllegalAnnotateExceptions.
>
> DicomObject is an interface and BasicDicomObject is the implementation of
> it. These are classes come from a library, so I cant use annotations to
> serialize the DICOM objects. I could use a wrapper class to serializes
> these
> objects to byte streams, but that would be only the last choice.
>
> Do you have better solution?
>
> Greets,
> cfind
>
>
> Wolfgang Laun-2 wrote:
> >
> > Way down in the dump I saw
> > org.dcm4che2.data.DicomObject is an interface, and JAXB can't handle
> > interfaces.
> >
> > -W
> >
> >
> > On 7 September 2010 11:36, cfind <hong-linh_at_gmx.de> wrote:
> >
> >>
> >> Anyone has some ideas? :(
> >> --
> >> View this message in context:
> >>
> http://old.nabble.com/%40XmlJavaTypeAdapter-ignored-on-method-level%2C-class-level-and-package-level-tp29605773p29641255.html
> >> Sent from the java.net - jaxb users mailing list archive at Nabble.com.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> >> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
> >>
> >>
> >
> >
>
> --
> View this message in context:
> http://old.nabble.com/%40XmlJavaTypeAdapter-ignored-on-method-level%2C-class-level-and-package-level-tp29605773p29641595.html
> Sent from the java.net - jaxb users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>