Example: Inject Atom links

WARNING - TOPIC NOT WRITTEN - TOPIC ID: 1787

This topic has not yet been written. The content below is from the topic description.
The following example illustrates how you would declare everything in order to get the Atom links injected in your book store: @Path("/") @Consumes({"application/xml", "application/json"}) @Produces({"application/xml", "application/json"}) public interface BookStore { @AddLinks @LinkResource(value = Book.class) @GET @Path("books") public Collection getBooks(); @LinkResource @POST @Path("books") public void addBook(Book book); @AddLinks @LinkResource @GET @Path("book/{id}") public Book getBook(@PathParam("id") String id); @LinkResource @PUT @Path("book/{id}") public void updateBook(@PathParam("id") String id, Book book); @LinkResource(value = Book.class) @DELETE @Path("book/{id}") public void deleteBook(@PathParam("id") String id); } And this is the definition of the Book resource: @Mapped(namespaceMap = @XmlNsMap(jsonName = "atom", namespace = "http://www.w3.org/2005/Atom")) @XmlRootElement @XmlAccessorType(XmlAccessType.NONE) public class Book { @XmlAttribute private String author; @XmlID @XmlAttribute private String title; @XmlElementRef private RESTServiceDiscovery rest; } If you do a GET /order/foo you will then get this XML representation: And in JSON format: { "book": { "@title":"foo", "@author":"bar", "atom.link": [ {"@href":"http://localhost:8081/books","@rel":"list"}, {"@href":"http://localhost:8081/books","@rel":"add"}, {"@href":"http://localhost:8081/book/foo","@rel":"self"}, {"@href":"http://localhost:8081/book/foo","@rel":"update"}, {"@href":"http://localhost:8081/book/foo","@rel":"remove"} ] } }