1.2. Introducing Restful Objects

As already stated, Restful Objects is a Naked Objects viewer implementation to expose a domain model using REST. That is, the resources are the actual domain objects, or - in some cases - a class member of one of those objects. The following table shows the resources exposed:

Table 1.1. Verbs by Resources

Verb \ ResourceObjectPropertyCollectionAction
GETcurrent state of all propertiesn/acurrent contentsn/a
PUTcreatesetadd ton/a
DELETEremoveclearremove fromn/a
POSTn/an/an/ainvoke

Restul Objects exposes a URL for each of the columns. So, for example:

So much for interacting with the resources, but what of their representation? Well, (following the suggestion in Richardson & Ruby's book) Restful Objects renders the domain objects using XHTML. This gives us a natural way to express links between resources: we just use hyperlinks using the <a href="..."/> tag. It also means that we can inspect the domain objects from an web browser. For example, here's Firefox displaying the resource representing an EmployeeRepository (part of of the example claims application that is in the Naked Objects Maven download):

In fact, Restful Objects also serves up a smidgeon of Javascript as well, to allow the web browser to perform PUT and DELETE as well as the usual GET and POST. This won't be needed by your own custom written web apps, of course. (It also won't be needed once XHTML 5 - with its support for these additional HTTP verbs - becomes mainstream).

Restful Objects itself is implemented using JBoss RestEasy.