users@jaxb.java.net

Re: Sub-classing JAXB generated classes

From: Wiedmann, Jochen <jochen.wiedmann_at_softwareag.com>
Date: Wed, 05 Feb 2003 20:05:15 +0100

> Kohsuke Kawaguchi [mailto:Kohsuke.Kawaguchi_at_Sun.COM] wrote:

> thus you just need to sub-class ObjectFactory and override some
> createXXX methods to use your sub-classes instead of the

[ ... ]

> No, in general you shouldn't sub-class the ObjectFactory class because
> it's highly implementation-dependent.

Isn't that a contradiction?

On a different approach: The JaxMe object factory is using an
automatically generated (but manually extendable) XML file in
the package directory, which looks roughly like the following

    <Configuration>
      <Manager
validatorClass="net.sf.jaxme.examples.misc.jaxb.SomeClassValidator"
               qName="{http://jaxme.sf.net/examples/misc/jaxb}MyClass"

marshallerClass="net.sf.jaxme.examples.misc.jaxb.SomeClassMarshaller"

handlerClass="net.sf.jaxme.examples.misc.jaxb.SomeClassUnmarshaller"
               elementInterface="net.sf.jaxme.examples.misc.jaxb.SomeClass"
               elementClass="net.sf.jaxme.examples.misc.jaxb.impl.SomeClass"

className="net.sf.jaxme.examples.misc.jaxb.SomeClassManager"/>
      ...
   </Configuration>

In other words: You may replace the automatically generated classes
with suitable subclasses or different implementations matching the
same interfaces.


Jochen