users@jaxb.java.net

Re: how to marshal classes that cannot be annotated?

From: Aleksei Valikov <valikov_at_gmx.net>
Date: Tue, 20 Nov 2007 09:25:19 +0100

Hi.

> Sorry if this is a total newbie question, but I've not found a
> definitive answer. I have a heirarchy of classes that are basically
> JavaBeans, but I do not own the source and cannot annotate them for
> JAXB. Is there still a way that I can use JAXB to marshal them to XML?
> Can someone point me to the sample or FAQ on how to get started with this?
> Thanks,

Right now, you can't.

Technically there is a way to do this. You should implement an
AnnotationReader which should read annotations from somewhere else
(like, say, XML files) and define your annotations in the
corresponding form. The you just create a JAXBContextImpl with this
annotation reader and use this context just normally.

Few month ago I developed a project called annox
(https://annox.dev.java.net). It contains a tool which can parse
annotations defined in XML (rather than in Java sources). This is a
perfect basis for the AnnotationReader as you need it.

Bye.
/lexi