Grouping multiple links using @InjectLinks

You can use the @org.glassfish.jersey.linking.InjectLinks annotation to group multiple hypermedia links as an array and inject it to the List or Link[] property present in the resource representation class. Here is an example:

@InjectLinks({ 
        @InjectLink( 
                value = "{id}/employees", 
                style = Style.RELATIVE_PATH, 
                bindings = @Binding(name = "id", value =  
                               "${instance.departmentId}"), 
                rel = "employees" 
        ), 
        @InjectLink( 
                value = "{id}/employees/{managerId}", 
                style = Style.RELATIVE_PATH, 
                bindings = { 
                    @Binding(name = "id", value = 
                        "${instance.departmentId}"), 
                    @Binding(name = "managerId", value =  
                        "${instance.managerId}")}, 
                rel = "manager" 
        )}) 
    @XmlJavaTypeAdapter(LinkAdaptor.class) 
    @XmlElement(name = "links") 
    List<Link> links; 

The sample resource link produced by the preceding definition may look like the following:

"links":[{"href":"300/employees","rel":"employees"}, 
         {"href":"300/employees/200","rel":"manager"}] 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.14.129.194