users@jaxb.java.net

RE: Re: XJC Plugin development question

From: Gertelman, Michael, VF-JP <michael.gertelman_at_vodafone.com>
Date: Tue, 14 Mar 2006 09:25:07 +0900

Hi Kohsuke,
yes, I need to access both ObjectFactories, in intf and in impl packages.
If it's too tricky it's ok, I found a way to work around it (ugly but at least it does not keep me from going on).
Of course, if you have a real solution it would be great.

As for JAXB-1.0 compatibility, I really don't care.

Michael

-----Original Message-----
From: Kohsuke Kawaguchi [mailto:Kohsuke.Kawaguchi_at_Sun.COM]
Sent: Tuesday, March 14, 2006 5:20 AM
To: users_at_jaxb.dev.java.net
Subject: Re: XJC Plugin development question


Gertelman, Michael, VF-JP 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 ?

As Malachi pointed out the iterator is meant for different packages, and
not for interface/impl split.

For Malachi, the reason he's getting two ObjectFactories is because he
chose not to generate value classes (but intf/impl pairs.)


This actually led me to find a bug in the code, so now this same method
actually returns a private ObjectFactory (in the impl class.)

Allowing you to access both is bit tricky. Would this change get you
going? (IOW, do you need to access both ObjectFactories, or just the one
in the impl package?)

-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com