users@jaxb.java.net

Re: Sub-classing JAXB generated classes

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Wed, 05 Feb 2003 09:35:11 -0800

In the next release, the ObjectFactory class will have non-static
createXXX methods (in the beta release, they are all static).

This means that JAXB RI could follow the factory design pattern, where
all the generated code use the createXXX methods to create a new object
thus you just need to sub-class ObjectFactory and override some
createXXX methods to use your sub-classes instead of the default class.

I'm not sure we got this completely right --- we were focusing on making
it specification compliant and this is definitely an RI-only feature.
Anyway, so things would be probably better in the next release.


> Is this going to be changed for the final release of JAXB? It would be
> so useful if it was and in my opinion is such a fundamental requirement.

No, in general you shouldn't sub-class the ObjectFactory class because
it's highly implementation-dependent. You can't assume anything about
how those content interfaces are implemented without sacrificing the
portability.


I'm not sure if I'm fully understanding what you think should should be
a "fundamental regiment", but I hope I addressed your concern, if not
completely.

regards,
--
Kohsuke KAWAGUCHI                  408-276-7063 (x17063)
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com