org.jvnet.ws.wadl2java
Class WJCTask

java.lang.Object
  extended by org.apache.tools.ant.ProjectComponent
      extended by org.apache.tools.ant.Task
          extended by org.jvnet.ws.wadl2java.WJCTask

public class WJCTask
extends org.apache.tools.ant.Task

Ant task implementation for the WADL to Java tool

Use as an ant task:

 <property name="jaxws.home" value="/path/to/jax-ws/directory" />
 <property name="wadl2java.home" value="/path/to/wadl2java/directory" />

 <taskdef name="wjc" classname="org.jvnet.ws.wadl2java.WJCTask">
   <classpath>
     <fileset dir="${jaxws.home}" includes="lib/*.jar" />
     <pathelement location="${wadl2java.home}/dist/wadl2java.jar"/>
   </classpath>
 </taskdef>

 <target name="-pre-compile">
   <echo message="Compiling the description..." />
   <wjc description="file.wadl" package="com.yahoo.search"
       autoSchemaPackage="true|false" target="gen-src">
     <customizations dir="." includes="binding.xjc"/>
     <produces dir="gen-src/com/yahoo/search" includes="*.java"/>
     <depends dir="." includes="schema.xsd"/>
     <customClassName uri="http://yahoo.com/rest" classname="YahooRest" />
   </wjc>
 </target>

Author:
mh124079

Nested Class Summary
 class WJCTask.ClassNameMapper
           
 
Field Summary
 
Fields inherited from class org.apache.tools.ant.Task
description, location, taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
project
 
Constructor Summary
WJCTask()
          Default constructor for WJCTask
 
Method Summary
 void addConfiguredCustomizations(org.apache.tools.ant.types.FileSet fileset)
          Add a pre-configured FileSet for a produces child element.
 void addConfiguredDepends(org.apache.tools.ant.types.FileSet fileset)
          Add a pre-configured FileSet for a depends child element.
 void addConfiguredProduces(org.apache.tools.ant.types.FileSet fileset)
          Add a pre-configured FileSet for a produces child element.
 WJCTask.ClassNameMapper createCustomClassName()
          This option allows the caller to override the name of the class being generated for a particular root URI.
 void execute()
          Processes the previously set WADL file and generated code in the specified package and target directory.
 void init()
          Initializes the task ready to process a WADL file.
 void setAutoSchemaPackage(boolean auto)
          Controls whether packages for classes generated from schemas are automatic (true) or use the package specified for endpoint classes.
 void setDescription(URI desc)
          Sets the WADL file to be processed.
 void setGenerationStyle(String generationStyle)
          Set the generationStyle for the code, defaults to jersey1x.
 void setPackage(String pkg)
          Set the package in which generates code will be placed.
 void setTarget(File target)
          Set the directory in which generated code will be placed.
 
Methods inherited from class org.apache.tools.ant.Task
getDescription, getLocation, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, isInvalid, log, log, maybeConfigure, perform, reconfigure, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
getProject, setProject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WJCTask

public WJCTask()
Default constructor for WJCTask

Method Detail

createCustomClassName

public WJCTask.ClassNameMapper createCustomClassName()
This option allows the caller to override the name of the class being generated for a particular root URI.

Returns:
A new instance of the class mapper so that the Ant system can properly populate it.

setPackage

public void setPackage(String pkg)
Set the package in which generates code will be placed. Equivalent to the command line -p package option.

Parameters:
pkg - the package in which to generate code, e.g. 'org.example.test'.

setGenerationStyle

public void setGenerationStyle(String generationStyle)
Set the generationStyle for the code, defaults to jersey1x.


setAutoSchemaPackage

public void setAutoSchemaPackage(boolean auto)
Controls whether packages for classes generated from schemas are automatic (true) or use the package specified for endpoint classes. Equivalent to the command line -a option.

Parameters:
auto - whether package for schema classes should be autogenerated.

setDescription

public void setDescription(URI desc)
Sets the WADL file to be processed.

Parameters:
desc - the WADL file to be processed.

setTarget

public void setTarget(File target)
Set the directory in which generated code will be placed. Equivalent to the command line -o directory option.

Parameters:
target - the directory in which generated code will be written. E.g. if target is gen-src and package is org.example.test then generated code will be written to gen-src/org/example/test. target must exist, subdirectories will be created as required.

addConfiguredProduces

public void addConfiguredProduces(org.apache.tools.ant.types.FileSet fileset)
Add a pre-configured FileSet for a produces child element. The fileset defines a set of files produced by this task and is used in an up-to-date check when deciding if the WADL description should be compiled or not.

Parameters:
fileset - the pre-configured FileSet object

addConfiguredCustomizations

public void addConfiguredCustomizations(org.apache.tools.ant.types.FileSet fileset)
Add a pre-configured FileSet for a produces child element. The fileset defines a set of files produced by this task and is used in an up-to-date check when deciding if the WADL description should be compiled or not.

Parameters:
fileset - the pre-configured FileSet object

addConfiguredDepends

public void addConfiguredDepends(org.apache.tools.ant.types.FileSet fileset)
Add a pre-configured FileSet for a depends child element. The fileset defines a set of files used by this task and is used in an up-to-date check when deciding if the WADL description should be compiled or not. The description file is automatically included in the up-to-date check and doesn't need to be specified separately.

Parameters:
fileset - the pre-configured FileSet object

init

public void init()
          throws org.apache.tools.ant.BuildException
Initializes the task ready to process a WADL file.

Overrides:
init in class org.apache.tools.ant.Task
Throws:
org.apache.tools.ant.BuildException - if an error occurs during initialization.

execute

public void execute()
             throws org.apache.tools.ant.BuildException
Processes the previously set WADL file and generated code in the specified package and target directory.

Overrides:
execute in class org.apache.tools.ant.Task
Throws:
org.apache.tools.ant.BuildException - if processing of the WADL file fails.


Copyright © 2014. All Rights Reserved.