Chapter 2. Using Restful Objects in Prototypes

Table of Contents

2.1. Parent Module
2.2. CommandLine Module
2.3. Launch Configuration
2.4. Testing the Viewer

Exposing a RESTful domain model with Restful Objects is really pretty straightforward; we just need to boot Naked Objects to use the Restful Objects' viewer rather than the DnD viewer or HTML viewer that comes out-of-the-box. That means adding references to the POM, and the running with the appropriate command line flags.

If you ran the Naked Objects archetype then you'll have a Maven parent module with a number of child modules:

xxx/pom.xml
    xxx-dom/pom.xml          # domain object model
    xxx-fixture/pom.xml      # fixtures for seeding object store
    xxx-service/pom.xml      # in-memory object store implementations of repositories
    xxx-commandline/pom.xml  # for deploying as a commandline, also for prototyping
    xxx-webapp/pom.xml       # for deploying as a webapp

The instructions here assume this directory structure.

2.1. Parent Module

In the parent module, first add in a <properties> section to specify the version of Restful Objects. This will transitively bring in any dependencies:

<properties>
  <restfulobjects.version>1.0.0</restfulobjects.version>             <!-- or whatever -->
</properties>

Then, add in references to the Restful Objects' applib and viewer modules to the <dependencyManagement>:

<dependencyManagement>
  <dependencies>
    ...
    <dependency>
      <groupId>org.starobjects.restful</groupId>
      <artifactId>applib</artifactId>
      <version>${restfulobjects.version}</version>
    </dependency>
    <dependency>
      <groupId>org.starobjects.restful</groupId>
      <artifactId>viewer</artifactId>
      <version>${restfulobjects.version}</version>
    </dependency>
    ...
  </dependencies>
</dependencyManagement>

Note that an alternate approach for setting up dependencies is to have the parent module inherit from org.starobjects.restful:release. Doing it this way means that it isn't necessary to add entries to <dependencyManagement> because they are inherited. However, Maven2 does only allow a single parent, so this may not be an option for you if you want to use some other POM as your parent.