On Sun, Apr 28, 2013 at 11:42 AM, Grant <gsing...@apache.org> wrote: > > I haven't dug into this code, but I suspect you aren't manipulating > > References properly. I advise printing out the intermediate steps of your > > Reference computation to see where it goes wrong. > > That's just it, I don't think it is even selecting my Redirector as the > target for the endpoint, b/c it is not even calling getTargetRef due to the > child endpoints. Is there something else on Redirector or in my attachment > I should be overriding so that it stops trying to match once it resolves > the parent? >
I don't know what you mean by "parent" or "child endpoints". If getTargetRef isn't being called, it's because the routing is wrong. If you want the application or component to send *all* requests to the redirector, use attachDefault: router.attachDefault(new MyRedirector(getContext(), ... other args ...); > Also, the template argument to Redirector is ignored if you > override getTargetRef. > > Hmm, that doesn't seem to be the case for me, since my code is almost an > exact copy the parent class. > The point of overriding getTargetRef is to give you the freedom to determine the target in arbitrary ways, which can be independent of the template. Here's the code for Redirector: https://github.com/restlet/restlet-framework-java/blob/master/modules/org.restlet/src/org/restlet/routing/Redirector.java You can see that the template is only used in getTargetRef. Your overridden getTargetRef need not use that template. You can just do something like this: public class MyRedirector extends Redirector { final Function<Reference, Reference> targetMapper; public MyRedirector(Context context, Function<Reference, Reference> targetMapper, int mode) { super(context, "<ignored>", mode); this.targetMapper = targetMapper; } protected Reference getTargetRef(Request request, Response response) { return targetMapper.apply(request.getOriginalRef()); } } I'm using Guava's Function type as a shorthand here, to illustrate how the template can be made irrelevant to the redirection logic, but you can obviously write this any way you want. --tim ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3054490