The /services link indicated in Section 3.1, “HomePageResource” corresponds to the
ServicesResource
:
import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; public interface ServicesResource { @GET @Produces( {"application/xhtml+xml", "text/html"} ) @Path("/") public String services(); }
The implementation of this interface in Restful
Objects viewer (ServicesResourceImpl
)
also defines a @Path("/services")
for the class as a whole.
This therefore defines a URL in the form
/services supporting the GET
method.
I believe that the @Path("/services")
annotation
should reside on the interface, not the implementation. This seems to
be a limitation with RestEasy, the underlying library used by
Restful Objects. Certainly for RestEasy 1.0.2 and
also 1.1-rc2 this did not work, however.
Here's the resource that's returned, as shown in a browser:
The first two sections are the same; what's new is the
list of services, corresponding to the registered services in
nakedobjects.properties
. The
XHTML for this is:
<?xml version="1.0"?> <html> <head><title>Services</title></head> <body id="body"> ... <div class="nof-section"> <p class="nof-section">Services</p> <ul class="nof-services"> <li> <a href="/object/OID:1" rel="service" rev="services" class="nof-service"> Employees </a> </li> <li> <a href="/object/OID:2" rel="service" rev="services" class="nof-service"> Claims </a> </li> </ul> </div> </body> </html>
Again, we can use XPath to pull back the resources:
//a[@class='nof-service']/@href will return the hyperlinks to the object resources representing these services, in the form /object/OID.
And let's look at object resources next.