|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.restlet.Uniform
org.restlet.Restlet
org.restlet.Application
org.restlet.ext.wadl.WadlApplication
public class WadlApplication
WADL configured application. Can automatically configure itself given a WADL
description document.
It creates a root router and for each resource found in the WADL document, it
tries to attach a Restlet Resource class to the router using its WADL path.
It looks up the qualified name of the Resource class using the WADL "id"
attribute of the "resource" elements. This is the only Restlet specific
constraint on the WADL document.
Also, it has an attachToComponent(Component)
to attach the
application to an existing component and a attachToHost(VirtualHost)
to attach it to an existing virtual host using the "base" attribute of the
WADL "resources" element.
Such application is also able to generate a description of itself under two
formats: WADL or HTML (the latter is actually a transformation of the
former). You can obtain this representation with an OPTIONS request addressed
exactly to the application URI (e.g. "http://host:port/path/to/application").
By default, the returned representation gleans the list of all attached
Resources. This default behaviour can be customized by overriding the
getApplicationInfo() method.
Concurrency note: instances of this class or its subclasses can be invoked by
several threads at the same time and therefore must be thread-safe. You
should be especially careful when storing state in member variables.
Constructor Summary | |
---|---|
WadlApplication()
Creates an application that can automatically introspect and expose itself as with a WADL description upon reception of an OPTIONS request on the "*" target URI. |
|
WadlApplication(Context context)
Creates an application that can automatically introspect and expose itself as with a WADL description upon reception of an OPTIONS request on the "*" target URI. |
|
WadlApplication(Context context,
Representation wadl)
Creates an application described using a WADL document. |
|
WadlApplication(Representation wadl)
Creates an application described using a WADL document. |
Method Summary | |
---|---|
VirtualHost |
attachToComponent(Component component)
Attaches the application to the given component if the application has a WADL base reference. |
void |
attachToHost(VirtualHost host)
Attaches the application to the given host using the WADL base reference. |
ApplicationInfo |
getApplicationInfo(Request request,
Response response)
Returns a WADL description of the current application. |
Reference |
getBaseRef()
Returns the WADL base reference. |
protected Variant |
getPreferredWadlVariant(ClientInfo clientInfo)
Returns the preferred WADL variant according to the client preferences specified in the request. |
Router |
getRouter()
Returns the router where the Resources created from the WADL description document are attached. |
java.lang.String |
getTitle()
Returns the title of this documented application. |
protected java.util.List<Variant> |
getWadlVariants()
Returns the available WADL variants. |
void |
handle(Request request,
Response response)
Handles the requests normally in all cases then handles the special case of the OPTIONS requests that exactly target the application. |
boolean |
isAutoDescribed()
Indicates if the application should be automatically described via WADL when an OPTIONS request handles a "*" target URI. |
void |
setAutoDescribed(boolean autoDescribed)
Indicates if the application should be automatically described via WADL when an OPTIONS request handles a "*" target URI. |
void |
setBaseRef(Reference baseRef)
Sets the WADL base reference. |
void |
setTitle(java.lang.String title)
Sets the title of this documented application. |
protected Representation |
wadlRepresent(Request request,
Response response)
Represents the resource as a WADL description. |
Representation |
wadlRepresent(Variant variant,
Request request,
Response response)
Represents the resource as a WADL description for the given variant. |
Methods inherited from class org.restlet.Application |
---|
createRoot, getAuthor, getConnectorService, getConverterService, getCurrent, getDecoderService, getDescription, getMetadataService, getName, getOwner, getRangeService, getRoot, getStatusService, getTaskService, getTunnelService, setAuthor, setConnectorService, setConverterService, setCurrent, setDecoderService, setDescription, setMetadataService, setName, setOwner, setRangeService, setRoot, setStatusService, setTaskService, setTunnelService, start, stop |
Methods inherited from class org.restlet.Restlet |
---|
getApplication, getContext, getLogger, init, isStarted, isStopped, setContext |
Methods inherited from class org.restlet.Uniform |
---|
delete, delete, get, get, handle, head, head, options, options, post, post, put, put |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public WadlApplication()
public WadlApplication(Context context)
context
- The context to use based on parent component context. This
context should be created using the
Context.createChildContext()
method to ensure a proper
isolation with the other applications.public WadlApplication(Context context, Representation wadl)
setAutoDescribed(boolean)
.
context
- The context to use based on parent component context. This
context should be created using the
Context.createChildContext()
method to ensure a proper
isolation with the other applications.wadl
- The WADL description document.public WadlApplication(Representation wadl)
setAutoDescribed(boolean)
.
wadl
- The WADL description document.Method Detail |
---|
public VirtualHost attachToComponent(Component component)
component
- The parent component to update.
public void attachToHost(VirtualHost host)
host
- The virtual host to attach to.public ApplicationInfo getApplicationInfo(Request request, Response response)
request
- The current request.response
- The current response.
public Reference getBaseRef()
protected Variant getPreferredWadlVariant(ClientInfo clientInfo)
clientInfo
- The client preferences and info.
public Router getRouter()
public java.lang.String getTitle()
protected java.util.List<Variant> getWadlVariants()
public void handle(Request request, Response response)
getApplicationInfo(Request, Response)
method.
handle
in class Application
request
- The request to handle.response
- The response to update.public boolean isAutoDescribed()
public void setAutoDescribed(boolean autoDescribed)
autoDescribed
- True if the application should be automatically described via
WADL.public void setBaseRef(Reference baseRef)
baseRef
- The WADL base reference.public void setTitle(java.lang.String title)
title
- The title of this documented application.protected Representation wadlRepresent(Request request, Response response)
request
- The current request.response
- The current response.
public Representation wadlRepresent(Variant variant, Request request, Response response)
variant
- The WADL variant.request
- The current request.response
- The current response.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |