users@glassfish.java.net

Re: CycleRecoverable any good illustrations?

From: Sahoo <Sahoo_at_Sun.COM>
Date: Thu, 27 Dec 2007 13:06:38 +0530

I think an effective, portable strategy is to use @XmlTransient and
Marshal event callbacks (beforeMarshal & afterMarshal).

Thanks,
Sahoo

Kenneth Clark wrote:
>
> Hi all. I have been fighting with the infamous “cycle in XML graph”
> issue described in http://forums.java.net/jive/thread.jspa?threadID=13670
>
>
>
> I used to manually code the break in the graph but this is leading to
> errors as the current object model I am working with effectively
> references all the data in all the objects which leads to a stack of
> cycles.
>
>
>
> I came across the CycleRecoverable interface and thought it was a
> rather nifty idea. The only problem I am having is that I have no clue
> as to the best way to use this interface. In the initial idea by
> gadams00 the onCycleDetected function allowed for the passing of the
> object into the function their by allowing the instantiation of the
> object with the properties.
>
>
>
> Is the implementation of the onCycleDetected method supposed to be
> something along the lines of
>
>
>
> @Entity
>
> Public class MyObject implements Serializable, CycleRecoverable {
>
> Private String id;
>
>
>
> Public MyObject(String id){
>
> This.id = id
>
> }
>
>
>
> public Object onCycleDetected(CycleRecoverable.Context context) {
>
> MyObject obj = new MyObject(this.id);
>
> return obj;
>
> }
>
> }
>
>
>
> (Excuse the incorrect syntax, it is 3am and I don’t feel like fighting
> with the auto messer upper of the email client)
>
>
>
> I have tried the @XmlTransient but the example only provides one
> relationship and there is nothing on ManyToMany relationships. Any
> help in the direction of examples of the best way to implement the
> CycleRecoverable would be greatly appreciated. The primary purpose of
> the serialization of these objects is for transmission using web services.
>
>
>
> Any help would be greatly appreciated.
>
>
>
> ________________
>
> Thanks and regards
>
>
>
> *Kenneth Clark*
>
> Solutions Engineer
>
>
>
> ShadowLogo.png
>
> *Tel:** *27 (0) 11 679 3075
>
> *Fax: *27 (0) 86 647 4819
>
> *Mobile:** *27 (0) 84 583 1348
>
> *Email:** *_kenneth.clark_at_skyetech.co.za
> <mailto:kenneth.clark_at_skyetech.co.za>_
>
> *Website:** *http://www.skyetech.co.za**
>
>
>
>
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.5.516 / Virus Database: 269.17.9/1197 - Release Date:
> 2007/12/25 20:04
>