users@jsr311.java.net

Path annotations for class resources

From: Sergey Beryozkin <sergey.beryozkin_at_iona.com>
Date: Wed, 27 Feb 2008 14:24:59 -0000

Hi

I have few questions about the @Path annotations

1. Is it a requirement that a root resource class is annotated with @Path ?
Is it an error if a root resource is missing this annotation ? If not then can a default value like "/" be used ?

The spec says that root resources are directly annotated with @Path but no more information is given

2. Can classes representing subresources locators be annotated with @Path ?

The spec says that a @Path value for a subresource method is a concatenation of the class's @Path value and that method's @Path value, so, given that subresource locators can have their own subresource methods, I assume that at the very least subresource locators have default '/' values, and thus nothing prevents them from having more complicated @Path values, is it right ?

For ex.

@Path("/root")
class RootResource {
    @GET
    @Path("/bar/foo/{i1}/baz/{i2}")
    public Baz getBaz(@PathParam String i1, @PathParam String i2) {
    }

    @Path("/bar")
    public Bar getBar() {
        return bar;
    }
}

@Path("/foo/{i1}")
class BarResource {
    @GET
    @Path("/baz/{i2}")
    public Baz getBaz(@PathParam String i1, @PathParam String i2) {
    }
}

Is BarResource a valid subresource locator class ?



Thanks, Sergey

----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland