users@jaxb.java.net

Re: Java inheritance

From: David Blevins <david.blevins_at_visi.com>
Date: Mon, 10 Jul 2006 16:08:53 -0700

On Jul 10, 2006, at 2:31 PM, Dmitri Colebatch wrote:

> Hi David,
>
> The second post was mine, and I should retract the opening of it as it
> is not a bug at all, rather it is an accurate reflection of xml schema
> inheritance.
>
> In xml schema, inheritance can only append elements, and so that is
> what jaxb does.

Sure, I get that justification. I'm dealing with a spec-defined
schema, so I need the marshalling tool to be a bit more pragmatic on
this as I don't have the option to take up the slack by changing the
schema.

Concretely, the three complexTypes I'm dealing with don't use any xml
schema inheritance anyway, so I don't actually have the issue for
which the justification applies. I.e. there is no xml schema
inheritance for these particular complexTypes to respect or preserve.

Some way to explicitly deviate from the rules so that I could *add*
inheritance where it does not exist in the schema seems totally
reasonable. Even if i had to explicitly annotate my subclass with a
list the java props i wanted inherited, that be totally doable.

> Unfortunately you wont be able to swap the order of foo and bar, which
> I gather is what you'd like to do.

Right.

> Does this help you? Please post some code and also some desired
> output and I'll see if I can help more.

The complexTypes I'm referring to (EntityBeanType,
MessageDrivenBeanType and SessionBeanType) are very large as are the
java classes. Posting links instead.

Here they are with no inheritance:

http://fisheye.codehaus.org/browse/openejb/trunk/openejb3/container/
openejb-jee/src/main/java/org/openejb/jee2/EntityBeanType.java?r=2744
http://fisheye.codehaus.org/browse/openejb/trunk/openejb3/container/
openejb-jee/src/main/java/org/openejb/jee2/MessageDrivenBeanType.java?
r=2744
http://fisheye.codehaus.org/browse/openejb/trunk/openejb3/container/
openejb-jee/src/main/java/org/openejb/jee2/SessionBeanType.java?r=2744

They share 20 properties. Their own individual properties are mixed-
in at various places with those properties. Simplistically, they
should look like this:

http://docs.codehaus.org/display/OPENEJB/JAXB2+Java+Inheritance

That shows just SessionBeanType as a subclass of EnterpriseBean, but
both EntityBeanType and MessageDrivenBeanType would be subclasses as
well.

I understand I could override and annotate the get/set method for
each of the 20 properties in all 3 of the of the subclasses. But
that would give me 120 unwanted methods and this isn't the only place
i'd like to use java inheritance where xml schema inheritance doesn't
exist. I definitely need to find a way to make this work.

-David


> cheers
> dim
>
>
> On 7/11/06, David Blevins <david.blevins_at_visi.com> wrote:
>> These two posts seem to detail quite nicely what I'm facing.
>>
>> https://jaxb.dev.java.net/servlets/ReadMsg?list=users&msgNo=4111
>> https://jaxb.dev.java.net/servlets/ReadMsg?listName=users&msgNo=4252
>>
>> In short, I've generated a JAXB2 annotated Java tree from the Java EE
>> 5 ejb-jar xsd and would now like to introduce a superclass
>> (EnterpriseBean) for EntityBeanType, MessageDrivenBeanType and
>> SessionBeanType as 80% of their properties are the same.
>>
>> I'm finding this to be an impossible task as declaring the propOrder
>> in the subclass results in the "..._at_XmlType.propOrder... no such
>> property exists" exception and declaring a @XmlType.propOrder in the
>> superclass gives me the wrong order in xml.
>>
>> What will it take to support this feature? I understand there may be
>> issues, but I'm almost certain i'd prefer those issues over this one.
>>
>> Thanks,
>> David
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
>> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>