users@jaxb.java.net

RE: Re: XJC Plugin development question

From: Gertelman, Michael, VF-JP <michael.gertelman_at_vodafone.com>
Date: Mon, 13 Mar 2006 17:05:18 +0900

 
I am using JAXB from JWSDP-2.0 and XJC version "2.0-b26-ea3".
It generates two packages: one for interfaces and one for implementations and two ObjectFactory.java files in both packages.
With the code that you use I can only get access to the ObjectFactory from the interfaces package. I don't know how to get the impl ObjectFactory...
 
Michael
 

-----Original Message-----
From: Malachi de Alfweald [mailto:malachid_at_gmail.com]
Sent: Monday, March 13, 2006 4:31 PM
To: users_at_jaxb.dev.java.net
Subject: Re: XJC Plugin development question


That is the same code I used for mine. Specifically, I did:
 
  for(PackageOutline pOutline : outline.getAllPackageContexts())
  {
   /**
    * For each package, locate the ObjectFactory class
    */
   JDefinedClass objectFactory = pOutline.objectFactory();
...
 
I get more than one PackageOutline. This is because I have multiple schemas getting compiled at once and each XSD specifies the package binding via:
 
 <xsd:annotation>
  <xsd:appinfo>
   <jaxb:schemaBindings>
    <jaxb:package name="org.eoti.spec.gaea.event"/>
   </jaxb:schemaBindings>
  </xsd:appinfo>
 </xsd:annotation>
 
Now, each of the PackageOutline's that are returned have the .objectFactory() method that returns the ObjectFactory.java for that specific schema. I know that it is the correct one, because I am extracting the JAXBElement<?> at the bottom of the class for my usage.
 
I am using JAXB2.... It only generates a minimal set of classes... If you are getting both interfaces and implementations, are you running specific JAXB2 options, or are you running JAXB1? If you are running JAXB1, do you have the option of upgrading to the newer JAXB2?
 
Malachi

 
On 3/12/06, Gertelman, Michael, VF-JP <michael.gertelman_at_vodafone.com> wrote:

Hello,

I'm trying to inject some code into the ObjectFactory from the impl package.
I use the following code in my Plugin's run method:

 for (PackageOutline po : outline.getAllPackageContexts()) {
      JDefinedClass objectFactory = po.objectFactory();
 }

Actually, Iterator always returns only one PackageOutline - for the interfaces package. My problem is that this objectFactory refers to the class in the interfaces package.

If I inject any code into this objectFactory it affects only the one from the interfaces package.

How can I access the ObjectFactory class from the implementation package ?

Thanks,
Michael