concept Restlet in category restlet

appears as: Restlet
Restlet in Action

This is an excerpt from Manning's book Restlet in Action.

The second method, overriding createInboundRoot(), is a factory method called by the framework when the application starts. It’s in charge of creating the inbound root Restlet (shown as a small circle in figure 2.3). For now, you attach a simple Restlet that returns a string formatted from the method name, the target resource URI, and information on the user agent. If you run this example and point your browser to http://localhost:8111/test/abcd, a result page like this will be displayed:

Figure 2.5. Class diagram of Application and its parent class, Restlet

Some of the properties and methods that we discuss, like the name and description properties and the start() method, come from the Restlet class and apply to other subclasses than Application.

Table 2.1 summarizes the properties inherited from Restlet.

Table 2.1. Properties of Restlet inherited by Application

Name

Description

author Developer who is the author of this Restlet subclass
description Description of the purpose of this Restlet subclass
name Displayable name for this Restlet subclass
owner Name of the organization owning the source code
application Parent application containing this Restlet instance (read-only)
context Execution context of this Restlet instance
logger Logger to which warning, info, or debug messages can be sent
started Indicates whether the Restlet instance was started (read-only)
stopped Indicates whether the Restlet instance was stopped (read-only)

The first four properties are optional, but it can be useful to set their values for debugging purposes and feedback in administration consoles. The other properties provide information on the execution environment of Restlet and its lifecycle. The following listing defines the constructor of the application by setting some common properties.

Note also that org.restlet.Restlet implements the org.restlet.Uniform interface, which defines the central method that must be implemented by all Restlet subclasses to handle inbound or outbound calls: handle (Request, Response).