users@jaxb.java.net

Re: Plugin for EJB 3.0 annotations

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Fri, 12 Aug 2005 10:11:36 -0700

Scott Allan wrote:
> I am able to get all the class level customizations and replace them all
> with the correct annotations.

Cool!

> I'm not sure how to access the element level customizations to annotate
> the methods.

I'm not sure what you mean by "element level", but perhaps you mean
customization attached to element declarations that are bound to
JAXBElement.

ElementOutline is only created for those elements that are bound to
classes. For other elements that do not map to classes (IOW only appear
as a factory method on ObjectFactory), there will be no ElementOutline
(I don't know if this is a good thing, though.)

What you can do is to use Model.getAllElements() to get to all element
mappings (CElementInfo). This class extends from CCustomizable, so you
can access all the customizations attached to it.

To access properties of the JAXB-bound classes, you'd use
ClassOutline.getDeclaredFields() (this should be really renamed to
getProperties() for symmetricity) for the outline, and
CClassInfo.getProperties() for the model.

For the structure of the model, it might be easier to see the interfaces
in the com.sun.xml.bind.v2.model.core package. All XJC model classes
inherit these core model interfaces, and the core model is hopefully
well-documented. Also check out the architecture document of the core
model package.

Currently outline probably doesn't expose enough information to let you
get to JMethod objects. So, I think we need to change them somewhat, so
I appreciate your input on this.


> I was thinking somehow I must need to access ElementOutline from Outline
> but the only method I can find is ElementOutline getElement(CElementInfo
> ei) and I'm not sure how to implement it. I'd appreciate some advice.

Hope the above explanation helps. Otherwise perhaps you could explain me
what you want to achieve (like where you'd like to put an annotation.)

-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com