jsr339-experts@jax-rs-spec.java.net

[jsr339-experts] Re: [jax-rs-spec users] _at_Default and _at_PathParam?

From: Santiago Pericas-Geertsen <Santiago.PericasGeertsen_at_oracle.com>
Date: Thu, 16 May 2013 12:51:30 -0400

On May 16, 2013, at 10:00 AM, Bill Burke <bburke_at_redhat.com> wrote:

> Does @Default on a @PathParam even make sense?

 It's a good question. I suppose a method can be matched in different ways as follows:

@Path("widgets")
public class WidgetsResource {

    @Path("{id}")
    public WidgetResource findWidget(@PathParam("id") String id) {
        return new WidgetResource(id);
    }
}

@Path("boxed-widgets/{box}")
public class WidgetsBoxResource {

    @Path("{id}")
    public WidgetResource findWidget(@PathParam("id") String id) {
        return new WidgetResource(id);
    }
}

public class WidgetResource {
    public WidgetResource(String id) {...}

    @GET
    public Widget getDetails(@Default("no-box") @PathParam("box") String box) {...}
}

 and the URLs,

    /widgets/25
    /boxed-widgets/box1/25

 Does that make sense?

-- Santiago