Hi,
apologies if it is an off-topic post, I can easily forward this email to a more appropriate list. I used this one as the question is specifcally about maping a JAX-RS resource.
here is a sample resource :
@Path("/books")
public class Books {
@GET public Books getAll() {}
@POST public void addBook() {}
@GET @PATH("{id}") public Book getBook(@PathParam("id") String id, @QueryParam("name") String name) {};
@PATH("chapters") public Chapters getBooks(@QueryParam("id") String id) {}
}
public class Chapters {
@GET @Path("/content") public Chapters getl() {}
}
here is a possible mapping, with some questions in the copmments, I reread the wadl spec only yesterday so be patient please :-)
<application xmlns="wadl ns">
<grammar>
<!-- schemas for Books, Book -->
</grammar>
<resources base="
http://localhost:8080/rest">
<resource path="/books">
<!-- Books.getAll -->
<method name="GET">
<response><representation id="books"/></response>
</method>
<!-- Books.addBook -->
<method name="POST">
<request><representation id="book"/></request>
</method>
</resource>
<!-- Books.getBook -->
<resource path="/books/{id}">
<param name="id" style="template"/>
<method name="GET">
<param name="name" style="query"/>
<response><representation id="book"/></response>
</method>
</resources>
<!-- Books.getChapters, Chapters.get() -->
<resource path="/books/chapters/content">
<method name="GET">
<param name="id" style="query"/>
<response><representation id="chapters"/></response>
</method>
</resources>
</application>
Few questions :
- Can a resource "books/{id}" be a sibling of /books resource or does it have to be embedded in it with path {id} ? I think both options are valid
- Is it correct that any unique Path combination in a given JAX-RS resource class has to be represented as an indibidual wadl <resource> instance ?
- Is the mapping for a subresource Chapters correct ? I'm presuming it can also be embedded inside "books" with path="/chapters/content"
thanks, Sergey