2012年2月2日 星期四

JAX-RS Sub-resources

JAX-RS Sub-resources
Root resources can declare sub-resources that will
match the unmatched part of the URI path
  • Sub-resources method
    A sub-resource method is decorated with both a @Path
    annotation and one of the HTTP verb annotations. The subresource
    method is directly responsible for handling a request
    made on the resource using the specified HTTP verb.

  • Sub-resource locator
    Sub-resource locators are not decorated with one of the
    HTTP verb annotations and do not directly handle are request
    on the sub-resource. Instead, a sub-resource locator returns
    an instance of a resource class that can handle the request.
  • Sample
    @Path("properties")

    public class Props {
    @GET
    @Path("java.home")
    Prop getProperty() {…}
    @Path("{name}")
    Object getProp(@PathParam("name")String
    name){
    return new Dyna(name); }
    }
    public class Dyna {
    @GET Prop getProperty() {…}
    }
    GET http://.../context/properties/java.home
    GET http://.../context/properties/java.tmp.dir


沒有留言:

張貼留言