Modular Compilation: How to access "Episode" information via the "Outline" in the plugin API

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Modular Compilation: How to access "Episode" information via the "Outline" in the plugin API

Mirko Klemm
Hi all,
Currently I’m developing a plugin for XJC. In order to support modular compilation, i need to access the bindings defined in the „episode“ file in upstream modules.
Specifically, I want to resolve a complexType’s type use via qualified name against the class and package name defined in an upstream module, given all the possible customizations of class and package names that may have been applied in the upstream module.
Now, my assumption is, that somewhere the upstream module’s „episode“ information must be loaded into the „Model“ of the current module.
How can i access this information from my plugin while my downstream module is compiled in XJC?

Thanks!
Mirko

signature.asc (169 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Modular Compilation: How to access "Episode" information via the "Outline" in the plugin API

Aleksei Valikov
Hi,

Disclaimer: I'm the author of JAXB2-Basic (https://github.com/highsource/jaxb2-basics). Not an Oracle employee/JAXB developer.

> Now, my assumption is, that somewhere the upstream module’s „episode“ information must be loaded into the „Model“ of the current module.

Episode files are just bindings files with SCD binding. An episode file basically says the following:

<bindings scd="x-schema::tns" xmlns:tns="http://www.opengis.net/cat/csw/2.0.2">
    <schemaBindings map="false">
      <package name="net.opengis.csw.v_2_0_2"/>
    </schemaBindings>

"Target namespace http://www.opengis.net/cat/csw/2.0.2 will be mapped to the package net.opengis.csw.v_2_0_2, but don't generate any classes."

    <bindings scd="~tns:AbstractRecordType">
      <class ref="net.opengis.csw.v_2_0_2.AbstractRecordType"/>
    </bindings>

"Use the class net.opengis.csw.v_2_0_2.AbstractRecordType for the complex type AbstractRecordType"

    <bindings scd="~tns:ElementSetType">
      <typesafeEnumClass ref="net.opengis.csw.v_2_0_2.ElementSetType"/>
    </bindings>

"Use the enum net.opengis.csw.v_2_0_2.ElementSetType for ElementSetType".

Probably a few more things of this kind. But it's all just binding files with a bunch of jaxb:class/@ref. Episode don't have any "special" representation in the model. For any tasks you want to do with episodes, you just have to analyze the model for the effects of the applied episode. In the case of jaxb:class/@ref this will be a CClassRef instead of CClassInfo.

If I understood you correctly, you want to find the fully qualified class name for a QName of a certain complex type. You're then interested in CClass instances which are either CClassInfo or CClassRef. CClassInfo are available via model.beans. And CClassInfo has getTypeName() which should return the QName of the originating type.

CClassRefs are trickier (this is why you're asking, I guess). They are not listed in the model. So you'll have to scan the whole model and gather CClassRefs.

CClassRef also has a getTypeName(), but that's always null. I see two approaches to find out the qualified type name for a CClassRef:
* Get XSComponent via cclassRef.getSchemaComponent() and find out the qualified name from there. However I am not sure that it is initialized correctly.
* cclassRef.fullName() gives you a fully qualified name of the class. If that class is available from the classloader, you can find out the type name from that compiled class using the reflection on annotations.

The first way is much better, of course, but I'm not sure you'll have the XSComponent on cclassRef.

FYI in JAXB2-Basics I did quite an effort to "brush pu" the XJC model that it's a bit more usable:


This does not cove your case, though.

Best wishes,
Alexey


On Sun, Feb 1, 2015 at 5:01 PM, Mirko Klemm <[hidden email]> wrote:
Hi all,
Currently I’m developing a plugin for XJC. In order to support modular compilation, i need to access the bindings defined in the „episode“ file in upstream modules.
Specifically, I want to resolve a complexType’s type use via qualified name against the class and package name defined in an upstream module, given all the possible customizations of class and package names that may have been applied in the upstream module.
Now, my assumption is, that somewhere the upstream module’s „episode“ information must be loaded into the „Model“ of the current module.
How can i access this information from my plugin while my downstream module is compiled in XJC?

Thanks!
Mirko

Loading...