tags:

views:

196

answers:

1

I've gone through the firstResource bit of the Restlet 1.1 tutorial and put together a web service that handles GET, POST, DELETE, PUT by subclassing the Resource class and overriding the appropriate methods and using a Router to attach the subclassed Resource classes.

So I'm left thinking - what's the point of a Restlet?

  • I can attach a Resource or a Restlet to an Application Router

  • A Resource has methods to handle HTTP GET POST etc.

  • A Restlet has a handle method - do I somehow forward that on to a Resource class?

What's the difference? When do I use one or the other? What would I put in a Restlet handle method?

Thanks.

+3  A: 

Restlet is the base class for various restlet server facilities, among them Application and Router. When its handle() method is called it's supposed to interpret the request, dispatch it to a suitable child restlet or query the matching resource (the GET/POST/... handle methods), and put the result back in the response.

So, restlets and resources are nodes of a tree. Resources are the leafs of that tree.

Restlets usually don't answer to request but delegate them down the tree. Resources actually reply.

In general, you will program only custom resources and use pre-defined restlets.

Wolfgang