users@jaxb.java.net

Re: Annox plugin.

From: Aleksei Valikov <valikov_at_gmx.net>
Date: Tue, 10 Mar 2009 11:38:05 +0100

Hi.

> The scenario I am dealing with goes like this. I have a XSD which I
> convert it into java classes . Having the necessary data structures I
> convert the objects of the generated classes to XML.
>
> Now it so happened that, I have given a element of "anytype" in the
> XSD which then would be converted to member of class of java type
> "Object" . Now this Object is in turn used to store complex data
> object (data model, table model, model listener et al). I dont want
> this member to be serialized when I convert the object to XML through
> marshalling. This can be done in two ways:
>
> 1. Applying @XmlTransient annotation to the member element.
> 2. By extending the generating class to a child class and then
> annotating the new class. I dont want to do this since my
> implementation is working fine but for the manual addition of
> @XmlTransient. I want to annotate the member with @XmlTransient
> automatically without any manual intervention. This will make my
> application robust.
>
> If there is any other solution or feedback, please let me know. I
> appreciate your time and effort on this.

I have to say I don't think that mixing JAXB model data and utilities
is a good idea, but it's up to you.

Further on, if you use a schema-derived property to store utility
objects you essentially misuse your schema therefore from the
architecture point of you I'd say (2) is more preferrable than (1).

Next, as I can say, annox/annotate plugin can not help you make your
property transient. Yes, you can get @XmlTransient added to your
field, BUT this will not work at the end because other @Xml
annotations can not and will not be deleted from this field.

If you want to use schema-derived field to store custom data as you
described, I think you best option is to wrap you data in some wrapper
class where all the properties are @XmlTransient. The wrapper class
will be then marshalled, but your custom data not.

Bye.
/lexi