Hi Tal, For now, I've moved up the variables table at the top of Resolver's Javadocs. I agree we should expose this feature even more in examples, etc. I've got some ideas for Restlet 2.1 on this front.
Best regards, Jerome Louvel -- Restlet ~ Founder and Technical Lead ~ http://www.restlet.org Noelios Technologies ~ http://www.noelios.com -----Message d'origine----- De : Tal Liron [mailto:[email protected]] Envoyé : vendredi 26 février 2010 19:31 À : [email protected] Objet : Re: How to write an Universal redirector Hi Thierry -- The documentation for the URI template variables is so deeply hidden (Resolver API doc) that I always have trouble finding it. My recommendation is to put it somewhere much more obvious, possibly even in the "first Resource" tutorials, and to document it more with examples. It's such a powerful feature of Restlet! -Tal On 02/24/2010 02:32 AM, Thierry Boileau wrote: > Hello, > > actually, the second parameter in the Redirector constructor is a > template using a set of known variables (see [0]). > You should be able to use the shipped Redirector, as follow (or > something similar) > new Redirector(getContext(), > "http://192.168.100.1:8080/RESTfulServices{rr}", > Redirector.MODE_CLIENT_DISPATCHER)); > > Don't forget to declare the client HTTP connector on the component > (such redirection is seen as a new client call issued by the > Component). This is done in the web.xml file see ([1]) > <servlet> > [...] > <init-param> > <param-name>org.restlet.clients</param-name> > <param-value>HTTP</param-value> > </init-param> > [...] > </servlet> > > [0] > http://www.restlet.org/documentation/2.0/jse/api/org/restlet/util/Resolver.h tml > [1] > http://www.restlet.org/documentation/2.0/jee/ext/org/restlet/ext/servlet/Ser verServlet.html > > Best regards, > Thierry Boileau > >> Hello everybody, >> >> Could please anyone help me to write a universal redirector to match >> all requests and to redirected them to a remote host? >> Example: >> Start: /redirect/RESTfulServices/resources/customers/pkey/2176172632 >> Finish:http://192.168.100.1:8080/RESTfulServices/resources/customers/pkey/21 76172632 >> >> >> GWT Client side: >> ClientResource r = new ClientResource("/redirect/RESTfulServices/resources/customers/pkey/217617263 2"); >> >> >> Server side class TestRestletApplication extends Application (my >> web.xml was changed to forward all /redirect/* requests to >> TestRestletApplication) >> Router router = new Router(getContext()); >> router.attach("/RESTfulServices", new MyRedirector(getContext(), null)); //<-- this is wrong >> >> and MyRedirector class: >> public class MyRedirector extends Redirector { >> >> public MyRedirector(Context context, String targetTemplate) { >> // By default, the mode is MODE_CLIENT_DISPATCHER >> super(context, targetTemplate); >> } >> >> @Override >> protected Reference getTargetRef(Request request, Response response) { >> Reference ref = request.getResourceRef(); >> ref.setHostDomain("192.168.100.1"); >> ref.setHostPort(8080); >> //<-- here is missing something >> return ref; >> } >> } >> Thank you for helping me. >> >> ab >> ------------------------------------------------------------------------ >> View this message in context: How to write an Universal redirector >> <http://n2.nabble.com/How-to-write-an-Universal-redirector-tp4620578p4620578 .html> >> Sent from the Restlet Discuss mailing list archive >> <http://n2.nabble.com/Restlet-Discuss-f1400322.html> at Nabble.com. ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=24526 68 ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2456943

