Hi Yuri,

> Hi Jerome, I guess now you have the start of the RC3 tutorial 
> on resources...
> ;-) thanks it was very useful. 

Indeed! Actually this list is also a great starting point when I 
want to extend the FAQ pages.

> In the same way that the Restlet framework provides a design 
> supporting
> URI->Resource "mapping", would it also make sense to provide 
> a design for
> generating a resource URI, i.e. a Resource->URI mapping?

Another common need is to dynamically insert URIs into a result
representation.

> There are situations where one wants to redirect to a single 
> resource from more
> than one place and it would be very nice to define the 
> Resource->URI mapping
> declaratively and simply redirect to this Resource instance. 
> The resource 
> redirection would generate the URI automatically under the covers.

I have already thought about this but the biggest problem is that 
this mapping isn't 1-1 as the same resource (class) can be mapped 
from several URIs.

> Maybe a combination of a URI template and an abstract 
> Resource API allowing it
> to expose any number of key/values used to generate a final URI?

First, there is always the Template class available. It can be 
manually instantiated with a URI template and called by a model or
a request/response pair to generate a URI.

Also, with the latest changes, the Resource class expects three 
parameters at construction time: a Context, a Request and a Response. 
They become properties on the instance that could be leveraged to 
support a "generateUri(String uriTemplate)" method. I have just added
this method as well as a new variable for the Request.rootRef property 
in the list of predefined variables on Template. 

As a result you will be able to write:

    myRes.generateRef("{o}/bean/{beanId}");

Note the {o} variable to insert the root reference. The list of variables 
is available (minus the new "o" one of course) at:
http://www.restlet.org/docs/api/org/restlet/util/Template.html

Best,
Jerome

Reply via email to