users@jsr311.java.net

Re: Order of path templates <was> Re: JSR311: Re: Some comments to JSR 311

From: Bill Burke <bburke_at_redhat.com>
Date: Tue, 08 Jan 2008 09:35:10 -0500

Paul Sandoz wrote:
> Hi Bill,
>
> Bill Burke wrote:
>>> You raise a tricky issue, it seems to me that generating an error
>>> would be the right thing to do. Unless someone has a better idea for
>>> how to pick amongst the alternatives ?
>>>
>>
>> No error. The way I've implemented it was
>>
>> http://.../abc/def tries to match the more explicit mapping
>> (@Path("abc/{var")) first before trying to match wildcards.
>>
>
> Did you order "abc/{var}" and "{var}/def? (or say "xyz/abc/{var}" and
> "xyz/{var}/def")
>

yes. abc/{var} comes before {var}/def. xyz/abc/{var} maps before
xyz/{var}/def.

> i.e. how did you determine which was more explicit?
>

I break up paths into a tree structure and walk the tree to do
matchings. Initially, I didn't like the idea of linearly iterating over
a list of regular expressions. Seemed really slow, so I implemented the
tree idea. I was lucky in that the side effect was that I could support
this use case we're talking about.

Here's the code. I haven't expanded the test cases fully yet so there's
probably some bugs:

http://resteasy.svn.sourceforge.net/viewvc/resteasy/trunk/jsr311/src/main/java/org/resteasy/Registry.java?revision=50&view=markup




-- 
Bill Burke
JBoss, a division of Red Hat
http://bill.burkecentral.com