users@jaxb.java.net

custom ObjectFactory?

From: Philip, Tim <Tim_Philip_at_intuit.com>
Date: Thu, 25 Sep 2003 12:22:03 -0700

I was looking around to find the functionality to provide a custom
ObjectFactory when unmarshalling an XML file, and was surprised when I
didn't find it.
 
It seemed to me that a sensible approach to using the JAXB generated classes
would be to extend those classes into my own specific objects, and then
extend the generated ObjectFactory and overload the methods to construct my
derived classes instead.
 
It seems that this would give me a lot of the benefit of the "Mapping"
(manual binding to my own Java classes), without having a complicated
mapping file (instead my ObjectFactory and class hierarchy would become my
Mapping file).
 
I understand that when the schema definition changes and I regen my code
that it could certainly break a lot of things. However, I don't see how
that is all that different than the alternative, which is to write a layer
of code which copies information from the generated classes into the objects
that I want them in. If I did it this way, then when the schema definition
changed my translation layer would just break. Same story, different
location. (And I'd probably still end up changing my objects to suit the
modified schema.)
 
So did I miss the functionality somehow? Or am I missing/misunderstanding
some programming paradigm/methodology that we are being encouraged to use?
 
 
Thanks!
Tim.
 
PS: Please feel free to expound at length on any useful methodologies for
integrating the JAXB generated classes into an existing codebase. :)