object model can represent a graph at the server side and it must be serialized into an xml which can only represent a tree (not a graph especially with cycles) while using xml web services..
here is the same problem: http://forums.java.net/jive/thread.jspa?threadID=13670
the solution is here (in Turkish) : http://egurbuz.wordpress.com/2009/10/27/jaxb-dongusel-baglari-xmlde-anahtarlma-cyclic-reference-problem/
CycleRecoverable is an interface which detects cycles on the implementing object and executes the method onCycleDetected when the object is about to serialize into XML. Thus it gives you a chance to break the cycles in the object graph and make it a tree, thus representable by xml.
import com.sun.xml.bind.CycleRecoverable;
import com.sun.xml.bind.CycleRecoverable.Context;
public class Clazz implements CycleRecoverable {
// ...
@Override
public Object onCycleDetected(Context arg0) {
// do whatever you do
return object;
}
Hiç yorum yok:
Yorum Gönder