users@jaxb.java.net

Re: XJC Plugin development question

From: Malachi de Ælfweald <malachid_at_gmail.com>
Date: Sun, 12 Mar 2006 23:31:12 -0800

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
>
>
>