Java Reference
In-Depth Information
@Path("/employees/{firstname}.{lastname}@{domain}.com")
@Produces("text/xml")
public String getEmployeeLastName(@PathParam("lastname") String
lastName) {
...
}
}
The getEmployeeLastName method returns doe for the following GET request:
GET /employeeinfo/employees/john.doe@example.com
Subresource Locators
A subresource locator returns an object that will handle an HTTP request. The method
must not be annotated with a request method designator. You must declare a subresource
locator within a subresource class, and only subresource locators are used for runtime re-
source resolution.
The following code snippet shows a subresource locator:
Click here to view code image
// Root resource class
@Path("/employeeinfo")
public class EmployeeInfo {
// Subresource locator: obtains the subresource Employee
// from the path /employeeinfo/employees/{empid}
@Path("/employees/{empid}")
public Employee getEmployee(@PathParam("empid") String id) {
// Find the Employee based on the id path parameter
Employee emp = ...;
...
return emp;
}
}
// Subresource class
public class Employee {
// Subresource method: returns the employee's last name
@GET
@Path("/lastname")
public String getEmployeeLastName() {
...
return lastName
Search WWH ::




Custom Search