org.jvnet.ws.wadl2java
Class Wadl2Java

java.lang.Object
  extended by org.jvnet.ws.wadl2java.Wadl2Java

public class Wadl2Java
extends Object

Processes a WADL file and generates client-side stubs for the resources and methods described.

Author:
mh124079

Nested Class Summary
static class Wadl2Java.Parameters
          A parameter object to make it easier to extend this class without having to add more constructors or parameters.
protected  class Wadl2Java.SchemaCompilerErrorListener
          Inner class implementing the JAXB ErrorListener interface to support error reporting from the JAXB infrastructure.
 
Field Summary
static QName JSON_SCHEMA_DESCRIBEDBY
           
static String STYLE_DEFAULT
           
static String STYLE_JAXRS20
           
static String STYLE_JERSEY1X
           
static Set<String> STYLE_SET
           
 
Constructor Summary
Wadl2Java(Wadl2Java.Parameters parameters)
          Creates a new instance of a Wadl2Java processor.
 
Method Summary
protected  void generateEndpointClass(URI rootResource, ResourceNode root)
          Create a class that acts as a container for a hierarchy of static inner classes, one for each resource described by the WADL file.
protected  void generateResourceTypeInterfaces()
          Generate Java interfaces for WADL resource types
protected  void generateSubClass(com.sun.codemodel.JDefinedClass parent, com.sun.codemodel.JVar $global_base_uri, ResourceNode resource)
          Creates an inner static class that represents a resource and its methods.
 void process(URI rootDesc)
          Process the root WADL file and generate code.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STYLE_JERSEY1X

public static final String STYLE_JERSEY1X
See Also:
Constant Field Values

STYLE_JAXRS20

public static final String STYLE_JAXRS20
See Also:
Constant Field Values

STYLE_DEFAULT

public static final String STYLE_DEFAULT
See Also:
Constant Field Values

STYLE_SET

public static final Set<String> STYLE_SET

JSON_SCHEMA_DESCRIBEDBY

public static final QName JSON_SCHEMA_DESCRIBEDBY
Constructor Detail

Wadl2Java

public Wadl2Java(Wadl2Java.Parameters parameters)
Creates a new instance of a Wadl2Java processor.

Method Detail

process

public void process(URI rootDesc)
             throws JAXBException,
                    IOException,
                    com.sun.codemodel.JClassAlreadyExistsException,
                    InvalidWADLException
Process the root WADL file and generate code.

Parameters:
rootDesc - the URI of the WADL file to process
Throws:
JAXBException - if the WADL file is invalid, a referenced WADL file is invalid, or if the code generator encounters a problem.
IOException - if the specified WADL file cannot be read.
com.sun.codemodel.JClassAlreadyExistsException - if, during code generation, the WADL processor attempts to create a duplicate class. This indicates a structural problem with the WADL file, e.g. duplicate peer resource entries.
InvalidWADLException - TODO.

generateResourceTypeInterfaces

protected void generateResourceTypeInterfaces()
                                       throws com.sun.codemodel.JClassAlreadyExistsException
Generate Java interfaces for WADL resource types

Throws:
com.sun.codemodel.JClassAlreadyExistsException - if the interface to be generated already exists

generateEndpointClass

protected void generateEndpointClass(URI rootResource,
                                     ResourceNode root)
                              throws com.sun.codemodel.JClassAlreadyExistsException
Create a class that acts as a container for a hierarchy of static inner classes, one for each resource described by the WADL file.

Parameters:
rootResource - the root URI to the WADL so we can generate the required annotations
root - the resource element that corresponds to the root of the resource tree
Throws:
com.sun.codemodel.JClassAlreadyExistsException - if, during code generation, the WADL processor attempts to create a duplicate class. This indicates a structural problem with the WADL file, e.g. duplicate peer resource entries.

generateSubClass

protected void generateSubClass(com.sun.codemodel.JDefinedClass parent,
                                com.sun.codemodel.JVar $global_base_uri,
                                ResourceNode resource)
                         throws com.sun.codemodel.JClassAlreadyExistsException
Creates an inner static class that represents a resource and its methods. Recurses the tree of child resources.

Parameters:
parent - the outer class for the static inner class being generated. This can either be a top level class or a nested static inner class for a parent resource.
resource - the WADL resource element being processed.
$base_uri - The root URI for this resource class
Throws:
com.sun.codemodel.JClassAlreadyExistsException - if, during code generation, the WADL processor attempts to create a duplicate class. This indicates a structural problem with the WADL file, e.g. duplicate peer resource entries.


Copyright © 2014. All Rights Reserved.