users@jaxb.java.net

Some codemodel questions

From: Colin Fleming <colin.mailinglist_at_gmail.com>
Date: Mon, 14 May 2007 13:37:38 +0200

Hi all,

We need a plugin basically as described by malachid in the comments on
Kohsuke's blog here:
http://weblogs.java.net/blog/kohsuke/archive/2006/03/why_does_jaxb_p.html.
It seems as though it never got published, so I'm trying to write one
myself. It's mostly been pretty straightforward, but the sticking
point (as usual, it seems) is working out the codemodel. The API is
generally pretty good, but sometimes seemingly simple things are
difficult to work out.

Anyway, I have two questions: I have a JBlock, and I'd like to add a
'return new JAXBElement(<params>), but I can't figure out how to add a
constructor invocation for a class that I don't have a JClass for.

Also, I don't fully understand when an element factory method will be
added to the ObjectFactory. The following schema seems to create one:

  <xs:element name="isomsg" type="IsoMessage"/>

but the following doesn't:

  <xs:element name="Users">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="cardUser" type="User" minOccurs="0"
maxOccurs="unbounded"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

Can I test if a createXXX function is generated on the ObjectFactory
using the codemodel? I couldn't find anything in either ClassOutline,
CClassInfo or JDefinedClass that would tell me. I thought
CClassInfo.isElement and getElementName might do the trick, but it
seems not. Also, is there any way to get a reference to the create
function generated on the ObjectFactory (or, even better, a reference
to the ObjectFactory class) so I can invoke it?

Thanks for any help,
Colin