In the current JAXB RI, developed by Sun, there is a series of "proprietary" JAXB extensions which provide advanced functionality outside of the JAXB specification (these extension classes and properties reside in the '''com.sun.xml.bind''' package).

−

+

−

In the current JAXB RI, developed by Sun, there are a series of "proprietary" JAXB extensions that are available to provide advanced JAXB functionality outside of the JAXB spec (these extension classes reside in the '''com.sun.xml.bind''' package).

+

The '''CycleRecoverable ''' interface allows the user to write their own logic to be used when object cycles are detected during marshal operations. When a cycle is detected, MOXy will invoke the '''onCycleDetected''' method, which returns a "replacement" object for the one that caused the cycle.

The '''CycleRecoverable ''' interface allows the user to write their own logic to be used when object cycles are detected during marshal operations. When a cycle is detected, MOXy will invoke the '''onCycleDetected''' method, which returns a "replacement" object for the one that caused the cycle.

−

−

This document will outline the design for EclipseLink support for this extension.

Latest revision as of 10:36, 18 June 2012

Contents

Cycle Recoverable

In the current JAXB RI, developed by Sun, there is a series of "proprietary" JAXB extensions which provide advanced functionality outside of the JAXB specification (these extension classes and properties reside in the com.sun.xml.bind package).

The CycleRecoverable interface allows the user to write their own logic to be used when object cycles are detected during marshal operations. When a cycle is detected, MOXy will invoke the onCycleDetected method, which returns a "replacement" object for the one that caused the cycle.

A cycle is detected in the object graph. This will cause an infinite loop: Department@122cdb6 -> Employee@1ef9157 -> Department@122cdb6

By implementing the CycleRecoverable interface on the Department class, the user has the opportunity to provide a new Object for marshalling, replacing the duplicate Department. In this example, we will return a DepartmentPointer object that holds the id of the real Department.