users@jersey.java.net

Re: [Jersey] Re: Generate WADL on runtime

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Mon, 13 Jul 2009 16:15:28 +0200

On Jul 13, 2009, at 4:03 PM, António Mota wrote:

> Paul Sandoz wrote:
>> 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.
>>
> I'm sorry for my ignorance on JAXB things, but to use it I have to
> have some kind of classes compiled from schema and have that in
> some kind of context?
>

You can either create JAXB types from code, or you can compile a
schema to generate JAXB types. Jersey does the latter and compiles the
WADL schema to JAXB source, which it then compiles and includes with
the jersey-server module.


> Or are the com.sun.research.ws.wadl.* classes already those compiled
> classes, in case of wich how do I know what context to use?
>

You can do the following:

    JAXBContext c = JAXBContext.newInstance("com.sun.research.ws.wadl");

to create a JAXBContext that is capable of serializing Application.


> I'm must say that besides my ignorance in Jaxb, I'm also one of
> those left-wing restfarian extremists who think WADL is harmful to
> our cause... :)))))))))))))))))))
>

Oh dear... You do not have to use it :-)

You can think of WADL as hypermedia giving more information about the
service beyond the meagre default offered by OPTIONS. I strongly
advice not to bind code statically to WADL but it can be rather useful
when done dynamically using say JavaScript.

The WADL representation has also been used to create documentation.
WADL itself or programatically via the JAXB objects have been used to
generate documentation as part of the service.

Paul.