users@jaxb.java.net

RE: Re: Edit the generated Code

From: <HeruMartinus.Salim_at_infineon.com>
Date: Mon, 16 Oct 2006 17:51:08 +0200

Hi,

Thanks for your response.
I don't get what you mean with your 1st solution. Generate with
addons/plugins?

And for your 2nd, I found it's not be able to be used in my case. While
the XSD file itself keeps changing. So I can't just subclass my own
class to the generated code. If the xsd file changes, and new Codes
generated, all the extension will be gone.

In my project, I'm creating an API of a system (The system itself would
be translated to schema file, which later be used by JAXB to generate
the Java codes.
So I would like to wrap/package the generated code with functionality
which is allowed in this API. In this way, it would also protecting the
lost of functionality when new features were added to the system. So I'm
wondering the best way to do this.
Any advice?

Best regards,
Heru

-----Original Message-----
From: Aleksei Valikov [mailto:valikov_at_gmx.net]
Sent: Monday, October 16, 2006 3:48 PM
To: users_at_jaxb.dev.java.net
Subject: Re: Edit the generated Code

Hi.

> I'm pretty new in using JAXB, and I have some questions about
> developing using JAXB.
> The problem I met is, the XSD file I used, is still keep changing.
> This makes difficult to edit the JAXB generated Code, while when the
> XSD file is updated, all the changes I made, would be replaced by the
> generated code?
>
> My question is:
> How do people usually develop using JAXB? Do the altering the
> generated Code? Or simply creating a subclass of the generated
> classes, and altering the subclasses?
>
> The solution which I took so far, is by subclassing it in another
> package. But still found some problem when generating the XML files,
> while the JAXBElement created from the Object factory is from the
> package of the generated classes (not the subclasses which I
expected).
>
> Can anybody share the experience in developing using JAXB?

My two cents.

Cent one: I generate a lot of things with addons/plugins. Once you
master them, you can really do things that MDA/UML tools could even not
dream of.

Cent two: apart from subclassing your class from the schema-derived
class (like you sketched out above) you can also subclass _the_
schema-derived class _from_ your class. This way the object factory will
still create instances of generated classes, but they will bear the
inherited functionality from your base classes that they extend.

I prefer not to edit generated code, never. Sometimes I use JAXB
annotations just manually on my hand-written classes, but I never edit
the generated code.

Bye.
/lexi

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net