users@jaxb.java.net

Re: Some principal question

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Mon, 04 Aug 2003 08:23:22 -0700

qw qw wq qw qw <r198080_at_yahoo.com> wrote:
> Then I found an option of using -binding- option and
> compile all the schamas at once. But here I met
> troubles. Just a couple of generated packages has
> runtime subpackage (so when I call
> JAXBContext.newInstance(packageName) I don't get
> really correct package (since it returns
> implementation class and not every package which name
> I pass as a parameter has one). Shortly speaking that
> call doesn't always work. I see that now I can't
> explicitly assign a package the engine has to
> unmarshal data onto but the engine itself decides
> which one to use basing on its logic and on a schema
> namespace XML data must supply.
> My question is: what's the logic I have to use and
> what's the right way to do it?

I don't fully understand what the problem is. If the XJC compilation
generates classes into multiple packages, you can just pass them all
(like "org.acme.foo:org.acme.bar") to the JAXBContext.newInstance method.

What will happen if you do this?


> Another question is which binding out of the described
> above should I use? All together or each schema
> separately?

Both would work.

> Third question is why do I need
> JAXBContext object at all? If I can explicitly create
> an ObjectFactory (that every generated package has)
> then I can create marshaller/unmarshaller by its help.
> I think I miss the point:-)

JAXBContext.newInstance is supposedly more portable. Plus it allows you
to combine multiple packages. ObjectFactory doesn't.



regards,
--
Kohsuke Kawaguchi                  408-276-7063 (x17063)
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com