Hi.
>> > Would it be possible for you to help me upgrade the extendedCloneable
>> > jaxbcommons plugin into xjc2?
>>
>> I have implemented the "copyable" plugin in jaxb2-commons/basic. It
>> produces two
>> copyTo methods:
>>
>> public Object copyTo(Object target, CopyBuilder copyBuilder)
>> {
>> ....
>> }
>>
>> public Object copyTo(Object target)
>> {
>> final CopyBuilder copyBuilder = new JAXBCopyBuilder();
>> return copyTo(target, copyBuilder);
>> }
>>
>
> Thank you for the reply.
> I now have the following questions:
>
> 1) I cannot find this plugin deployed in the maven2 java.net repo.
> Do i have to check it out, build and deploy it in a private repo?
At the moment, yes. I think I haven't made any release yet.
> 2) In order to use the plugin for cyclic documents, do i have to:
>
> a) implement my CopyBuilder which in its copy(Object) method does
> ref accounting before invoking the super.copy(Object)
Correct. An identity map of object/clone would be fine, if you encounter an
existing key object then you simply return back the value.
> and also,
> b) ensure that all xjc generated classes implement the Cloneable
> interface (how?)
No, this is not required. If you use the Copyable plugin, all classes are
guaranteed to implement CopyTo - and this is enough to make deep copies.
> 3) (assuming the above assumptions are correct)
> In the old 'extendedCloneable' plugin, you didn't use ref-accounting
> at all, but instead ensured that all xjc-generated classes implement a
> specific interface that handles cycles appropriately.
> You have pointed out that using ref accounting with ThreadLocal does
> not constitute a solid solution.
> Do you think that ref accounting *within* copyBuilder is a safe operation?
I think yes. Copy builder is quasi-atomic for a single copy operation. In
extendedCloneable we had something like ClonedObjects - copy builder is an
analog of this one.
> 4) Also, i couldn't find any mention of this plugin on jaxb2-commons site.
I've started the work on the documentation in the GF wiki:
http://www.glassfishwiki.org/gfwiki/Wiki.jsp?page=Jaxb2Commons
http://www.glassfishwiki.org/gfwiki/Wiki.jsp?page=Jaxb2CommonsUsingAndDeveloping
But I'm not too far with it.
Bye.
/lexi