users@jaxb.java.net

Re: use case for Unmarshal / Marshal callback events

From: Mark Hansen <mark_at_javector.com>
Date: Wed, 02 Nov 2005 14:05:43 -0500

Thanks. Very helpful stuff. Please post a link to your blog on this
topic if you can find it.

-- Mark


Kohsuke Kawaguchi wrote:
> Mark Hansen wrote:
>
>> I'm trying to understand the intended use of Unmarshal / Marshal
>> callback events. For unmarshalling, what kind of bean property would
>> I want to set on a value class either before or after unmarshal?
>
>
> One use is to set parent pointers. The other is so that you can
> implement custom ID/IDREF-like reference mechanism. I think I mentioned
> this in one of my blogs.
>
>> I'm even more confused about marshal callback events. The marshal
>> callback interface doesn't provide access to the XML infoset that is
>> being marshalled in to - only the parent of the JAXB value class and
>> the Marshaller. What is the use case for setting properties of either
>> the Marshaller and/or value class before or after marshalling it out
>> to an infoset?
>
>
> The initial motivation for me at least was only on the unmarshalling
> side, but then many of us felt that not having anything for the
> marshaller side would be somewhat inconsistent.
>
> I think one potential use is to clean up / normalize the in-memory data
> structure right before the marshalling.
>
> I think you have a good point that it doesn't let you access the XML
> infoset, but given that JAXB can marshal to so many different forms,
> it's bit tricky to provide any XML infoset information to application.
>