users@jersey.java.net

One Resource class for two URLs

From: Martin Probst <mail_at_martin-probst.com>
Date: Mon, 21 Apr 2008 18:57:26 +0200

Hi,

in the next chapter of my adventures with Jersey and JSR311, I'm
trying to model my resources into persistent entities and non-
persistent classes representing root collections of those entities.
That is, if I have a "book" resource, I'd like to have these two
classes:

@Path("/books/")
class Books {
   List<Book> getBooks() { ... }
   @Path(" ??? ")
   Book getBook() { ... }
}

Ideally, I'd like my book collection to reside on "/books/" and my
single books to reside on "/book/12". Is that possible with JSR311
annotations? Can I refer to a parent path e.g. by "../book/{bookId}"?
Or is this better served by a different implementation pattern?

Sorry if I'm spamming the list, I promise to write responses into FAQ
entries, once I understand how to do this :-)

Regards,
Martin