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 \ Resource | Object | Property | Collection | Action |
---|---|---|---|---|
GET | current state of all properties | n/a | current contents | n/a |
PUT | create | set | add to | n/a |
DELETE | remove | clear | remove from | n/a |
POST | n/a | n/a | n/a | invoke |
Restul Objects exposes a URL for each of the columns. So, for example:
a Customer
instance id=12345 might be
exposed as http://localhost:8080/object/CUS|12345
, where
"CUS|12345" is the (string representation of) the internal Naked
Objects object identifier (or Oid) that uniquely
identifies the domain object. Performing a GET on
this would list all of the properties of the
Customer
.
the orders
collection for this same
Customer
would be exposed as
http://localhost:8080/object/CUS|12345/collection/orders
.
Performing a GET on this would list (links to)
the contents of the collection.
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.