users@jersey.java.net

Re: [Jersey] Re: Generate WADL on runtime

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Mon, 13 Jul 2009 14:00:45 +0200

On Jul 13, 2009, at 1:39 PM, António Mota wrote:

> Paul Sandoz wrote:
>>
>> On Jul 13, 2009, at 12:43 PM, António Mota wrote:
>>
>>> Hi again.
>>>
>>> Finally, I'm trying to generate my Wadl using pieces and bits of
>>> Jersey, basically like this:
>>>
>>> WadlBuilder builder = new WadlBuilder(new WadlGeneratorImpl());
>>> Application application = builder.generate(abstractResource);
>>>
>>> Then I just serialize this "application" object using XStream.
>>
>> You need to use JAXB to marshall out an instance of Application as
>> a WADL document.
>>
> Well, yes, but since we are not using Jaxb for the reasons I've
> told, and we are not using the full stack of Jersey, I'm using
> XStream to serialize the Application object. Basically I just
> introspect all the classes that I found in com.sun.research.ws.wadl
> and use the annotation XmlRootElement value as the alias for
> XStream. That part is working OK.
>

Take a closer look at the Application class there are other
annotations that inform the JAXB marshaller how to marshall out the
instance to XML, in addition to other rules specified by JAXB to
marshall classes.


> Now the OPTIONS is just that method I choosed to invoke my code, it
> has nothing specific as the same code was being invoked with a GET
> with application/vnd.sun.wadl+xml as well.
>
> And if I debug the application object, I do see that there is a
>
> application.doc[ArrayList].Doc
>
> application.resoures.resource[ArrayList].Resource
>
> So should I assume that the JAXB Marshaling is getting read of some
> of the fields? Besides the XmlRootElement are there other
> annotations for the Marshaling?
>

JAXB is marshaling as per the JAXB annotations defined on the
Application class and the rules defined by JAXB.

You are essentially trying to emulate JAXB marshalling without using
JAXB.

I strongly recommend you use JAXB, otherwise you are going to make
things very difficult for yourself. If you are using SE 6 that JAXB is
there already.

Paul.