I wrote a Cloneable plugin a long time ago. I know you keep bugging me to
host it but I don't know how and wouldn't have the time to maintain it. In
fact I have an ejb3 plugin (very basic) and a default values plugin also. Here
are the files I created. I hope they are still compatible.
In a message dated 6/6/2006 10:00:03 A.M. Central Daylight Time,
aukcioner_at_yahoo.com writes:
Actually, Hanson's suggestion to use XStream to clone instances of
JAXB-generated work great for me.
Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM> wrote:
Alec Swan wrote:
> I need to create a "deep" copy of a JAXBElement which was constructed by
> JAXB during the unmarshalling process. None of the classes generated by
> JAXB implement clone() method from java.lang.Object. The ObjectFactory
> class generated by JAXB didn't provide any API useful for this purpose
either.
Right.
There's an RFE filed in the issue tracker about writing a plugin that
would make the generated classes cloneable, but to my knowledge it
hasn't done yet (partly because of the problem of JAXBElement not
implementing cloneable.)
Perhaps one might be able to develop a similar plugin based on Ray's
idea --- the copy constructor.
> However, I noticed that JAXBElement implements Serializable and I could
> potentially use this to implement object cloning by serializing and
> de-serializing the target JAXBElement instance.
Yeah, I think that would be a good work around. There's a global
customization to make all the generated classes serializable.
> What is the right way to clone a JAXBElement instance?
It doesn't exist today. I'm hoping that someone would volunteer to write
a plugin.
--
Kohsuke Kawaguchi
Sun Microsystems kohsuke.kawaguchi_at_sun.com