Hi,

Sorry to not have replied a bit sooner, (dsl woes, you don't want to know).

I will definitely be taking on-board with regard to the hierarchy advice from evryone and have ordered a copy of Restful Web Services as it seems to be highly regarded. (I forgot to click via restlet.org affiliate link - doh, sorry Jerome!).

The test cases did work, and after experimenting I realised it was a configuration error. Isn't it always!
Just in case anyone else falls into the same trap with restlet and spring.

<bean id="resourceManager" class="com.aniom.rest.ext.spring.ResourceManager">
       <property name="resourceMappings">
           <bean class="java.util.HashMap">
               <constructor-arg>
                   <map>
                       <entry key="/user/list">
                           <ref local="userList"/>
</entry> <entry key="/user/{userId}">
                           <ref local="user"/>
</entry> <entry key="/user">
                           <ref local="user"/>
                       </entry>
                   </map>
               </constructor-arg>
           </bean>
       </property>
   </bean>

Anyone spot the mistake? :)

I used a HashMap which of course you all know does not guarantee the order. Sometimes it did though, which threw me off. Anyway <bean class="java.util.LinkedHashMap"> sorts it out.

Thanks for the help,

Jonathan Hall



Jerome Louvel wrote:
Hi Jonathan,

Beside the URI design recommendations with which I agree, the router should
work as expected with FIRST routing mode.

I've tested tutorial Part 11 with a modified router:

                // Attach the handlers to the root router
                router.attach("/users/{user}", account).getTemplate()
                        .setMatchingMode(Template.MODE_EQUALS);
                router.attach("/users/{user}/order/list", orders);
                router.attach("/users/{user}/order/{order}", order);
                router.setRoutingMode(Router.FIRST);

It worked fine. I've also tested this which works too and is simpler:

                // Attach the handlers to the root router
                router.attach("/users/{user}", account);
                router.attach("/users/{user}/order/list", orders);
                router.attach("/users/{user}/order/{order}", order);

Please enter a bug report if you observe a different behavior.

Best regards,
Jerome
-----Message d'origine-----
De : Jonathan Hall [mailto:[EMAIL PROTECTED] Envoyé : vendredi 8 juin 2007 17:30
À : [email protected]
Objet : URI matching again

Hi,

Is it possible to do this:

/user
/user/{id}
/user/list

The problem comes from the app thinking list is just a {id} variable. I thought router.setRoutingMode(Router.FIRST) sounded like it would pick the route I wished by the order they were attached.
 In which case this would work:

 /user
/user/list
/user/{id}

However, it seems to not work like that. No matter what order I attach the routes they seem to end up in the same order in a RouteList. I also need to have optional parameters attached to all of the urls.


Any ideas?

Best Regards,

Jon


Reply via email to