users@jersey.java.net

RE: [Jersey] Generating WADL's with references to XSD of JAXB schema

From: Rabick, Mark A (IS) <"Rabick,>
Date: Wed, 29 Apr 2009 17:53:41 -0500

Thanks for the offer Andy. I've got it working so far. I added another
target build-wadl-html that uses saxon9 to apply the xsl transformation
and I'm reviewing the results. I ended up taking your source from here
(http://n2.nabble.com/WADL-%2B-Ant-td2240710.html) and created the
class/jar accordingly.

The generatewadl task is:
 
<taskdef name="generatewadl"
classname="com.sun.jersey.wadl.GenerateWadlTask">
        <classpath>
                <path refid="Build Support.userclasspath"/>
                <path refid="Web App Libraries.libraryclasspath"/>
        </classpath>
</taskdef>

This is the target to build the wadl including all of the wadl generator
configuration elements:

        <target name="build-wadl" depends="build-project,
build-wadl-resourcedoc" description="Generate wadl doc">
           <generatewadl wadlFile="${build.dir}/application.wadl"
formatWadlFile="true" baseUri="http://www.cnodb.mil">
               <classpath>
                   <!-- have to add the path to your compiled resources
as well! -->
                   <pathelement location="${build.dir}/classes}" />
                   <path refid="webServices.classpath" />
               </classpath>
               <packages>
                   <package name="mil.cnodb.rs" />
               </packages>
               <wadlGenerators>
                   <wadlGeneratorDescription
name="com.sun.jersey.server.wadl.generators.resourcedoc.WadlGeneratorRes
ourceDocSupport">
                       <param name="resourceDocFile"
value="${build.dir}/classes/resourcedoc.xml" />
                   </wadlGeneratorDescription>
                   <wadlGeneratorDescription
name="com.sun.jersey.server.wadl.generators.WadlGeneratorGrammarsSupport
">
                       <param name="grammarsFile"
value="${build.dir}/classes/application-grammars.xml" />
                   </wadlGeneratorDescription>
                   <wadlGeneratorDescription
name="com.sun.jersey.server.wadl.generators.WadlGeneratorApplicationDoc"
>
                       <param name="applicationDocsFile"
value="${build.dir}/classes/application-doc.xml" />
                   </wadlGeneratorDescription>
               </wadlGenerators>
           </generatewadl>
        </target>

The saxon build target:

<target name="build-wadl-html" depends="build-wadl">
        <property name="saxon.jar"
value="/dev/tools/saxonb9-1-0-5j/saxon9.jar"/>
        <java dir="${build.dir}" jar="${saxon.jar}" fork="true">
                <arg value="-t"/>
                <arg value="-s:application.wadl"/>
                <arg value="-xsl:../wadl_doc/wadl_documentation.xsl"/>
                <arg value="-o:application.wadl.html"/>
                <classpath>
                        <pathelement location="build/classes"/>
                </classpath>
        </java>
</target>

Where the Build Support.userclasspath is:

        <path id="Build Support.userclasspath">
                <pathelement
location="./build-support/jsr173_1.0_api.jar"/>
                <pathelement
location="./build-support/maven-wadl-plugin-1.0.3.jar"/>
                <pathelement
location="./build-support/wadl-resourcedoc-doclet-1.0.3.jar"/>
                <pathelement
location="./build-support/xercesImpl-2.6.1.jar"/>
                <pathelement
location="./build-support/ant-wadl-task-1.0.3.jar"/>
        </path>

--mark

_______________________________________________
Mark A. Rabick - Software Engineer
Em: mark.rabick_at_ngc.com

 


________________________________

        From: aochsner_at_gmail.com [mailto:aochsner_at_gmail.com] On Behalf
Of Andrew Ochsner
        Sent: Wednesday, April 29, 2009 5:00 PM
        To: users_at_jersey.dev.java.net
        Subject: Re: [Jersey] Generating WADL's with references to XSD
of JAXB schema
        
        
        Hi Mark:
        
        
https://jersey.dev.java.net/servlets/BrowseList?list=users&by=thread&fro
m=1538471 is the thread that contains the wadl ant task. It's
definitely a first draft but was good enough to work for me. I've since
abandoned generating WADL in our project so I haven't looked at this in
a while. But I'm happy to try to remember and help out where you need
it!
        
        Andy O
        
        
        On Wed, Apr 29, 2009 at 4:38 PM, Rabick, Mark A (IS)
<Mark.Rabick_at_ngc.com> wrote:
        

                Martin,
                
                I can't find the wadl ant task. The build.xml file
defines the class:
                
                <taskdef name="generatewadl"
                classname="com.sun.jersey.wadl.GenerateWadlTask">
                
                Your class path includes:
                       <include
        
name="com/sun/jersey/contribs/ant-wadl-task/${jersey-release-version}/an
                t-wadl-task-${jersey-release-version}.jar" />
                
                Assume I'm using the Java 1.5 path through the build. I
don't have the
                ant-wadl-task under contribs in my local repository or
out on:
                

        
http://download.java.net/maven/2/com/sun/jersey/contribs/
                
                
                It's not in the maven-wadl-plugin-1.0.3.jar either.
                
                --mark
                

                _______________________________________________
                Mark A. Rabick - Software Engineer
                Em: mark.rabick_at_ngc.com
                
                
                
> -----Original Message-----
                
> From: Martin Grotzke
[mailto:martin.grotzke_at_freiheit.com]
                
> Sent: Tuesday, April 28, 2009 4:14 PM
> To: users_at_jersey.dev.java.net
                
> Subject: RE: [Jersey] Generating WADL's with
references to
> XSD of JAXB schema
>
> Hi Mark,
>
> once I started to create an ant sample that shows how
to
> generate wadl with ant (using the GenerateWadlTask
provided
> by Andrew Ochsner).
> However, creating an ant build that supports both java
1.5
> and java 1.6 and beeing platform independent prevented
me
> from finishing this. I attach the stuff I have, you
can have
> a look at the "wadl" target in the build.xml.
>
> But your question was also, what the generate-wadl
sample is
> doing to create the application.wadl:
>
> - generate jaxb-beans from the schema.xml (the is done
in the
> generate-sources phase before compile, in ant terms
compile depends on
> generate-sources)
> - generate the resourcedoc.xml using the javadoc
plugin with
> the ResourceDoclet (this is bound to the compile
phase)
> - generate the application.wadl using the
maven-wadl-plugin
> (this is also bound to the compile phase)
>
> The maven-wadl-plugin is configured to use several
> WadlGenerators, one of them is the
> WadlGeneratorGrammarsSupport that allows to include
the grammars file.
>
> As you say that it's not clear what's done 'online'
and what
> is needed to generate 'offline': The maven-wadl-plugin
was
> created to allow generating the application.wadl
completely
> offline - no runtime required at all.
> Would you say this gets clearer when the sample would
be
> reduced to only generate the application.wadl,
removing the
> stuff with mvn exec:java that starts jersey with the
example
> resources?
>
> Cheers,
> Martin
>
>
> On Tue, 2009-04-28 at 15:32 -0500, Rabick, Mark A (IS)
wrote:
> > My problem with the generate-wadl example is that
I've
> never used mvn
> > before. I can get the example to 'do stuff'
according to the
> > readme.txt but I can't interpret the mvn output or
the
> pom.xml file to
> > determine what it is actually doing. I setup my
build process to
> > generate the XSD from my JAXB beans and now I'm
trying to
> generate the
> > wadl with the application-grammars.xml support to
include
> that schema
> > info. It's hard to distinguish in the sample code
what is 'online'
> > and is used to generate the
> > http://host:port/<resource-base>/application.wadl
and what
> is needed
> > to generate the WADL 'offline'. I'd like to use ANT
so if
> someone can decipher the pom.xml directives into ant
tasks/targets.
> >
> > The mvn plugins are confusing to me and I don't see
a
> 1-to-1 mapping
> > of mvn instructions to ant tasks/targets.
> >
> > -mark
> >
> > _______________________________________________
> > Mark A. Rabick - Software Engineer
> > Em: mark.rabick_at_ngc.com
> >
> >
> >
> > > -----Original Message-----
> > > From: Arul Dhesiaseelan [mailto:arul_at_fluxcorp.com]
> > > Sent: Wednesday, April 22, 2009 6:32 PM
> > > To: users_at_jersey.dev.java.net
> > > Subject: Re: [Jersey] Generating WADL's with
references to
> > > XSD of JAXB schema
> > >
> > > Hi Mark,
> > >
> > > I would suggest you to statically create your XSD
from your
> > > JAXB beans.
> > > You could do this by schemagen utility bundled
with JAXB RI.
> > > I think it is not a good idea to generate your
schema at
> > > runtime just for the purposes of documentation.
> > >
> > > You could use the WadlGenerator:
WadlGeneratorGrammarsSupport
> > > to use the generated schema referenced from your
WADL using
> > > application-grammars.xml. You can look at the
generate-wadl
> > > [1] example in Jersey for more details.
> > >
> > > Hope this helps.
> > >
> > > -Arul
> > >
> > > [1]
> > >
https://jersey.dev.java.net/source/browse/jersey/trunk/jersey/
> > > samples/generate-wadl/
> > >
> > > Rabick, Mark A (IS) wrote:
> > > >
> > > > I posted this as a question on Paul's blog post:
> > > >
_http://blogs.sun.com/sandoz/entry/jersey_1_0_3_is_
> > > >
> > > > I asked:
> > > >
> > > > Regarding:
> > > >
> > > > >Developer defined WADL-based resource
classes,
> inspired by
> > > > James Strachan's use of WADL and Jersey
MVC.
> > > > Injecting WadlApplicationContext enables
access to
> > > the WADL JAXB
> > > > representation for the application.
> > > >
> > > > Is there a sample that demonstrates the
> generation of a WADL
> > > > that includes the XSD of JAX-B annotated
entities? Is it
> > > > possible to generate a WADL outside of
having to
> deploy the
> > > > web-app and visit URI:
> > > >
_http://host:port/<resource-base>/application.wadl_
> > > >
<http://host:port/%3Cresource-base%3E/application.wadl> ??
> > > >
> > > > Arul responded with a blog post illustrating how
to
> render the xml
> > > > wadl formatted using XSLT. I would like to have
included
> > > in the wadl
> > > > in whatever format it is in to link to a
generated XSD
> > > based on a set
> > > > of JAXB annotated entities.
> > > >
> > > > Any ideaa?
> > > >
> > > > -mark
> > > >
> > > >
*_______________________________________________*
> > > > *Mark A. Rabick*
> > > > *Em: mark.rabick_at_ngc.com*
> > > >
> > >
> > >
> > >
> > >
>
---------------------------------------------------------------------
> > > To unsubscribe, e-mail:
users-unsubscribe_at_jersey.dev.java.net
> > > For additional commands, e-mail:
users-help_at_jersey.dev.java.net
> > >
> > >
> >
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
users-unsubscribe_at_jersey.dev.java.net
> > For additional commands, e-mail:
users-help_at_jersey.dev.java.net
>
> --
> Martin Grotzke
> http://www.javakaffee.de/blog/
>
                
        
---------------------------------------------------------------------
                To unsubscribe, e-mail:
users-unsubscribe_at_jersey.dev.java.net
                For additional commands, e-mail:
users-help_at_jersey.dev.java.net