You can use a plain Restlet for this.

public void handle(Request req, Response res) {
    computeTargetFromRequest(req).handle(req, res);
}

Restlet computeTargetFromRequest(Request req) {
    if (req.hasSomeCondition) {
        return someRestlet;
    } else {
        return someOtherRestlet;
    }
}

Note that a Router is a specialized application of this approach.

Or consider using a Redirector with MODE_SERVER_OUTBOUND and the internal
router. This has the advantage of allowing you to expose someRestlet and
someOtherRestlet as independent routable targets.

--tim


On Tue, Jul 5, 2011 at 11:56 AM, Martin Svensson <[email protected]> wrote:

> If I want to change the next restlet in a filter given some condition of
> the request, e.e.
>
> beforeHandle(Request req, Response res){
>  if(req hasSomeCondition)
>    setNext(someRestlet)
>  else
>    setNext(someOtherRestlet)
> }
>
> that would not work right because handle in Filter is not synchronized.
> What would be the best way to do something achieve that kind of behaviour?
>
> thanks,
> martin
>
> ------------------------------------------------------
>
> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2785006
>

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2785008

Reply via email to