users@jaxb.java.net

Re: Specifying Interfaces that generated classes extend/implement

From: Ryan Shoemaker - JavaSoft East <Ryan.Shoemaker_at_sun.com>
Date: Wed, 05 Mar 2003 16:05:19 -0500

Erik Ostermueller wrote:
> So, is it true jaxb does not code generate
> custom 'implements' statements?
>

I don't see how it could. Obviously, the generated interfaces can't implement
other interfaces. We could add 'implements' on the generated impl classes, but
the code wouldn't compile because the implementation of those methods would be
missing. Making the impl classes abstract won't work because JAXB doesn't
support sub-classing the generated classes.

The <xjc:superClass> customization is a vendor extension of the RI - it is not
described by the specification. As a JAXB provider, the RI can not modify the
signatures of the interfaces generated by the binding compiler by adding 'extends'.
However, we are allowed to modify the signatures of our implementation classes.
The <xjc:superClass> customization adds an 'extends' on each of the generated
classes. Perhaps in the next release we can allow finer grained control (ie -
specify the customization on a per class basis rather than globally).

I assume you've already taken a look at the URL below. You should also have a
look at $JWSDP_HOME/jaxb-1.0/examples/vendor-extensions for an example of how
this feature behaves.

Please let us know if you have any other thoughts on this topic.

--Ryan Shoemaker, Sun Microsystems, Inc.



>
> > -----Original Message-----
> > From: Ryan Shoemaker - JavaSoft East
> > [mailto:Ryan.Shoemaker_at_Sun.COM]
> > Sent: Tuesday, March 04, 2003 4:34 PM
> > To: JAXB-INTEREST_at_JAVA.SUN.COM
> > Subject: Re: [JAXB-INTEREST] Specifying Interfaces that
> > generated
> > classes extend/implement
> >
> >
> > Douglas Jackson wrote:
> > > Has there been any discussion of allowing the
> > > specification of an interface that a generated
> > > class extends/implements? (The generated interface
> > > would extend the interface and the generated
> > > implementation would implement it)
> > > This would be handy for cases where an API was
> > > exposing some methods and the jaxb class was going
> > > to provide the implementation of the API.
> > >
> > > Something along the line of:
> > >
> > > <xs:element name="x">
> > > <xs:annotation><xs:appinfo>
> > > <jaxb:class interface="com.x"/>
> > > </xs:appinfo></xs:annotation>
> > > <xs:complexType>
> > > <xs:choice>
> > > <xs:element ref="y"/>
> > > </xs:choice>
> > > </xs:complexType>
> > > </xs:element>
> > >
> >
> > The specification doesn't address this, but there is a
> > feature like what
> > you've described in the RI:
> >
> > http://java.sun.com/webservices/docs/1.1/jaxb-1.0/vendor
> > .html#superclass
> >
> > --Ryan
> >
>