Russell Bateman
February 2014
last update:
I decided to get more intimately acquainted with Enunciate. Enunciate is an engine for enhancing a Java web service API that creates full HTML documentation, client-side libraries for consumers of your web service, interface-definition documents such as WADLs.
So, I did the quick-start example in order to start from scratch. This example creates a tiny ReSTful web service. It's a little over-elaborated if only to have something show up in the documentation.
The example was pretty simple:
~/dev $ tree enunciate-quick-start enunciate-quick-start `-- src `-- com `-- ifyouwannabecool +-- api | +-- ExclusiveGroupException.java | +-- PermissionDeniedException.java | +-- PersonaService.java | `-- SocialGroupService.java +-- domain | +-- link | | +-- Link.java | | `-- SocialGroup.java | `-- persona | +-- Name.java | `-- Persona.java `-- impl +-- PersonaServiceImpl.java `-- SocialGroupServiceImpl.java 9 directories, 11 files
<?xml version="1.0" ?> <!DOCTYPE project> <project name="enunciate-quick-start"> <property name="enunciate.home" location="${basedir}/lib/enunciate" /> <property name="build.dir" location="${basedir}/build" /> <path id="enunciate.classpath"> <!--<fileset dir="${enunciate.home}/lib">--> <fileset dir="${enunciate.home}"> <include name="*.jar"/> </fileset> <!--include (optional) spring module <fileset dir="${enunciate.home}/lib/modules/spring"> <include name="*.jar"/> </fileset>--> <fileset dir="${java.home}"> <include name="lib/tools.jar"/> </fileset> </path> <taskdef name="enunciate" classname="org.codehaus.enunciate.main.EnunciateTask"> <classpath refid="enunciate.classpath"/> </taskdef> <!--<enunciate basedir="src/main/java">--> <enunciate basedir="src"> <include name="**/*.java"/> <classpath refid="enunciate.classpath"/> <--<export artifactId="war.file" destination="${tomcat.home}/webapps/myapp.war"/>--> <export artifactId="war.file" destination="${build.dir}/webapps/${ant.project.name}.war"/> <javacArgument argument="-g"/> </enunciate> </project>
Before running Enunciate (via ant), I did the download from CodeHaus. I blew open the tarball, then copied the contents of the lib subdirectory to my project's lib subdirectory whence ant accesses them—as hinted by the ant script if you looked closely above.
~/dev $ tree enunciate-quick-start/lib enunciate-quick-start `--lib +-- asm-3.2.jar +-- enunciate | +-- activation-1.1.jar | +-- ... | +-- enunciate-c-1.27.jar | +-- enunciate-core-1.27.jar | +-- enunciate-core-annotations-1.27.jar | +-- enunciate-core-rt-1.27.jar | +-- enunciate-csharp-1.27.jar | +-- enunciate-docs-1.27.jar | +-- enunciate-java-client-1.27.jar | +-- enunciate-jaxws-ri-1.27.jar | +-- enunciate-jaxws-support-1.27.jar | +-- enunciate-jersey-1.27.jar | +-- enunciate-jersey-rt-1.27.jar | +-- enunciate-obj-c-1.27.jar | +-- enunciate-php-1.27.jar | +-- enunciate-ruby-1.27.jar | +-- enunciate-xml-1.27.jar | `-- ... +-- jersey-bundle-1.9-ea01.jar +-- jersey-client-1.9.1.jar +-- jersey-json-1.9.1.jar +-- jersey-server-1.9.jar `-- jsr311-api-1.1.1.jar
$ ant
Buildfile: /home/russ/dev/enunciate-quick-start/build.xml
Loading modules from the specified classpath....
Discovered module c
Discovered module csharp
Discovered module docs
Discovered module java-client
Discovered module jaxws-ri
Discovered module jaxws-support
Discovered module jersey
...
[enunciate] warning: [options] bootstrap class path not set in conjunction with -source 1.5
[enunciate] 1 warning
[enunciate]
[enunciate]
[enunciate]
[enunciate]
[enunciate]
BUILD SUCCESSFUL
Total time: 5 seconds
$ sudo apt-get install tomcat6
$ sudo cp enunciate-quick-start.war /var/lib/tomcat6/webapps $ pu /var/lib/tomcat6/webapps/ $ ll total 4220 drwxrwxr-x 4 tomcat6 tomcat6 4096 May 9 10:41 . drwxr-xr-x 6 root root 4096 May 9 10:39 .. drwxr-xr-x 6 tomcat6 tomcat6 4096 May 9 10:41 enunciate-quick-start -rw-r--r-- 1 root root 4302032 May 9 10:41 enunciate-quick-start.war drwxr-xr-x 3 root root 4096 May 9 10:39 ROOT