users@jaxb.java.net

Re: binding complexType element defintions to Fields

From: Kohsuke Kawaguchi <kohsuke.kawaguchi_at_sun.com>
Date: Tue, 10 Jan 2006 06:14:07 +0900

mark_at_javector.com wrote:
> Yes - I understand that it wouldn't be part of the JAXB specification. My
> question was just on the syntax of how to express the mapping to a
> field. Couldn't it be done using an extension binding declation - as
> described in
> Section 7.1.1? I.e., where the namespace for the field mapping declaration is
> specified using the <jaxb:extensionBindingPrefixes>.

Ah, yes, that can be also done, if you'd want to.


The "Developing on top of JAXB RI" section of [1] contains some
resources about writing plugins.

"Writing an XJC plug-in" explains the basic idea of writing plugins,
such as what interface to implement, how XJC finds it, and so on. XJC
itself bundles a few plugins in it, so you should check its source code
(com.sun.xml.tools.xjc.addon.)

The architecture document is a pumped-up javadoc, and it should take you
to many of the basic abstractions inside XJC. In particular,
FieldRenderers are defined in the com.sun.tools.xjc.generator.bean.field
package. Also check FieldOutline (com.sun.tools.xjc.outline) and their
derived classes, which do most of the significant works.

Each FieldRenderer dictates how a field is generated, and since there
are only so many different ways to generate a field, there are constants
defined that represent each possible code generation style, which you'll
find in the FieldRender interface.

What I'm thinking about is to make this a factory class, instead of
constants, and then let a plugin replace it. In that way, you can create
your own FieldRenderers that generate just fields and no accessors.

Please play around with it a bit, and let me know how you think. I'm
traveling for this week, so if I don't reply in a timely fashion that's
probably because I don't have e-mail access.

Any feedback on doc/code/anything would be appreciated.


[1] http://jaxb.dev.java.net/
-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com