org.restlet.ext.wadl
Class WadlResource

java.lang.Object
  extended by org.restlet.Handler
      extended by org.restlet.resource.Resource
          extended by org.restlet.ext.wadl.WadlResource

public class WadlResource
extends Resource

Resource that is able to automatically describe itself with WADL. This description can be customized by overriding the describe() and describeMethod(Method, MethodInfo) methods. When used to describe a class of resources in the context of a parent application, a special instance will be created using the default constructor (with no request, response associated). In this case, the resource should do its best to return the generic information when the WADL description methods are invoked, like describe() and delegate methods.

Author:
Jerome Louvel

Constructor Summary
WadlResource()
          Constructor.
WadlResource(Context context, Request request, Response response)
          Constructor.
 
Method Summary
 boolean allowOptions()
          Indicates if OPTIONS calls are allowed by checking the "readable" property.
protected  Representation describe()
          Describes the resource as a WADL document.
 void describe(java.lang.String path, ResourceInfo info)
          Returns a WADL description of the current resource.
protected  Representation describe(Variant variant)
          Describes the resource as a WADL document for the given variant.
protected  void describeDelete(MethodInfo info)
          Describes the DELETE method.
protected  void describeGet(MethodInfo info)
          Describes the GET method.
By default, it describes the response with the available variants based on the Resource.getVariants() method.
protected  void describeMethod(Method method, MethodInfo info)
          Returns a WADL description of the given method.
protected  void describeOptions(MethodInfo info)
          Describes the OPTIONS method.
By default it describes the response with the available variants based on the getWadlVariants() method.
protected  void describePost(MethodInfo info)
          Describes the POST method.
protected  void describePut(MethodInfo info)
          Describes the PUT method.
protected  java.util.List<ParameterInfo> getParametersInfo()
          Returns the description of the parameters of this resource.
protected  Variant getPreferredWadlVariant()
          Returns the preferred WADL variant according to the client preferences specified in the request.
protected  java.lang.String getResourcePath()
          Returns the resource's relative path.
protected  Reference getResourcesBase()
          Returns the application resources base URI.
 java.lang.String getTitle()
          Returns the title of this documented resource.
protected  java.util.List<Variant> getWadlVariants()
          Returns the available WADL variants.
 void handleOptions()
           
 boolean isAutoDescribed()
          Indicates if the resource should be automatically described via WADL when an OPTIONS request is handled.
 boolean isDescribable(Method method)
          Indicates if the given method exposes its WADL description.
 void setAutoDescribed(boolean autoDescribed)
          Indicates if the resource should be automatically described via WADL when an OPTIONS request is handled.
 void setTitle(java.lang.String title)
          Sets the title of this documented resource.
 
Methods inherited from class org.restlet.resource.Resource
acceptRepresentation, allowDelete, allowGet, allowPost, allowPut, delete, getPreferredRepresentation, getPreferredVariant, getRepresentation, getVariants, handleDelete, handleGet, handlePost, handlePut, init, isAvailable, isModifiable, isNegotiateContent, isReadable, post, put, removeRepresentations, represent, represent, setAvailable, setModifiable, setNegotiateContent, setReadable, setVariants, storeRepresentation
 
Methods inherited from class org.restlet.Handler
allowHead, generateRef, getAllowedMethods, getApplication, getContext, getLogger, getMatrix, getQuery, getRequest, getResponse, handleHead, setContext, setRequest, setResponse, updateAllowedMethods
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WadlResource

public WadlResource()
Constructor.


WadlResource

public WadlResource(Context context,
                    Request request,
                    Response response)
Constructor.

Parameters:
context - The parent context.
request - The request to handle.
response - The response to return.
Method Detail

allowOptions

public boolean allowOptions()
Indicates if OPTIONS calls are allowed by checking the "readable" property.

Overrides:
allowOptions in class Handler
Returns:
True if the method is allowed.

describe

protected Representation describe()
Describes the resource as a WADL document.

Returns:
The WADL description.

describe

public void describe(java.lang.String path,
                     ResourceInfo info)
Returns a WADL description of the current resource.

Parameters:
path - Path of the current resource.
info - WADL description of the current resource to update.

describe

protected Representation describe(Variant variant)
Describes the resource as a WADL document for the given variant.

Parameters:
variant - The WADL variant.
Returns:
The WADL description.

describeDelete

protected void describeDelete(MethodInfo info)
Describes the DELETE method.

Parameters:
info - The method description to update.

describeGet

protected void describeGet(MethodInfo info)
Describes the GET method.
By default, it describes the response with the available variants based on the Resource.getVariants() method. Thus in the majority of cases, the method of the super class must be called when overriden.

Parameters:
info - The method description to update.

describeMethod

protected void describeMethod(Method method,
                              MethodInfo info)
Returns a WADL description of the given method.

Parameters:
method - The method to describe.
info - The method description to update.

describeOptions

protected void describeOptions(MethodInfo info)
Describes the OPTIONS method.
By default it describes the response with the available variants based on the getWadlVariants() method.

Parameters:
info - The method description to update.

describePost

protected void describePost(MethodInfo info)
Describes the POST method.

Parameters:
info - The method description to update.

describePut

protected void describePut(MethodInfo info)
Describes the PUT method.

Parameters:
info - The method description to update.

getParametersInfo

protected java.util.List<ParameterInfo> getParametersInfo()
Returns the description of the parameters of this resource. Returns null by default.

Returns:
The description of the parameters.

getPreferredWadlVariant

protected Variant getPreferredWadlVariant()
Returns the preferred WADL variant according to the client preferences specified in the request.

Returns:
The preferred WADL variant.

getResourcePath

protected java.lang.String getResourcePath()
Returns the resource's relative path.

Returns:
The resource's relative path.

getResourcesBase

protected Reference getResourcesBase()
Returns the application resources base URI.

Returns:
The application resources base URI.

getTitle

public java.lang.String getTitle()
Returns the title of this documented resource.

Returns:
The title of this documented resource.

getWadlVariants

protected java.util.List<Variant> getWadlVariants()
Returns the available WADL variants.

Returns:
The available WADL variants.

handleOptions

public void handleOptions()
Overrides:
handleOptions in class Handler

isAutoDescribed

public boolean isAutoDescribed()
Indicates if the resource should be automatically described via WADL when an OPTIONS request is handled.

Returns:
True if the resource should be automatically described via WADL.

isDescribable

public boolean isDescribable(Method method)
Indicates if the given method exposes its WADL description. By default, HEAD and OPTIONS are not exposed. This method is called by describe(String, ResourceInfo).

Parameters:
method - The method
Returns:
True if the method exposes its description, false otherwise.

setAutoDescribed

public void setAutoDescribed(boolean autoDescribed)
Indicates if the resource should be automatically described via WADL when an OPTIONS request is handled.

Parameters:
autoDescribed - True if the resource should be automatically described via WADL.

setTitle

public void setTitle(java.lang.String title)
Sets the title of this documented resource.

Parameters:
title - The title of this documented resource.


Copyright © 2005-2008 Noelios Technologies.