users@jsr311.java.net

Re: Selecting between method candidates

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Tue, 06 May 2008 14:32:14 -0700

Sorry for the slow reply, Paul and I are at JavaOne this week.

On May 6, 2008, at 10:37 AM, Sergey Beryozkin wrote:
>
> I have one question with respect to selecting between multiple
> methods ...
>
> Consider this class :
>
> @Path("{a}/{b}/{c}/d")

I assume there should be {} around d above.

> public class FooClass {
>
> @GET
> public Bars listBars() {
> return bars;
> }
>
> @GET
> @PATH("/{e}")
> public Bar readBar() {
> return bar;
> }
> }
>
> In CXF a request like URI /1/2/3/4 is delegated to readBar() but the
> user is expecting listBars be invoked and I'm wondering, where
> exacly CXF fails to follow the spec...
> Both methods match the request and both methods are added to the list.
>
listBars would match since there's no trailing '/' on the request URI.
readBar would only match if you used /1/2/3/4/ or /1/2/3/4/something.

Section 3.7 describes the algorithm used to match requests to resource
classes and methods.

Marc.


> In both cases the number of capturing groups is 3, the source is
> different (readBar is a resource method, listBars is a locator).
>
> Is the users's expectation is correct that listBars() should be
> invoked. If yes, what piece of teh JAX-RS specification says why in
> this case listBars() needs to be invoked ?
>
> Many thanks, Sergey
>
>
>
>
> ----------------------------
> IONA Technologies PLC (registered in Ireland)
> Registered Number: 171387
> Registered Address: The IONA Building, Shelbourne Road, Dublin 4,
> Ireland

---
Marc Hadley <marc.hadley at sun.com>
CTO Office, Sun Microsystems.