Hi Sean,

First, I apologize for the confusion with the recent changes. They were not
intended to come in so late in the RC process but became very obvious to me
while working on some concrete examples recently. 

FYI, the upcoming RC3 to be released today or tomorrow will contain all the
planned features and changes, including a more complete tutorial. This
should be the last RC release unless some major bugs appear. The final 1.0
release should follow after that, at the end of January or beginning of
February.

I'm not sure which version you were previously using but the recent changes
should really simplify your code instead or increasing the complexity as you
feel right now. To summarize:

 - In 1.0 RC2, we have the Router class which routes calls to attached
Restlets using intermediary Filters called Routes. In general you don't care
to much about the Route class because the Router.attach() method creates
them transparently. Then, you would often attach a subclass of Handler to
the Router that would do three actions:
        * find the target resource (via the abstract findTarget() method).
        * dispatch the request from the handle(Request, Response) method to
one of the handleGet() or handlePut() or handlePost() etc. method in your
Handler subclass.
        * the selected handle*() method would then do some preprocessing and
invoke the methods on the target Resource instance found via the
findTarget() method. The methods invoked are getVariants(),
getRepresentation(), post(), put(), etc.

As a result, you had to create a Handler subclass for each one of your
Resource class, just to provide the findTarget() method implementation. I'm
not sure why you had to override the handlePost() method too as this logic
should probably go in the post(Representation) method instead.

 - In 1.0 RC3, we have replaced the Handler class by a trimmed down Finder
class. You can now directly pass the Resource subclass to the Router's
attach method which transparently creates a new Route and a new Finder. At
call time it will do this:
        * find the target resource via the concrete findTarget() method. By
default it automatically creates a new instance of the Resource subclass you
passed as a parameter to the constructor. The Resource constructor must have
three parameters: context, request, response like the super Resource class.
        * dispatch the request from the handle(Request, Response) method to
one of the handleGet() or handlePut() or handlePost() etc. method in your
target Resource subclass instance returned by the previous findTarget()
method. Note that the dispatching doesn't result in a method call on Finder
but directly on Resource.
        * the selected handle*() method on the target Resource would then do
some preprocessing and invoke the methods getVariants(),
getRepresentation(), post(), put(), etc. depending on the needs. 

The advantages is that you just need to create one subclass instead of two
and that your Resource has full access and control on the context, request
and response while processing the call which was not the case before. It is
important to realize that the Router, Route and Finder instances are
shared/mutli-threaded between calls while the Resource subclass instance is
dedicated for one and only one call. Therefore it can be more stateful,
freely add member variables and initialize them at construction time. It
also has useful "request", "response", "context", "logger" property
automatically set.

I've attached some diagrams that should help you understand the changes.

Best regards,
Jerome  

> -----Message d'origine-----
> De : news [mailto:[EMAIL PROTECTED] De la part de Sean Landis
> Envoyé : jeudi 18 janvier 2007 00:33
> À : discuss@restlet.tigris.org
> Objet : Struggling with recent changes
> 
> I seem to have missed something fundamental regarding the 
> recent changes. It 
> now appears one must create a Resource to handle the 
> dispatching of post, etc.
> 
> We have several web services that previously dispatched to a 
> Handler that 
> implemented handlePost. I am unclear what to do with this 
> Resource requirement.
> 
> It seems, at least for us, the complexity of using Restlet 
> has increased 
> dramatically. Please tell me I'm missing something.
> 
> Sean

Attachment: component.gif
Description: GIF image

Attachment: restlets.gif
Description: GIF image

Reply via email to