...
The @Parent annotation provides the ability to define a base template URI for the URI specified in a resources @Path annotation.
If a resource is annotated with the @Parent annotation, the Apache Wink runtime calculates the final resource template by first retrieving the value of the @Parent annotation, which holds the parent resource class, and then concatenates the resource path template definition to the path template definition of the parent resource.
@Parent Annotation Specification
Value | Description | |
---|---|---|
Mandatory | No | |
Target | Provider class or Resource class | |
Parameters | Name | Type |
| Value | Class<?> |
Example | @Parent(ParentResource.class) |
Example 1
Code Block | ||||
---|---|---|---|---|
| ||||
@Path("services")
public class ParentResource {
...
}
|
Example 2
Code Block | ||||
---|---|---|---|---|
| ||||
@Parent(BaseResource.class)
@Path("service1")
public class ResourceA {
...
}
|
Explanation
In the example, the user defined two resources: A ParentResource and ResourceA. ParentResource defines the @Path annotation to associate it with "services" URI. ResourceA defines the @Path annotation to associate it with "service1" URI and defines ParentResource to be its parent by specifying it in the @Parent annotation. In this case, the final URI path for ResourceA is "services/service1".