users@jaxb.java.net

Re: Customize ObjectFactory To Be Serializable

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Wed, 26 Apr 2006 15:04:35 -0700

Scott Kaszyk wrote:
>
>
> Is it possible to generate an ObjectFactory that is serializable? I am
> trying to serailize a class that wraps a jaxb class and provides other
> methods such as creating new instances and saving state. However, when I
> attempt to serialize this wrapper class to a file, I get a the following
> error:

Since ObjectFactory doesn't maintain any state in it, normally you don't
have to make it serializable. None of the JAXB classes refer back to
ObjectFactory either.

So the error suggests that one of your objects is maintaining a back
pointer to ObjectFactory, and I suspect that's unnecessary.

If you do extend ObjectFactory and add state in it, then as Dmitri
pointed out, that's where you want to implement Serializable.

If you really think you should be able to generate ObjectFactory as
serializable, well, I guess you can write a plugin.

-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com