Root Resource, Subresource, subresource locator
Reference(http://docs.oracle.com/javaee/6/tutorial/doc/gknav.html)
You can use a resource class to process only a part of the URI request. A root resource can then implement subresources that can process the remainder of the URI path.
A resource class method that is annotated with @Path is either a subresource method or a subresource locator:
Example of a root resource and sub-resource
You can use a resource class to process only a part of the URI request. A root resource can then implement subresources that can process the remainder of the URI path.
A resource class method that is annotated with @Path is either a subresource method or a subresource locator:
- A subresource method is used to handle requests on a subresource of the corresponding resource.
- A subresource locator is used to locate subresources of the corresponding resource.
Example of a root resource and sub-resource
package test; import javax.ws.rs.Path; import javax.ws.rs.PathParam; @Path("person") public class PersonInfo { @Path("{pid}") public Person getPerson(@PathParam("pid") Integer pid){ Person p = new Person(); p.setFirstName("John"); p.setLastName("Lennon"); return p; } } import javax.ws.rs.GET; import javax.ws.rs.Path; public class Person { public String firstName; public String lastName; @GET @Path("firstname") public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } @GET @Path("lastname") public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } }