2

Is it possible to have CXF's wsdl2java emit cloneable classes? Maybe via some option or a plug-in?

What I need to do is copy by value a rather complex schema structure from one object tree to another and would rather not get/set each member value by hand or touch the generated classes by hand.

/Björn

Bjorn Thor Jonsson
  • 827
  • 1
  • 10
  • 21

3 Answers3

1

I would recommend you avoid Cloneable, and rather have the emitted classes be serializable and serialize and deserialize the class(es) to clone them. Here are some instructions on how to do that with CXF, although I never tried it myself.

Yishai
  • 90,445
  • 31
  • 189
  • 263
1

You COULD write an XJC plugin to do this. CXF does have a couple XJC plugins to do various things that you could use as a model. (and maybe submit back to CXF)

Daniel Kulp
  • 14,447
  • 4
  • 45
  • 37
  • That indeed occurred to me. If I understand things correctly then it should be enough to add _ implements Cloneable _ to each class. I haven't yet tried the serializing / deserializing way mentioned here... – Bjorn Thor Jonsson Jul 10 '10 at 11:17
1

Now I've implemented and contributed an XJC plugin that emits cloneable classes: https://issues.apache.org/jira/browse/CXF-3354

Bjorn Thor Jonsson
  • 827
  • 1
  • 10
  • 21
  • 1
    After implementing this cxf-xjc-cloneable plugin I've found [CC-XJC](http://ccxjc.sourceforge.net/) which does a better job handling the standard Java Collections which don't implement Cloneable, so CC-XJC uses Cloneable where possible and then iterates over all Java Collections instances and appropriately calls `.clone()` on their elements. If I'd already found CC-XJC I wouldn't have implemented my own plugin but it was a fun exercise :) – Bjorn Thor Jonsson Feb 24 '11 at 15:04