Package org.restlet.ext.wadl
Class WadlApplication
- java.lang.Object
-
- org.restlet.Restlet
-
- org.restlet.Application
-
- org.restlet.ext.wadl.WadlApplication
-
- All Implemented Interfaces:
Uniform
@Deprecated public class WadlApplication extends Application
Deprecated.Will be removed in next major release.WADL enabled application. ThisApplicationsubclass can describe itself in WADL by introspecting its content, supporting the standard WADL/XML format or a WADL/HTML one based on a built-in XSLT transformation. 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 attachedServerResourceclasses and callsRestlet.getName()to get the title andRestlet.getDescription()the textual content of the WADL document generated. This default behavior can be customized by overriding thegetApplicationInfo(Request, Response)method.
In case you want to customize the XSLT stylesheet, you can override thecreateWadlRepresentation(ApplicationInfo)method and return an instance of anWadlRepresentationsubclass overriding theWadlRepresentation.getHtmlRepresentation()method.
In addition, this class can create an instance and configure it with an user-provided WADL/XML document. In this case, it creates a rootRouterand for each resource found in the WADL document, it tries to attach aServerResourceclass to the router using its WADL path. For this, it looks up the qualified name of theServerResourcesubclass using the WADL's "id" attribute of the "resource" elements. This is the only Restlet specific convention on the original WADL document.
To attach an application configured in this way to an existing component, you can call theattachToComponent(Component)or theattachToHost(VirtualHost)methods. In this case, it uses the "base" attribute of the WADL "resources" element as the URI attachment path to the virtual host.
For the HTML description to work properly, you will certainly have to update your classpath with a recent version of Apache Xalan XSLT engine (version 2.7.1 has been successfully tested). This is due to the XSLT stylesheet bundled which relies on EXSLT features.
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.
-
-
Field Summary
Fields Modifier and Type Field Description private booleanautoDescribingDeprecated.Indicates if the application should be automatically described via WADL when an OPTIONS request handles a "*" target URI.private ReferencebaseRefDeprecated.The WADL base reference.private RouterrouterDeprecated.The router toServerResourceclasses.
-
Constructor Summary
Constructors Constructor Description WadlApplication()Deprecated.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)Deprecated.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)Deprecated.Creates an application described using a WADL document.WadlApplication(Representation wadl)Deprecated.Creates an application described using a WADL document.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description private voidaddConnectors(Component component)Deprecated.Adds the necessary server connectors to the component.private voidattachResource(ResourceInfo currentResource, ResourceInfo parentResource, Router router)Deprecated.Attaches a resource, as specified in a WADL document, to a specified router, then recursively attaches its child resources.VirtualHostattachToComponent(Component component)Deprecated.Attaches the application to the given component if the application has a WADL base reference.voidattachToHost(VirtualHost host)Deprecated.Attaches the application to the given host using the WADL base reference.protected booleancanDescribe(java.lang.String remainingPart, Request request, Response response)Deprecated.Indicates if the application and all its resources can be described using WADL.protected FindercreateFinder(Router router, java.lang.String uriPattern, ResourceInfo resourceInfo)Deprecated.Creates a finder for the given resource info.protected RepresentationcreateHtmlRepresentation(ApplicationInfo applicationInfo)Deprecated.Creates a new HTML representation for a givenApplicationInfoinstance describing an application.protected RepresentationcreateWadlRepresentation(ApplicationInfo applicationInfo)Deprecated.Creates a new WADL representation for a givenApplicationInfoinstance describing an application.protected ApplicationInfogetApplicationInfo(Request request, Response response)Deprecated.Returns a WADL description of the current application.ReferencegetBaseRef()Deprecated.Returns the WADL base reference.private RoutergetNextRouter(Restlet current)Deprecated.Returns the next router available.protected VariantgetPreferredWadlVariant(Request request)Deprecated.Returns the preferred WADL variant according to the client preferences specified in the request.private ResourceInfogetResourceInfo(ApplicationInfo applicationInfo, Finder finder, java.lang.String path, Request request, Response response)Deprecated.Completes the data available about a given Finder instance.private ResourceInfogetResourceInfo(ApplicationInfo applicationInfo, Restlet restlet, java.lang.String path, Request request, Response response)Deprecated.Completes the data available about a given Restlet instance.private ResourceInfogetResourceInfo(ApplicationInfo applicationInfo, Filter filter, java.lang.String path, Request request, Response response)Deprecated.Completes the data available about a given Filter instance.private ResourceInfogetResourceInfo(ApplicationInfo applicationInfo, Route route, java.lang.String basePath, Request request, Response response)Deprecated.Returns the WADL data about the given Route instance.private java.util.List<ResourceInfo>getResourceInfos(ApplicationInfo applicationInfo, Router router, Request request, Response response)Deprecated.Completes the list of ResourceInfo instances for the given Router instance.RoutergetRouter()Deprecated.Returns the router where theServerResourceclasses created from the WADL description document are attached.private VirtualHostgetVirtualHost(Component component)Deprecated.Returns the virtual host matching the WADL application's base reference.protected java.util.List<Variant>getWadlVariants()Deprecated.Returns the available WADL variants.voidhandle(Request request, Response response)Deprecated.Handles the requests normally in all cases then handles the special case of the OPTIONS requests that exactly target the application.booleanisAutoDescribing()Deprecated.Indicates if the application should be automatically described via WADL when an OPTIONS request handles a "*" target URI.voidsetAutoDescribing(boolean autoDescribed)Deprecated.Indicates if the application should be automatically described via WADL when an OPTIONS request handles a "*" target URI.voidsetBaseRef(Reference baseRef)Deprecated.Sets the WADL base reference.protected RepresentationwadlRepresent(Variant variant, Request request, Response response)Deprecated.Represents the resource as a WADL description for the given variant.protected RepresentationwadlRepresent(Request request, Response response)Deprecated.Represents the resource as a WADL description.-
Methods inherited from class org.restlet.Application
createInboundRoot, createOutboundRoot, getConnectorService, getConnegService, getConverterService, getCurrent, getDecoderService, getEncoderService, getInboundRoot, getMetadataService, getOutboundRoot, getRangeService, getRole, getRoles, getServices, getStatusService, getTaskService, getTunnelService, isDebugging, setConnectorService, setConnegService, setContext, setConverterService, setCurrent, setDebugging, setDecoderService, setEncoderService, setInboundRoot, setInboundRoot, setMetadataService, setOutboundRoot, setOutboundRoot, setRangeService, setRoles, setStatusService, setTaskService, setTunnelService, start, stop
-
Methods inherited from class org.restlet.Restlet
createFinder, finalize, getApplication, getAuthor, getContext, getDescription, getFinderClass, getLogger, getName, getOwner, handle, handle, handle, isStarted, isStopped, setAuthor, setDescription, setFinderClass, setName, setOwner
-
-
-
-
Field Detail
-
autoDescribing
private volatile boolean autoDescribing
Deprecated.Indicates if the application should be automatically described via WADL when an OPTIONS request handles a "*" target URI.
-
baseRef
private volatile Reference baseRef
Deprecated.The WADL base reference.
-
router
private volatile Router router
Deprecated.The router toServerResourceclasses.
-
-
Constructor Detail
-
WadlApplication
public WadlApplication()
Deprecated.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
public WadlApplication(Context context)
Deprecated.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.- Parameters:
context- The context to use based on parent component context. This context should be created using theContext.createChildContext()method to ensure a proper isolation with the other applications.
-
WadlApplication
public WadlApplication(Context context, Representation wadl)
Deprecated.Creates an application described using a WADL document. Creates a router where Resource classes are attached and set it as the root Restlet. By default the application is not automatically described. If you want to, you can callsetAutoDescribing(boolean).- Parameters:
context- The context to use based on parent component context. This context should be created using theContext.createChildContext()method to ensure a proper isolation with the other applications.wadl- The WADL description document.
-
WadlApplication
public WadlApplication(Representation wadl)
Deprecated.Creates an application described using a WADL document. Creates a router where Resource classes are attached and set it as the root Restlet. By default the application is not automatically described. If you want to, you can callsetAutoDescribing(boolean).- Parameters:
wadl- The WADL description document.
-
-
Method Detail
-
addConnectors
private void addConnectors(Component component)
Deprecated.Adds the necessary server connectors to the component.- Parameters:
component- The parent component to update.
-
attachResource
private void attachResource(ResourceInfo currentResource, ResourceInfo parentResource, Router router) throws java.lang.ClassNotFoundException
Deprecated.Attaches a resource, as specified in a WADL document, to a specified router, then recursively attaches its child resources.- Parameters:
currentResource- The resource to attach.parentResource- The parent resource. Needed to correctly resolve the "path" of the resource. Should be null if the resource is root-level.router- The router to which to attach the resource and its children.- Throws:
java.lang.ClassNotFoundException- If the class name specified in the "id" attribute of the resource does not exist, this exception will be thrown.
-
attachToComponent
public VirtualHost attachToComponent(Component component)
Deprecated.Attaches the application to the given component if the application has a WADL base reference. The application will be attached to an existing virtual host if possible, otherwise a new one will be created.- Parameters:
component- The parent component to update.- Returns:
- The parent virtual host.
-
attachToHost
public void attachToHost(VirtualHost host)
Deprecated.Attaches the application to the given host using the WADL base reference.- Parameters:
host- The virtual host to attach to.
-
canDescribe
protected boolean canDescribe(java.lang.String remainingPart, Request request, Response response)Deprecated.Indicates if the application and all its resources can be described using WADL.- Parameters:
remainingPart- The URI remaining part.request- The request to handle.response- The response to update.
-
createFinder
protected Finder createFinder(Router router, java.lang.String uriPattern, ResourceInfo resourceInfo) throws java.lang.ClassNotFoundException
Deprecated.Creates a finder for the given resource info. By default, it looks up for an "id" attribute containing a fully qualified class name.- Parameters:
router- The parent router.resourceInfo- The WADL resource descriptor.- Returns:
- The created finder.
- Throws:
java.lang.ClassNotFoundException
-
createHtmlRepresentation
protected Representation createHtmlRepresentation(ApplicationInfo applicationInfo)
Deprecated.Creates a new HTML representation for a givenApplicationInfoinstance describing an application.- Parameters:
applicationInfo- The application description.- Returns:
- The created
WadlRepresentation.
-
createWadlRepresentation
protected Representation createWadlRepresentation(ApplicationInfo applicationInfo)
Deprecated.Creates a new WADL representation for a givenApplicationInfoinstance describing an application.- Parameters:
applicationInfo- The application description.- Returns:
- The created
WadlRepresentation.
-
getApplicationInfo
protected ApplicationInfo getApplicationInfo(Request request, Response response)
Deprecated.Returns a WADL description of the current application. By default, this method discovers all the resources attached to this application. It can be overridden to add documentation, list of representations, etc.- Parameters:
request- The current request.response- The current response.- Returns:
- An application description.
-
getBaseRef
public Reference getBaseRef()
Deprecated.Returns the WADL base reference.- Returns:
- The WADL base reference.
-
getNextRouter
private Router getNextRouter(Restlet current)
Deprecated.Returns the next router available.- Parameters:
current- The current Restlet to inspect.- Returns:
- The first router available.
-
getPreferredWadlVariant
protected Variant getPreferredWadlVariant(Request request)
Deprecated.Returns the preferred WADL variant according to the client preferences specified in the request.- Parameters:
request- The request including client preferences.- Returns:
- The preferred WADL variant.
-
getResourceInfo
private ResourceInfo getResourceInfo(ApplicationInfo applicationInfo, Filter filter, java.lang.String path, Request request, Response response)
Deprecated.Completes the data available about a given Filter instance.- Parameters:
applicationInfo- The parent application.filter- The Filter instance to document.path- The base path.request- The current request.response- The current response.- Returns:
- The resource description.
-
getResourceInfo
private ResourceInfo getResourceInfo(ApplicationInfo applicationInfo, Finder finder, java.lang.String path, Request request, Response response)
Deprecated.Completes the data available about a given Finder instance.- Parameters:
applicationInfo- The parent application.resourceInfo- The ResourceInfo object to complete.finder- The Finder instance to document.request- The current request.response- The current response.
-
getResourceInfo
private ResourceInfo getResourceInfo(ApplicationInfo applicationInfo, Restlet restlet, java.lang.String path, Request request, Response response)
Deprecated.Completes the data available about a given Restlet instance.- Parameters:
applicationInfo- The parent application.resourceInfo- The ResourceInfo object to complete.restlet- The Restlet instance to document.request- The current request.response- The current response.
-
getResourceInfo
private ResourceInfo getResourceInfo(ApplicationInfo applicationInfo, Route route, java.lang.String basePath, Request request, Response response)
Deprecated.Returns the WADL data about the given Route instance.- Parameters:
applicationInfo- The parent application.route- The Route instance to document.basePath- The base path.request- The current request.response- The current response.- Returns:
- The WADL data about the given Route instance.
-
getResourceInfos
private java.util.List<ResourceInfo> getResourceInfos(ApplicationInfo applicationInfo, Router router, Request request, Response response)
Deprecated.Completes the list of ResourceInfo instances for the given Router instance.- Parameters:
applicationInfo- The parent application.router- The router to document.request- The current request.response- The current response.- Returns:
- The list of ResourceInfo instances to complete.
-
getRouter
public Router getRouter()
Deprecated.Returns the router where theServerResourceclasses created from the WADL description document are attached.- Returns:
- The root router.
-
getVirtualHost
private VirtualHost getVirtualHost(Component component)
Deprecated.Returns the virtual host matching the WADL application's base reference. Creates a new one and attaches it to the component if necessary.- Parameters:
component- The parent component.- Returns:
- The related virtual host.
-
getWadlVariants
protected java.util.List<Variant> getWadlVariants()
Deprecated.Returns the available WADL variants.- Returns:
- The available WADL variants.
-
handle
public void handle(Request request, Response response)
Deprecated.Handles the requests normally in all cases then handles the special case of the OPTIONS requests that exactly target the application. In this case, the application is automatically introspected and described as a WADL representation based on the result of thegetApplicationInfo(Request, Response)method.
The automatic introspection happens only if the request hasn't already been successfully handled. That is to say, it lets users provide their own handling of OPTIONS requests.- Specified by:
handlein interfaceUniform- Overrides:
handlein classApplication- Parameters:
request- The request to handle.response- The response to update.
-
isAutoDescribing
public boolean isAutoDescribing()
Deprecated.Indicates if the application should be automatically described via WADL when an OPTIONS request handles a "*" target URI.- Returns:
- True if the application should be automatically described via WADL.
-
setAutoDescribing
public void setAutoDescribing(boolean autoDescribed)
Deprecated.Indicates if the application should be automatically described via WADL when an OPTIONS request handles a "*" target URI.- Parameters:
autoDescribed- True if the application should be automatically described via WADL.
-
setBaseRef
public void setBaseRef(Reference baseRef)
Deprecated.Sets the WADL base reference.- Parameters:
baseRef- The WADL base reference.
-
wadlRepresent
protected Representation wadlRepresent(Request request, Response response)
Deprecated.Represents the resource as a WADL description.- Parameters:
request- The current request.response- The current response.- Returns:
- The WADL description.
-
wadlRepresent
protected Representation wadlRepresent(Variant variant, Request request, Response response)
Deprecated.Represents the resource as a WADL description for the given variant.- Parameters:
variant- The WADL variant.request- The current request.response- The current response.- Returns:
- The WADL description.
-
-