users@jaxb.java.net

Re: Specifying Interfaces that generated classes extend/implement

From: Hank Ratzesberger <hankr_at_crustal.ucsb.edu>
Date: Wed, 09 Jul 2003 09:16:04 -0700

I have a similar issue, but I wonder if this can be accomplished
with a delegated class that uses reflection? With some considerable
checking, it could match the "getter" and "setter" between classes
to copy values using Method.invoke.

(A colleague in my office wrote something like this already, so
I think the answer is yes, depending on whether your classes
match. In my case, I am creating entity beans that match
the classes, so I think it will work.)

--Hank

============================================
Replying to a list? I'll get my copy there!

Hank Ratzesberger
http://crustal.ucsb.edu/ | http://neesgrid.org/
Institute for Crustal Studies
University of California, Santa Barbara
============================================



----- Original Message -----
From: "Marcus Walls" <marcus.walls_at_ASPECTIVE.COM>
To: <JAXB-INTEREST_at_JAVA.SUN.COM>
Sent: Wednesday, July 09, 2003 12:39 AM
Subject: Re: Specifying Interfaces that generated classes extend/implement


> On Thu, 6 Mar 2003 17:46:32 -0500, Ryan Shoemaker wrote:
>
> Apologies for re-opening this thread after 4 months, but I
> now find myself needing an answer to this one as well!
>
> I have the same problem as the original poster - I have
> several schemas which have common properties, (e.g. height
> and width) and I'd like to be able to pass them around in
> my code without having to copy the JAXB objects into
> intermediate objects.
>
> Sticking with the original example: I have two objects
> defined in two separate schemas, both of which have
> width and height elements. I want to define an interface
>
> public interface Sizeable {
> public int getHeight();
> public void setHeight(int value);
> public int getWidth();
> public void setWidth(int value);
> }
>
> and be able to pass the two objects around inside my code
> to functions that expect a Sizeable interface.
>
> >I still don't see how we could allow an "implements"
> >customization on the generated impl classes.
>
> [...]
>
> >If we were to allow such a customization today, you would
> >have to compile your schema and then edit the generated
> >code before it could be used or even compiled.
>
> I can see what you're saying here, however I'm not sure I
> agree. If the schema definition guarantees that the RI
> implementation (or any other implementation for that matter)
> will generate get/set methods for width/height, then the
> code should automatically compile and do what I want.
>
> Is this something the RI could support as a vendor extension?
> I guess the functionality is a bit like the serialization
> interface support, but applied at a local level like implClass
> rather than a global customisation.
>
> This would save me a lot of useless code. At the moment I
> have 8 schemas I cannot change, and all of them share 20+
> fields. Presently I have to create a common class to store
> the 20+ fields, and then have 8 pieces of conversion code
> which is rather nasty, and a pain to maintain.
>
> Marcus
>