users@jaxb.java.net

Re: Build my own implementations?

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Mon, 27 Sep 2004 11:59:53 -0400

Brant Boehmann wrote:
> I'm new to JAXB, and I've stumbled across an interesting issue.
> We have a schema which models a bunch of content types for our content
> management system (articles, recipes, polls, etc)
>
> If I were creating an object model I would create a ContentType
> interface which defines things like getName, get ShortDescription, etc.
> getShort Description in one content type may refer to the "description"
> element in the recipe schema, but may refer to the "abstract" element in
> the artucle schema.
>
> I would like to be able to use the power of interfaces to accomplish
> generic things like "add a ContentType to a cart" regardless of what the
> specific content type is.
>
> I would like to be able to implement my own classes instead of having
> JAXB generate them for me so I can create this logic. However, I really
> like the XML marshalling/unmarshalling that JAXB provides. Is there a
> way I can turn off "value object generation" and define mapping for the
> Marshallers to use?

Unfortunately, it's really not quite easy to do that.

I believe that the intention of the JAXB 1.0 spec to have interfaces is
to hide vendor-specific implmentations behind the curtain and not
primarily to let people swap the generated code manually.

One possibly related feature is, you can derive your own class from the
generated code, and you can use a JAXB customization (<jaxb:class
implClass>) to tell the JAXB RI to use it.

Also, if you'd like, you can take the generated code and put that into
the source control system, then start modifying it manually. If your
schema is stable enough, this would probably work just fine. But if it's
not, then it's kind of tricky to merge changes.


-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net