Kohsuke,
I had originally thought that I'd host it myself because I like
subversion much better than cvs, but have since reconsidered. I've
requested a developer role at jaxb2-commons and would be happy to put
my work in there if somebody approves me. Besides, as a codemodel/xjc
plugin newbie, I could stand the code review. :-)
On 1/25/07, Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_sun.com> wrote:
> Gregory Kick wrote:
> > I'm working on an xjc plugin that would automatically generate parent
> > pointers similar to the example (
> > https://jaxb.dev.java.net/guide/Mapping_cyclic_references_to_XML.html
> > ) in the jaxb guide. Obviously, since I'm trying to do it in xjc, I'm
> > not trying to avoid cycles, but rather just hold on to a reference to
> > the parent in order to make traversing the object tree a little
> > easier.
>
> Wonderful. I think this is very useful. Would you be interested in
> hosting that on http://jaxb2-commons.dev.java.net/ ?
>
> > I currently have a pretty simple little plugin that uses a field of
> > type Object and just assigns the parent parameter of afterUnmarshal()
> > to it. (By the way, doesn't there need to be a cast in the example?)
> > This works pretty well, but relies on a lot of instanceof and casting.
>
> Fixed the doc. Thanks for the problem report.
>
> > Ideally, I would like something a little more type-safe. In a lot of
> > cases, there will only be one type for the parent so something like
> > "private Department parent;" would work. In the cases with more than
> > one type of parent, maybe have multiple fields and the ones that
> > aren't used just stay null?
>
> ... or you can compute the common base type. There's code in XJC to do
> that. That's how we compute the type of the property.
>
>
> > Anyway, the question at hand is how would I figure out what the
> > possible parent types are from a plugin? The whole xjc
> > model/codemodel thing isn't hugely documented and I can't figure it
> > out.
>
> I hope Lexi's explanation got you going. If not, let me know.
>
> Also, if you have suggestions for doc improvements, like where you got
> stuck, etc, that would be really helpful.
>
>
> --
> Kohsuke Kawaguchi
> Sun Microsystems kohsuke.kawaguchi_at_sun.com
>
>
>
--
Gregory Kick
gk5885_at_gmail.com