users@jaxb.java.net

Re: xjc: how to make a class implement Serialiazable without changing the schema?

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Tue, 31 May 2005 19:04:59 -0700

Dmitri Colebatch wrote:
> Hi all,
>
> I want to use xjc to generate java classes for 3rd party schemas - as
> such I don't have control over the schemas and would like to avoid
> having to xslt them in order to have the generated classes implement
> Serializable.
>
> Is it possible to direct xjc to make all generated classes implement
> the Serializable interface without changing the schemas?

Yes. The customization to do this is:

        <jaxb:globalBindings>
          <jaxb:serializable/>
        </jaxb:globalBindings>

And you can use external customizations to set this outside the schema
file. See one of the bundled sample applications for how to use external
customizations. (I think I also blogged recently about to how to use
external binding files quickly, although I used different customizations
[1].)


[1]
http://weblogs.java.net/blog/kohsuke/archive/2005/05/compiling_mathm_1.html
-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com